예제 #1
0
 void EditItem(IFitFunction func)
 {
     if (null != func)
     {
         object[] args = new object[] { func };
         if (Current.Gui.ShowDialog(args, "Edit fit function script"))
         {
             if (args[0] is FitFunctionScript)
             {
                 Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController ctrl = new Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController((FitFunctionScript)args[0]);
                 if (Current.Gui.ShowDialog(ctrl, "Store?"))
                 {
                     // Note: category and/or name can have changed now, so it is more save to
                     // completely reinitialize the fit function tree
                     Initialize();
                 }
             }
         }
     }
 }
        private FitFunctionScript Edit(IFitFunction func, bool editItemCopy)
        {
            if (null != func)
            {
                if (func is FitFunctionScript)
                {
                    editItemCopy = true; // for scripts, we always edit a copy
                }
                object[] args = new object[] { (editItemCopy && func is ICloneable cfunc) ? cfunc.Clone() : func };
                if (Current.Gui.ShowDialog(args, "Edit fit function script"))
                {
                    if (args[0] is FitFunctionScript editedScript)
                    {
                        var ctrl = new Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController();
                        ctrl.InitializeDocument(editedScript);
                        if (Current.Gui.ShowDialog(ctrl, "Store?"))
                        {
                            // add the new script to the list
                            var editedScript2 = Current.Project.FitFunctionScripts.Add(editedScript);

                            if (!object.ReferenceEquals(editedScript, editedScript2))
                            {
                                Current.Gui.InfoMessageBox("Edited fit function was not added because exactly the same fit function already exists.", "To your information");
                            }

                            // Note: category and/or name can have changed now, so it is more save to
                            // completely reinitialize the fit function tree
                            Initialize(true);

                            return(editedScript2);
                        }
                    }
                }
            }
            return(null);
        }
		private void EditItem(IFitFunction func, bool editCopy)
		{
			if (null != func)
			{
				object[] args = new object[] { (editCopy && (func is ICloneable)) ? ((ICloneable)func).Clone() : func };
				if (Current.Gui.ShowDialog(args, "Edit fit function script"))
				{
					if (args[0] is FitFunctionScript)
					{
						var ctrl = new Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController();
						ctrl.InitializeDocument((FitFunctionScript)args[0]);
						if (Current.Gui.ShowDialog(ctrl, "Store?"))
						{
							// add the new script to the list
							Current.Project.FitFunctionScripts.Add((FitFunctionScript)args[0]);

							// Note: category and/or name can have changed now, so it is more save to
							// completely reinitialize the fit function tree
							Initialize();
						}
					}
				}
			}
		}
    void EditItem(IFitFunction func)
    {
      if (null != func)
      {
        object[] args = new object[] { func };
        if (Current.Gui.ShowDialog(args, "Edit fit function script"))
        {
          if (args[0] is FitFunctionScript)
          {
            Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController ctrl = new Altaxo.Gui.Scripting.FitFunctionNameAndCategoryController((FitFunctionScript)args[0]);
            if (Current.Gui.ShowDialog(ctrl, "Store?"))
            {
              // Note: category and/or name can have changed now, so it is more save to
              // completely reinitialize the fit function tree
              Initialize();
            }
          }

        }
      }
    }