protected override void OnPaint(PaintEventArgs e) { if (!this.Visible || Parent != null && !Parent.Visible) { return; } DrawInternalBackground(e, false); // Presumably only one of the image, line and hatching will be defined... Image image = null; int drawSize = 0; // usually the image is drawn at its actual size, but if we are to make it expand we must draw at a specific size if (!string.IsNullOrEmpty(m_ImageName)) { image = (Image)GUIUtilities.RM.GetObject(m_ImageName); } else if (m_Parameter == Parameters.Tool) { drawSize = this.Width - EXCESSSIZE; drawSize += EXCESSSIZE * m_SelectionDisplayFraction / 300; // maximum value of m_SelectionDisplayFraction is 255; deliberately dividing by bit more to keep the image smaller image = GUIUtilities.ShapeImage((Shape.Shapes)m_ParameterValue, drawSize); } if (m_Image != null) { image = m_Image; } if (m_Parameter == Parameters.Tool) { if ((Shape.Shapes)m_ParameterValue == Shape.Shapes.Polygon) { // for the polygon we draw the current number of sides Rectangle rctNumber = new Rectangle(INSET + 1, INSET + 4, Width - INSET * 2 - 5, Height - INSET * 2 - 5); e.Graphics.DrawString(Polygon.CURRENTSIDES.ToString(), GUIUtilities.ShortcutFont, Brushes.Black, rctNumber, GUIUtilities.StringFormatCentreCentre); } } if (image != null) { DrawStandardImage(e.Graphics, image, drawSize); if (image != m_Image) { image.Dispose(); } } if (m_SampleLine != null) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.DrawLine(m_SampleLine, SAMPLEINSET, SAMPLEINSET, Width - SAMPLEINSET, Height - SAMPLEINSET); } if (m_SampleHatch != null) { e.Graphics.FillRectangle(m_SampleHatch, SAMPLEINSET, SAMPLEINSET, Width - SAMPLEINSET * 2, Height - SAMPLEINSET * 2); } DrawHighlightAndKey(e); }
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); } }