private void InitCommands()
        {
            #region Commands

            _addFolderCommand = new AddFolderCommand()
            {
                GetArgumentHandler = () =>
                {
                    FolderEntityIndex folderEntityIndex = _currentFolder;
                    return(folderEntityIndex.Folder);
                }
            };

            _addWindowCommand = new AddWindowCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_currentFolder != null);
                },
                GetArgumentHandler = () =>
                {
                    FolderEntityIndex folderEntityIndex = _currentFolder;
                    return(folderEntityIndex.Folder);
                }
            };

            _editCommand = new EditCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.SelectedItemsCount == 1);
                },
                GetArgumentHandler = () =>
                {
                    return(_controller.GetSelectedItem <IEntityIndex>());
                }
            };

            _deleteCommand = new DeleteCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.SelectedItemsCount > 0);
                },
                GetArgumentHandler = () =>
                {
                    return(_controller.GetSelectedItems <IEntityIndex>());
                }
            };

            #endregion
        }
 public GridViewContextMenu()
     : base("GridViewContextMenu")
 {
     this.Items.Add(new ToolStripMenuItemCodon("Add", Language.Current.Explorer_GridViewContextMenu_Add,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.AddCommand != null)
         {
             AddCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (AddCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(AddCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripMenuItemCodon("AddFolder", Language.Current.Explorer_GridViewContextMenu_AddFolder,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.AddFolderCommand != null)
         {
             AddFolderCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (AddFolderCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(AddFolderCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripMenuItemCodon("Edit", Language.Current.Explorer_GridViewContextMenu_Edit,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.EditCommand != null)
         {
             EditCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (EditCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(EditCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripMenuItemCodon("Delete", Language.Current.Explorer_GridViewContextMenu_Delete,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.DeleteCommand != null)
         {
             DeleteCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (DeleteCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(DeleteCommand.CanExcute());
                              } }
     });
 }
示例#3
0
 public TreeMenuFolder()
     : base("TreeMenuFolder")
 {
     this.Items.Add(new ToolStripMenuItemCodon("Add", Language.Current.TreeMenuFolder_Add,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.AddCommand != null)
         {
             AddCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (AddCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(AddCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripMenuItemCodon("Edit", Language.Current.TreeMenuFolder_Edit,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.EditCommand != null)
         {
             EditCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (EditCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(EditCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripMenuItemCodon("Delete", Language.Current.TreeMenuFolder_Delete,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.DeleteCommand != null)
         {
             DeleteCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (DeleteCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(DeleteCommand.CanExcute());
                              } }
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new ToolStripMenuItemCodon("AddWindow", Language.Current.TreeMenuFolder_AddWindow,
                                               delegate(object sender, ToolStripItemCodonEventArgs args)
     {
         if (this.AddWindowCommand != null)
         {
             AddWindowCommand.Excute();
         }
     })
     {
         IsEnabled = (e) => { if (AddWindowCommand == null)
                              {
                                  return(false);
                              }
                              else
                              {
                                  return(AddWindowCommand.CanExcute());
                              } }
     });
 }