Example #1
0
        void AddAlgNode(string algName, double x = 0, double y = 0, LoopControl loop = null)
        {
            Type algType = HydrologyCore.AlgorithmTypes[algName];

            DataTable paramsTable = new DataTable();
            paramsTable.Columns.Add("Name");
            paramsTable.Columns.Add("Value");

            foreach (ParameterAttribute attr in algType.GetCustomAttributes<ParameterAttribute>())
            {
                DataRow row = paramsTable.NewRow();
                row["Name"] = attr.Name;
                row["Value"] = attr.DefaultValue;
                paramsTable.Rows.Add(row);
            }

            var algSettings = new AlgorithmSettings(FolderDialog, paramsTable, algType)
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };
            if (ViewedLoop != null)
                algSettings.ParentLoop = ViewedLoop;
            bool? dialogResult = algSettings.ShowDialog();
            if (dialogResult.HasValue && dialogResult.Value)
            {
                AddNode(algType, algSettings.Path, algSettings.ParamsTable, x, y, loop, algSettings.VarLoop);
            }
        }
Example #2
0
 public void node_SettingsClicked(object sender, EventArgs e)
 {
     AlgorithmNodeControl node = (AlgorithmNodeControl)sender;
     var algSettings = new AlgorithmSettings(FolderDialog, node.ParamsTable, node.AlgorithmType)
     {
         Owner = this,
         Path = node.InitPath,
         WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
     };
     if (ViewedLoop != null)
         algSettings.ParentLoop = ViewedLoop;
     try
     {
         bool? dialogResult = algSettings.ShowDialog();
         if (dialogResult.HasValue && dialogResult.Value)
         {
             node.InitPath = algSettings.Path;
             node.ParamsTable = algSettings.ParamsTable;
             node.VarLoop = algSettings.VarLoop;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Произошла ошибка во время сохранения настроек: {0}", ex.Message),
             "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }