Exemplo n.º 1
0
        void RefreshMenuItems()
        {
            foreach (var menuPairs in _menus)
            {
                var referenceGridForm = menuPairs.Key;
                var menu = menuPairs.Value;
                if (menu != null)
                {
                    for (int index = menu.Tool.Tools.Count - 1; index >= 0; index--)
                    {
                        using (var tool = menu.Tool.Tools[index])
                        {
                            menu.Tool.Tools.Remove(tool);
                            menu.Tool.ToolbarsManager.Tools.Remove(tool);
                        }
                    }

                    foreach (var workSpace in _settings.WorkSpaces)
                    {
                        menu.AddCommandbarButton(ButtonKey.FormatString(referenceGridForm.Id.ToString(), workSpace.Id), workSpace.Caption);
                    }


                    var button = menu.AddCommandbarButton(ButtonKey_Create.FormatString(referenceGridForm.Id.ToString()), Properties.Resources.Button_CreateWorkSpace);
                    button.HasSeparator = true;
                    menu.AddCommandbarButton(ButtonKey_Edit.FormatString(referenceGridForm.Id.ToString()), Properties.Resources.Button_EditWorkSpaces);
                }
            }
        }
Exemplo n.º 2
0
        // Methods

        public override void OnBeforePerformingCommand(ReferenceGridForm referenceGridForm, BeforePerformingCommandEventArgs e)
        {
            e.Handled = true;

            if (e.Key.Equals(ButtonKey_Edit.FormatString(referenceGridForm.Id.ToString()), StringComparison.Ordinal))
            {
                EditWorkSpaces(referenceGridForm);
            }
            else if (e.Key.Equals(ButtonKey_Create.FormatString(referenceGridForm.Id.ToString()), StringComparison.Ordinal))
            {
                CreateWorkSpace(referenceGridForm);
            }
            else
            {
                if (_settings.WorkSpaces.FirstOrDefault(ws => e.Key.Equals(ButtonKey.FormatString(referenceGridForm.Id.ToString(), ws.Id), StringComparison.Ordinal)) is WorkSpace workSpace)
                {
                    referenceGridForm.LoadWorkSpace(workSpace);
                }
                else
                {
                    e.Handled = false;
                }
            }
        }