Exemplo n.º 1
0
        /////////////////
        static public void MakeContextMenuBlock(List <ToolStripItem> menuItemList, object selectedObject, IContentContainer container)
        {
            menuItemList.Add(new ToolStripSeparator());
            ToolStripMenuItem menuItem = null;
            JDocPanelLayout   item     = (JDocPanelLayout)selectedObject;

            if (item != null)
            {
                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = FrwCRUDRes.Save_current_widget_placement_to_this_entry;
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        AppManager.Instance.SaveLayout(item);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemList.Add(menuItem);

                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = FrwCRUDRes.Download_widget_placement_from_this_entry;
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        AppManager.Instance.LoadLayout(item);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemList.Add(menuItem);
            }
        }
Exemplo n.º 2
0
        protected void CreateFileMenuItems(ToolStripMenuItem menuItemFile)
        {
            ToolStripMenuItem menuItem  = null;
            ToolStripMenuItem groupItem = null;

            groupItem = new ToolStripMenuItem(FrwCRUDRes.Close);
            menuItemFile.DropDownItems.Add(groupItem);



            menuItem        = new ToolStripMenuItem(FrwCRUDRes.ActiveDocumentWindow);
            menuItem.Click += (s, em) =>
            {
                try
                {
                    CloseActiveDocument();
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            menuItem        = new ToolStripMenuItem(FrwCRUDRes.AllDocumentsExpectActive);
            menuItem.Click += (s, em) =>
            {
                try
                {
                    CloseAllContents(true, true);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            menuItem        = new ToolStripMenuItem(FrwCRUDRes.AllDocuments);
            menuItem.Click += (s, em) =>
            {
                try
                {
                    CloseAllContents(false, true);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            menuItem        = new ToolStripMenuItem(FrwCRUDRes.AllWindows);
            menuItem.Click += (s, em) =>
            {
                try
                {
                    CloseAllContents(false, false);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);


            groupItem = new ToolStripMenuItem(FrwCRUDRes.WidgetSConfiguration);
            menuItemFile.DropDownItems.Add(groupItem);

            menuItem        = new ToolStripMenuItem(FrwCRUDRes.LoadConfiguration);
            menuItem.Click += (s, em) =>
            {
                SimpleListDialog listDialog = new SimpleListDialog(typeof(JDocPanelLayout));
                DialogResult     res        = listDialog.ShowDialog();
                if (res == DialogResult.OK && listDialog.SelectedObjects != null && listDialog.SelectedObjects.Count > 0)
                {
                    IList layouts = listDialog.SelectedObjects;

                    foreach (var layout in layouts)
                    {
                        //JDocPanelLayout layout = Dm.Instance.FindAll<JDocPanelLayout>().FirstOrDefault<JDocPanelLayout>(c => c.JDocPanelLayoutId == "1");
                        AppManager.Instance.LoadLayout((JDocPanelLayout)layout);
                        break;
                    }
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            menuItem        = new ToolStripMenuItem(FrwCRUDRes.SaveConfiguration);
            menuItem.Click += (s, em) =>
            {
                JDocPanelLayout  layout = Dm.Instance.EmptyObject <JDocPanelLayout>(null);
                SimpleTextDialog dlg    = new SimpleTextDialog();
                if (dlg.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dlg.EditedText))
                {
                    layout.Name = dlg.EditedText;
                    AppManager.Instance.SaveLayout(layout);
                    Dm.Instance.SaveObject(layout);
                }
            };
            groupItem.DropDownItems.Add(menuItem);

            menuItem         = new ToolStripMenuItem(FrwCRUDRes.UpdateCurrentConfiguration);
            menuItem.Name    = "UpdateCurrentConfiguration";
            menuItem.Enabled = (AppManager.Instance.CurrentLayout != null);
            menuItem.Click  += (s, em) =>
            {
                AppManager.Instance.SaveLayout(AppManager.Instance.CurrentLayout);
            };

            groupItem.DropDownOpening += (s, em) =>
            {
                var mc = groupItem.DropDownItems["UpdateCurrentConfiguration"];
                if (mc != null)
                {
                    mc.Enabled = (AppManager.Instance.CurrentLayout != null);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            CreateMainMenuItemForEntityType(groupItem, typeof(JDocPanelLayout));

            menuItem        = new ToolStripMenuItem(FrwCRUDRes.BaseMainAppForm_OpenNewContainerWindow);
            menuItem.Click += (s, em) =>
            {
                Cursor cursor = Cursor.Current;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    BaseMainAppForm.CreateWindowNotClosable = false;
                    Form newWindow = (Form)Activator.CreateInstance(this.GetType());
                    newWindow.Show();
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
                finally
                {
                    Cursor.Current = cursor;
                }
            };
            menuItemFile.DropDownItems.Add(menuItem);

            if (NotClosable && DocPanelIndex == 0)
            {
                menuItem        = new ToolStripMenuItem(FrwCRUDRes.BaseMainAppForm_HideMainApplicationWindow);//
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        FrwConfig.Instance.SetPropertyValue(BaseApplicationContext.SETTING_showMainFormOnStartup, false);
                        Hide();
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemFile.DropDownItems.Add(menuItem);

                menuItem        = new ToolStripMenuItem(FrwCRUDRes.CloseApplication);
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        AppManager.Instance.ExitApplication();
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemFile.DropDownItems.Add(menuItem);
            }
            else
            {
                menuItemFile.DropDownItems.Add(menuItem);
                menuItem        = new ToolStripMenuItem(DocPanelIndex == 0 ? FrwCRUDRes.CloseApplication : FrwCRUDRes.BaseMainAppForm_CloseContainerWindow);
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        Close();
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                menuItemFile.DropDownItems.Add(menuItem);
            }
        }
Exemplo n.º 3
0
        public void MakeContextMenu(IListProcessor list, List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, string aspectName)
        {
            JDocPanelLayout item = selectedObject as JDocPanelLayout;

            JDocPanelLayoutUtils.MakeContextMenuBlock(menuItemList, item, list.ContentContainer);
        }