Exemple #1
0
    // Update tool wheel and guide based on current fields
    private void UpdateUI()
    {
        // Tool wheel
        toolWheel.SetActive(wandMenuOpen);

        // Tool guide
        if (!hasSetUIPointers)
        {
            SetupUIPointers();
        }

        // Update tool
        toolUI.SetActive(tool != ToolType.None);
        toolText.text = tool.ToString().Replace('_', ' ');

        // Enable UI main action
        mainUI.SetActive(toolActionMain != ToolAction.None);
        mainText.text = toolActionMain.ToString().Replace('_', ' ');

        // Enable UI off action
        offUI.SetActive(toolActionOff != ToolAction.None);
        offText.text = toolActionOff.ToString().Replace('_', ' ');

        // Enable UI off action
        if (!wandMenuOpen)
        {
            spaceText.text = "Tool Wheel";
        }
        else
        {
            spaceText.text = "Garden";
        }
    }
        private bool IsToolActionEnabled(ToolAction action)
        {
            if (_operationInProgress)
            {
                return(false);
            }

            for (int i = 0; i < toolStripMain.Items.Count; i++)
            {
                ToolStripItem btn = toolStripMain.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return(btn.Enabled);
                }
            }

            return(true);
        }
Exemple #3
0
        private bool IsToolActionEnabled(ToolAction action)
        {
            if (_operationInProgress)
                return false;

            for (int i = 0; i < contextMenuStrip.Items.Count; i++)
            {
                ToolStripItem btn = contextMenuStrip.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return btn.Enabled;
                }
            }

            for (int i = 0; i < toolStripMain.Items.Count; i++)
            {
                ToolStripItem btn = toolStripMain.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return btn.Enabled;
                }
            }

            return true;
        }
Exemple #4
0
        public void Fill(AppliedConfig applied)
        {
            // fill the Treeview showing the possible actions
            try
            {
                TV.Nodes.Clear();                                          // should already be empty, but just in case...
                ActionImageList.Images.Clear();
                ActionImageList.Images.Add("Folder", Resources.AM.folder); // must be first, because by default the Treeview uses index 0 for the folders
                ActionImageList.Images.Add("Empty", Resources.AM.Empty);
                ActionImageList.Images.Add("CursorClick", Resources.AM.CursorClick);

                // shapes...
                TreeNode folder = TV.Nodes.Add(Strings.Item("Config_ShapesTools"));
                foreach (Shape.Shapes shape in Shape.UserShapes.Union(new[] { Shape.Shapes.SetRotation }))                 // set rotation is included in here, although not entirely a normal user shape
                {
                    //If Shape.HideShapeType (eShape) andalso not **advanced continue for
                    ToolAction action = new ToolAction(shape);
                    TreeNode   node   = folder.Nodes.Add(action.DescriptionWithoutAccelerator());
                    Image      image  = GUIUtilities.ShapeImage(shape, 32);
                    if (image != null)
                    {
                        ActionImageList.Images.Add(action.ToString(), image);
                        node.ImageKey         = action.ToString();
                        node.SelectedImageKey = action.ToString();
                    }
                    else
                    {
                        node.ImageKey = node.SelectedImageKey = "Empty";
                    }
                    node.Tag = action;
                }


                // Drawing area...
                folder = TV.Nodes.Add(Strings.Item("Config_KeysDrawing"));
                AddKeyVerbs(1000, (int)Codes.Decrement, "Config_ShapeVerbs", folder.Nodes);                 // excludes ChooseExisting
                if (Mode != Modes.Button)
                {
                    AddKeyVerbs(1100, 1149, "Config_MouseControl", folder.Nodes);
                }
                AddKeyVerbs(1150, 1199, "Config_Scrolling", folder.Nodes);
                AddKeyVerbs(1200, 1249, "Config_ShapeSelection", folder.Nodes);
                TreeNode subFolder = folder.Nodes.Add(Strings.Item("Config_Keys_Snapping"));
                foreach (Shape.SnapModes snap in new[] { Shape.SnapModes.Off, Shape.SnapModes.Grid, Shape.SnapModes.Shape, Shape.SnapModes.Angle })
                {
                    AddAction(subFolder, new SnapAction(snap));
                }
                AddAction(subFolder, new ShowGridAction(1));
                if (Mode != Modes.Button)
                {
                    Action tools = new PaletteAction(Parameters.Tool);
                    AddAction(folder, tools, tools.DescriptionWithoutAccelerator(), "CursorClick");
                }

                // Verbs...
                TreeNode verbs = AddKeyVerbs(0, 999, "Config_Verbs");

                // Styles...
                folder = TV.Nodes.Add(Strings.Item("Config_Keys_Styles"));
                FillStyleActions(folder, Parameters.FillColour, true);
                FillStyleActions(folder, Parameters.FillPattern);
                FillStyleActions(folder, Parameters.LineColour, true);
                FillStyleActions(folder, Parameters.LineWidth, true);
                FillStyleActions(folder, Parameters.LinePattern);

                // font doesn't use normal parameters
                subFolder = folder.Nodes.Add(Strings.Item("Palette_TextStyle"));
                if (Mode == Modes.Key)
                {
                    AddAction(subFolder, new PaletteAction(Parameters.FontSize), Strings.Item("Config_SwitchToPalette"), "CursorClick");
                }
                AddAction(subFolder, new ParameterAction(Parameters.TextAlignment, (int)StringAlignment.Near), Strings.Item("Align_Left"));
                AddAction(subFolder, new ParameterAction(Parameters.TextAlignment, (int)StringAlignment.Center), Strings.Item("Align_Centre"));
                AddAction(subFolder, new ParameterAction(Parameters.TextAlignment, (int)StringAlignment.Far), Strings.Item("Align_Right"));
                AddAction(subFolder, new ParameterAction(Parameters.TextVerticalAlignment, (int)StringAlignment.Near), Strings.Item("Align_Top"));
                AddAction(subFolder, new ParameterAction(Parameters.TextVerticalAlignment, (int)StringAlignment.Center), Strings.Item("Align_Middle"));
                AddAction(subFolder, new ParameterAction(Parameters.TextVerticalAlignment, (int)StringAlignment.Far), Strings.Item("Align_Bottom"));
                AddAction(subFolder, Verb.Find(Codes.TextSmaller));
                AddAction(subFolder, Verb.Find(Codes.TextLarger));

                // arrows just select palette
                //subFolder = folder.Nodes.Add(Strings.Item("Palette_Arrowheads"));
                //if (Mode == Modes.Key)
                //	AddAction(subFolder, new PaletteAction(Parameters.ArrowheadEndType), Strings.Item("Config_SwitchToPalette"), "CursorClick");

                subFolder = folder.Nodes.Add(Strings.Item("Config_Keys_Palettes"));
                AddAction(subFolder, new PaletteButtonAction(1), Strings.Item("Config_Keys_Palette_Refine"), "Empty");
                AddAction(subFolder, new PaletteButtonAction(2), Strings.Item("Config_Keys_Palette_Transparent"), "Empty");
                // in palettes main folder:
                AddAction(folder, Verb.Find(Codes.MovePalette));
                AddAction(folder, Verb.Find(Codes.ResizePalette));
                if (Mode == Modes.Key)
                {
                    subFolder = folder.Nodes.Add(Strings.Item("Config_SwitchToPalette_Other"));
                    foreach (Palette objPalette in from p in Palette.List.Values where p.PalettePurpose.IsCustom orderby Strings.Translate(p.Title) select p)
                    {
                        // only lists custom ones - assuming all purposes can be/have been listed separately
                        AddAction(subFolder, objPalette.PalettePurpose.GetSelectAction(), Strings.Translate(objPalette.EditDescription));
                    }
                }

                subFolder = folder.Nodes.Add(Strings.Item("Config_PalettesToggle"));
                AddAction(subFolder, new ShowPaletteAction(Palette.Purpose.Specials.Rotation), Strings.Item("Palette_Rotation"));
                AddAction(subFolder, new ShowPaletteAction(Palette.Purpose.Specials.CoordEdit), Strings.Item("Palette_CoordEdit"));
                AddAction(subFolder, new ShowPaletteAction(Palette.Purpose.Specials.Scale), Strings.Item("Palette_ShowScale"));

                if (Mode == Modes.Button)
                {
                    m_KeyNode                  = TV.Nodes.Add(Strings.Item("Action_SimulateKey"));
                    m_KeyNode.ImageIndex       = -1;
                    m_KeyNode.Tag              = new KeyAction(Keys.None);        // actual key will be selected in the editing screen
                    m_CharacterNode            = TV.Nodes.Add(Strings.Item("Action_TypeCharacter"));
                    m_CharacterNode.ImageIndex = -1;
                    m_CharacterNode.Tag        = new CharAction((char)0);              // actual text will be selected in the editing screen
                    m_TextNode                 = TV.Nodes.Add(Strings.Item("Action_TypeText"));
                    m_TextNode.ImageIndex      = -1;
                    m_TextNode.Tag             = new TextAction("");         // actual text will be selected in the editing screen
                }
            }
            catch (Exception ex) when(!Globals.Root.IsDebug)
            {
                MessageBox.Show(ex.Message);
            }
        }