Esempio n. 1
0
        private void LoadSamples(object state)
        {
            progress = MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...");
            try {
                var assembly = Assembly.GetExecutingAssembly();
                var samples  = assembly.GetManifestResourceNames().Where(x => x.EndsWith(SampleNameSuffix));
                int count    = samples.Count();

                foreach (var entry in groupLookup)
                {
                    var group      = entry.Key;
                    var sampleList = entry.Value;
                    foreach (var sampleName in sampleList)
                    {
                        string resourceName = SampleNamePrefix + sampleName + SampleNameSuffix;
                        LoadSample(resourceName, assembly, group, count);
                    }
                }

                var categorizedSamples   = groupLookup.Select(x => x.Value).SelectMany(x => x).Select(x => SampleNamePrefix + x + SampleNameSuffix);
                var uncategorizedSamples = samples.Except(categorizedSamples);

                foreach (var resourceName in uncategorizedSamples)
                {
                    LoadSample(resourceName, assembly, uncategorizedGroup, count);
                }

                OnAllSamplesLoaded();
            } finally {
                MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
            }
        }
        protected override void OnContentChanged()
        {
            base.OnContentChanged();

            if (Content == null)
            {
                panel.Controls.Clear();
            }
            else if (Content.GetType() == contentType && view != null)
            {
                view.Content = Content;
            }
            else
            {
                view        = null;
                contentType = Content.GetType();
                panel.Controls.Clear();
                var viewType = MainFormManager.GetViewTypes(Content.GetType(), true).FirstOrDefault(t => typeof(DataAnalysisSolutionView).IsAssignableFrom(t));
                if (viewType != null)
                {
                    view          = (DataAnalysisSolutionView)MainFormManager.CreateView(viewType);
                    view.Locked   = Locked;
                    view.ReadOnly = ReadOnly;
                    view.Dock     = DockStyle.Fill;
                    view.Content  = Content;
                    panel.Controls.Add(view);
                }
            }
        }
        private void RefreshMenuItems()
        {
            if (InvokeRequired)
            {
                Invoke((Action)RefreshMenuItems);
            }
            else
            {
                foreach (ToolStripMenuItem m in menuItems.Values)
                {
                    m.Dispose();
                }
                this.Items.Clear();
                this.menuItems.Clear();

                if (this.item != null)
                {
                    ToolStripMenuItem  menuItem;
                    IEnumerable <Type> types = MainFormManager.GetViewTypes(item.GetType(), true);
                    foreach (Type t in types.Except(IgnoredViewTypes))
                    {
                        menuItem      = new ToolStripMenuItem();
                        menuItem.Tag  = t;
                        menuItem.Text = ViewAttribute.GetViewName(t);

                        this.menuItems.Add(t, menuItem);
                        this.Items.Add(menuItem);
                    }
                }
            }
        }
        private void AddFilter(Filter filter)
        {
            Content.Filters.Add(filter);
            int rowIndex = Content.Filters.Count;

            tableLayoutPanel.SuspendLayout();
            tableLayoutPanel.RowCount++;
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));

            Button removeButton = new Button();

            removeButton.Size   = new System.Drawing.Size(24, 24);
            removeButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            removeButton.Image  = HeuristicLab.Common.Resources.VSImageLibrary.Remove;
            removeButton.Tag    = filter;
            removeButton.Click += new System.EventHandler(removeButton_Click);
            tableLayoutPanel.Controls.Add(removeButton, 0, rowIndex);

            ContentView filterView = (ContentView)MainFormManager.CreateDefaultView(filter.GetType());

            filterView.Content = filter;
            filterView.Anchor  = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            tableLayoutPanel.Controls.Add(filterView, 1, rowIndex);

            tableLayoutPanel.ResumeLayout();
        }
Esempio n. 5
0
        public IContentView ShowContent(IContent content, Type viewType)
        {
            if (InvokeRequired)
            {
                return((IContentView)Invoke((Func <IContent, Type, IContentView>)ShowContent, content, viewType));
            }
            else
            {
                if (content == null)
                {
                    throw new ArgumentNullException("Content cannot be null.");
                }
                if (viewType == null)
                {
                    throw new ArgumentNullException("ViewType cannot be null.");
                }

                IContentView view = null;
                if (ShowContentInViewHost)
                {
                    ViewHost viewHost = new ViewHost();
                    viewHost.ViewType = viewType;
                    view = viewHost;
                }
                else
                {
                    view = MainFormManager.CreateView(viewType);
                }

                view.Content = content;
                view.Show();
                return(view);
            }
        }
Esempio n. 6
0
 private void graphContextMenuStrip_Opening(object sender, CancelEventArgs e)
 {
     viewToolStripMenuItem.Enabled       = false;
     breakpointToolStripMenuItem.Enabled = false;
     breakpointToolStripMenuItem.Checked = false;
     if (graphTreeView.SelectedNode != null)
     {
         IOperator op = GetOperatorTag(graphTreeView.SelectedNode);
         if (op != null)
         {
             Type viewType = MainFormManager.GetDefaultViewType(op.GetType());
             if (viewType != null)
             {
                 viewToolStripMenuItem.Enabled = true;
                 viewToolStripMenuItem.Tag     = op;
             }
             breakpointToolStripMenuItem.Enabled = !Locked;
             breakpointToolStripMenuItem.Tag     = op;
             if (op.Breakpoint)
             {
                 breakpointToolStripMenuItem.Checked = true;
             }
         }
     }
 }
