Exemplo n.º 1
0
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new RegressionImportTypeDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                IRegressionProblemData instance = null;

                Task.Factory.StartNew(() => {
                    var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
                    // lock active view and show progress bar
                    IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;

                    try {
                        var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");

                        Content.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; };

                        instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                    } catch (IOException ex) {
                        ErrorWhileParsing(ex);
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(instance);
                    } catch (IOException ex) {
                        ErrorWhileLoading(ex, importTypeDialog.Path);
                    } finally {
                        Invoke((Action)(() => instancesComboBox.SelectedIndex = -1));
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                    }
                });
            }
        }
        protected override void instancesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            toolTip.SetToolTip(instancesComboBox, String.Empty);
            if (instancesComboBox.SelectedIndex >= 0)
            {
                var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;

                IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
                var          mainForm   = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
                // lock active view and show progress bar
                mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");

                Task.Factory.StartNew(() => {
                    CFGData data;
                    try {
                        data = Content.LoadDataLocal(descriptor, treeCheckBox.Checked, (int)numberOfTempVarUpDown.Value);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex);
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(data);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
                    } finally {
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                    }
                });
            }
        }
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new CFGImportGenerateDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                CFGData instance = null;
                try {
                    if (importTypeDialog.ImportButtonClick)
                    {
                        instance = Content.ImportData(importTypeDialog.Path);
                    }
                    else
                    {
                        instance = Content.GenerateGrammar(importTypeDialog.GenerateOptions);
                    }
                } catch (IOException ex) {
                    ErrorWhileParsing(ex);
                    return;
                }
                try {
                    GenericConsumer.Load(instance);
                    instancesComboBox.SelectedIndex = -1;
                } catch (IOException ex) {
                    ErrorWhileLoading(ex, importTypeDialog.Path);
                }
            }
        }
Exemplo n.º 4
0
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var provider = Content as DataAnalysisInstanceProvider <T, DataAnalysisImportType>;

            if (provider != null)
            {
                var importTypeDialog = new DataAnalysisImportDialog();
                if (importTypeDialog.ShowDialog() == DialogResult.OK)
                {
                    T instance = default(T);
                    try {
                        instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                    } catch (IOException ex) {
                        ErrorWhileParsing(ex);
                        return;
                    }
                    try {
                        GenericConsumer.Load(instance);
                        instancesComboBox.SelectedIndex = -1;
                    } catch (IOException ex) {
                        ErrorWhileLoading(ex, importTypeDialog.Path);
                    }
                }
            }
            else
            {
                base.importButton_Click(sender, e);
            }
        }
Exemplo n.º 5
0
        protected virtual void instancesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            toolTip.SetToolTip(instancesComboBox, String.Empty);
            if (instancesComboBox.SelectedIndex >= 0)
            {
                var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;

                IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
                var          content    = activeView.Content;
                // lock active view and show progress bar
                Progress.Show(content, "Loading problem instance.", ProgressMode.Indeterminate);

                Task.Factory.StartNew(() => {
                    T data;
                    try {
                        data = Content.LoadData(descriptor);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex);
                        Progress.Hide(content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(data);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
                    } finally {
                        Progress.Hide(content);
                    }
                });
            }
        }
 protected override void importButton_Click(object sender, EventArgs e)
 {
     using (var dialog = new TSPLIBImportDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             var instance = Content.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
             try {
                 GenericConsumer.Load(instance);
                 instancesComboBox.SelectedIndex = -1;
             } catch (Exception ex) {
                 MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
             }
         }
     }
 }
Exemplo n.º 7
0
 protected virtual void importButton_Click(object sender, EventArgs e)
 {
     openFileDialog.FileName = Content.Name + " instance";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         T instance = default(T);
         try {
             instance = Content.ImportData(openFileDialog.FileName);
         } catch (Exception ex) {
             MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         try {
             GenericConsumer.Load(instance);
             instancesComboBox.SelectedIndex = -1;
         } catch (Exception ex) {
             MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
         }
     }
 }
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new TimeSeriesPrognosisImportDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                ITimeSeriesPrognosisProblemData instance = null;
                try {
                    instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                } catch (IOException ex) {
                    ErrorWhileParsing(ex);
                    return;
                }
                try {
                    GenericConsumer.Load(instance);
                    instancesComboBox.SelectedIndex = -1;
                } catch (IOException ex) {
                    ErrorWhileLoading(ex, importTypeDialog.Path);
                }
            }
        }