void LoadSimulation(string path) { var form = new Forms.Flowsheet(); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; AddUserCompounds(form.FlowsheetObject); var loadingdialog = new LoadingData(); loadingdialog.loadingtext.Text = "Please wait, loading data...\n(" + Path.GetFileNameWithoutExtension(path) + ")"; loadingdialog.Show(); Task.Factory.StartNew(() => { if (System.IO.Path.GetExtension(path).ToLower() == ".dwxmz") { var xdoc = form.FlowsheetObject.LoadZippedXML(path); } else if (System.IO.Path.GetExtension(path).ToLower() == ".dwxml") { form.FlowsheetObject.LoadFromXML(XDocument.Load(path)); } else if (System.IO.Path.GetExtension(path).ToLower() == ".xml") { form.FlowsheetObject.LoadFromMXML(XDocument.Load(path)); } form.FlowsheetObject.FilePath = path; form.FlowsheetObject.FlowsheetOptions.FilePath = path; }).ContinueWith((t) => { Application.Instance.Invoke(() => { loadingdialog.Close(); var surface = (DWSIM.Drawing.SkiaSharp.GraphicsSurface)form.FlowsheetObject.GetSurface(); surface.ZoomAll(ClientSize.Width, ClientSize.Height); surface.ZoomAll(ClientSize.Width, ClientSize.Height); form.FlowsheetObject.UpdateInterface(); form.Title = form.FlowsheetObject.Options.SimulationName + " [" + form.FlowsheetObject.Options.FilePath + "]"; form.Show(); if (!GlobalSettings.Settings.MostRecentFiles.Contains(path)) { MostRecentList.Items.Add(new ListItem { Text = path, Key = path }); GlobalSettings.Settings.MostRecentFiles.Add(path); } form.FlowsheetObject.ProcessScripts(Interfaces.Enums.Scripts.EventType.SimulationOpened, Interfaces.Enums.Scripts.ObjectType.Simulation, ""); }); }); }
void InitializeComponent() { //exception handling Application.Instance.UnhandledException += (sender, e) => { new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync(); }; string imgprefix = "DWSIM.UI.Forms.Resources.Icons."; Title = "DWSIMLauncher".Localize(); switch (GlobalSettings.Settings.RunningPlatform()) { case GlobalSettings.Settings.Platform.Windows: ClientSize = new Size(690, 420); break; case GlobalSettings.Settings.Platform.Linux: ClientSize = new Size(690, 370); break; case GlobalSettings.Settings.Platform.Mac: ClientSize = new Size(690, 350); break; } Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); var bgcolor = new Color(0.051f, 0.447f, 0.651f); Eto.Style.Add <Button>("main", button => { button.BackgroundColor = bgcolor; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = 230; }); Eto.Style.Add <Button>("donate", button => { button.BackgroundColor = Colors.LightYellow; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = bgcolor; button.ImagePosition = ButtonImagePosition.Left; button.Width = 230; }); var btn1 = new Button() { Style = "main", Text = "OpenSavedFile".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenFolder_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn2 = new Button() { Style = "main", Text = "NewSimulation".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Workflow_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn3 = new Button() { Style = "main", Text = "NewCompound".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Peptide_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn4 = new Button() { Style = "main", Text = "NewDataRegression".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "AreaChart_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn6 = new Button() { Style = "main", Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Help_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn7 = new Button() { Style = "main", Text = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Info_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn8 = new Button() { Style = "donate", Text = "Donate ", Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "PayPal_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn9 = new Button() { Style = "main", Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "VerticalSettingsMixer_100px.png"), 40, 40, ImageInterpolation.Default) }; btn9.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; btn6.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; btn1.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; btn2.Click += (sender, e) => { var form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; form.newsim = true; form.Show(); }; btn7.Click += (sender, e) => new AboutBox().Show(); btn8.Click += (sender, e) => Process.Start("http://sourceforge.net/p/dwsim/donate/"); var stack = new StackLayout { Orientation = Orientation.Vertical, Spacing = 5 }; stack.Items.Add(btn1); stack.Items.Add(btn2); stack.Items.Add(btn9); stack.Items.Add(btn6); stack.Items.Add(btn7); stack.Items.Add(btn8); var tableright = new TableLayout(); tableright.Padding = new Padding(5, 5, 5, 5); tableright.Spacing = new Size(10, 10); MostRecentList = new ListBox { BackgroundColor = bgcolor, Height = 330 }; SampleList = new ListBox { BackgroundColor = bgcolor, Height = 330 }; FoldersList = new ListBox { BackgroundColor = bgcolor, Height = 330 }; if (Application.Instance.Platform.IsGtk && GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { MostRecentList.TextColor = bgcolor; SampleList.TextColor = bgcolor; FoldersList.TextColor = bgcolor; } else { MostRecentList.TextColor = Colors.White; SampleList.TextColor = Colors.White; FoldersList.TextColor = Colors.White; } var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles); invertedlist.Reverse(); foreach (var item in invertedlist) { if (File.Exists(item)) { MostRecentList.Items.Add(new ListItem { Text = Path.GetFileName(item), Key = item }); } } var samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*"); foreach (var item in samplist) { if (File.Exists(item)) { SampleList.Items.Add(new ListItem { Text = Path.GetFileName(item), Key = item }); } } foreach (String f in invertedlist) { if (Path.GetExtension(f).ToLower() != ".dwbcs") { if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0) { FoldersList.Items.Add(new ListItem { Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f) }); } } } FoldersList.SelectedIndexChanged += (sender, e) => { if (FoldersList.SelectedIndex >= 0) { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Directory = new Uri(FoldersList.SelectedKey); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } } }; MostRecentList.SelectedIndexChanged += (sender, e) => { if (MostRecentList.SelectedIndex >= 0) { LoadSimulation(MostRecentList.SelectedKey); MostRecentList.SelectedIndex = -1; } ; }; SampleList.SelectedIndexChanged += (sender, e) => { if (SampleList.SelectedIndex >= 0) { LoadSimulation(SampleList.SelectedKey); MostRecentList.SelectedIndex = -1; } ; }; var tabview = new TabControl(); var tab1 = new TabPage(MostRecentList) { Text = "Recent Files" };; var tab2 = new TabPage(SampleList) { Text = "Samples" };; var tab3 = new TabPage(FoldersList) { Text = "Recent Folders" };; tabview.Pages.Add(tab1); tabview.Pages.Add(tab2); tabview.Pages.Add(tab3); tableright.Rows.Add(new TableRow(tabview)); var tl = new DynamicLayout(); tl.Add(new TableRow(stack, tableright)); TableContainer = new TableLayout { Padding = 10, Spacing = new Size(5, 5), Rows = { new TableRow(tl) }, BackgroundColor = bgcolor, }; Content = TableContainer; var quitCommand = new Command { MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); var aboutCommand = new Command { MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png")) }; aboutCommand.Executed += (sender, e) => new AboutBox().Show(); var aitem1 = new ButtonMenuItem { Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png")) }; aitem1.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; var aitem2 = new ButtonMenuItem { Text = "Open Classic UI", Shortcut = Keys.Alt | Keys.C }; aitem2.Click += (sender, e) => { DWSIM.macOS.ClassicUILoader.Loader.Load(); }; var hitem1 = new ButtonMenuItem { Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem1.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; var hitem2 = new ButtonMenuItem { Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem2.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/wiki/index.php?title=Support"); }; var hitem3 = new ButtonMenuItem { Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem3.Click += (sender, e) => { Process.Start("https://sourceforge.net/p/dwsim/tickets/"); }; var hitem4 = new ButtonMenuItem { Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem4.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br"); }; // create menu Menu = new MenuBar { ApplicationItems = { aitem1, aitem2 }, QuitItem = quitCommand, HelpItems = { hitem1, hitem4, hitem2, hitem3 }, AboutItem = aboutCommand }; Shown += MainForm_Shown; Closing += MainForm_Closing; //Plugins LoadPlugins(); }
void InitializeComponent() { //exception handling var sf = s.UIScalingFactor; Application.Instance.UnhandledException += (sender, e) => { new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync(); }; Title = "DWSIMLauncher".Localize(); switch (GlobalSettings.Settings.RunningPlatform()) { case GlobalSettings.Settings.Platform.Windows: ClientSize = new Size((int)(690 * sf), (int)(420 * sf)); break; case GlobalSettings.Settings.Platform.Linux: ClientSize = new Size((int)(690 * sf), (int)(370 * sf)); break; case GlobalSettings.Settings.Platform.Mac: ClientSize = new Size((int)(690 * sf), (int)(350 * sf)); break; } Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); var bgcolor = new Color(0.051f, 0.447f, 0.651f); if (s.DarkMode) { bgcolor = SystemColors.ControlBackground; } Eto.Style.Add <Button>("main", button => { button.BackgroundColor = bgcolor; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = (int)(sf * 250); button.Height = (int)(sf * 50); }); Eto.Style.Add <Button>("donate", button => { button.BackgroundColor = !s.DarkMode ? Colors.LightYellow : SystemColors.ControlBackground; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = !s.DarkMode ? bgcolor : Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = (int)(sf * 250); button.Height = (int)(sf * 50); }); var btn1 = new Button() { Style = "main", Text = "OpenSavedFile".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenFolder_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn2 = new Button() { Style = "main", Text = "NewSimulation".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn3 = new Button() { Style = "main", Text = "NewCompound".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Peptide_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn4 = new Button() { Style = "main", Text = "NewDataRegression".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "AreaChart_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn6 = new Button() { Style = "main", Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Help_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn7 = new Button() { Style = "main", Text = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Info_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn8 = new Button() { Style = "donate", Text = "Become a Patron", Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-patreon.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn9 = new Button() { Style = "main", Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "ReportCard_96px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; btn9.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; btn6.Click += (sender, e) => { var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf"); }; btn1.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; btn2.Click += (sender, e) => { var form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; form.newsim = true; form.Show(); }; btn7.Click += (sender, e) => new AboutBox().Show(); btn8.Click += (sender, e) => Process.Start("https://patreon.com/dwsim"); var stack = new StackLayout { Orientation = Orientation.Vertical, Spacing = 5 }; stack.Items.Add(btn1); stack.Items.Add(btn2); stack.Items.Add(btn9); stack.Items.Add(btn6); stack.Items.Add(btn7); stack.Items.Add(btn8); var tableright = new TableLayout(); tableright.Padding = new Padding(5, 5, 5, 5); tableright.Spacing = new Size(10, 10); MostRecentList = new TreeGridView { Height = (int)(sf * 330) }; SampleList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; FoldersList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; FOSSEEList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; if (Application.Instance.Platform.IsGtk && GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { SampleList.TextColor = bgcolor; FoldersList.TextColor = bgcolor; FOSSEEList.TextColor = bgcolor; } else if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { SampleList.BackgroundColor = SystemColors.ControlBackground; FoldersList.BackgroundColor = SystemColors.ControlBackground; FOSSEEList.BackgroundColor = SystemColors.ControlBackground; SampleList.TextColor = SystemColors.ControlText; FoldersList.TextColor = SystemColors.ControlText; FOSSEEList.TextColor = SystemColors.ControlText; } else { SampleList.TextColor = Colors.White; FoldersList.TextColor = Colors.White; FOSSEEList.TextColor = Colors.White; } MostRecentList.AllowMultipleSelection = false; MostRecentList.ShowHeader = true; MostRecentList.Columns.Clear(); MostRecentList.Columns.Add(new GridColumn { DataCell = new ImageViewCell(0) { ImageInterpolation = ImageInterpolation.High } }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(1), HeaderText = "Name", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(2), HeaderText = "Date", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(3), HeaderText = "DWSIM Version", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(4), HeaderText = "Operating System", Sortable = true }); var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles); invertedlist.Reverse(); var tgc = new TreeGridItemCollection(); foreach (var item in invertedlist) { if (File.Exists(item)) { var li = new TreeGridItem(); var data = new Dictionary <string, string>(); if (Path.GetExtension(item).ToLower() == ".dwxmz") { data = SharedClasses.Utility.GetSimulationFileDetails(FlowsheetBase.FlowsheetBase.LoadZippedXMLDoc(item)); } else { data = SharedClasses.Utility.GetSimulationFileDetails(XDocument.Load(item)); } li.Tag = data; data.Add("Path", item); DateTime dt; if (data.ContainsKey("SavedOn")) { dt = DateTime.Parse(data["SavedOn"]); } else { dt = File.GetLastWriteTime(item); } string dwsimver, osver; if (data.ContainsKey("DWSIMVersion")) { dwsimver = data["DWSIMVersion"]; } else { dwsimver = "N/A"; } if (data.ContainsKey("OSInfo")) { osver = data["OSInfo"]; } else { osver = "N/A"; } li.Values = new object[] { new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png")).WithSize(16, 16), System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(item)), dt, dwsimver, osver }; tgc.Add(li); } } tgc = new TreeGridItemCollection(tgc.OrderByDescending(x => ((DateTime)((TreeGridItem)x).Values[2]).Ticks)); MostRecentList.DataStore = tgc; var samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*"); foreach (var item in samplist) { if (File.Exists(item)) { SampleList.Items.Add(new ListItem { Text = Path.GetFileNameWithoutExtension(item), Key = item }); } } foreach (String f in invertedlist) { if (Path.GetExtension(f).ToLower() != ".dwbcs") { if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0) { if (Directory.Exists(Path.GetDirectoryName(f))) { FoldersList.Items.Add(new ListItem { Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f) }); } } } } FOSSEEList.Items.Add(new ListItem { Text = "Downloading flowsheet list, please wait...", Key = "" }); Dictionary <string, SharedClasses.FOSSEEFlowsheet> fslist = new Dictionary <string, SharedClasses.FOSSEEFlowsheet>(); Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.GetFOSSEEFlowsheets()); }).ContinueWith((t) => { Application.Instance.Invoke(() => { FOSSEEList.Items.Clear(); if (t.Exception != null) { FOSSEEList.Items.Add(new ListItem { Text = "Error loading flowsheet list. Check your internet connection.", Key = "" }); } else { foreach (var item in t.Result) { fslist.Add(item.DownloadLink, item); FOSSEEList.Items.Add(new ListItem { Text = item.DisplayName, Key = item.DownloadLink }); } } }); }); FoldersList.SelectedIndexChanged += (sender, e) => { if (FoldersList.SelectedIndex >= 0) { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Directory = new Uri(FoldersList.SelectedKey); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } } }; MostRecentList.SelectedItemChanged += (sender, e) => { if (MostRecentList.SelectedItem != null) { var si = (TreeGridItem)MostRecentList.SelectedItem; var data = (Dictionary <string, string>)si.Tag; LoadSimulation(data["Path"]); //MostRecentList.SelectedIndex = -1; } ; }; SampleList.SelectedIndexChanged += (sender, e) => { if (SampleList.SelectedIndex >= 0) { LoadSimulation(SampleList.SelectedKey); //MostRecentList.SelectedIndex = -1; } ; }; FOSSEEList.SelectedIndexChanged += (sender, e) => { if (FOSSEEList.SelectedIndex >= 0 && FOSSEEList.SelectedKey != "") { var item = fslist[FOSSEEList.SelectedKey]; var sb = new StringBuilder(); sb.AppendLine("Title: " + item.Title); sb.AppendLine("Author: " + item.ProposerName); sb.AppendLine("Institution: " + item.Institution); sb.AppendLine(); sb.AppendLine("Click 'Yes' to download and open this flowsheet."); if (MessageBox.Show(sb.ToString(), "Open FOSSEE Flowsheet", MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.Yes) == DialogResult.Yes) { var loadingdialog = new LoadingData(); loadingdialog.loadingtext.Text = "Please wait, downloading file...\n(" + FOSSEEList.SelectedKey + ")"; loadingdialog.Show(); var address = FOSSEEList.SelectedKey; Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.DownloadFlowsheet(address, (p) => { Application.Instance.Invoke(() => loadingdialog.loadingtext.Text = "Please wait, downloading file... (" + p + "%)\n(" + address + ")"); })); }).ContinueWith((t) => { Application.Instance.Invoke(() => loadingdialog.Close()); if (t.Exception != null) { MessageBox.Show(t.Exception.Message, "Error downloading file", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } else { Application.Instance.Invoke(() => LoadSimulation(SharedClasses.FOSSEEFlowsheets.LoadFlowsheet(t.Result))); } }); FOSSEEList.SelectedIndex = -1; } } ; }; var fosseecontainer = c.GetDefaultContainer(); var l1 = c.CreateAndAddLabelRow3(fosseecontainer, "About the Project"); var l2 = c.CreateAndAddDescriptionRow(fosseecontainer, "FOSSEE, IIT Bombay, invites chemical engineering students, faculty and practitioners to the flowsheeting project using DWSIM. We want you to convert existing flowsheets into DWSIM and get honoraria and certificates."); var bu1 = c.CreateAndAddButtonRow(fosseecontainer, "Submit a Flowsheet", null, (b1, e1) => Process.Start("https://dwsim.fossee.in/flowsheeting-project")); var bu2 = c.CreateAndAddButtonRow(fosseecontainer, "About FOSSEE", null, (b2, e2) => Process.Start("https://fossee.in/")); var l3 = c.CreateAndAddLabelRow3(fosseecontainer, "Completed Flowsheets"); if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { fosseecontainer.BackgroundColor = SystemColors.ControlBackground; } else { fosseecontainer.BackgroundColor = bgcolor; l1.TextColor = Colors.White; l2.TextColor = Colors.White; l3.TextColor = Colors.White; bu1.TextColor = Colors.White; bu2.TextColor = Colors.White; bu1.BackgroundColor = bgcolor; bu2.BackgroundColor = bgcolor; } fosseecontainer.Add(FOSSEEList); fosseecontainer.EndVertical(); var tabview = new TabControl(); var tab1 = new TabPage(MostRecentList) { Text = "Recent Files" };; var tab2 = new TabPage(SampleList) { Text = "Samples" };; var tab2a = new TabPage(fosseecontainer) { Text = "FOSSEE Flowsheets" };; var tab3 = new TabPage(FoldersList) { Text = "Recent Folders" };; tabview.Pages.Add(tab1); tabview.Pages.Add(tab2); tabview.Pages.Add(tab2a); tabview.Pages.Add(tab3); tableright.Rows.Add(new TableRow(tabview)); var tl = new DynamicLayout(); tl.Add(new TableRow(stack, tableright)); TableContainer = new TableLayout { Padding = 10, Spacing = new Size(5, 5), Rows = { new TableRow(tl) } }; if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { TableContainer.BackgroundColor = SystemColors.ControlBackground; } else { TableContainer.BackgroundColor = bgcolor; } Content = TableContainer; var quitCommand = new Command { MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => { try { DWSIM.GlobalSettings.Settings.SaveSettings("dwsim_newui.ini"); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error Saving Settings to File", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } if (MessageBox.Show(this, "ConfirmAppExit".Localize(), "AppExit".Localize(), MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.No) == DialogResult.Yes) { Application.Instance.Quit(); } }; var aboutCommand = new Command { MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png")) }; aboutCommand.Executed += (sender, e) => new AboutBox().Show(); var aitem1 = new ButtonMenuItem { Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png")) }; aitem1.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; var hitem1 = new ButtonMenuItem { Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem1.Click += (sender, e) => { var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf"); }; var hitem2 = new ButtonMenuItem { Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem2.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/wiki/index.php?title=Support"); }; var hitem3 = new ButtonMenuItem { Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem3.Click += (sender, e) => { Process.Start("https://sourceforge.net/p/dwsim/tickets/"); }; var hitem4 = new ButtonMenuItem { Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem4.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br"); }; // create menu Menu = new MenuBar { ApplicationItems = { aitem1 }, QuitItem = quitCommand, HelpItems = { hitem1, hitem4, hitem2, hitem3 }, AboutItem = aboutCommand }; Shown += MainForm_Shown; Closing += MainForm_Closing; //Plugins LoadPlugins(); }
void InitializeComponent() { //exception handling var sf = s.UIScalingFactor; width = (int)(width * sf); height = (int)(height * sf); Application.Instance.UnhandledException += (sender, e) => { new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync(); }; Title = "DWSIMLauncher".Localize(); ClientSize = new Size((int)(width * sf), (int)(height * sf)); Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); if (Application.Instance.Platform.IsGtk) { BackgroundColor = Colors.White; } var abslayout = new PixelLayout(); var background = new ImageView { Size = ClientSize, Image = new Bitmap(Bitmap.FromResource("DWSIM.UI.Forms.Resources.Bitmaps.background_welcome.png")) }; abslayout.Add(background, 0, 0); int dx = (int)(15 * sf), dy = (int)(15 * sf), dx2 = (int)(10 * sf), dy2 = (int)(10 * sf); float fsize1, fsize2; if (GlobalSettings.Settings.RunningPlatform() == s.Platform.Mac) { fsize1 = 12.0f; fsize2 = 10.0f; } else { fsize1 = 11.0f; fsize2 = 9.0f; } var boldfont = new Font(SystemFont.Bold, fsize1, FontDecoration.None); var regularfont = new Font(SystemFont.Default, fsize2, FontDecoration.None); var boldfont2 = new Font(SystemFont.Bold, fsize2, FontDecoration.None); var bfh = (int)boldfont.LineHeight; var rfh = (int)regularfont.LineHeight; var psize = new Size((int)(100 * sf), (int)(100 * sf)); var psize2 = new Size((int)(80 * sf), (int)(80 * sf)); var lsize = new Size((int)(350 * sf), (int)(50 * sf)); abslayout.Add(new Label { Text = "Welcome to DWSIM!", Width = (int)(200 * sf), Font = boldfont }, dx, dy); abslayout.Add(new Label { Text = "Quick Access", Width = (int)(200 * sf), Font = boldfont }, dx * 2 + (int)(500 * sf), dy); PixelLayout pfile, pccreator, pdocs, pabout, ppatreon; pfile = new PixelLayout { BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf) }; pfile.Add(new Label { Text = "Process Modeling", Width = (int)(200 * sf), Font = boldfont }, dx2, dy2); pfile.Add(new Label { Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Create or load chemical steady-state or dynamic process models." }, dx2, dy2 * 2 + bfh); var img1 = new ImageView { Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-chemical_plant.png")) }; pfile.Add(img1, (int)(400 * sf), 0); var link1 = new LinkButton { Text = "Create New", Width = (int)(140 * sf), Font = boldfont2 }; pfile.Add(link1, dx2, (int)(100 * sf - rfh - dy)); var link2 = new LinkButton { Text = "Open Existing", Width = (int)(200 * sf), Font = boldfont2 }; pfile.Add(link2, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy)); link2.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; link1.Click += (sender, e) => { var form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; form.newsim = true; form.Show(); }; abslayout.Add(pfile, dx, dy * 2 + bfh); pccreator = new PixelLayout { BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf) }; pccreator.Add(new Label { Text = "Compound Creator", Width = (int)(200 * sf), Font = boldfont }, dx2, dy2); pccreator.Add(new Label { Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Use this tool to create new compounds and load them in your models." }, dx2, dy2 * 2 + bfh); var img2 = new ImageView { Size = psize2, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-test_tube.png")) }; pccreator.Add(img2, (int)(410 * sf), (int)(10 * sf)); var link3 = new LinkButton { Text = "Create New", Width = (int)(140 * sf), Font = boldfont2 }; pccreator.Add(link3, dx2, (int)(100 * sf - rfh - dy)); link3.Click += (sender, e) => { var form = new Desktop.Editors.CompoundCreatorWizard(null); form.SetupAndDisplayPage(1); }; abslayout.Add(pccreator, dx, dy * 3 + bfh + (int)(100 * sf)); ppatreon = new PixelLayout { BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf) }; ppatreon.Add(new Label { Text = "Become a Patron", Width = (int)(200 * sf), Font = boldfont }, dx2, dy2); ppatreon.Add(new Label { Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Become a Patron and get access to exclusive Unit Operations, Property Packages and Plugins/Add-Ins!" }, dx2, dy2 * 2 + bfh); var img4 = new ImageView { Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "Patreon_Navy.jpg")) }; ppatreon.Add(img4, (int)(400 * sf), 0); var link4 = new LinkButton { Text = "Support the Project", Width = (int)(140 * sf), Font = boldfont2 }; ppatreon.Add(link4, dx2, (int)(100 * sf - rfh - dy)); var bwidth = 70; if (Application.Instance.Platform.IsGtk) { bwidth = 140; } var link4a = new LinkButton { Text = "Get Benefits", Width = bwidth, Font = boldfont2, BackgroundColor = Colors.DodgerBlue, TextColor = Colors.White }; ppatreon.Add(link4a, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy)); link4.Click += (sender, e) => "https://patreon.com/dwsim".OpenURL(); link4a.Click += (sender, e) => "https://www.patreon.com/join/dwsim?".OpenURL(); abslayout.Add(ppatreon, dx, dy * 4 + bfh + 2 * (int)(100 * sf)); pdocs = new PixelLayout { BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf) }; pdocs.Add(new Label { Text = "Documentation", Width = (int)(200 * sf), Font = boldfont }, dx2, dy2); pdocs.Add(new Label { Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "View DWSIM's User Guide in PDF format." }, dx2, dy2 * 2 + bfh); var img5 = new ImageView { Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-books.png")) }; pdocs.Add(img5, (int)(400 * sf), 0); var link5 = new LinkButton { Text = "User Guide", Width = (int)(140 * sf), Font = boldfont2 }; pdocs.Add(link5, dx2, (int)(100 * sf - rfh - dy)); var link6 = new LinkButton { Text = "Learning Resources", Width = (int)(140 * sf), Font = boldfont2 }; pdocs.Add(link6, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy)); link6.Click += (sender, e) => "http://dwsim.inforside.com.br/wiki/index.php?title=Tutorials".OpenURL(); link5.Click += (sender, e) => { var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); try { Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error opening User Guide", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } }; abslayout.Add(pdocs, dx, dy * 5 + bfh + 3 * (int)(100 * sf)); pabout = new PixelLayout { BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf) }; pabout.Add(new Label { Text = "About DWSIM", Width = (int)(200 * sf), Font = boldfont }, dx2, dy2); pabout.Add(new Label { Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Adjust Global Settings and view DWSIM licensing and version information." }, dx2, dy2 * 2 + bfh); var img6 = new ImageView { Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "DWSIM_ico.png")) }; pabout.Add(img6, (int)(400 * sf), 0); var link7 = new LinkButton { Text = "Global Settings", Width = (int)(140 * sf), Font = boldfont2 }; pabout.Add(link7, dx2, (int)(100 * sf - rfh - dy)); var link8 = new LinkButton { Text = "About DWSIM", Width = (int)(140 * sf), Font = boldfont2 }; pabout.Add(link8, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy)); link7.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; link8.Click += (sender, e) => new AboutBox().Show(); abslayout.Add(pabout, dx, dy * 6 + bfh + 4 * (int)(100 * sf)); MostRecentList = new TreeGridView(); SampleList = new ListBox(); FoldersList = new ListBox(); FOSSEEList = new ListBox(); MostRecentList.AllowMultipleSelection = false; MostRecentList.ShowHeader = true; MostRecentList.Columns.Clear(); MostRecentList.Columns.Add(new GridColumn { DataCell = new ImageViewCell(0) { ImageInterpolation = ImageInterpolation.High } }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(1), HeaderText = "Name", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(2), HeaderText = "Date", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(3), HeaderText = "DWSIM Version", Sortable = true }); MostRecentList.Columns.Add(new GridColumn { DataCell = new TextBoxCell(4), HeaderText = "Operating System", Sortable = true }); var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles); invertedlist.Reverse(); var tgc = new TreeGridItemCollection(); foreach (var item in invertedlist) { if (File.Exists(item)) { try { var li = new TreeGridItem(); var data = new Dictionary <string, string>(); if (Path.GetExtension(item).ToLower() == ".dwxmz") { data = SharedClasses.Utility.GetSimulationFileDetails(FlowsheetBase.FlowsheetBase.LoadZippedXMLDoc(item)); } else { data = SharedClasses.Utility.GetSimulationFileDetails(XDocument.Load(item)); } li.Tag = data; data.Add("Path", item); DateTime dt; if (data.ContainsKey("SavedOn")) { dt = DateTime.Parse(data["SavedOn"]); } else { dt = File.GetLastWriteTime(item); } string dwsimver, osver; if (data.ContainsKey("DWSIMVersion")) { dwsimver = data["DWSIMVersion"]; } else { dwsimver = "N/A"; } if (data.ContainsKey("OSInfo")) { osver = data["OSInfo"]; } else { osver = "N/A"; } li.Values = new object[] { new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png")).WithSize(16, 16), System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(item)), dt, dwsimver, osver }; tgc.Add(li); } catch { } } } tgc = new TreeGridItemCollection(tgc.OrderByDescending(x => ((DateTime)((TreeGridItem)x).Values[2]).Ticks)); MostRecentList.DataStore = tgc; IEnumerable <string> samplist = new List <string>(); try { samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*"); } catch { } foreach (var item in samplist.OrderBy((x) => Path.GetFileNameWithoutExtension(x))) { if (File.Exists(item)) { SampleList.Items.Add(new ListItem { Text = Path.GetFileNameWithoutExtension(item), Key = item }); } } foreach (String f in invertedlist) { if (Path.GetExtension(f).ToLower() != ".dwbcs") { if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0) { if (Directory.Exists(Path.GetDirectoryName(f))) { FoldersList.Items.Add(new ListItem { Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f) }); } } } } FOSSEEList.Items.Add(new ListItem { Text = "Downloading flowsheet list, please wait...", Key = "" }); Dictionary <string, SharedClasses.FOSSEEFlowsheet> fslist = new Dictionary <string, SharedClasses.FOSSEEFlowsheet>(); Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.GetFOSSEEFlowsheets()); }).ContinueWith((t) => { Application.Instance.Invoke(() => { FOSSEEList.Items.Clear(); if (t.Exception != null) { FOSSEEList.Items.Add(new ListItem { Text = "Error loading flowsheet list. Check your internet connection.", Key = "" }); } else { foreach (var item in t.Result) { fslist.Add(item.DownloadLink, item); FOSSEEList.Items.Add(new ListItem { Text = item.DisplayName, Key = item.DownloadLink }); } } }); }); FoldersList.SelectedIndexChanged += (sender, e) => { if (FoldersList.SelectedIndex >= 0) { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Directory = new Uri(FoldersList.SelectedKey); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } } }; MostRecentList.SelectedItemChanged += (sender, e) => { if (MostRecentList.SelectedItem != null) { var si = (TreeGridItem)MostRecentList.SelectedItem; var data = (Dictionary <string, string>)si.Tag; LoadSimulation(data["Path"]); MostRecentList.UnselectAll(); } ; }; SampleList.SelectedIndexChanged += (sender, e) => { if (SampleList.SelectedIndex >= 0) { LoadSimulation(SampleList.SelectedKey); SampleList.SelectedValue = null; } ; }; FOSSEEList.SelectedIndexChanged += (sender, e) => { if (FOSSEEList.SelectedIndex >= 0 && FOSSEEList.SelectedKey != "") { var item = fslist[FOSSEEList.SelectedKey]; var sb = new StringBuilder(); sb.AppendLine("Title: " + item.Title); sb.AppendLine("Author: " + item.ProposerName); sb.AppendLine("Institution: " + item.Institution); sb.AppendLine(); sb.AppendLine("Click 'Yes' to download and open this flowsheet."); if (MessageBox.Show(sb.ToString(), "Open FOSSEE Flowsheet", MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.Yes) == DialogResult.Yes) { var loadingdialog = new LoadingData(); loadingdialog.loadingtext.Text = "Please wait, downloading file...\n(" + FOSSEEList.SelectedKey + ")"; loadingdialog.Show(); var address = FOSSEEList.SelectedKey; Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.DownloadFlowsheet(address, (p) => { Application.Instance.Invoke(() => loadingdialog.loadingtext.Text = "Please wait, downloading file... (" + p + "%)\n(" + address + ")"); })); }).ContinueWith((t) => { Application.Instance.Invoke(() => loadingdialog.Close()); if (t.Exception != null) { MessageBox.Show(t.Exception.Message, "Error downloading file", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } else { Application.Instance.Invoke(() => LoadSimulation(SharedClasses.FOSSEEFlowsheets.LoadFlowsheet(t.Result))); } }); FOSSEEList.SelectedIndex = -1; } } ; }; var fosseecontainer = c.GetDefaultContainer(); var l1 = c.CreateAndAddLabelRow3(fosseecontainer, "About the Project"); var l2 = c.CreateAndAddDescriptionRow(fosseecontainer, "FOSSEE, IIT Bombay, invites chemical engineering students, faculty and practitioners to the flowsheeting project using DWSIM. We want you to convert existing flowsheets into DWSIM and get honoraria and certificates."); var bu1 = c.CreateAndAddButtonRow(fosseecontainer, "Submit a Flowsheet", null, (b1, e1) => Process.Start("https://dwsim.fossee.in/flowsheeting-project")); var bu2 = c.CreateAndAddButtonRow(fosseecontainer, "About FOSSEE", null, (b2, e2) => Process.Start("https://fossee.in/")); var l3 = c.CreateAndAddLabelRow3(fosseecontainer, "Completed Flowsheets"); fosseecontainer.Add(FOSSEEList); fosseecontainer.EndVertical(); var tabview = new TabControl(); var tab1 = new TabPage(MostRecentList) { Text = "Recent Files" };; var tab2 = new TabPage(SampleList) { Text = "Samples" };; var tab2a = new TabPage(fosseecontainer) { Text = "FOSSEE Flowsheets" };; var tab3 = new TabPage(FoldersList) { Text = "Recent Folders" };; tabview.Pages.Add(tab1); tabview.Pages.Add(tab2); tabview.Pages.Add(tab2a); tabview.Pages.Add(tab3); if (Application.Instance.Platform.IsGtk) { tabview.Size = new Size((int)(480 * sf), (int)(636 - dy * 4 - bfh)); } else { tabview.Size = new Size((int)(480 * sf), (int)(ClientSize.Height - dy * 4 - bfh)); } abslayout.Add(tabview, dx * 2 + (int)(500 * sf), dy * 2 + bfh); Content = abslayout; var quitCommand = new Command { MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => { try { DWSIM.GlobalSettings.Settings.SaveSettings("dwsim_newui.ini"); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error Saving Settings to File", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } if (MessageBox.Show(this, "ConfirmAppExit".Localize(), "AppExit".Localize(), MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.No) == DialogResult.Yes) { Application.Instance.Quit(); } }; var aboutCommand = new Command { MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png")) }; aboutCommand.Executed += (sender, e) => new AboutBox().Show(); var aitem1 = new ButtonMenuItem { Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png")) }; aitem1.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; var hitem1 = new ButtonMenuItem { Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem1.Click += (sender, e) => { var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf"); }; var hitem2 = new ButtonMenuItem { Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem2.Click += (sender, e) => { "http://dwsim.inforside.com.br/wiki/index.php?title=Support".OpenURL(); }; var hitem3 = new ButtonMenuItem { Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem3.Click += (sender, e) => { "https://sourceforge.net/p/dwsim/tickets/".OpenURL(); }; var hitem4 = new ButtonMenuItem { Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem4.Click += (sender, e) => { "http://dwsim.inforside.com.br".OpenURL(); }; // create menu Menu = new MenuBar { ApplicationItems = { aitem1 }, QuitItem = quitCommand, HelpItems = { hitem1, hitem4, hitem2, hitem3 }, AboutItem = aboutCommand }; Shown += MainForm_Shown; Closing += MainForm_Closing; //Plugins LoadPlugins(); }
void InitializeComponent() { //exception handling Application.Instance.UnhandledException += (sender, e) => { new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync(); }; string imgprefix = "DWSIM.UI.Forms.Resources.Icons."; Title = "DWSIMLauncher".Localize(); switch (GlobalSettings.Settings.RunningPlatform()) { case GlobalSettings.Settings.Platform.Windows: ClientSize = new Size(690, 420); break; case GlobalSettings.Settings.Platform.Linux: ClientSize = new Size(690, 365); break; case GlobalSettings.Settings.Platform.Mac: ClientSize = new Size(690, 350); break; } Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); var bgcolor = new Color(0.051f, 0.447f, 0.651f); Eto.Style.Add <Button>("main", button => { button.BackgroundColor = bgcolor; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = 230; }); var btn1 = new Button() { Style = "main", Text = "OpenSavedFile".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenFolder_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn2 = new Button() { Style = "main", Text = "NewSimulation".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Workflow_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn3 = new Button() { Style = "main", Text = "NewCompound".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Peptide_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn4 = new Button() { Style = "main", Text = "NewDataRegression".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "AreaChart_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn5 = new Button() { Style = "main", Text = "OpenSamples".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenBook_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn6 = new Button() { Style = "main", Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Help_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn7 = new Button() { Style = "main", Text = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Info_100px.png"), 40, 40, ImageInterpolation.Default) }; var btn8 = new Button() { Style = "main", Text = "Donate".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "PayPal_100px.png"), 40, 40, ImageInterpolation.Default) }; btn5.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "OpenSamples".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.Directory = new Uri(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples")); dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; btn6.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; btn1.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; btn2.Click += (sender, e) => { var form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; form.Show(); }; btn7.Click += (sender, e) => new AboutBox().Show(); btn8.Click += (sender, e) => Process.Start("http://sourceforge.net/p/dwsim/donate/"); var stack = new StackLayout { Orientation = Orientation.Vertical, Spacing = 5 }; stack.Items.Add(btn1); stack.Items.Add(btn2); stack.Items.Add(btn5); stack.Items.Add(btn6); stack.Items.Add(btn7); stack.Items.Add(btn8); var tableright = new TableLayout(); tableright.Padding = new Padding(5, 5, 5, 5); tableright.Spacing = new Size(10, 10); MostRecentList = new ListBox { BackgroundColor = bgcolor }; if (Application.Instance.Platform.IsGtk && GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { MostRecentList.TextColor = bgcolor; } else { MostRecentList.TextColor = Colors.White; } var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles); invertedlist.Reverse(); foreach (var item in invertedlist) { if (File.Exists(item)) { MostRecentList.Items.Add(new ListItem { Text = item, Key = item }); } } MostRecentList.SelectedIndexChanged += (sender, e) => { if (MostRecentList.SelectedIndex >= 0) { LoadSimulation(MostRecentList.SelectedKey); MostRecentList.SelectedIndex = -1; } ; }; tableright.Rows.Add(new TableRow(new Label { Text = "Recent Files", Font = SystemFonts.Bold(), TextColor = Colors.White })); tableright.Rows.Add(new TableRow(MostRecentList)); var tl = new DynamicLayout(); tl.Add(new TableRow(stack, tableright)); TableContainer = new TableLayout { Padding = 10, Spacing = new Size(5, 5), Rows = { new TableRow(tl) }, BackgroundColor = bgcolor, }; Content = TableContainer; var quitCommand = new Command { MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); var aboutCommand = new Command { MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png")) }; aboutCommand.Executed += (sender, e) => new AboutBox().Show(); var aitem1 = new ButtonMenuItem { Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png")) }; aitem1.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; var hitem1 = new ButtonMenuItem { Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem1.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; var hitem2 = new ButtonMenuItem { Text = "Discussion Forums".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem2.Click += (sender, e) => { Process.Start("http://sourceforge.net/p/dwsim/discussion/"); }; var hitem3 = new ButtonMenuItem { Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem3.Click += (sender, e) => { Process.Start("https://sourceforge.net/p/dwsim/tickets/"); }; var hitem4 = new ButtonMenuItem { Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem4.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br"); }; // create menu Menu = new MenuBar { ApplicationItems = { aitem1 }, QuitItem = quitCommand, HelpItems = { hitem1, hitem4, hitem2, hitem3 }, AboutItem = aboutCommand }; Shown += MainForm_Shown; Closing += MainForm_Closing; //check for updates (automatic updater) SetupUpdateItems(); if (GlobalSettings.Settings.AutomaticUpdates && GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Windows) { Task.Factory.StartNew(() => LaunchUpdateProcess()); } }
void LoadSimulation(string path) { Task.Factory.StartNew(() => Task.Delay(1000).Wait()).ContinueWith((td) => { Forms.Flowsheet form = null; LoadingData loadingdialog = null; Application.Instance.Invoke(() => { form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); form.Closed += (sender2, e2) => { OpenForms -= 1; }; OpenForms += 1; Task.Factory.StartNew(() => { if (System.IO.Path.GetExtension(path).ToLower() == ".dwxmz") { var xdoc = form.FlowsheetObject.LoadZippedXML(path); } else if (System.IO.Path.GetExtension(path).ToLower() == ".dwxml") { form.FlowsheetObject.LoadFromXML(XDocument.Load(path)); } else if (System.IO.Path.GetExtension(path).ToLower() == ".xml") { form.FlowsheetObject.LoadFromMXML(XDocument.Load(path)); } form.FlowsheetObject.FilePath = path; form.FlowsheetObject.FlowsheetOptions.FilePath = path; }).ContinueWith((t) => { Application.Instance.Invoke(() => { loadingdialog.Close(); var surface = (DWSIM.Drawing.SkiaSharp.GraphicsSurface)form.FlowsheetObject.GetSurface(); surface.ZoomAll(ClientSize.Width, ClientSize.Height); surface.ZoomAll(ClientSize.Width, ClientSize.Height); form.FlowsheetObject.UpdateInterface(); form.Title = form.FlowsheetObject.Options.SimulationName + " [" + form.FlowsheetObject.Options.FilePath + "]"; form.Show(); if (!GlobalSettings.Settings.MostRecentFiles.Contains(path)) { GlobalSettings.Settings.MostRecentFiles.Add(path); var ds = (TreeGridItemCollection)MostRecentList.DataStore; var li = new TreeGridItem(); var data = new Dictionary <string, string>(); if (Path.GetExtension(path).ToLower() == ".dwxmz") { data = SharedClasses.Utility.GetSimulationFileDetails(FlowsheetBase.FlowsheetBase.LoadZippedXMLDoc(path)); } else { data = SharedClasses.Utility.GetSimulationFileDetails(XDocument.Load(path)); } li.Tag = data; data.Add("Path", path); DateTime dt; if (data.ContainsKey("SavedOn")) { dt = DateTime.Parse(data["SavedOn"]); } else { dt = File.GetLastWriteTime(path); } string dwsimver, osver; if (data.ContainsKey("DWSIMVersion")) { dwsimver = data["DWSIMVersion"]; } else { dwsimver = "N/A"; } if (data.ContainsKey("OSInfo")) { osver = data["OSInfo"]; } else { osver = "N/A"; } li.Values = new object[] { new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png")).WithSize(16, 16), System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(path)), dt, dwsimver, osver }; ds.Add(li); MostRecentList.ReloadData(); } form.FlowsheetObject.ProcessScripts(Interfaces.Enums.Scripts.EventType.SimulationOpened, Interfaces.Enums.Scripts.ObjectType.Simulation, ""); }); }); loadingdialog = new LoadingData(); loadingdialog.loadingtext.Text = "Please wait, loading data...\n(" + Path.GetFileNameWithoutExtension(path) + ")"; loadingdialog.Show(); }); }); }
void InitializeComponent() { //exception handling var sf = s.UIScalingFactor; Application.Instance.UnhandledException += (sender, e) => { new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync(); }; string imgprefix = "DWSIM.UI.Forms.Resources.Icons."; Title = "DWSIMLauncher".Localize(); switch (GlobalSettings.Settings.RunningPlatform()) { case GlobalSettings.Settings.Platform.Windows: ClientSize = new Size((int)(690 * sf), (int)(420 * sf)); break; case GlobalSettings.Settings.Platform.Linux: ClientSize = new Size((int)(690 * sf), (int)(370 * sf)); break; case GlobalSettings.Settings.Platform.Mac: ClientSize = new Size((int)(690 * sf), (int)(350 * sf)); break; } Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); var bgcolor = new Color(0.051f, 0.447f, 0.651f); if (s.DarkMode) { bgcolor = SystemColors.ControlBackground; } Eto.Style.Add <Button>("main", button => { button.BackgroundColor = bgcolor; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = (int)(230 * sf); }); Eto.Style.Add <Button>("donate", button => { button.BackgroundColor = !s.DarkMode ? Colors.LightYellow : SystemColors.ControlBackground; button.Font = new Font(FontFamilies.Sans, 12f, FontStyle.None); button.TextColor = !s.DarkMode ? bgcolor : Colors.White; button.ImagePosition = ButtonImagePosition.Left; button.Width = (int)(sf * 230); }); var btn1 = new Button() { Style = "main", Text = "OpenSavedFile".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenFolder_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn2 = new Button() { Style = "main", Text = "NewSimulation".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Workflow_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn3 = new Button() { Style = "main", Text = "NewCompound".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Peptide_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn4 = new Button() { Style = "main", Text = "NewDataRegression".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "AreaChart_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn6 = new Button() { Style = "main", Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Help_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn7 = new Button() { Style = "main", Text = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Info_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn8 = new Button() { Style = "donate", Text = "Donate ", Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "PayPal_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; var btn9 = new Button() { Style = "main", Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "VerticalSettingsMixer_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default) }; btn9.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; btn6.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; btn1.Click += (sender, e) => { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } }; btn2.Click += (sender, e) => { var form = new Forms.Flowsheet(); AddUserCompounds(form.FlowsheetObject); OpenForms += 1; form.Closed += (sender2, e2) => { OpenForms -= 1; }; form.newsim = true; form.Show(); }; btn7.Click += (sender, e) => new AboutBox().Show(); btn8.Click += (sender, e) => Process.Start("http://sourceforge.net/p/dwsim/donate/"); var stack = new StackLayout { Orientation = Orientation.Vertical, Spacing = 5 }; stack.Items.Add(btn1); stack.Items.Add(btn2); stack.Items.Add(btn9); stack.Items.Add(btn6); stack.Items.Add(btn7); stack.Items.Add(btn8); var tableright = new TableLayout(); tableright.Padding = new Padding(5, 5, 5, 5); tableright.Spacing = new Size(10, 10); MostRecentList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; SampleList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; FoldersList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; FOSSEEList = new ListBox { BackgroundColor = bgcolor, Height = (int)(sf * 330) }; if (Application.Instance.Platform.IsGtk && GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac) { MostRecentList.TextColor = bgcolor; SampleList.TextColor = bgcolor; FoldersList.TextColor = bgcolor; FOSSEEList.TextColor = bgcolor; } else { MostRecentList.TextColor = Colors.White; SampleList.TextColor = Colors.White; FoldersList.TextColor = Colors.White; FOSSEEList.TextColor = Colors.White; } var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles); invertedlist.Reverse(); foreach (var item in invertedlist) { if (File.Exists(item)) { MostRecentList.Items.Add(new ListItem { Text = Path.GetFileName(item), Key = item }); } } var samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*"); foreach (var item in samplist) { if (File.Exists(item)) { SampleList.Items.Add(new ListItem { Text = Path.GetFileName(item), Key = item }); } } foreach (String f in invertedlist) { if (Path.GetExtension(f).ToLower() != ".dwbcs") { if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0) { FoldersList.Items.Add(new ListItem { Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f) }); } } } FOSSEEList.Items.Add(new ListItem { Text = "Downloading flowsheet list, please wait...", Key = "" }); Dictionary <string, SharedClasses.FOSSEEFlowsheet> fslist = new Dictionary <string, SharedClasses.FOSSEEFlowsheet>(); Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.GetFOSSEEFlowsheets()); }).ContinueWith((t) => { Application.Instance.Invoke(() => { FOSSEEList.Items.Clear(); if (t.Exception != null) { FOSSEEList.Items.Add(new ListItem { Text = "Error loading flowsheet list. Check your internet connection.", Key = "" }); } else { foreach (var item in t.Result) { fslist.Add(item.DownloadLink, item); FOSSEEList.Items.Add(new ListItem { Text = item.Title, Key = item.DownloadLink }); } } }); }); FoldersList.SelectedIndexChanged += (sender, e) => { if (FoldersList.SelectedIndex >= 0) { var dialog = new OpenFileDialog(); dialog.Title = "Open File".Localize(); dialog.Directory = new Uri(FoldersList.SelectedKey); dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" })); dialog.MultiSelect = false; dialog.CurrentFilterIndex = 0; if (dialog.ShowDialog(this) == DialogResult.Ok) { LoadSimulation(dialog.FileName); } } }; MostRecentList.SelectedIndexChanged += (sender, e) => { if (MostRecentList.SelectedIndex >= 0) { LoadSimulation(MostRecentList.SelectedKey); MostRecentList.SelectedIndex = -1; } ; }; SampleList.SelectedIndexChanged += (sender, e) => { if (SampleList.SelectedIndex >= 0) { LoadSimulation(SampleList.SelectedKey); MostRecentList.SelectedIndex = -1; } ; }; FOSSEEList.SelectedIndexChanged += (sender, e) => { if (FOSSEEList.SelectedIndex >= 0 && FOSSEEList.SelectedKey != "") { var item = fslist[FOSSEEList.SelectedKey]; var sb = new StringBuilder(); sb.AppendLine("Title: " + item.Title); sb.AppendLine("Author: " + item.ProposerName); sb.AppendLine("Institution: " + item.Institution); sb.AppendLine(); sb.AppendLine("Click 'Yes' to download and open this flowsheet."); if (MessageBox.Show(sb.ToString(), "Open FOSSEE Flowsheet", MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.Yes) == DialogResult.Yes) { var loadingdialog = new LoadingData(); loadingdialog.loadingtext.Text = "Please wait, downloading file...\n(" + FOSSEEList.SelectedKey + ")"; loadingdialog.Show(); var address = FOSSEEList.SelectedKey; Task.Factory.StartNew(() => { return(SharedClasses.FOSSEEFlowsheets.DownloadFlowsheet(address, (p) => { Application.Instance.Invoke(() => loadingdialog.loadingtext.Text = "Please wait, downloading file... (" + p + "%)\n(" + address + ")"); })); }).ContinueWith((t) => { Application.Instance.Invoke(() => loadingdialog.Close()); if (t.Exception != null) { MessageBox.Show(t.Exception.Message, "Error downloading file", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK); } else { Application.Instance.Invoke(() => LoadSimulation(SharedClasses.FOSSEEFlowsheets.LoadFlowsheet(t.Result))); } }); FOSSEEList.SelectedIndex = -1; } } ; }; var fosseecontainer = c.GetDefaultContainer(); fosseecontainer.BackgroundColor = bgcolor; var l1 = c.CreateAndAddLabelRow3(fosseecontainer, "About the Project"); var l2 = c.CreateAndAddDescriptionRow(fosseecontainer, "FOSSEE, IIT Bombay, invites chemical engineering students, faculty and practitioners to the flowsheeting project using DWSIM. We want you to convert existing flowsheets into DWSIM and get honoraria and certificates."); var bu1 = c.CreateAndAddButtonRow(fosseecontainer, "Submit a Flowsheet", null, (b1, e1) => Process.Start("https://dwsim.fossee.in/flowsheeting-project")); var bu2 = c.CreateAndAddButtonRow(fosseecontainer, "About FOSSEE", null, (b2, e2) => Process.Start("https://fossee.in/")); var l3 = c.CreateAndAddLabelRow3(fosseecontainer, "Completed Flowsheets"); l1.TextColor = Colors.White; l2.TextColor = Colors.White; l3.TextColor = Colors.White; bu1.TextColor = Colors.White; bu2.TextColor = Colors.White; bu1.BackgroundColor = bgcolor; bu2.BackgroundColor = bgcolor; fosseecontainer.Add(FOSSEEList); fosseecontainer.EndVertical(); var tabview = new TabControl(); var tab1 = new TabPage(MostRecentList) { Text = "Recent Files" };; var tab2 = new TabPage(SampleList) { Text = "Samples" };; var tab2a = new TabPage(fosseecontainer) { Text = "FOSSEE Flowsheets" };; var tab3 = new TabPage(FoldersList) { Text = "Recent Folders" };; tabview.Pages.Add(tab1); tabview.Pages.Add(tab2); tabview.Pages.Add(tab2a); tabview.Pages.Add(tab3); tableright.Rows.Add(new TableRow(tabview)); var tl = new DynamicLayout(); tl.Add(new TableRow(stack, tableright)); TableContainer = new TableLayout { Padding = 10, Spacing = new Size(5, 5), Rows = { new TableRow(tl) }, BackgroundColor = bgcolor, }; Content = TableContainer; var quitCommand = new Command { MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); var aboutCommand = new Command { MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png")) }; aboutCommand.Executed += (sender, e) => new AboutBox().Show(); var aitem1 = new ButtonMenuItem { Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png")) }; aitem1.Click += (sender, e) => { new Forms.Forms.GeneralSettings().GetForm().Show(); }; var aitem2 = new ButtonMenuItem { Text = "Open Classic UI", Shortcut = Keys.Alt | Keys.C }; aitem2.Click += (sender, e) => { DWSIM.macOS.ClassicUILoader.Loader.Load(); }; var hitem1 = new ButtonMenuItem { Text = "Help".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem1.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/docs/crossplatform/help/"); }; var hitem2 = new ButtonMenuItem { Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem2.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br/wiki/index.php?title=Support"); }; var hitem3 = new ButtonMenuItem { Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem3.Click += (sender, e) => { Process.Start("https://sourceforge.net/p/dwsim/tickets/"); }; var hitem4 = new ButtonMenuItem { Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png")) }; hitem4.Click += (sender, e) => { Process.Start("http://dwsim.inforside.com.br"); }; // create menu Menu = new MenuBar { ApplicationItems = { aitem1, aitem2 }, QuitItem = quitCommand, HelpItems = { hitem1, hitem4, hitem2, hitem3 }, AboutItem = aboutCommand }; Shown += MainForm_Shown; Closing += MainForm_Closing; //Plugins LoadPlugins(); }