x 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. commit 67732818a3c25804ae6462f9d43015b358744686
  2. Author: miguel <[email protected]>
  3. Date: Sun May 13 22:25:16 2018 -0400
  4. Make the demo work better on WIndows
  5. diff --git a/Designer/Designer.csproj b/Designer/Designer.csproj
  6. index 91afb5c..a81a74d 100644
  7. --- a/Designer/Designer.csproj
  8. +++ b/Designer/Designer.csproj
  9. @@ -1,4 +1,4 @@
  10. -<?xml version="1.0" encoding="utf-8"?>
  11. +<?xml version="1.0" encoding="utf-8"?>
  12. <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  13. <PropertyGroup>
  14. <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  15. @@ -7,7 +7,8 @@
  16. <OutputType>Exe</OutputType>
  17. <RootNamespace>Designer</RootNamespace>
  18. <AssemblyName>Designer</AssemblyName>
  19. - <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
  20. + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
  21. + <TargetFrameworkProfile />
  22. </PropertyGroup>
  23. <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
  24. <DebugSymbols>true</DebugSymbols>
  25. @@ -48,6 +49,7 @@
  26. </ProjectReference>
  27. </ItemGroup>
  28. <ItemGroup>
  29. + <None Include="app.config" />
  30. <None Include="packages.config" />
  31. </ItemGroup>
  32. <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  33. diff --git a/Example/demo.cs b/Example/demo.cs
  34. index 8c4eb89..d6f95af 100644
  35. --- a/Example/demo.cs
  36. +++ b/Example/demo.cs
  37. @@ -153,15 +153,14 @@ static class Demo {
  38. ml2 = new Label (1, 1, "Mouse Debug Line");
  39. d.Add (ml2);
  40. Application.Run (d);
  41. - }
  42. -
  43. - //
  44. - // Creates a nested editor
  45. - static void Editor (Toplevel top)
  46. - {
  47. + }
  48. +
  49. + //
  50. + // Creates a nested editor
  51. + static void Editor(Toplevel top) {
  52. var tframe = top.Frame;
  53. - var ntop = new Toplevel (tframe);
  54. - var menu = new MenuBar (new MenuBarItem [] {
  55. + var ntop = new Toplevel(tframe);
  56. + var menu = new MenuBar(new MenuBarItem[] {
  57. new MenuBarItem ("_File", new MenuItem [] {
  58. new MenuItem ("_Close", "", () => {Application.RequestStop ();}),
  59. }),
  60. @@ -171,18 +170,27 @@ static class Demo {
  61. new MenuItem ("_Paste", "", null)
  62. }),
  63. });
  64. - ntop.Add (menu);
  65. -
  66. - var win = new Window ("/etc/passwd") {
  67. + ntop.Add(menu);
  68. +
  69. + string fname = null;
  70. + foreach (var s in new[] { "/etc/passwd", "c:\\windows\\win.ini" })
  71. + if (System.IO.File.Exists(s)) {
  72. + fname = s;
  73. + break;
  74. + }
  75. +
  76. + var win = new Window(fname ?? "Untitled") {
  77. X = 0,
  78. - Y = 0,
  79. - Width = Dim.Fill (),
  80. - Height = Dim.Fill ()
  81. + Y = 1,
  82. + Width = Dim.Fill(),
  83. + Height = Dim.Fill()
  84. };
  85. - ntop.Add (win);
  86. + ntop.Add(win);
  87. - var text = new TextView (new Rect (0, 0, tframe.Width - 2, tframe.Height - 3));
  88. - text.Text = System.IO.File.ReadAllText ("/etc/passwd");
  89. + var text = new TextView(new Rect(0, 0, tframe.Width - 2, tframe.Height - 3));
  90. +
  91. + if (fname != null)
  92. + text.Text = System.IO.File.ReadAllText (fname);
  93. win.Add (text);
  94. Application.Run (ntop);