public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Set the current working directory to the bin folder. string binFolder = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); Directory.SetCurrentDirectory(binFolder); // Get the environment variable 'ModelName' string modelName = System.Environment.GetEnvironmentVariable("ModelName"); // Open wheat validation in a tab string fileName = Path.Combine(binFolder, @"..\Tests\" + modelName + @"\" + modelName + "Validation.apsimx"); tabbedExplorerPresenter.OpenApsimXFileInTab(fileName); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; presenter.SelectNode(".Simulations"); // Export the model to HTML string folderName = Path.Combine(binFolder, @"..\Documentation\PDF"); Directory.CreateDirectory(folderName); ExportNodeCommand command = new ExportNodeCommand(presenter, presenter.CurrentNodePath); command.Do(null); // Copy the file into the PDF directory. File.Copy(command.FileNameWritten, @"..\Documentation\PDF\" + modelName + ".pdf"); // Close the user interface. tabbedExplorerPresenter.Close(false); }
public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Open test.apsimx in a tab tabbedExplorerPresenter.OpenApsimXFileInTab(@"..\Tests\Test.apsimx"); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; // Select the field model. presenter.SelectNode(".Simulations.Test"); // Copy the simulation model. ContextMenu menu = new ContextMenu(presenter); menu.OnCopyClick(null, null); // Select the top model presenter.SelectNode(".Simulations"); // Paste the model. menu.OnPasteClick(null, null); // Make sure the paste has worked by clicking on a child. presenter.SelectNode(".Simulations.Test1.Clock"); // Make sure the parenting of children has worked correctly. Clock clock = Apsim.Get(presenter.ApsimXFile, ".Simulations.Test1.Clock") as Clock; if (clock.Parent == null) throw new Exception("Parenting of models after copy/paste hasn't worked"); // Close the user interface. tabbedExplorerPresenter.Close(false); }
public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Open the standard toolbox in a tab tabbedExplorerPresenter.OnStandardToolboxClick(null, null); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; // Loop through all nodes in the standard toolbox and select each in turn. while (presenter.SelectNextNode()); // Close the user interface. tabbedExplorerPresenter.Close(); }
/// <summary> /// Constructor /// </summary> public MainForm(string[] args) { InitializeComponent(); Application.EnableVisualStyles(); // Adjust font size for MONO. if (Environment.OSVersion.Platform != PlatformID.Win32NT && Environment.OSVersion.Platform != PlatformID.Win32Windows) { this.Font = new Font(this.Font.FontFamily, 10.2F); } tabbedExplorerView1.Font = this.Font; tabbedExplorerView2.Font = this.Font; Presenter1 = new TabbedExplorerPresenter(); Presenter1.Attach(tabbedExplorerView1); Presenter2 = new TabbedExplorerPresenter(); Presenter2.Attach(tabbedExplorerView2); SplitContainer.Panel2Collapsed = true; commandLineArguments = args; }
/// <summary> /// Constructor /// </summary> public MainForm(string[] args) : base(null) { commandLineArguments = args; // Gtk.Settings.Default.SetLongProperty("gtk-button-images", 1, ""); // Gtk.Settings.Default.ThemeName = "Raleigh"; // The following code for changing theme settings comes from https://github.com/picoe/Eto/issues/442 // The XftRgba setting makes a big difference on Windows // Get the Global Settings //Settings setts = Gtk.Settings.Default; // This enables clear text on Win32, makes the text look a lot less crappy //setts.XftRgba = "rgb"; // This enlarges the size of the controls based on the dpi //setts.XftDpi = 96; // By Default Anti-aliasing is enabled, if you want to disable it for any reason set this value to 0 // setts.XftAntialias = 0; // Enable text hinting // setts.XftHinting = 1; // setts.XftHintstyle = "hintslight"; // setts.XftHintstyle = "hintfull"; // Load the Theme // Gtk.CssProvider css_provider = new Gtk.CssProvider(); // css_provider.LoadFromPath("themes/DeLorean-3.14/gtk-3.0/gtk.css"); // css_provider.LoadFromPath("themes/DeLorean-Dark-3.14/gtk-3.0/gtk.css"); // Gtk.StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800) // Glade can generate files in two different formats: libglade or GtkBuilder. // libglade is the older format; GtkBuilder is intended to eventually replace it. // However, in the GtkSharp layer (well, version 2 anyway), the support for // GtkBuilder lacks the ability to autoconnect widgets and events contained // in the glade descriptions. The connections must be done manually. // In GtkSharp version 3, though, Builder does have an Autoconnect member for // event connections. // What is the better way to add resources to a .NET assembly? // Should we use the .resx mechanism, or just add things and // set their Build Action to "Embedded Resource"? // Depending on how the resources are added, they are read in // slightly different ways, apparently. So we might instead have: // Builder Gui = new Builder(); // Gui.AddFromString(GTKUserInterface.Properties.Resources.MainForm); // Here's how we load the form description using an embedded GtkBuilder file // Builder Gui = new Builder("GTKUserInterface.Resources.Glade.MainForm.glade"); // window1 = (Window)Gui.GetObject("window1"); // hpaned1 = (HPaned)Gui.GetObject("hpaned1"); // And here's part of how it works with libglade format. // The "[Widget]" attributes are part of the libglade // autoconnection stuff, replacing the need for the .GetObject // calls used with GtkBuilder. //Console.WriteLine("") //Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.Glade.MainForm.glade"); //Glade.XML gxmla = new Glade.XML(s, "mainWindow", null); Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.MainForm.glade", "mainWindow"); gxml.Autoconnect(this); _mainWidget = mainWindow; mainWindow.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); Presenter1 = new Presenters.TabbedExplorerPresenter(); Presenter2 = new Presenters.TabbedExplorerPresenter(); TabbedExplorerView ExplorerView1 = new TabbedExplorerView(this); TabbedExplorerView ExplorerView2 = new TabbedExplorerView(this); Presenter1.Attach(ExplorerView1); Presenter2.Attach(ExplorerView2); hpaned1.Pack1(ExplorerView1.MainWidget, true, true); hpaned1.Pack2(ExplorerView2.MainWidget, true, true); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; Console.WriteLine("Getting assembly version"); // Get the version of the current assembly. Version version = Assembly.GetExecutingAssembly().GetName().Version; if (version.Major == 0) { mainWindow.Title = "APSIM (Custom Build)"; } else { mainWindow.Title = "APSIM " + version.ToString(); } try { if (Utility.Configuration.Settings.MainFormMaximized) { mainWindow.GdkWindow.Maximize(); } else { System.Drawing.Point location = Utility.Configuration.Settings.MainFormLocation; System.Drawing.Size size = Utility.Configuration.Settings.MainFormSize; mainWindow.Move(location.X, location.Y); mainWindow.Resize(size.Width, size.Height); } } catch (System.Exception) { mainWindow.GdkWindow.Maximize(); } // Look for a script specified on the command line. if (commandLineArguments != null && commandLineArguments.Length > 0) { if (commandLineArguments[0].EndsWith(".cs")) { try { ProcessStartupScript(commandLineArguments[0]); } catch (Exception err) { ErrorMessage = err.Message; if (err.InnerException != null) { ErrorMessage += "\r\n" + err.InnerException.Message; } ErrorMessage += "\r\n" + err.StackTrace; queryClose = false; mainWindow.Destroy(); // Is this right? } } else if (commandLineArguments[0].EndsWith(".apsimx")) { Presenter1.OpenApsimXFileInTab(commandLineArguments[0]); } } }
/// <summary> /// Constructor /// </summary> public MainForm(string[] args) : base(null) { commandLineArguments = args; // Gtk.Settings.Default.SetLongProperty("gtk-button-images", 1, ""); // Gtk.Settings.Default.ThemeName = "Raleigh"; // The following code for changing theme settings comes from https://github.com/picoe/Eto/issues/442 // The XftRgba setting makes a big difference on Windows // Get the Global Settings //Settings setts = Gtk.Settings.Default; // This enables clear text on Win32, makes the text look a lot less crappy //setts.XftRgba = "rgb"; // This enlarges the size of the controls based on the dpi //setts.XftDpi = 96; // By Default Anti-aliasing is enabled, if you want to disable it for any reason set this value to 0 // setts.XftAntialias = 0; // Enable text hinting // setts.XftHinting = 1; // setts.XftHintstyle = "hintslight"; // setts.XftHintstyle = "hintfull"; // Load the Theme // Gtk.CssProvider css_provider = new Gtk.CssProvider(); // css_provider.LoadFromPath("themes/DeLorean-3.14/gtk-3.0/gtk.css"); // css_provider.LoadFromPath("themes/DeLorean-Dark-3.14/gtk-3.0/gtk.css"); // Gtk.StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800) // Glade can generate files in two different formats: libglade or GtkBuilder. // libglade is the older format; GtkBuilder is intended to eventually replace it. // However, in the GtkSharp layer (well, version 2 anyway), the support for // GtkBuilder lacks the ability to autoconnect widgets and events contained // in the glade descriptions. The connections must be done manually. // In GtkSharp version 3, though, Builder does have an Autoconnect member for // event connections. // What is the better way to add resources to a .NET assembly? // Should we use the .resx mechanism, or just add things and // set their Build Action to "Embedded Resource"? // Depending on how the resources are added, they are read in // slightly different ways, apparently. So we might instead have: // Builder Gui = new Builder(); // Gui.AddFromString(ApsimNG.Properties.Resources.MainForm); // Here's how we load the form description using an embedded GtkBuilder file // Builder Gui = new Builder("ApsimNG.Resources.Glade.MainForm.glade"); // window1 = (Window)Gui.GetObject("window1"); // hpaned1 = (HPaned)Gui.GetObject("hpaned1"); // And here's part of how it works with libglade format. // The "[Widget]" attributes are part of the libglade // autoconnection stuff, replacing the need for the .GetObject // calls used with GtkBuilder. //Console.WriteLine("") //Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.Glade.MainForm.glade"); //Glade.XML gxmla = new Glade.XML(s, "mainWindow", null); Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.MainForm.glade", "mainWindow"); gxml.Autoconnect(this); _mainWidget = mainWindow; mainWindow.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); Presenter1 = new Presenters.TabbedExplorerPresenter(); Presenter2 = new Presenters.TabbedExplorerPresenter(); TabbedExplorerView ExplorerView1 = new TabbedExplorerView(this); TabbedExplorerView ExplorerView2 = new TabbedExplorerView(this); Presenter1.Attach(ExplorerView1); Presenter2.Attach(ExplorerView2); hpaned1.Pack1(ExplorerView1.MainWidget, true, true); hpaned1.Pack2(ExplorerView2.MainWidget, true, true); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; Console.WriteLine("Getting assembly version"); // Get the version of the current assembly. Version version = Assembly.GetExecutingAssembly().GetName().Version; if (version.Major == 0) mainWindow.Title = "APSIM (Custom Build)"; else mainWindow.Title = "APSIM " + version.ToString(); try { if (Utility.Configuration.Settings.MainFormMaximized) mainWindow.GdkWindow.Maximize(); else { System.Drawing.Point location = Utility.Configuration.Settings.MainFormLocation; System.Drawing.Size size = Utility.Configuration.Settings.MainFormSize; mainWindow.Move(location.X, location.Y); mainWindow.Resize(size.Width, size.Height); } } catch (System.Exception) { mainWindow.GdkWindow.Maximize(); } // Look for a script specified on the command line. if (commandLineArguments != null && commandLineArguments.Length > 0) { if (commandLineArguments[0].EndsWith(".cs")) { try { ProcessStartupScript(commandLineArguments[0]); } catch (Exception err) { ErrorMessage = err.Message; if (err.InnerException != null) ErrorMessage += "\r\n" + err.InnerException.Message; ErrorMessage += "\r\n" + err.StackTrace; queryClose = false; mainWindow.Destroy(); // Is this right? } } else if (commandLineArguments[0].EndsWith(".apsimx")) { Presenter1.OpenApsimXFileInTab(commandLineArguments[0]); } } }