示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }