Ejemplo n.º 1
0
        public static EditorAction.GetStateContext EditorActionGetState(EditorAction.HolderEnum holder, string actionName)
        {
            var action = EditorActions.GetByName(actionName);

            if (action == null)
            {
                return(null);
            }
            return(EditorActionGetState(holder, action));
        }
Ejemplo n.º 2
0
        public static void EditorActionClick(EditorAction.HolderEnum holder, string actionName)
        {
            var action = EditorActions.GetByName(actionName);

            if (action == null)
            {
                return;
            }
            EditorActionClick(holder, action);
        }
Ejemplo n.º 3
0
        public static bool ProcessShortcuts(Keys keyCode)          //!!!!из старого, bool processCharactersWithoutModifiers )
        {
            Keys keys = keyCode | Control.ModifierKeys;

            var shortcuts = new Dictionary <Keys, Component_ProjectSettings.ShortcutSettingsClass.ActionItem>(64);

            foreach (var a in ProjectSettings.Get.ShortcutSettings.Actions)
            {
                if (a.Shortcut1 != Keys.None)
                {
                    shortcuts[a.Shortcut1] = a;
                }
                if (a.Shortcut2 != Keys.None)
                {
                    shortcuts[a.Shortcut2] = a;
                }
            }

            shortcuts.TryGetValue(keys, out var actionItem);

            if (actionItem != null)
            {
                var action = EditorActions.GetByName(actionItem.Name);
                if (action != null)
                {
                    foreach (var shortcut in actionItem.ToArray())
                    {
                        if (shortcut != Keys.None && shortcut == keys)
                        {
                            var c = EditorActionGetState(EditorAction.HolderEnum.ShortcutKey, action);
                            if (c.Enabled)
                            {
                                EditorActionClick(EditorAction.HolderEnum.ShortcutKey, action.Name);
                                return(true);
                            }
                        }
                    }
                }
            }

            //if( action.ShortcutKeys != null && Array.IndexOf( action.ShortcutKeys, keys ) != -1 )
            //{
            //	var c = EditorActionGetState( EditorAction.HolderEnum.ShortcutKey, action );
            //	if( c.Enabled )
            //	{
            //		EditorActionClick( EditorAction.HolderEnum.ShortcutKey, action.Name );
            //		return true;
            //	}
            //}
            //}

            return(false);
        }
            public bool AddAction(string actionName)
            {
                var action = EditorActions.GetByName(actionName);

                if (action == null)
                {
                    //Log.Fatal( "EditorRibbonDefaultConfiguration: Group: AddAction: No action with name \"{0}\".", actionName );
                    return(false);
                }
                Children.Add(action);
                return(true);
            }
Ejemplo n.º 5
0
        private void StartPageWindow_Load(object sender, EventArgs e)
        {
            if (WinFormsUtility.IsDesignerHosted(this))
            {
                return;
            }

            EditorLocalization.TranslateForm("StartPageWindow", this);

            timer1.Start();

            UpdateControls();

            if (EditorActions.GetByName("Store") != null && EditorActions.GetByName("Store").CompletelyDisabled)
            {
                kryptonButtonOpenStore.Visible = false;
            }
        }
Ejemplo n.º 6
0
        void QATButtonsCheckForRecreate(ref bool needRepaint)
        {
            var config = ProjectSettings.Get.RibbonAndToolbarActions;

            if (qatUpdatedForConfiguration == null || !config.Equals(qatUpdatedForConfiguration))
            {
                qatUpdatedForConfiguration = config.Clone();

                kryptonRibbon.QATButtons.Clear();

                foreach (var actionItem in config.ToolbarActions)
                {
                    var action = EditorActions.GetByName(actionItem.Name);
                    if (action != null && action.QatSupport && actionItem.Enabled)
                    {
                        AddActionToQAT(action);
                    }
                }

                needRepaint = true;
            }
        }
