예제 #1
0
                /// <summary>
                ///
                /// </summary>
                public SpecialCommandsGroup(ViewerStateModel vsm, Point location, Size size, int tabIndex)
                {
                    this.SuspendLayout();

                    this.FlatStyle = FlatStyle.System;
                    this.Location  = location;
                    this.Size      = size;
                    this.TabIndex  = tabIndex;
                    this.Name      = "SpecialCommandsGroup";
                    this.TabStop   = false;
                    this.Text      = Strings.CustomCommands;
                    this.Enabled   = true;

                    // Add the controls
                    this.Controls.Add(new DeviceInfoLabel(new Point(16, 17), new Size(100, 24), 7));
                    deviceDropDown = new DeviceDropDown(vsm, new Point(118, 16), new Size(308, 21), 8);
                    this.Controls.Add(deviceDropDown);
                    this.Controls.Add(new CloneInfoLabel(new Point(30, 41), new Size(148, 24), 9));
                    cloneTextBox = new CloneTextBox(vsm, new Point(180, 40), new Size(246, 21), 10);
                    this.Controls.Add(cloneTextBox);
                    this.Controls.Add(new ExtendedInfoLabel(new Point(30, 65), new Size(138, 24), 11));
                    extendedTextBox = new ExtendedTextBox(vsm, new Point(180, 64), new Size(246, 21), 12);
                    this.Controls.Add(extendedTextBox);

                    this.ResumeLayout();
                }
        public void ExternalScript_DefaultValue()
        {
            // Arrange
            var testObject = new ExtendedTextBox();

            // Act, Assert
            AssertNotFX1(string.Empty, testObject.ExternalScript);
            AssertFX1(ExternalScriptDefault, testObject.ExternalScript);
        }
        public void ExternalScript_SetAndGetValue()
        {
            // Arrange
            var testObject = new ExtendedTextBox();

            // Act
            testObject.ExternalScript = TestValue;

            // Assert
            testObject.ExternalScript.ShouldBe(TestValue);
        }
                /// <summary>
                ///
                /// </summary>
                public SpecialCommandsGroup( ViewerStateModel vsm, Point location, Size size, int tabIndex )
                {
                    this.SuspendLayout();

                    this.FlatStyle = FlatStyle.System;
                    this.Location = location;
                    this.Size = size;
                    this.TabIndex = tabIndex;
                    this.Name = "SpecialCommandsGroup";
                    this.TabStop = false;
                    this.Text = Strings.CustomCommands;
                    this.Enabled = true;

                    // Add the controls
                    this.Controls.Add( new DeviceInfoLabel( new Point( 16, 17 ), new Size( 100, 24 ), 7 ) );
                    deviceDropDown = new DeviceDropDown( vsm, new Point( 118, 16 ), new Size( 308, 21 ), 8 );
                    this.Controls.Add( deviceDropDown );
                    this.Controls.Add( new CloneInfoLabel( new Point( 30, 41 ), new Size( 148, 24 ), 9 ) );
                    cloneTextBox = new CloneTextBox( vsm, new Point( 180, 40 ), new Size( 246, 21 ), 10 );
                    this.Controls.Add( cloneTextBox );
                    this.Controls.Add( new ExtendedInfoLabel( new Point( 30, 65 ), new Size( 138, 24 ), 11 ) );
                    extendedTextBox = new ExtendedTextBox( vsm, new Point( 180, 64 ), new Size( 246, 21 ), 12 );
                    this.Controls.Add( extendedTextBox );

                    this.ResumeLayout();
                }
