private void OnAddAlgoButtonClick(object sender, EventArgs e)
        {
            var algo = sourceAlgos.SelectedItem as string;
            if (algo == null)
            {
                return;
            }

            string customeName = string.Empty;

            using (var nameWindow = new NameWindow())
            {
                nameWindow.ObjectName = algo;
                do
                {
                    nameWindow.ShowDialog();
                    if (this.SystemInstance.Algorithms.FirstOrDefault(
                        x => x.CustomName == nameWindow.ObjectName) == null)
                    {
                        customeName = nameWindow.ObjectName;
                        break;
                    }

                    if (nameWindow.DialogResult == DialogResult.OK)
                    {
                        MessageBox.Show(Resources.AlgoNameNotUnique, string.Empty, MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    }

                } while (nameWindow.DialogResult != DialogResult.Cancel);

                if (nameWindow.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            var algorithmInfo = new AlgorithmInfo
                {
                    AlgorithName = algo,
                    CustomName = customeName
                };
            algorithmInfo.Parameters = new List<AlgorithmParameter>();
            foreach (AlgorithmParameter parameter in AppFacade.DI.Container.Resolve<IAlgorithm>(algo).Parameters
                )
            {
                algorithmInfo.Parameters.Add(
                    new AlgorithmParameter(parameter.Name, parameter.DefaultValue)
                    {
                        Value = parameter.DefaultValue
                    });
            }

            SystemInstance.Algorithms.Add(algorithmInfo);
        }
        private void OnAddObserverClick(object sender, EventArgs e)
        {
            using (var nameWindow = new NameWindow())
            {
                if (nameWindow.ShowDialog() == DialogResult.OK)
                {
                    SystemInstance.AddObserver(nameWindow.ObjectName);
                }
            }

            observersBindingSource.ResetBindings(false);
        }
Esempio n. 3
0
 private void OnNewToolStripMenuItemClick(object sender, EventArgs e)
 {
     using (var nameDialog = new NameWindow())
     {
         if (nameDialog.ShowDialog() == DialogResult.OK)
         {
             SubjectiveSystem system = SubjectiveSystem.CreateNew(nameDialog.ObjectName);
             ShowSystem(system);
         }
     }
 }