Ejemplo n.º 7
0
        void RibbonSubGroupAddItemsRecursive(EditorRibbonDefaultConfiguration.Group subGroup, KryptonContextMenuCollection contextMenuItems)
        {
            var items = new List <KryptonContextMenuItemBase>();

            foreach (var child in subGroup.Children)
            {
                //!!!!impl
                ////sub group
                //var subGroup = child as EditorRibbonDefaultConfiguration.Group;
                //if( subGroup != null )
                //{
                //	var tripple = new KryptonRibbonGroupTriple();
                //	ribbonGroup.Items.Add( tripple );

                //	var button = new KryptonRibbonGroupButton();
                //	//button.Tag = action;
                //	button.TextLine1 = subGroup.DropDownGroupText.Item1;
                //	button.TextLine2 = subGroup.DropDownGroupText.Item2;
                //	//button.ImageSmall = action.imageSmall;
                //	button.ImageLarge = subGroup.DropDownGroupImage;
                //	button.ToolTipBody = subGroup.Name;
                //	button.ButtonType = GroupButtonType.DropDown;

                //	button.KryptonContextMenu = new KryptonContextMenu();
                //	RibbonSubGroupAddItemsRecursive( subGroup, button.KryptonContextMenu.Items );

                //	tripple.Items.Add( button );
                //}

                //action
                var action = child as EditorAction;
                if (action == null)
                {
                    var actionName = child as string;
                    if (actionName != null)
                    {
                        action = EditorActions.GetByName(actionName);
                    }
                }
                if (action != null)
                {
                    if (!action.CompletelyDisabled)
                    {
                        EventHandler clickHandler = delegate(object s, EventArgs e2)
                        {
                            var item2 = (KryptonContextMenuItem)s;

                            var action2 = item2.Tag as EditorAction;
                            if (action2 != null)
                            {
                                EditorAPI.EditorActionClick(EditorAction.HolderEnum.RibbonQAT, action2.Name);
                            }
                        };

                        var item = new KryptonContextMenuItem(action.GetContextMenuText(), null, clickHandler);
                        //var item = new KryptonContextMenuItem( action.GetContextMenuText(), action.imageSmall, clickHandler );
                        item.Tag = action;
                        items.Add(item);
                    }
                }
                //separator
                else if (child == null)
                {
                    items.Add(new KryptonContextMenuSeparator());
                }
            }

            if (items.Count != 0)
            {
                contextMenuItems.Add(new KryptonContextMenuItems(items.ToArray()));
            }
        }