Esempio n. 7
0
        private void UploadAsync()
        {
            var       message  = "Uploading runs to OKB...";
            IProgress progress = MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
            double    count    = dataGridView.Rows.Count;
            int       i        = 0;

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                i++;
                if (!Convert.ToBoolean(row.Cells[UploadColumn.Name].Value))
                {
                    continue;
                }
                selectedAlgorithm = algorithms.FirstOrDefault(x => x.Name == row.Cells[OKBAlgorithmColumn.Name].Value.ToString());
                selectedProblem   = problems.FirstOrDefault(x => x.Name == row.Cells[OKBProblemColumn.Name].Value.ToString());
                if (selectedAlgorithm == null || selectedProblem == null)
                {
                    throw new ArgumentException("Can't retrieve the algorithm/problem to upload");
                }

                OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id);
                run.Store();
                progress.ProgressValue = ((double)i) / count;
            }
            MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
            ClearRuns();
        }
        private void AddProgressView(string progressMessage)
        {
            var mainForm = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>();

            mainForm.AddOperationProgressToView(this, progressMessage);
            progressViewCreated = true;
        }
Esempio n. 9
0
        private void RebuildDataTableAsync()
        {
            string resultName = (string)dataTableComboBox.SelectedItem;

            if (string.IsNullOrEmpty(resultName))
            {
                return;
            }

            string rowName = (string)dataRowComboBox.SelectedItem;

            var task = Task.Factory.StartNew(() => {
                sem.Wait();
                progress = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");
                RebuildDataTable(resultName, rowName);
            });

            task.ContinueWith((t) => {
                MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception);
                sem.Release();
            }, TaskContinuationOptions.OnlyOnFaulted);

            task.ContinueWith((t) => {
                MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                sem.Release();
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
        }
Esempio n. 10
0
        private void CalculateValuesAsync(string groupName)
        {
            CalculateAllGroupsTest();
            CalculateNormalityTest();
            CalculatePairwiseTest(groupName);

            MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
        }
 protected override void DeregisterContentEvents()
 {
     base.DeregisterContentEvents();
     Content.ModelChanged       -= Content_Changed;
     Content.ProblemDataChanged -= Content_Changed;
     treeChart.Repainted        -= treeChart_Repainted;
     MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(grpSimplify, false);
 }
 protected override void RegisterContentEvents()
 {
     base.RegisterContentEvents();
     Content.ModelChanged       += Content_Changed;
     Content.ProblemDataChanged += Content_Changed;
     treeChart.Repainted        += treeChart_Repainted;
     MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToView(grpSimplify, progress);
 }
Esempio n. 13
0
 private void progress_ProgressStateChanged(object sender, EventArgs e)
 {
     if (progress.ProgressState != ProgressState.Started)
     {
         MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromContent(content);
         progress.ProgressStateChanged -= progress_ProgressStateChanged;
     }
 }
Esempio n. 14
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync);

            task.ContinueWith((t) => {
                MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception);
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
 private void DeleteHiveJobsAsync(object items)
 {
     MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Deleting job...");
     foreach (RefreshableJob item in (List <RefreshableJob>)items)
     {
         Content.Remove(item);
     }
     MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
 }
Esempio n. 16
0
 private void RunCreationClient_Refreshed(object sender, EventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke((Action <object, EventArgs>)RunCreationClient_Refreshed, sender, e); return;
     }
     MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
     refreshing = false;
     SetEnabledStateOfControls();
 }
Esempio n. 17
0
 public void FinishProgressView()
 {
     if (InvokeRequired)
     {
         Invoke(new Action(FinishProgressView));
     }
     else
     {
         MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
     }
 }
        private void RemoveProgressView()
        {
            if (!progressViewCreated)
            {
                return;
            }
            var mainForm = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>();

            mainForm.RemoveOperationProgressFromView(this);
            progressViewCreated = false;
        }
Esempio n. 19
0
        public void Close(CloseReason closeReason)
        {
            MainForm mainform = MainFormManager.GetMainForm <MainForm>();
            Form     form     = mainform.GetForm(this);

            if (form != null)
            {
                this.IsShown = false;
                mainform.CloseView(this, closeReason);
            }
        }
 protected virtual void AddEvaluationViewTypes()
 {
     if (Content != null && !Content.ProblemData.IsEmpty)
     {
         var viewTypes = MainFormManager.GetViewTypes(Content.GetType(), true)
                         .Where(t => typeof(IDataAnalysisSolutionEvaluationView).IsAssignableFrom(t));
         foreach (var viewType in viewTypes)
         {
             AddViewListViewItem(viewType, ((IDataAnalysisSolutionEvaluationView)Activator.CreateInstance(viewType)).ViewImage);
         }
     }
 }
