Ejemplo n.º 1
0
 /// <summary>User has finished renaming a node.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The EventArgs instance containing the event data.</param>
 private void OnAfterLabelEdit(object sender, EditedArgs e)
 {
     try
     {
         textRender.Editable = false;
         // TreeView.ContextMenuStrip = this.PopupMenu;
         if (Renamed != null && !string.IsNullOrEmpty(e.NewText))
         {
             NodeRenameArgs args = new NodeRenameArgs()
             {
                 NodePath = this.nodePathBeforeRename,
                 NewName  = e.NewText
             };
             Renamed(this, args);
             if (!args.CancelEdit)
             {
                 previouslySelectedNodePath = args.NodePath;
             }
         }
     }
     catch (Exception err)
     {
         ShowError(err);
     }
 }
Ejemplo n.º 2
0
 /// <summary>User has renamed a node.</summary>
 /// <param name="sender">Sending object</param>
 /// <param name="e">Event node arguments</param>
 private void OnRename(object sender, NodeRenameArgs e)
 {
     try
     {
         e.CancelEdit = false;
         if (e.NewName != null)
         {
             if (this.IsValidName(e.NewName))
             {
                 Model model = Apsim.Get(this.ApsimXFile, e.NodePath) as Model;
                 if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty)
                 {
                     this.HideRightHandPanel();
                     RenameModelCommand cmd = new RenameModelCommand(model, e.NewName, this.view);
                     CommandHistory.Add(cmd);
                     this.ShowRightHandPanel();
                     e.CancelEdit = model.Name != e.NewName;
                 }
             }
             else
             {
                 MainPresenter.ShowError("Use alpha numeric characters only!");
                 e.CancelEdit = true;
             }
         }
     }
     catch (Exception err)
     {
         MainPresenter.ShowError(err);
     }
 }
Ejemplo n.º 3
0
 /// <summary>User has renamed a node.</summary>
 /// <param name="sender">Sending object</param>
 /// <param name="e">Event node arguments</param>
 private void OnRename(object sender, NodeRenameArgs e)
 {
     e.CancelEdit = false;
     if (e.NewName != null)
     {
         if (this.IsValidName(e.NewName))
         {
             Model model = Apsim.Get(this.ApsimXFile, e.NodePath) as Model;
             if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty)
             {
                 this.HideRightHandPanel();
                 string             parentModelPath = StringUtilities.ParentName(e.NodePath);
                 RenameModelCommand cmd             = new RenameModelCommand(model, e.NewName, view);
                 CommandHistory.Add(cmd);
                 this.ShowRightHandPanel();
                 e.CancelEdit = (model.Name != e.NewName);
             }
         }
         else
         {
             MainPresenter.ShowMessage("Use alpha numeric characters only!", Simulation.ErrorLevel.Error);
             e.CancelEdit = true;
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>User has finished renamed a node.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NodeLabelEditEventArgs"/> instance containing the event data.</param>
 private void OnAfterLabelEdit(object sender, EditedArgs e)
 {
     // TreeView.ContextMenuStrip = this.PopupMenu;
     if (Renamed != null && !string.IsNullOrEmpty(e.NewText))
     {
         NodeRenameArgs args = new NodeRenameArgs()
         {
             NodePath = this.nodePathBeforeRename,
             NewName  = e.NewText
         };
         Renamed(this, args);
         if (!args.CancelEdit)
         {
             previouslySelectedNodePath = args.NodePath;
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>User has finished renamed a node.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NodeLabelEditEventArgs"/> instance containing the event data.</param>
 private void OnAfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     TreeView.ContextMenuStrip = this.PopupMenu;
     if (Renamed != null && e.Label != null)
     {
         NodeRenameArgs args = new NodeRenameArgs()
         {
             NodePath = this.nodePathBeforeRename,
             NewName  = e.Label
         };
         Renamed(this, args);
         e.CancelEdit = args.CancelEdit;
         if (!e.CancelEdit)
         {
             previouslySelectedNodePath = args.NodePath;
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>User has finished renamed a node.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NodeLabelEditEventArgs"/> instance containing the event data.</param>
 private void OnAfterLabelEdit(object sender, EditedArgs e)
 {
     // TreeView.ContextMenuStrip = this.PopupMenu;
     if (Renamed != null && !string.IsNullOrEmpty(e.NewText))
     {
         NodeRenameArgs args = new NodeRenameArgs()
         {
             NodePath = this.nodePathBeforeRename,
             NewName = e.NewText
         };
         Renamed(this, args);
         if (!args.CancelEdit)
             previouslySelectedNodePath = args.NodePath;
     }
 }
Ejemplo n.º 7
0
 /// <summary>User has renamed a node.</summary>
 /// <param name="sender">Sending object</param>
 /// <param name="e">Event node arguments</param>
 private void OnRename(object sender, NodeRenameArgs e)
 {
     e.CancelEdit = false;
     if (e.NewName != null)
     {
         if (this.IsValidName(e.NewName))
         {
             Model model = Apsim.Get(this.ApsimXFile, e.NodePath) as Model;
             if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty)
             {
                 this.HideRightHandPanel();
                 string parentModelPath = StringUtilities.ParentName(e.NodePath);
                 RenameModelCommand cmd = new RenameModelCommand(model,  e.NewName, view);
                 CommandHistory.Add(cmd);
                 this.ShowRightHandPanel();
                 e.CancelEdit = (model.Name != e.NewName);
             }
         }
         else
         {
             MainPresenter.ShowMessage("Use alpha numeric characters only!", DataStore.ErrorLevel.Error);
             e.CancelEdit = true;
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>User has finished renamed a node.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NodeLabelEditEventArgs"/> instance containing the event data.</param>
 private void OnAfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     TreeView.ContextMenuStrip = this.PopupMenu;
     if (Renamed != null && e.Label != null)
     {
         NodeRenameArgs args = new NodeRenameArgs()
         {
             NodePath = this.nodePathBeforeRename,
             NewName = e.Label
         };
         Renamed(this, args);
         e.CancelEdit = args.CancelEdit;
         if (!e.CancelEdit)
             previouslySelectedNodePath = args.NodePath;
     }
 }