Ejemplo n.º 8
0
        void RibbonButtonsCheckForRecreate()
        {
            var config = ProjectSettings.Get.RibbonAndToolbarActions;

            if (ribbonUpdatedForConfiguration == null || !config.Equals(ribbonUpdatedForConfiguration) || needRecreatedRibbonButtons)
            {
                ribbonUpdatedForConfiguration = config.Clone();
                needRecreatedRibbonButtons    = false;

                ribbonLastSelectedTabTypeByUser_DisableUpdate = true;

                kryptonRibbon.RibbonTabs.Clear();

                foreach (var tabSettings in ProjectSettings.Get.RibbonAndToolbarActions.RibbonTabs)
                {
                    if (!tabSettings.Enabled)
                    {
                        continue;
                    }

                    //can be null
                    EditorRibbonDefaultConfiguration.Tab tab = null;
                    if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic)
                    {
                        tab = EditorRibbonDefaultConfiguration.GetTab(tabSettings.Name);
                    }

                    var ribbonTab = new KryptonRibbonTab();
                    ribbonTab.Tag = tab;

                    if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic)
                    {
                        ribbonTab.Text = EditorLocalization.Translate("Ribbon.Tab", tabSettings.Name);
                    }
                    else
                    {
                        ribbonTab.Text = tabSettings.Name;
                    }

                    ribbonTab.KeyTip = GetTabKeyTip(tabSettings.Name);

                    kryptonRibbon.RibbonTabs.Add(ribbonTab);

                    var usedKeyTips = new ESet <string>();

                    string GetKeyTip(string name)
                    {
                        foreach (var c in name + alphabetNumbers)
                        {
                            var s = c.ToString().ToUpper();
                            if (s != " " && !usedKeyTips.Contains(s))
                            {
                                usedKeyTips.AddWithCheckAlreadyContained(s);
                                return(s);
                            }
                        }
                        return("");
                    }

                    foreach (var groupSettings in tabSettings.Groups)
                    {
                        if (!groupSettings.Enabled)
                        {
                            continue;
                        }

                        var ribbonGroup = new KryptonRibbonGroup();

                        if (groupSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.GroupItem.TypeEnum.Basic)
                        {
                            ribbonGroup.TextLine1 = EditorLocalization.Translate("Ribbon.Group", groupSettings.Name);
                        }
                        else
                        {
                            ribbonGroup.TextLine1 = groupSettings.Name;
                        }

                        ribbonGroup.DialogBoxLauncher = false;                        //!!!!для группы Transform можно было бы в настройки снеппинга переходить
                        //ribbonTab.Groups.Add( ribbonGroup );

                        foreach (var groupSettingsChild in groupSettings.Actions)
                        {
                            if (!groupSettingsChild.Enabled)
                            {
                                continue;
                            }

                            //sub group
                            if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.SubGroupOfActions)
                            {
                                EditorRibbonDefaultConfiguration.Group subGroup = null;
                                if (tab != null)
                                {
                                    var group = tab.Groups.Find(g => g.Name == groupSettings.Name);
                                    if (group != null)
                                    {
                                        foreach (var child in group.Children)
                                        {
                                            var g = child as EditorRibbonDefaultConfiguration.Group;
                                            if (g != null && g.Name == groupSettingsChild.Name)
                                            {
                                                subGroup = g;
                                                break;
                                            }
                                        }
                                    }
                                }

                                if (subGroup != null)
                                {
                                    var tripple = new KryptonRibbonGroupTriple();
                                    ribbonGroup.Items.Add(tripple);

                                    var button = new KryptonRibbonGroupButton();
                                    button.Tag = "SubGroup";
                                    //button.Tag = action;

                                    var str = subGroup.DropDownGroupText.Item1;
                                    if (subGroup.DropDownGroupText.Item2 != "")
                                    {
                                        str += "\n" + subGroup.DropDownGroupText.Item2;
                                    }

                                    var str2 = EditorLocalization.Translate("Ribbon.Action", str);
                                    var strs = str2.Split(new char[] { '\n' });

                                    button.TextLine1 = strs[0];
                                    if (strs.Length > 1)
                                    {
                                        button.TextLine2 = strs[1];
                                    }

                                    //button.TextLine1 = subGroup.DropDownGroupText.Item1;
                                    //button.TextLine2 = subGroup.DropDownGroupText.Item2;

                                    if (subGroup.DropDownGroupImageSmall != null)
                                    {
                                        button.ImageSmall = subGroup.DropDownGroupImageSmall;
                                    }
                                    else if (subGroup.DropDownGroupImageLarge != null)
                                    {
                                        button.ImageSmall = EditorAction.ResizeImage(subGroup.DropDownGroupImageLarge, 16, 16);
                                    }
                                    button.ImageLarge = subGroup.DropDownGroupImageLarge;

                                    //EditorLocalization.Translate( "EditorAction.Description",

                                    if (!string.IsNullOrEmpty(subGroup.DropDownGroupDescription))
                                    {
                                        button.ToolTipBody = EditorLocalization.Translate("EditorAction.Description", subGroup.DropDownGroupDescription);
                                    }
                                    else
                                    {
                                        button.ToolTipBody = subGroup.Name;
                                    }

                                    button.ButtonType = GroupButtonType.DropDown;
                                    button.ShowArrow  = subGroup.ShowArrow;

                                    button.KryptonContextMenu = new KryptonContextMenu();
                                    RibbonSubGroupAddItemsRecursive(subGroup, button.KryptonContextMenu.Items);

                                    tripple.Items.Add(button);
                                }
                            }

                            //action
                            if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.Action)
                            {
                                var action = EditorActions.GetByName(groupSettingsChild.Name);

                                if (action != null && !action.CompletelyDisabled)
                                {
                                    if (action.ActionType == EditorAction.ActionTypeEnum.Button || action.ActionType == EditorAction.ActionTypeEnum.DropDown)
                                    {
                                        //Button, DropDown

                                        var tripple = new KryptonRibbonGroupTriple();
                                        ribbonGroup.Items.Add(tripple);

                                        var control = new KryptonRibbonGroupButton();

                                        //!!!!
                                        //control.ImageSmall = NeoAxis.Properties.Resources.Android_16;

                                        control.Tag = action;

                                        var str = action.RibbonText.Item1;
                                        if (action.RibbonText.Item2 != "")
                                        {
                                            str += "\n" + action.RibbonText.Item2;
                                        }

                                        var str2 = EditorLocalization.Translate("Ribbon.Action", str);
                                        var strs = str2.Split(new char[] { '\n' });

                                        control.TextLine1 = strs[0];
                                        if (strs.Length > 1)
                                        {
                                            control.TextLine2 = strs[1];
                                        }

                                        //control.TextLine1 = action.RibbonText.Item1;
                                        //control.TextLine2 = action.RibbonText.Item2;

                                        control.ImageSmall  = action.GetImageSmall();
                                        control.ImageLarge  = action.GetImageBig();
                                        control.ToolTipBody = action.ToolTip;
                                        control.KeyTip      = GetKeyTip(action.Name);

                                        //_buttonType = GroupButtonType.Push;
                                        //_toolTipImageTransparentColor = Color.Empty;
                                        //_toolTipTitle = string.Empty;
                                        //_toolTipBody = string.Empty;
                                        //_toolTipStyle = LabelStyle.SuperTip;

                                        if (action.ActionType == EditorAction.ActionTypeEnum.DropDown)
                                        {
                                            control.ButtonType         = GroupButtonType.DropDown;
                                            control.KryptonContextMenu = action.DropDownContextMenu;
                                        }

                                        control.Click += Button_Click;

                                        tripple.Items.Add(control);
                                    }
                                    else if (action.ActionType == EditorAction.ActionTypeEnum.Slider)
                                    {
                                        //Slider

                                        var tripple = new KryptonRibbonGroupTriple();
                                        ribbonGroup.Items.Add(tripple);

                                        var control = new KryptonRibbonGroupSlider();
                                        control.Tag         = action;
                                        control.ToolTipBody = action.ToolTip;

                                        control.Control.Size = new System.Drawing.Size((int)((float)control.Control.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height);
                                        control.Control.kryptonSplitContainer2.Size             = new System.Drawing.Size((int)((float)control.Control.kryptonSplitContainer2.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height);
                                        control.Control.kryptonSplitContainer2.Panel1MinSize    = (int)((float)control.Control.kryptonSplitContainer2.Panel1MinSize * EditorAPI.DPIScale);
                                        control.Control.kryptonSplitContainer1.Panel2MinSize    = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale);
                                        control.Control.kryptonSplitContainer1.SplitterDistance = 10000;

                                        control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1);
                                        control.Control.Init(action.Slider.Minimum, action.Slider.Maximum, action.Slider.ExponentialPower);
                                        control.Control.SetValue(action.Slider.Value);

                                        control.Control.Tag           = action;
                                        control.Control.ValueChanged += Slider_ValueChanged;

                                        tripple.Items.Add(control);
                                    }
                                    //else if( action.ActionType == EditorAction.ActionTypeEnum.ComboBox )
                                    //{
                                    //	//ComboBox

                                    //	var tripple = new KryptonRibbonGroupTriple();
                                    //	ribbonGroup.Items.Add( tripple );

                                    //	var control = new KryptonRibbonGroupComboBox();
                                    //	control.Tag = action;

                                    //	control.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                                    //	foreach( var item in action.ComboBox.Items )
                                    //		control.Items.Add( item );

                                    //	if( control.Items.Count != 0 )
                                    //		control.SelectedIndex = 0;

                                    //	//control.MinimumLength = action.Slider.Length;
                                    //	//control.MaximumLength = action.Slider.Length;

                                    //	control.SelectedIndexChanged += ComboBox_SelectedIndexChanged;

                                    //	tripple.Items.Add( control );
                                    //}
                                    else if (action.ActionType == EditorAction.ActionTypeEnum.ListBox)
                                    {
                                        //ListBox

                                        var tripple = new KryptonRibbonGroupTriple();
                                        ribbonGroup.Items.Add(tripple);

                                        var control = new KryptonRibbonGroupListBox();
                                        control.Tag         = action;
                                        control.ToolTipBody = action.ToolTip;

                                        control.Control.Size = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height);
                                        control.Control.kryptonSplitContainer1.Size             = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height);
                                        control.Control.kryptonSplitContainer1.Panel2MinSize    = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale);
                                        control.Control.kryptonSplitContainer1.SplitterDistance = 10000;
                                        //if( action.ListBox.Length != 172 )
                                        //	control.Control.Size = new System.Drawing.Size( action.ListBox.Length, control.Control.Size.Height );

                                        control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1);

                                        var browser = control.Control.contentBrowser1;

                                        if (action.ListBox.Mode == EditorAction.ListBoxSettings.ModeEnum.Tiles)
                                        {
                                            browser.ListViewModeOverride             = new ContentBrowserListModeTilesRibbon(browser);
                                            browser.Options.PanelMode                = ContentBrowser.PanelModeEnum.List;
                                            browser.Options.ListMode                 = ContentBrowser.ListModeEnum.Tiles;
                                            browser.UseSelectedTreeNodeAsRootForList = false;
                                            browser.Options.Breadcrumb               = false;
                                            browser.ListViewBorderDraw               = BorderSides.Left | BorderSides.Right | BorderSides.Bottom;
                                            browser.Options.TileImageSize            = 22;
                                        }
                                        else
                                        {
                                            browser.RemoveTreeViewIconsColumn();
                                            browser.TreeView.RowHeight -= 2;
                                        }

                                        browser.Tag = action;

                                        //update items
                                        control.SetItems(action.ListBox.Items);

                                        browser.ItemAfterSelect += ListBrowser_ItemAfterSelect;

                                        if (browser.Items.Count != 0)
                                        {
                                            browser.SelectItems(new ContentBrowser.Item[] { browser.Items.ToArray()[0] });
                                        }

                                        //browser.ItemAfterSelect += ListBrowser_ItemAfterSelect;

                                        tripple.Items.Add(control);
                                    }
                                }
                            }
                        }

                        if (ribbonGroup.Items.Count != 0)
                        {
                            ribbonTab.Groups.Add(ribbonGroup);
                        }
                    }

                    //select
                    var tabType = "";
                    if (tab != null)
                    {
                        tabType = tab.Type;
                    }
                    if (ribbonLastSelectedTabTypeByUser != "" && tabType == ribbonLastSelectedTabTypeByUser)
                    {
                        kryptonRibbon.SelectedTab = ribbonTab;
                    }
                }

                ribbonLastSelectedTabTypeByUser_DisableUpdate = false;
            }
        }