static void UpdateTreeStyle(Cairo.Color newBgColor) { string oddRowColor, bgColor; bgColor = CairoExtensions.ColorGetHex(newBgColor); if (bgColor == currentBgColor) { return; } if (IdeApp.Preferences.UserInterfaceTheme == Ide.Theme.Light) { oddRowColor = CairoExtensions.ColorGetHex(newBgColor.AddLight(-0.02)); } else { oddRowColor = CairoExtensions.ColorGetHex(newBgColor.AddLight(-0.02)); } string rc = "style \"" + innerTreeName + "\" = \"treeview\" {\n"; rc += string.Format("GtkTreeView::odd-row-color = \"{0}\"\n", oddRowColor); rc += string.Format("base[NORMAL] = \"{0}\"\n", bgColor); rc += "\n}\n"; rc += string.Format("widget \"*.{0}\" style \"{0}\" ", innerTreeName); Rc.ParseString(rc); currentBgColor = bgColor; }
static DockNotebook() { Rc.ParseString("style \"gdl-dock-notebook-default\" {\n" + "xthickness = 2\n" + "ythickness = 2\n" + "}\n" + "widget_class \"*.GtkNotebook.Gdl_DockItem\" " + "style : gtk \"gdl-dock-notebook-default\"\n"); }
static DockItem() { Rc.ParseString("style \"gdl-dock-item-default\" {\n" + "xthickness = 0\n" + "ythickness = 0\n" + "}\n" + "class \"Gdl_DockItem\" " + "style : gtk \"gdl-dock-item-default\"\n"); }
static void UpdateStyles() { var bgColorHex = Styles.ColorGetHex(Styles.NewProjectDialog.ProjectConfigurationRightHandBackgroundColor); string rcstyle = "style \"projectFolderPreviewWidget\"\r\n{\r\n" + " base[NORMAL] = \"" + bgColorHex + "\"\r\n" + " GtkTreeView::even-row-color = \"" + bgColorHex + "\"\r\n" + "}\r\n"; rcstyle += "widget \"*projectFolderPreviewWidget*\" style \"projectFolderPreviewWidget\"\r\n"; Rc.ParseString(rcstyle); }
private static void SetupTheme(string themeName) { try { Rc.ParseString("gtk-theme-name = Default"); string path; if (string.IsNullOrEmpty(themeName)) { path = "theme_clearlooks"; } else { path = themeName; } string path2; if (Platform.IsWindows) { path2 = "gtkrc.win32"; } else { path2 = "gtkrc.mac"; } string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; string text = Path.Combine(baseDirectory, path); text = Path.Combine(text, path2); bool flag = true; if (flag) { Environment.SetEnvironmentVariable("GTK2_RC_FILES", text); } else { Environment.SetEnvironmentVariable("GTK2_RC_FILES", "D:\\Repository\\CocoStudio-2.0\\CocoStudioMono\\CocoStudio.Core\\theme_clearlooks\\gtkrc.win32"); text = "D:\\Repository\\CocoStudio-2.0\\CocoStudioMono\\CocoStudio.Core\\theme_clearlooks\\gtkrc.win32"; } using (FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read)) { using (TextReader textReader = new StreamReader(fileStream)) { string rc_string = textReader.ReadToEnd(); Rc.ParseString(rc_string); } } } catch (Exception exception) { LogConfig.Logger.Error("Read theme file failed,", exception); } }
/// <summary>Populate the tree view.</summary> private void PopulateTreeView() { var types = new Type[table.Columns.Count]; columns = new List <TreeViewColumn>(); cells = new List <CellRendererText>(); // Clear all columns from tree. while (tree.Columns.Length > 0) { tree.RemoveColumn(tree.Columns[0]); } // initialise column headers for (int i = 0; i < table.Columns.Count; i++) { types[i] = typeof(string); var cell = new CellRendererText(); cells.Add(cell); columns.Add(new TreeViewColumn { Title = table.Columns[i].ColumnName, Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }); columns[i].PackStart(cells[i], false); columns[i].AddAttribute(cells[i], "text", i); columns[i].AddNotification("width", OnColumnWidthChange); columns[i].SetCellDataFunc(cell, OnFormatColumn); tree.AppendColumn(columns[i]); } var store = new ListStore(types); tree.Model = store; tree.Selection.Mode = SelectionMode.Multiple; tree.RubberBanding = true; tree.CanFocus = true; tree.RulesHint = true; string style = "style \"custom-treestyle\"{ GtkTreeView::odd-row-color = \"#ECF2FD\" GtkTreeView::even-row-color = \"#FFFFFF\" GtkTreeView::allow-rules = 1 } widget \"*custom_treeview*\" style \"custom-treestyle\""; tree.Name = "custom_treeview"; Rc.ParseString(style); // Populate with rows. store.Clear(); foreach (DataRow row in table.Rows) { store.AppendValues(row.ItemArray); } }
/// <summary> /// Sets the Gtk theme based on the user's previous choice. /// </summary> public void RefreshTheme() { if (Utility.Configuration.Settings.DarkTheme) { using (Stream rcStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.dark.gtkrc")) { using (StreamReader darkTheme = new StreamReader(rcStream)) Rc.ParseString(darkTheme.ReadToEnd()); } // Remove black colour from colour pallete. Color black = Color.FromArgb(0, 0, 0); ColourUtilities.Colours = ColourUtilities.Colours.Where(c => c != black).ToArray(); } else { Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".gtkrc")); } }
static void UpdateStyles() { var categoriesBackgroundColorHex = Styles.ColorGetHex(Styles.NewProjectDialog.CategoriesBackgroundColor); var templateListBackgroundColorHex = Styles.ColorGetHex(Styles.NewProjectDialog.TemplateListBackgroundColor); string rcstyle = "style \"templateCategoriesTreeView\"\r\n{\r\n" + " base[NORMAL] = \"" + categoriesBackgroundColorHex + "\"\r\n" + " GtkTreeView::even-row-color = \"" + categoriesBackgroundColorHex + "\"\r\n" + "}\r\n"; rcstyle += "style \"templatesTreeView\"\r\n{\r\n" + " base[NORMAL] = \"" + templateListBackgroundColorHex + "\"\r\n" + " GtkTreeView::even-row-color = \"" + templateListBackgroundColorHex + "\"" + "\r\n}"; rcstyle += "widget \"*templateCategoriesTreeView*\" style \"templateCategoriesTreeView\"\r\n"; rcstyle += "widget \"*templatesTreeView*\" style \"templatesTreeView\"\r\n"; Rc.ParseString(rcstyle); }
/// <summary> /// Constructor. Initialises the jobs TreeView and the controls associated with it. /// </summary> /// <param name="owner"></param> public CloudJobDisplayView(ViewBase owner) : base(owner) { store = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); Type[] types = new Type[columnTitles.Length]; tree = new Gtk.TreeView() { CanFocus = true, RubberBanding = true, Name = "custom_treeview" }; tree.Selection.Mode = SelectionMode.Multiple; for (int i = 0; i < columnTitles.Length; i++) { types[i] = typeof(string); TreeViewColumn col = new TreeViewColumn { Title = columnTitles[i], SortColumnId = i, Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }; CellRendererText cell = new CellRendererText(); col.PackStart(cell, false); col.AddAttribute(cell, "text", i); tree.AppendColumn(col); } store = new ListStore(types); // this filter holds the model (data) and is used to filter jobs based on whether // they were submitted by the user filterOwner = new TreeModelFilter(store, null) { VisibleFunc = FilterOwnerFunc }; filterOwner.Refilter(); // the filter then goes into this TreeModelSort, which is used to sort results when // the user clicks on a column header sort = new TreeModelSort(filterOwner) { DefaultSortFunc = (model, a, b) => SortData(model, a, b, Array.IndexOf(columnTitles, "Start Time")) }; for (int i = 0; i < columnTitles.Length; i++) { int count = i; sort.SetSortFunc(i, (model, a, b) => SortData(model, a, b, count)); } // change the colour of every other row - makes it easier to read string style = "style \"custom-treestyle\"{ GtkTreeView::odd-row-color = \"#ECF2FD\" GtkTreeView::even-row-color = \"#FFFFFF\" GtkTreeView::allow-rules = 1 } widget \"*custom_treeview*\" style \"custom-treestyle\""; //tree.CanFocus = true; tree.RulesHint = true; Rc.ParseString(style); // the tree holds the sorted, filtered data tree.Model = sort; // the tree goes into this ScrolledWindow, allowing users to scroll down // to view more jobs ScrolledWindow scroll = new ScrolledWindow(); scroll.Add(tree); // never allow horizontal scrolling, and only allow vertical scrolling when needed scroll.HscrollbarPolicy = PolicyType.Automatic; scroll.VscrollbarPolicy = PolicyType.Automatic; // the scrolled window goes into this frame to distinguish the job view // from the controls beside it Frame treeContainer = new Frame("Cloud Jobs"); treeContainer.Add(scroll); chkFilterOwner = new CheckButton("Display my jobs only"); // display the user's jobs only by default myJobsOnly = true; chkFilterOwner.Active = true; chkFilterOwner.Toggled += ApplyFilter; chkFilterOwner.Yalign = 0; downloadProgress = new ProgressBar(new Adjustment(0, 0, 1, 0.01, 0.01, 1)); lblDownloadProgress = new Label("Downloading: "); downloadProgressContainer = new HBox(); downloadProgressContainer.PackStart(lblDownloadProgress, false, false, 0); downloadProgressContainer.PackStart(downloadProgress, false, false, 0); loadingProgress = new ProgressBar(new Adjustment(0, 0, 100, 0.01, 0.01, 100)); loadingProgress.Adjustment.Lower = 0; loadingProgress.Adjustment.Upper = 100; lblDownloadStatus = new Label(""); lblDownloadStatus.Xalign = 0; btnChangeDownloadDir = new Button("Change Download Directory"); btnChangeDownloadDir.Clicked += BtnChangeDownloadDir_Click; tblButtonContainer = new Table(1, 1, false); tblButtonContainer.Attach(btnChangeDownloadDir, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); btnDownload = new Button("Download"); btnDownload.Clicked += BtnDownload_Click; HBox downloadButtonContainer = new HBox(); downloadButtonContainer.PackStart(btnDownload, false, true, 0); btnDelete = new Button("Delete Job(s)"); btnDelete.Clicked += BtnDelete_Click; HBox deleteButtonContainer = new HBox(); deleteButtonContainer.PackStart(btnDelete, false, true, 0); btnStop = new Button("Stop Job(s)"); btnStop.Clicked += BtnStop_Click; HBox stopButtonContainer = new HBox(); stopButtonContainer.PackStart(btnStop, false, true, 0); btnSetup = new Button("Credentials"); btnSetup.Clicked += BtnSetup_Click; HBox setupButtonContainer = new HBox(); setupButtonContainer.PackStart(btnSetup, false, true, 0); progress = new HBox(); progress.PackStart(new Label("Loading Jobs: "), false, false, 0); progress.PackStart(loadingProgress, false, false, 0); vboxDownloadStatuses = new VBox(); controlsContainer = new VBox(); controlsContainer.PackStart(chkFilterOwner, false, false, 0); controlsContainer.PackStart(downloadButtonContainer, false, false, 0); controlsContainer.PackStart(stopButtonContainer, false, false, 0); controlsContainer.PackStart(deleteButtonContainer, false, false, 0); controlsContainer.PackStart(setupButtonContainer, false, false, 0); controlsContainer.PackEnd(tblButtonContainer, false, false, 0); hboxPrimary = new HBox(); hboxPrimary.PackStart(treeContainer, true, true, 0); hboxPrimary.PackStart(controlsContainer, false, true, 0); vboxPrimary = new VBox(); vboxPrimary.PackStart(hboxPrimary); vboxPrimary.PackStart(lblDownloadStatus, false, false, 0); vboxPrimary.PackEnd(progress, false, false, 0); vboxPrimary.PackEnd(downloadProgressContainer, false, false, 0); mainWidget = vboxPrimary; vboxPrimary.ShowAll(); downloadProgressContainer.HideAll(); HideLoadingProgressBar(); }
/// <summary> /// Initialises and populates the TreeView. /// </summary> /// <param name="columnNames">The names of the columns.</param> /// <param name="simulations">List of simulations. Each simulation is a tuple comprised of the simulation name, the list of factor levels, and an enabled/disabled flag.</param> public void Initialise(List <string> columnNames) { Type[] types = new Type[columnNames.Count]; tree = new Gtk.TreeView(); tree.ButtonPressEvent += TreeClicked; columns = new List <TreeViewColumn>(); cells = new List <CellRendererText>(); // initialise column headers for (int i = 0; i < columnNames.Count; i++) { types[i] = typeof(string); cells.Add(new CellRendererText()); columns.Add(new TreeViewColumn { Title = columnNames[i], Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }); columns[i].PackStart(cells[i], false); columns[i].AddAttribute(cells[i], "text", i); columns[i].AddNotification("width", ColWidthChange); tree.AppendColumn(columns[i]); } store = new ListStore(types); tree.Model = store; tree.Selection.Mode = SelectionMode.Multiple; tree.RubberBanding = true; tree.CanFocus = true; tree.RulesHint = true; string style = "style \"custom-treestyle\"{ GtkTreeView::odd-row-color = \"#ECF2FD\" GtkTreeView::even-row-color = \"#FFFFFF\" GtkTreeView::allow-rules = 1 } widget \"*custom_treeview*\" style \"custom-treestyle\""; tree.Name = "custom_treeview"; Rc.ParseString(style); enableButton = new Button("Enable"); enableButton.Clicked += EnableSims; HBox enableButtonContainer = new HBox(); enableButtonContainer.PackStart(enableButton, true, true, 0); disableButton = new Button("Disable"); disableButton.Clicked += DisableSims; HBox disableButtonContainer = new HBox(); disableButtonContainer.PackStart(disableButton, true, true, 0); exportButton = new Button("Generate CSV"); exportButton.Clicked += OnExportToCsv; HBox csvExportButtonContainer = new HBox(); csvExportButtonContainer.PackStart(exportButton, true, true, 0); importButton = new Button("Import factor information from CSV file"); importButton.Clicked += OnImportCsv; HBox csvImportButtonCOntainer = new HBox(); csvImportButtonCOntainer.PackStart(importButton, true, true, 0); maxSimsInput = new Entry(Presenters.ExperimentPresenter.DefaultMaxSims.ToString()); changeMaxSimsButton = new Button("Apply"); changeMaxSimsButton.Clicked += BtnMaxSims_Click; HBox maxSimsContainer = new HBox(); maxSimsContainer.PackStart(maxSimsInput, true, true, 0); maxSimsContainer.PackStart(changeMaxSimsButton, false, false, 0); numSimsLabel = new Label { Xalign = 0f }; VBox controlsContainer = new VBox(); controlsContainer.PackStart(new Label("Max number of simulations to display:"), false, false, 0); controlsContainer.PackStart(maxSimsContainer, false, false, 0); controlsContainer.PackStart(new Label(""), false, false, 0); controlsContainer.PackStart(enableButtonContainer, false, false, 0); controlsContainer.PackStart(disableButtonContainer, false, false, 0); controlsContainer.PackStart(csvExportButtonContainer, false, false, 0); controlsContainer.PackStart(csvImportButtonCOntainer, false, false, 0); controlsContainer.PackEnd(numSimsLabel, false, false, 0); ScrolledWindow sw = new ScrolledWindow(); sw.Add(tree); sw.HscrollbarPolicy = PolicyType.Automatic; sw.VscrollbarPolicy = PolicyType.Automatic; AccelGroup agr = new AccelGroup(); maxSimsInput.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Return, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); maxSimsInput.Activated += BtnMaxSims_Click; Application.Invoke(delegate { primaryContainer.PackStart(sw, true, true, 0); primaryContainer.PackStart(controlsContainer, false, false, 0); primaryContainer.ShowAll(); }); contextMenu = new Menu(); run = new MenuItem("Run"); run.ButtonPressEvent += OnRunSim; contextMenu.Add(run); }
/// <summary> /// Initialises and populates the TreeView. /// </summary> /// <param name="columnNames">The names of the columns.</param> /// <param name="simulations">List of simulations. Each simulation is a tuple comprised of the simulation name, the list of factor levels, and an enabled/disabled flag.</param> public void Initialise(List <string> columnNames) { //primaryContainer = new HBox(); //_mainWidget = primaryContainer; Type[] types = new Type[columnNames.Count]; tree = new TreeView(); tree.ButtonPressEvent += TreeClicked; columns = new List <TreeViewColumn>(); cells = new List <CellRendererText>(); // initialise column headers for (int i = 0; i < columnNames.Count; i++) { types[i] = typeof(string); cells.Add(new CellRendererText()); columns.Add(new TreeViewColumn { Title = columnNames[i], Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }); columns[i].PackStart(cells[i], false); columns[i].AddAttribute(cells[i], "text", i); columns[i].AddNotification("width", ColWidthChange); tree.AppendColumn(columns[i]); } store = new ListStore(types); tree.Model = store; tree.Selection.Mode = SelectionMode.Multiple; tree.RubberBanding = true; tree.CanFocus = true; tree.RulesHint = true; string style = "style \"custom-treestyle\"{ GtkTreeView::odd-row-color = \"#ECF2FD\" GtkTreeView::even-row-color = \"#FFFFFF\" GtkTreeView::allow-rules = 1 } widget \"*custom_treeview*\" style \"custom-treestyle\""; tree.Name = "custom_treeview"; Rc.ParseString(style); btnEnable = new Button("Enable"); btnEnable.Clicked += (sender, e) => { BtnToggle(true); }; HBox enableButtonContainer = new HBox(); enableButtonContainer.PackStart(btnEnable, true, true, 0); btnDisable = new Button("Disable"); btnDisable.Clicked += (sender, e) => { BtnToggle(false); }; HBox disableButtonContainer = new HBox(); disableButtonContainer.PackStart(btnDisable, true, true, 0); btnExportCsv = new Button("Generate CSV"); btnExportCsv.Clicked += (sender, e) => { Presenter.GenerateCsv(AskUserForFileName("Export to CSV", "CSV file | .csv", Gtk.FileChooserAction.Save, (string)ApsimNG.Properties.Settings.Default["OutputDir"])); }; HBox csvExportButtonContainer = new HBox(); csvExportButtonContainer.PackStart(btnExportCsv, true, true, 0); btnImportCsv = new Button("Import factor information from CSV file"); btnImportCsv.Clicked += (sender, e) => { Presenter.ImportCsv(AskUserForFileName("Choose a .csv file", "CSV file | *.csv")); }; HBox csvImportButtonCOntainer = new HBox(); csvImportButtonCOntainer.PackStart(btnImportCsv, true, true, 0); btnSobol = new Button("Sobol Analysis"); btnSobol.Clicked += (sender, e) => { Presenter.Sobol(); }; btnSobol.Sensitive = false; btnMorris = new Button("Morris method analysis"); btnMorris.Clicked += (sender, e) => { Presenter.Morris(); }; btnMorris.Sensitive = false; VBox sensitivityContainer = new VBox(); sensitivityContainer.PackStart(btnSobol, false, false, 0); sensitivityContainer.PackStart(btnMorris, false, false, 0); Frame analysis = new Frame("Sensitivity Analysis"); analysis.Add(sensitivityContainer); entryMaxSims = new Entry(Presenters.FactorControlPresenter.DEFAULT_MAX_SIMS.ToString()); btnMaxSims = new Button("Apply"); btnMaxSims.Clicked += BtnMaxSims_Click; HBox maxSimsContainer = new HBox(); maxSimsContainer.PackStart(entryMaxSims, true, true, 0); maxSimsContainer.PackStart(btnMaxSims, false, false, 0); lblNumSims = new Label { Xalign = 0f }; VBox controlsContainer = new VBox(); controlsContainer.PackStart(new Label("Max number of simulations to display:"), false, false, 0); controlsContainer.PackStart(maxSimsContainer, false, false, 0); controlsContainer.PackStart(new Label(""), false, false, 0); controlsContainer.PackStart(enableButtonContainer, false, false, 0); controlsContainer.PackStart(disableButtonContainer, false, false, 0); controlsContainer.PackStart(csvExportButtonContainer, false, false, 0); controlsContainer.PackStart(csvImportButtonCOntainer, false, false, 0); controlsContainer.PackStart(new Label(""), false, false, 0); controlsContainer.PackStart(analysis, false, false, 0); controlsContainer.PackEnd(lblNumSims, false, false, 0); //(((Presenter.explorerPresenter.GetView().MainWidget as VBox).Children[1] as HPaned).Child2 as ScrolledWindow).HscrollbarPolicy = PolicyType.Always; ScrolledWindow sw = new ScrolledWindow(); sw.Add(tree); sw.HscrollbarPolicy = PolicyType.Automatic; sw.VscrollbarPolicy = PolicyType.Automatic; //Frame test = new Frame("Factor Control"); //test.Add(sw); AccelGroup agr = new AccelGroup(); entryMaxSims.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Return, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); entryMaxSims.Activated += BtnMaxSims_Click; Application.Invoke(delegate { primaryContainer.PackStart(sw, true, true, 0); primaryContainer.PackStart(controlsContainer, false, false, 0); primaryContainer.ShowAll(); }); contextMenu = new Menu(); run = new MenuItem("Run this simulation"); run.ButtonPressEvent += RunSim; contextMenu.Add(run); }
protected override bool OnEnterNotifyEvent(Gdk.EventCrossing evnt) { Rc.ParseString("class \"*<GtkMenuItem>.GtkCheckButton\" style \"theme-menu-item\""); return(base.OnEnterNotifyEvent(evnt)); }