コード例 #1
0
        private void AddProgressView(string progressMessage)
        {
            var mainForm = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>();

            mainForm.AddOperationProgressToView(this, progressMessage);
            progressViewCreated = true;
        }
コード例 #2
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);
        }
コード例 #3
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);
            }
        }
コード例 #4
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();
        }
コード例 #5
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;
     }
 }
コード例 #6
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);
 }
コード例 #9
0
 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);
 }
コード例 #10
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);
        }
コード例 #11
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();
 }
コード例 #12
0
ファイル: View.cs プロジェクト: thunder176/HeuristicLab
        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);
            }
        }
コード例 #13
0
        private void RemoveProgressView()
        {
            if (!progressViewCreated)
            {
                return;
            }
            var mainForm = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>();

            mainForm.RemoveOperationProgressFromView(this);
            progressViewCreated = false;
        }
コード例 #14
0
 public void FinishProgressView()
 {
     if (InvokeRequired)
     {
         Invoke(new Action(FinishProgressView));
     }
     else
     {
         MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
     }
 }
コード例 #15
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();
        }
コード例 #16
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);
     }
 }
コード例 #17
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();
         }
     }
 }
コード例 #18
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));
        }
コード例 #19
0
ファイル: View.cs プロジェクト: thunder176/HeuristicLab
        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));
        }
コード例 #20
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();
                }
            }
        }
コード例 #22
0
ファイル: FileManager.cs プロジェクト: lulzzz/HeuristicLab
 private static void SavingCompleted(IStorableContent content, Exception error)
 {
     try {
         if (error != null)
         {
             throw error;
         }
         MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle();
     } catch (OperationCanceledException) { // do nothing if canceled
     } catch (Exception ex) {
         ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot save file.", ex);
     } finally {
         Progress.Hide(content);
         MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor();
     }
 }
コード例 #23
0
 protected override void RegisterContentEvents()
 {
     base.RegisterContentEvents();
     Content.RefreshAutomaticallyChanged += new EventHandler(Content_RefreshAutomaticallyChanged);
     Content.JobChanged            += new EventHandler(Content_HiveExperimentChanged);
     Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
     Content.JobStatisticsChanged  += new EventHandler(Content_JobStatisticsChanged);
     Content.ExceptionOccured      += new EventHandler <EventArgs <Exception> >(Content_ExceptionOccured);
     Content.StateLogListChanged   += new EventHandler(Content_StateLogListChanged);
     Content.HiveTasksChanged      += new EventHandler(Content_HiveTasksChanged);
     Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     Content.ExecutionTimeChanged  += new EventHandler(Content_ExecutionTimeChanged);
     Content.Loaded       += new EventHandler(Content_Loaded);
     Content.TaskReceived += new EventHandler(Content_TaskReceived);
     MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress);
 }
コード例 #24
0
        private void CalculateValues()
        {
            if (!VerifyDataLength(true))
            {
                return;
            }

            if (data != null && data.All(x => x != null))
            {
                MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>()
                .AddOperationProgressToView(this, "Calculating...");

                string curItem = (string)groupCompComboBox.SelectedItem;
                Task.Factory.StartNew(() => CalculateValuesAsync(curItem));
            }
        }
コード例 #25
0
        public static void SaveAs(IContentView view)
        {
            IStorableContent content = view.Content as IStorableContent;

            if (!view.Locked && content != null)
            {
                if (saveFileDialog == null)
                {
                    saveFileDialog             = new SaveFileDialog();
                    saveFileDialog.Title       = "Save Item";
                    saveFileDialog.DefaultExt  = "hl";
                    saveFileDialog.Filter      = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*";
                    saveFileDialog.FilterIndex = 2;
                }

                INamedItem namedItem         = content as INamedItem;
                string     suggestedFileName = string.Empty;
                if (!string.IsNullOrEmpty(content.Filename))
                {
                    suggestedFileName = content.Filename;
                }
                else if (namedItem != null)
                {
                    suggestedFileName = namedItem.Name;
                }
                else
                {
                    suggestedFileName = "Item";
                }

                saveFileDialog.FileName = suggestedFileName;

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
                    SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName);
                    if (saveFileDialog.FilterIndex == 1)
                    {
                        ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
                    }
                    else
                    {
                        ContentManager.SaveAsync(content, saveFileDialog.FileName, true, SavingCompleted);
                    }
                }
            }
        }
コード例 #26
0
 private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null)
 {
     HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>();
     #region Mono Compatibility
     // removed the InvokeRequired check because of Mono
     mainForm.Invoke((Action) delegate {
         if (showProgress)
         {
             mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename)));
         }
         else
         {
             mainForm.RemoveOperationProgressFromContent(content);
         }
     });
     #endregion
 }
コード例 #27
0
        private void addLineToChart_Click(object sender, EventArgs e)
        {
            MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Adding fitted lines to charts...");

            string resultName = (string)dataTableComboBox.SelectedItem;
            string rowName    = (string)dataRowComboBox.SelectedItem;

            var task = Task.Factory.StartNew(() => AddLineToChart(resultName, rowName));

            task.ContinueWith((t) => {
                MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                ErrorHandling.ShowErrorDialog("An error occured while adding lines to charts. ", t.Exception);
            }, TaskContinuationOptions.OnlyOnFaulted);

            task.ContinueWith((t) => {
                MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
        }
コード例 #28
0
        private static void Save(IContentView view)
        {
            IStorableContent content = view.Content as IStorableContent;

            if (!view.Locked && content != null)
            {
                if (string.IsNullOrEmpty(content.Filename))
                {
                    SaveAs(view);
                }
                else
                {
                    MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
                    SetSaveOperationProgressInContentViews(content, true);
                    ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
                }
            }
        }
コード例 #29
0
        private void DeleteHiveJobs(EventArgs e)
        {
            if (itemsListView.SelectedItems.Count > 0)
            {
                List <RefreshableJob> items = new List <RefreshableJob>();
                foreach (ListViewItem item in itemsListView.SelectedItems)
                {
                    items.Add((RefreshableJob)item.Tag);
                }

                var task = System.Threading.Tasks.Task.Factory.StartNew(DeleteHiveJobsAsync, items);

                task.ContinueWith((t) => {
                    MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
                    ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception);
                }, TaskContinuationOptions.OnlyOnFaulted);

                task.ContinueWith((t) => {
                    itemsListView.Invoke(new Action(() => itemsListView.SelectedItems.Clear()));
                }, TaskContinuationOptions.OnlyOnRanToCompletion);
            }
        }
コード例 #30
0
        public override void Execute()
        {
            IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;

            content = activeView.Content as IItem;

            //IOptimizer and IExecutables need some special care
            if (content is IOptimizer)
            {
                ((IOptimizer)content).Runs.Clear();
            }
            if (content is IExecutable)
            {
                IExecutable exec = content as IExecutable;
                if (exec.ExecutionState != ExecutionState.Prepared)
                {
                    exec.Prepare();
                }
            }

            HiveClient.Instance.Refresh();

            ItemTask       hiveTask = ItemTask.GetItemTaskForItem(content);
            HiveTask       task     = hiveTask.CreateHiveTask();
            RefreshableJob rJob     = new RefreshableJob();

            rJob.Job.Name = content.ToString();
            rJob.HiveTasks.Add(task);
            task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun;

            progress      = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive...");
            rJob.Progress = progress;
            progress.ProgressStateChanged += progress_ProgressStateChanged;

            HiveClient.StartJob(new Action <Exception>(HandleEx), rJob, new CancellationToken());
        }