Esempio n. 21
0
 public void StartProgressView()
 {
     if (InvokeRequired)
     {
         Invoke(new Action(StartProgressView));
     }
     else
     {
         var message = "Downloading resources. Please be patient.";
         MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
     }
 }
Esempio n. 22
0
        private void RunCreationClient_Refreshing(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke((Action <object, EventArgs>)RunCreationClient_Refreshing, sender, e); return;
            }
            var message = "Refreshing algorithms and problems...";

            MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
            refreshing = true;
            SetEnabledStateOfControls();
        }
Esempio n. 23
0
 private void MainFormBase_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         MainFormManager.RegisterMainForm(this);
         this.CreateGUI();
         if (!this.initialized)
         {
             this.initialized = true;
             this.OnInitialized(EventArgs.Empty);
         }
     }
 }
Esempio n. 24
0
 private void samplesListView_DoubleClick(object sender, EventArgs e)
 {
     if (samplesListView.SelectedItems.Count == 1)
     {
         var mainForm = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>();
         try {
             mainForm.SetWaitCursor();
             mainForm.ShowContent((IContent)((IItem)samplesListView.SelectedItems[0].Tag).Clone());
         } finally {
             mainForm.ResetWaitCursor();
         }
     }
 }
Esempio n. 25
0
        public IContentView ShowContent(IContent content)
        {
            if (content == null)
            {
                throw new ArgumentNullException("Content cannot be null.");
            }
            Type viewType = MainFormManager.GetDefaultViewType(content.GetType());

            if (viewType != null)
            {
                return(ShowContent(content, viewType));
            }
            return(null);
        }
Esempio n. 26
0
        private void CalculatePairwise(string groupName)
        {
            if (groupName == null)
            {
                return;
            }
            if (!VerifyDataLength(false))
            {
                return;
            }

            MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToView(pairwiseTestGroupBox, "Calculating...");
            Task.Factory.StartNew(() => CalculatePairwiseAsync(groupName));
        }
Esempio n. 27
0
        public new void Show()
        {
            MainForm mainform       = MainFormManager.GetMainForm <MainForm>();
            bool     firstTimeShown = mainform.GetForm(this) == null;

            this.IsShown = true;
            mainform.ShowView(this);
            if (firstTimeShown)
            {
                Form form = mainform.GetForm(this);
                form.FormClosed  += new FormClosedEventHandler(OnClosedHelper);
                form.FormClosing += new FormClosingEventHandler(OnClosingHelper);
            }
            this.OnShown(new ViewShownEventArgs(this, firstTimeShown));
        }
Esempio n. 28
0
        private static frmStudioMain InitializeMainForm()
        {
            var mainForm = new frmStudioMain();

            mainForm.FormClosed += MainForm_FormClosed;
            MainFormManager.Start(mainForm);
            MainFormManager.ProcesArguments(Environment.GetCommandLineArgs());

            var toolkitOptions = new ToolkitOptions();

            toolkitOptions.Backend = PlatformBackend.PreferNative;
            Toolkit.Init(toolkitOptions);

            return(mainForm);
        }
Esempio n. 29
0
        protected override void itemsListView_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect != DragDropEffects.Copy)
            {
                return;
            }

            IDataAnalysisProblemData problemData = null;
            var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);

            if (dropData is IDataAnalysisProblemData)
            {
                problemData = (IDataAnalysisProblemData)dropData;
            }
            else if (dropData is IDataAnalysisProblem)
            {
                problemData = ((IDataAnalysisProblem)dropData).ProblemData;
            }
            else if (dropData is IValueParameter)
            {
                var param = (IValueParameter)dropData;
                problemData = param.Value as DataAnalysisProblemData;
            }
            if (problemData == null)
            {
                return;
            }

            problemData = (IDataAnalysisProblemData)problemData.Clone();

            try {
                problemData.AdjustProblemDataProperties(Content.ProblemData);
                Content.ProblemData = problemData;

                if (!Content.Name.EndsWith(" with changed problemData"))
                {
                    Content.Name += " with changed problemData";
                }
                Content.Filename = string.Empty;
                MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle();
            }
            catch (InvalidOperationException invalidOperationException) {
                ErrorHandling.ShowErrorDialog(this, invalidOperationException);
            }
            catch (ArgumentException argumentException) {
                ErrorHandling.ShowErrorDialog(this, argumentException);
            }
        }
        private void exportButton_Click(object sender, EventArgs e)
        {
            var exporter = new SymbolicDiscriminantFunctionClassificationSolutionExcelExporter();

            exportFileDialog.Filter = exporter.FileTypeFilter;
            if (exportFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                var name = exportFileDialog.FileName;
                using (BackgroundWorker bg = new BackgroundWorker()) {
                    MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");
                    bg.DoWork             += (o, a) => exporter.Export(Content, name);
                    bg.RunWorkerCompleted += (o, a) => MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                    bg.RunWorkerAsync();
                }
            }
        }