예제 #5
0
        public static void InterfaceThemeControl(Control root)
        {
            bLightTheme = GetSetting("ifc_bLightTheme");

            fdeltaColorMouseOver = GetSetting("ifc_fdeltaColorMouseOver");
            fdeltaColorMouseDown = GetSetting("ifc_fdeltaColorMouseDown");

            colBackground    = GetSetting("ifc_colBackground");
            colForeground    = GetSetting("ifc_colText");
            colSelection     = GetSetting("ifc_colSelection");
            colSelectionText = GetSetting("ifc_colSelectionText");
            colMouseOver     = ColorHSV.ModifyValue(colBackground, fdeltaColorMouseOver, !bLightTheme);
            colMouseDown     = ColorHSV.ModifyValue(colBackground, fdeltaColorMouseDown, !bLightTheme);
            colAccent        = GetSetting("ifc_colAccent");
            colBorder        = GetSetting("ifc_colBorder");

            strFont = GetSetting("ifc_strFont");

            bBorders    = GetSetting("ifc_bBorders");
            borderStyle = bBorders ? BorderStyle.FixedSingle : BorderStyle.None;

            root.BackColor = colBackground;

            if (root.ForeColor != Color.OrangeRed && root.ForeColor != colAccent)
            {
                root.ForeColor = colForeground;
            }

            if (root.Font.FontFamily.Name != "Webdings" && !(root is Form) && !root.HasChildren)
            {
                try {
                    //TODO: This is really slow, can we speed it up somehow?
                    root.Font = new Font(new FontFamily(strFont), root.Font.Size, root.Font.Style);
                } catch { }
            }

            if (root is ExtendedPanel || typeof(ExtendedPanel).IsAssignableFrom(root.GetType()))
            {
                ExtendedPanel panel = (ExtendedPanel)root;
                panel.BorderStyle = BorderStyle.None;
                panel.BorderColor = colBorder;
                if (panel.HasBorders && panel.AutoScroll && panel.Name != "container")
                {
                    // special case: we have to wrap this panel inside of another panel for the border to not mess up when scrolling
                    ExtendedPanel container = new ExtendedPanel();
                    container.Name        = "container";
                    container.Left        = panel.Left;
                    container.Top         = panel.Top;
                    container.Width       = panel.Width;
                    container.Height      = panel.Height;
                    container.BackColor   = panel.BackColor;
                    container.ForeColor   = panel.ForeColor;
                    container.BorderStyle = panel.BorderStyle;
                    container.HasBorders  = panel.HasBorders;
                    container.BorderColor = panel.BorderColor;
                    container.Anchor      = panel.Anchor;
                    Control parent = panel.Parent;
                    container.Controls.Add(panel);
                    parent.Controls.Add(container);
                    panel.HasBorders = false;
                    panel.Location   = new Point(1, 1);
                    panel.Size       = new Size(container.Width - 2, container.Height - 2);
                    panel.Anchor     = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                }
            }
            else if (root is Panel)
            {
                //TODO: Move these to some configurable array instead of hardcoding them in Nimble.dll...
                if (root.Name != "panelTopBar" && root.Name != "panelFormatting")
                {
                    Panel panel = (Panel)root;
                    panel.BorderStyle = borderStyle;
                }
            }

            if (root is FlatGroupBox)
            {
                FlatGroupBox box = (FlatGroupBox)root;
                box.BorderColor = colBorder;
                box.HasBorders  = bBorders;
            }

            if (root is FlatButton)
            {
                FlatButton btn = (FlatButton)root;
                btn.BackColorOver = colMouseOver;
                btn.BackColorDown = colMouseDown;
                btn.BorderColor   = colBorder;
                btn.HasBorder     = bBorders;
            }

            if (root is ExtendedTextBox)
            {
                ExtendedTextBox text = (ExtendedTextBox)root;
                text.HasBorders        = bBorders;
                text.BorderColor       = colBorder;
                text.BorderColorActive = colBorder;
            }

            if (root is DrawBox)
            {
                DrawBox db = (DrawBox)root;
                db.HasBorders     = bBorders;
                db.BorderColor    = colBorder;
                db.ColorPrimary   = colAccent;
                db.ColorSecondary = colBorder;
            }

            if (root is DraggablePictureBox)
            {
                DraggablePictureBox dpb = (DraggablePictureBox)root;
                dpb.BorderStyle = BorderStyle.None;
                dpb.HasBorders  = bBorders;
                dpb.BorderColor = colBorder;
            }

            if (root is FlatScrollbar)
            {
                FlatScrollbar scrollbar = (FlatScrollbar)root;
                scrollbar.BorderColor     = bBorders ? colBorder : Color.Empty;
                scrollbar.FillColor       = ColorHSV.ModifyValue(colBackground, GetSetting("ifc_fdeltaColorScrollbarFill"), !bLightTheme);
                scrollbar.HandleMargin    = GetSetting("ifc_fScrollbarHandleMargin");
                scrollbar.HandleColor     = ColorHSV.ModifyValue(colBackground, GetSetting("ifc_fdeltaColorScrollbarHandle"), !bLightTheme);
                scrollbar.HandleGripColor = ColorHSV.ModifyValue(colBackground, GetSetting("ifc_fdeltaColorScrollbarHandleGrip"), !bLightTheme);
                scrollbar.HandleGripCount = GetSetting("ifc_iScrollbarHandleCount");
                scrollbar.GuidelineColor  = ColorHSV.ModifyValue(colBackground, GetSetting("ifc_fdeltaColorScrollbarGuideline"), !bLightTheme);
            }

            if (root is FlatList)
            {
                FlatList list = (FlatList)root;
                list.BorderColor        = bBorders ? colBorder : Color.Empty;
                list.HoverColor         = colMouseOver;
                list.SelectionColor     = colSelection;
                list.SelectionTextColor = colSelectionText;
                list.BorderStyle        = borderStyle;
                list.ForeColorSub       = ColorHSV.ModifyValue(colForeground, GetSetting("ifc_fdeltaColorListSubtext"), !bLightTheme);
                list.FontSub            = new Font(list.Font.FontFamily, list.Font.Size * GetSetting("ifc_fListSubtextScale"));
            }

            if (root is FlatArrowContainer)
            {
                FlatArrowContainer fac = (FlatArrowContainer)root;
                fac.BorderColor = bBorders ? colBorder : Color.Empty;
            }

            if (root is FlatNumberBox)
            {
                FlatNumberBox numbox = (FlatNumberBox)root;
                numbox.ButtonBackColor     = colBackground;
                numbox.ButtonBackColorDown = colMouseDown;
                numbox.ButtonBackColorOver = colMouseOver;
                numbox.BorderColor         = colBorder;
                //numbox.ButtonsVertical = false; //TODO: Make this a setting
            }

            if (root is ExtendedComboBox)
            {
                ExtendedComboBox combo = (ExtendedComboBox)root;
                combo.FlatStyle           = FlatStyle.Popup;
                combo.HasBorders          = bBorders;
                combo.BorderColor         = colBorder;
                combo.BorderColorActive   = colBorder;
                combo.BorderColorDisabled = colBorder;
            }

            if (root is DraggableGraph)
            {
                DraggableGraph graph = (DraggableGraph)root;
                graph.DotColor    = colAccent;
                graph.LineColor   = ColorHSV.ModifyValue(colAccent, 0.25, !bLightTheme);
                graph.BorderColor = colBorder;
            }

            CustomCallback?.Invoke(root);

#if DEBUG
            if (root.GetType() == typeof(TextBox) ||
                root.GetType() == typeof(ComboBox) ||
                root.GetType() == typeof(TreeView))
            {
                System.Diagnostics.Debug.Assert(false, "Generic WinForms control of type '" + root.GetType().Name + "' found: " + root.Name + " - can you replace it with its (fixed and better working) extended version?");
            }
            if (root is ListBox ||
                root is ListView ||
                root is NumericUpDown ||
                root is Button)
            {
                System.Diagnostics.Debug.Assert(false, "Generic WinForms control of type '" + root.GetType().Name + "' found: " + root.Name + " - can you replace it with a flat control?");
            }
#endif

            // ignore if this is in a different namespace
            //TODO: ScintillaNET is caught on this, we should replace the inline find/replace thing with a custom one!
            string ns = root.GetType().Namespace;
            if (ns == "System.Windows.Forms" || ns.StartsWith("Nimble.") || (Namespace == null || ns.StartsWith(Namespace)))
            {
                foreach (Control ctl in root.Controls)
                {
                    InterfaceThemeControl(ctl);
                }
            }
        }