예제 #1
0
        /*
         * override protected void MakeContextMenu(List<ToolStripItem> menuItemList, object selectedListItem, object selectedObject, string aspectName)
         * {
         *  base.MakeContextMenu(menuItemList, selectedListItem, selectedObject, aspectName);
         *  menuItemList.Add(new ToolStripSeparator());
         *
         *  if (selectedObject != null)
         *  {
         *      if (selectedObject is EntityTreeFolder)
         *      {
         *          //no to add
         *      }
         *      else
         *      {
         *          //JCompDeviceListWindow.MakeContextMenuBlock(menuItemList, item, this.ContentContainer);
         *      }
         *  }
         * }
         */



        override protected void MakeContextMenuAddBlock(List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, JRights rights)
        {
            ToolStripMenuItem menuItem = null;

            TreeNode selectedNode = selectedListItem as TreeNode;

            if (selectedObject != null)
            {
                if (selectedObject is RootGroupTreeFolder)
                {
                    Type type = (selectedObject as RootGroupTreeFolder).EntityType;
                    menuItemList.Add(CreateAddNode(selectedListItem, selectedObject, rights, type, null));
                }
                else if (selectedObject is BranchGroupTreeFolder)
                {
                    BranchGroupTreeFolder bf = (selectedObject as BranchGroupTreeFolder);
                    menuItemList.Add(CreateAddNode(selectedListItem, bf.ParentObject, rights, bf.RefEntityInfo.RefEntity, bf.RefEntityInfo));
                }
                else
                {
                    List <RefEntityInfo> rels = Dm.Instance.GetAllReferencedToEntity(selectedObject, false);
                    foreach (var rt in rels)
                    {
                        if (rt.foreinProperty != null)
                        {
                            menuItemList.Add(CreateAddNode(selectedListItem, selectedObject, rights, rt.RefEntity, rt));
                        }
                    }
                }
            }
        }
        override protected void MakeContextMenuAddBlock(List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, JRights rights)
        {
            TreeNode parentNode = selectedListItem as TreeNode;

            ToolStripMenuItem menuItem = null;

            menuItem         = new ToolStripMenuItem();
            menuItem.Text    = FrwCRUDRes.List_Add_TopLevel_Record;
            menuItem.Enabled = rights.CanAdd;
            menuItem.Click  += (s, em) =>
            {
                try
                {
                    AddObject(selectedListItem, selectedObject, SourceObjectType, null);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            menuItemList.Add(menuItem);

            if (parentNode != null)
            {
                menuItem         = new ToolStripMenuItem();
                menuItem.Text    = FrwCRUDRes.List_Add_Child_Record;
                menuItem.Enabled = rights.CanAddChild;
                menuItem.Click  += (s, em) =>
                {
                    try
                    {
                        object x    = (parentNode.Tag is TreeObjectWrap) ? (parentNode.Tag as TreeObjectWrap).Tag : parentNode.Tag;
                        var    pars = new Dictionary <string, object> {
                            { "Parent", x }, { "ParentNode", parentNode }
                        };
                        AddObject(selectedListItem, selectedObject, SourceObjectType, pars);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemList.Add(menuItem);
            }
        }