Beispiel #1
0
 private void btnInterface2_Click(object sender, EventArgs e)
 {
     try
     {
         TypeSelectorDialog activitySelector = new TypeSelectorDialog(typeof(InputFileGenerator));
         if ((activitySelector.ShowDialog() == DialogResult.OK) && (!String.IsNullOrEmpty(activitySelector.AssemblyPath) && activitySelector.Activity != null))
         {
             txtFileInterfaceName.Text = string.Format("{0}, {1}", activitySelector.Activity.FullName, Path.GetFileNameWithoutExtension(activitySelector.AssemblyPath));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void newAlgorithmButton_Click(object sender, EventArgs e)
 {
     if (algorithmTypeSelectorDialog == null) {
     algorithmTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Algorithm" };
     algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms";
     algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true);
       }
       if (algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     try {
       Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     } catch (Exception ex) {
       ErrorHandling.ShowErrorDialog(this, ex);
     }
       }
 }
 private void setDefaultValueButton_Click(object sender, EventArgs e)
 {
     if (typeSelectorDialog == null)
     {
         typeSelectorDialog         = new TypeSelectorDialog();
         typeSelectorDialog.Caption = "Select Value";
         typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, true);
     }
     if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
     {
         try {
             Content.DefaultValue = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
         } catch (Exception ex) {
             ErrorHandling.ShowErrorDialog(this, ex);
         }
     }
 }
 private void newProblemButton_Click(object sender, EventArgs e)
 {
     if (problemTypeSelectorDialog == null)
     {
         problemTypeSelectorDialog         = new TypeSelectorDialog();
         problemTypeSelectorDialog.Caption = "Select Problem";
         problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
     }
     problemTypeSelectorDialog.TypeSelector.Configure(new List <Type>()
     {
         Content.ProblemType, Content.Algorithm.ProblemType
     }, false, true, true);
     if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK)
     {
         Content.Problem = (IDataAnalysisProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     }
 }
Beispiel #5
0
        private void btnInterface_Click(object sender, EventArgs e)
        {
            try
            {
                TypeSelectorDialog activitySelector = new TypeSelectorDialog(typeof(InputFileGenerator));

                if ((activitySelector.ShowDialog() == DialogResult.OK) && (!String.IsNullOrEmpty(activitySelector.AssemblyPath) && activitySelector.Activity != null))
                {
                    txtInterfaceNameGeneric.Text = string.Format("{0}, {1}", activitySelector.Activity.FullName, Path.GetFileNameWithoutExtension(activitySelector.AssemblyPath));
                    toolStripStatusLabel1.Text   = "";
                }
            }
            catch (Exception ex)
            {
                toolStripStatusLabel1.Text = ex.ToString();
                toolTip.SetToolTip(statusStrip1, ex.ToString());
            }
        }
Beispiel #6
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            TypeSelectorDialog typeSelectorDialog = new TypeSelectorDialog();

            //string selectedNameSpace;
            System.Windows.Forms.DialogResult dResult = typeSelectorDialog.ShowDialog();
            if ((dResult == System.Windows.Forms.DialogResult.OK) && (!String.IsNullOrEmpty(typeSelectorDialog.AssemblyPath) && typeSelectorDialog.Activity != null))
            {
                //selectedNameSpace = string.Format("clr-namespace:{0};assembly={1}", typeSelectorDialog.Activity.Namespace, System.IO.Path.GetFileNameWithoutExtension(typeSelectorDialog.AssemblyPath));
                string newAttributeName  = GenerateNewAttributeName(_TemplateWithJob, typeSelectorDialog.Activity.Namespace);
                string newAttributeValue = GenerateNewAttributeValue(typeSelectorDialog.Activity.Namespace, System.IO.Path.GetFileNameWithoutExtension(typeSelectorDialog.AssemblyPath));
                AddNewAttribute(_TemplateWithData, newAttributeName, newAttributeValue);
                AddNewAttribute(_TemplateWithJob, newAttributeName, newAttributeValue);
                if (MessageBox.Show("You need to close editor to reflect the changes. Do you want to do it now?", "New Reference Added", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    this.Close();
                }
            }
        }
        protected virtual X CreateItem <X>() where X : class
        {
            var typeSelectorDialog = new TypeSelectorDialog();

            typeSelectorDialog.Caption = "Select Item";
            typeSelectorDialog.TypeSelector.Caption = "Available Items";
            typeSelectorDialog.TypeSelector.Configure(typeof(X), false, true);

            if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
            {
                try {
                    return((X)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType());
                }
                catch (Exception ex) {
                    ErrorHandling.ShowErrorDialog(this, ex);
                }
            }
            return(null);
        }
 private void newProblemButton_Click(object sender, EventArgs e)
 {
     if (problemTypeSelectorDialog == null)
     {
         problemTypeSelectorDialog         = new TypeSelectorDialog();
         problemTypeSelectorDialog.Caption = "Select Problem";
         problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
         problemTypeSelectorDialog.TypeSelector.Configure(Content.ProblemType, false, true);
     }
     if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK)
     {
         try {
             Content.Problem = (IProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
         }
         catch (Exception ex) {
             ErrorHandling.ShowErrorDialog(this, ex);
         }
     }
 }
 private void newOptimizerButton_Click(object sender, EventArgs e)
 {
     if (optimizerTypeSelectorDialog == null)
     {
         optimizerTypeSelectorDialog         = new TypeSelectorDialog();
         optimizerTypeSelectorDialog.Caption = "Select Optimizer";
         optimizerTypeSelectorDialog.TypeSelector.Caption = "Available Optimizers";
         optimizerTypeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true);
     }
     if (optimizerTypeSelectorDialog.ShowDialog(this) == DialogResult.OK)
     {
         try {
             Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
         }
         catch (Exception ex) {
             ErrorHandling.ShowErrorDialog(this, ex);
         }
     }
 }
        protected virtual object CreateItem()
        {
            if (typeSelectorDialog == null)
            {
                typeSelectorDialog = new TypeSelectorDialog {
                    Caption = "Select Item"
                };
                typeSelectorDialog.TypeSelector.Caption = "Available Items";
                typeSelectorDialog.TypeSelector.Configure(typeof(IItem), false, true);
            }

            if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
            {
                try {
                    return((object)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType());
                } catch (Exception ex) {
                    ErrorHandling.ShowErrorDialog(this, ex);
                }
            }
            return(null);
        }
        private void addButton_Click(object sender, EventArgs e)
        {
            if (typeSelectorDialog == null)
            {
                typeSelectorDialog         = new TypeSelectorDialog();
                typeSelectorDialog.Caption = "Select Symbol";
                typeSelectorDialog.TypeSelector.Caption = "Available Symbols";
                typeSelectorDialog.TypeSelector.Configure(typeof(ISymbol), false, false, (t) => { return(!typeof(IReadOnlySymbol).IsAssignableFrom(t)); });
            }
            if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
            {
                try {
                    ISymbol symbol = (ISymbol)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
                    ChangeDuplicateSymbolNames(symbol);
                    GroupSymbol groupSymbol = null;

                    TreeNode selectedNode = symbolsTreeView.SelectedNode;
                    if (selectedNode != null)
                    {
                        groupSymbol = selectedNode.Tag as GroupSymbol;
                        if (groupSymbol == null && selectedNode.Parent != null)
                        {
                            groupSymbol = selectedNode.Parent.Tag as GroupSymbol;
                        }
                    }
                    if (groupSymbol != null)
                    {
                        groupSymbol.SymbolsCollection.Add(symbol);
                    }
                    else
                    {
                        Content.AddSymbol(symbol);
                    }
                }
                catch (Exception ex) {
                    ErrorHandling.ShowErrorDialog(this, ex);
                }
            }
        }
 private void newDataButton_Click(object sender, EventArgs e)
 {
     if (typeSelectorDialog == null)
     {
         typeSelectorDialog         = new TypeSelectorDialog();
         typeSelectorDialog.Caption = "Select Algorithm";
         typeSelectorDialog.TypeSelector.Caption = "Available Algorithms";
         typeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true);
     }
     if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
     {
         try {
             Content.DataTypeName     = typeSelectorDialog.TypeSelector.SelectedType.Name;
             Content.DataTypeTypeName = typeSelectorDialog.TypeSelector.SelectedType.AssemblyQualifiedName;
             data = null;
             dataViewHost.Content = (IContent)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
         }
         catch (Exception ex) {
             ErrorHandling.ShowErrorDialog(this, "Create new algorithm data failed.", ex);
         }
         SetEnabledStateOfControls();
     }
 }
 private void ShowTypeSelectorDialog(ISelectedType selectedType, string dialogTitle, TextBox textBox)
 {
     var view = new SelectedTypeViewModel(selectedType)
     {
         DialogTitle = dialogTitle,
         TextBox = textBox
     };
     var controller = new TypeSelectorController(view);
     controller.LoadView();
     var dialog = new TypeSelectorDialog()
     {
         Owner = this,
         WindowStartupLocation = WindowStartupLocation.CenterOwner,
         Model = view
     };
     view.SaveViewToModelCallback = controller.SaveView;
     if (dialog.ShowDialog() != true)
     {
         return;
     }
 }