Exemplo n.º 1
0
		public override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);

			if (this.mouseSelect)
			{
				Cursor.Current = Cursors.IBeam;

				// Pick char
				int pickedCharIndex;
				Point pickLoc = new Point(Math.Min(Math.Max(e.X, rect.X + 2), rect.Right - 2), rect.Y + rect.Height / 2);
				pickedCharIndex = ControlRenderer.PickCharTextField(
					this.rect, 
					this.text,
					ControlRenderer.DefaultFont,
					TextBoxStyle.Sunken,
					pickLoc,
					this.scroll);
				if (pickedCharIndex == -1) pickedCharIndex = this.text != null ? this.text.Length : 0;

				this.selectionLength = (this.cursorIndex + this.selectionLength) - pickedCharIndex;
				this.cursorIndex = pickedCharIndex;
				this.UpdateScroll();
				this.EmitInvalidate();
			}
			else
			{
				if (!this.rect.Contains(e.Location)) return;
				Cursor.Current = this.hovered && (Control.MouseButtons == MouseButtons.None) ? Cursors.IBeam : Cursors.Default;
			}
		}
Exemplo n.º 2
0
        public void OnMouseDown(MouseEventArgs e)
        {
            if (!this.rect.Contains(e.Location))
            {
                return;
            }

            // Pick char
            int   pickedCharIndex;
            Point pickLoc = new Point(Math.Min(Math.Max(e.X, rect.X + 2), rect.Right - 2), rect.Y + rect.Height / 2);

            pickedCharIndex = ControlRenderer.PickCharTextField(
                this.rect,
                this.text,
                ControlRenderer.FontRegular,
                TextBoxStyle.Sunken,
                pickLoc,
                this.scroll);
            if (pickedCharIndex == -1)
            {
                pickedCharIndex = this.text != null ? this.text.Length : 0;
            }

            this.cursorIndex     = pickedCharIndex;
            this.selectionLength = 0;
            this.UpdateScroll();
            this.EmitInvalidate();

            this.mouseSelect = true;
        }
Exemplo n.º 3
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case NativeWindowCommon.WM_VSCROLL:
            case NativeWindowCommon.WM_HSCROLL:
                //keep all FitToMDI children at location 0,0 even after scroll
                foreach (var item in mdiClient.MdiChildren)
                {
                    TagData tagData = item.Tag as TagData;
                    if (tagData != null && (tagData.WindowType == WindowType.FitToMdi || tagData.IsMDIClientForm))
                    {
                        item.Location = new Point();
                    }
                }
                mdiClient.Invalidate();
                break;

            case NativeWindowCommon.WM_PAINT:
                using (Graphics gr = Graphics.FromHwnd(mdiClient.Handle))
                {
                    //Paint the mdiClient its children, background image, border etc.
                    ControlRenderer.PaintMgPanel(mdiClient, gr);
                    NativeWindowCommon.ValidateRect(mdiClient.Handle, IntPtr.Zero);
                }
                return;

            default:
                break;
            }
            base.WndProc(ref m);
        }
Exemplo n.º 4
0
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap     = ControlsMap.getInstance();
            MgPanel     tabControlPanel = (MgPanel)sender;

            TabControl tabControl = ((TagData)(tabControlPanel.Tag)).ContainerTabControl;

            MapData mapData = controlsMap.getMapData(tabControl);

            switch (type)
            {
            case EventType.PAINT:
                ControlRenderer.FillRectAccordingToGradientStyle(((PaintEventArgs)e).Graphics, tabControlPanel.ClientRectangle, tabControlPanel.BackColor,
                                                                 tabControlPanel.ForeColor, ControlStyle.NoBorder, false, tabControlPanel.GradientColor,
                                                                 tabControlPanel.GradientStyle);
                break;
            }

            DefaultContainerHandler.getInstance().handleEvent(type, (Control)sender, e, mapData);

            if (type == EventType.DISPOSED)
            {
                tabControl.Tag = null;
            }
        }
Exemplo n.º 5
0
		public void OnPaint(PaintEventArgs e, bool enabled, bool multiple)
		{
			TextBoxState textBoxState;

			if (!enabled)
				textBoxState = TextBoxState.Disabled;
			else if (this.focused)
				textBoxState = TextBoxState.Focus;
			else if (this.hovered)
				textBoxState = TextBoxState.Hot;
			else
				textBoxState = TextBoxState.Normal;

			if (this.readOnly)
				textBoxState |= TextBoxState.ReadOnlyFlag;

			ControlRenderer.DrawTextField(
				e.Graphics, 
				rect, 
				text, 
				ControlRenderer.DefaultFont, 
				ControlRenderer.ColorText, 
				multiple ? ControlRenderer.ColorMultiple : ControlRenderer.ColorVeryLightBackground,
				textBoxState, 
				TextBoxStyle.Sunken,
				this.scroll,
				(this.selectionLength != 0 || this.cursorVisible) ? this.cursorIndex : -1,
				this.selectionLength);
		}
Exemplo n.º 6
0
        /// <summary>
        ///   print control's text
        /// </summary>
        /// <param name = "gc"></param>
        /// <param name = "rect"></param>
        /// <param name = "color"></param>
        /// <param name = "str"></param>
        internal virtual void printText(Graphics g, Rectangle rect, Color color, String str)
        {
            FontDescription font = new FontDescription(Font);

            ControlRenderer.PrintText(g, rect, color, font, str, MultiLine, ContentAlignment, Enabled, WordWrap, true, false,
                                      _rightToLeft);
        }
Exemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            ControlRenderer.DrawStringLine(e.Graphics,
                                           "Width:",
                                           SystemFonts.DefaultFont,
                                           this.rectLabelWidth,
                                           !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText);
            ControlRenderer.DrawStringLine(e.Graphics,
                                           "Height:",
                                           SystemFonts.DefaultFont,
                                           this.rectLabelHeight,
                                           !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText);
            ControlRenderer.DrawStringLine(e.Graphics,
                                           this.value != null ? this.value.Width.ToString() : " - ",
                                           SystemFonts.DefaultFont,
                                           this.rectLabelWidthVal,
                                           !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText);
            ControlRenderer.DrawStringLine(e.Graphics,
                                           this.value != null ? this.value.Height.ToString() : " - ",
                                           SystemFonts.DefaultFont,
                                           this.rectLabelHeightVal,
                                           !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText);

            if (this.PreviewFrameCount == 0)
            {
                ControlRenderer.DrawStringLine(e.Graphics,
                                               this.value != null ? this.value.Name : " - ",
                                               SystemFonts.DefaultFont,
                                               this.rectLabelName,
                                               !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText,
                                               StringAlignment.Far);
            }
        }
Exemplo n.º 8
0
        internal override void paintBackground(Graphics g, Rectangle rect, Color bgColor, Color fgColor, bool keepColor)
        {
            Rectangle rectImage = this.getRectangle();

            ControlRenderer.PaintBackGround(g, rectImage, bgColor, true);

            // no background
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rectImage     = new Rectangle(this.rectPreview.X + 1, this.rectPreview.Y + 1, this.rectPreview.Width - 2, this.rectPreview.Height - 2);
            Color     brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
            Color     darkChecker   = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);
            Bitmap    img           = this.GetPreviewFrame((int)this.subImageSelector.Value);

            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);
            if (img != null)
            {
                Size  imgSize        = img.Size;
                float widthForHeight = (float)imgSize.Width / (float)imgSize.Height;
                if (widthForHeight * (imgSize.Height - rectImage.Height) > imgSize.Width - rectImage.Width)
                {
                    imgSize.Height = Math.Min(rectImage.Height, imgSize.Height);
                    imgSize.Width  = MathF.RoundToInt(widthForHeight * imgSize.Height);
                }
                else
                {
                    imgSize.Width  = Math.Min(rectImage.Width, imgSize.Width);
                    imgSize.Height = MathF.RoundToInt(imgSize.Width / widthForHeight);
                }
                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                e.Graphics.DrawImage(img,
                                     rectImage.X + rectImage.Width / 2 - imgSize.Width / 2,
                                     rectImage.Y + rectImage.Height / 2 - imgSize.Height / 2,
                                     imgSize.Width,
                                     imgSize.Height);
                e.Graphics.InterpolationMode = InterpolationMode.Default;
            }

            ControlRenderer.DrawBorder(e.Graphics,
                                       this.rectPreview,
                                       BorderStyle.Simple,
                                       !this.Enabled ? BorderState.Disabled : BorderState.Normal);

            bool focusBg = this.Focused || (this is IPopupControlHost && (this as IPopupControlHost).IsDropDownOpened);

            ControlRenderer.DrawGroupHeaderBackground(
                e.Graphics,
                this.rectHeader,
                focusBg ? ControlRenderer.ColorBackground.ScaleBrightness(0.85f) : ControlRenderer.ColorBackground,
                GroupHeaderStyle.SmoothSunken);

            if (this.subImageSelector.Rect.Width > 0)
            {
                ControlRenderer.DrawStringLine(e.Graphics,
                                               "Frame Index",
                                               SystemFonts.DefaultFont,
                                               this.rectLabelName,
                                               !this.Enabled ? ControlRenderer.ColorGrayText : ControlRenderer.ColorText,
                                               StringAlignment.Far);
                this.subImageSelector.OnPaint(e, this.Enabled && !this.subImageSelector.ReadOnly, false);
            }
        }
Exemplo n.º 10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Color brightChecker = Color.FromArgb(224, 224, 224);
            Color darkChecker   = Color.FromArgb(192, 192, 192);

            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), this.rectPanel);
            if (this.value != null)
            {
                Color val      = Color.FromArgb(this.value.ToIntArgb());
                Color valSolid = Color.FromArgb(255, val);
                e.Graphics.FillRectangle(
                    new SolidBrush(val),
                    this.rectPanel.X,
                    this.rectPanel.Y,
                    this.rectPanel.Width / 2,
                    this.rectPanel.Height);
                e.Graphics.FillRectangle(
                    new SolidBrush(valSolid),
                    this.rectPanel.X + this.rectPanel.Width / 2,
                    this.rectPanel.Y,
                    this.rectPanel.Width / 2,
                    this.rectPanel.Height);
            }
            e.Graphics.DrawRectangle(SystemPens.ControlLightLight,
                                     this.rectPanel.X + 1,
                                     this.rectPanel.Y + 1,
                                     this.rectPanel.Width - 2,
                                     this.rectPanel.Height - 2);
            e.Graphics.DrawRectangle(SystemPens.ControlDark, this.rectPanel);

            ButtonState buttonState = ButtonState.Disabled;

            if (!this.ReadOnly && this.Enabled)
            {
                if (this.buttonPressed)
                {
                    buttonState = ButtonState.Pressed;
                }
                else if (this.buttonHovered || this.Focused)
                {
                    buttonState = ButtonState.Hot;
                }
                else
                {
                    buttonState = ButtonState.Normal;
                }
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButton,
                buttonState,
                null,
                EditorRes.GeneralResCache.ColorWheel);
        }
Exemplo n.º 11
0
        internal override void paintBackground(Graphics g, Rectangle rect, Color bgColor, Color fgColor, bool keepColor)
        {
            ControlStyle style = MgTextBox.ShouldDrawFlatTextBox ? ControlStyle.TwoD : ControlStyle.Windows;

            style = (ShowBorder ? style : ControlStyle.NoBorder);
            Rectangle drawRect = rect;

#if PocketPC
            // On Mobile, the offset is not set in the Graphics. Therefore we need to change
            // the offset for all static controls

            offsetStaticControlRect(ref drawRect);
#endif
            ControlRenderer.PaintBackgroundAndBorder(g, drawRect, bgColor, FgColor, style, true, EnabledBackGround || bgColor == Color.Transparent);
        }
Exemplo n.º 12
0
        /// <summary>
        ///   paint background
        /// </summary>
        /// <param name = "g"></param>
        /// <param name = "rect"></param>
        /// <param name = "bgColor"></param>
        /// <param name = "fgColor"></param>
        /// <param name = "keepColor"></param>
        internal virtual void paintBackground(Graphics g, Rectangle rect, Color bgColor, Color fgColor, bool keepColor)
        {
#if PocketPC
            offsetStaticControlRect(ref rect);
#endif
            if (GuiMgControl.SupportGradient() && keepColor)
            {
                ControlRenderer.FillRectAccordingToGradientStyle(g, rect, BgColor, FgColor, Style,
                                                                 false, GradientColor, GradientStyle);
            }
            else
            {
                ControlRenderer.PaintBackGround(g, rect, bgColor, true);
            }
        }
Exemplo n.º 13
0
        public Button(string label, ControlStyle style) : base()
        {
            if (style == null)
            {
                throw new NotSupportedException("A style must be provided for this button.");
            }

            Style = style;

            _render = new ControlRenderer(this);
            if (!string.IsNullOrEmpty(label) && style.FontStyle != null)
            {
                Label = new Label(label, style.FontStyle);
                Label.AnchorTo(this, Anchoring.PositionType.Inside_Middle_Center, 0, 0, Anchoring.AnchorType.Bounds);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal static void MgPanel_Paint(object sender, PaintEventArgs e)
        {
            Control ctrl = sender as MgPanel;

            // for mgpanel with parent MgTabPage set paint event
            if (ctrl is MgPanel && ctrl.Parent is MgTabPage)
            {
                MgPanel senderMgPanel = (MgPanel)sender;
                ControlRenderer.FillRectAccordingToGradientStyle(((PaintEventArgs)e).Graphics, senderMgPanel.ClientRectangle, senderMgPanel.BackColor,
                                                                 senderMgPanel.ForeColor, ControlStyle.NoBorder, false, senderMgPanel.GradientColor,
                                                                 senderMgPanel.GradientStyle);
            }
            else
            {
                ControlRenderer.PaintMgPanel(ctrl, e.Graphics);
            }
        }
        public void OnPaint(PaintEventArgs e, bool enabled, bool multiple)
        {
            ButtonState comboState = ButtonState.Normal;

            if (!enabled || this.ReadOnly)
            {
                comboState = ButtonState.Disabled;
            }
            else if (this.pressed || this.IsDropDownOpened || (this.focused && (Control.ModifierKeys & Keys.Control) == Keys.Control))
            {
                comboState = ButtonState.Pressed;
            }
            else if (this.hovered || this.focused)
            {
                comboState = ButtonState.Hot;
            }

            ControlRenderer.DrawComboBox(e.Graphics, this.rect, comboState, this.selectedObjStr);
        }
Exemplo n.º 16
0
        public PropertyGrid()
        {
            this.renderer = new ControlRenderer();

            this.updateTimer          = new Timer();
            this.updateTimer.Interval = 100;
            this.updateTimer.Tick    += this.updateTimer_Tick;
            this.updateTimer.Enabled  = true;

            this.AllowDrop  = true;
            this.AutoScroll = true;
            //this.DoubleBuffered = true;

            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }
Exemplo n.º 17
0
		public void UpdateScroll()
		{
			int cursorPixelPos = ControlRenderer.GetCharPosTextField(
				this.rect,
				this.text,
				ControlRenderer.DefaultFont,
				TextBoxStyle.Sunken,
				this.cursorIndex,
				this.scroll);
			if (cursorPixelPos - this.rect.X < 15 && this.scroll > 0)
			{
				this.scroll = Math.Max(this.scroll - (15 - cursorPixelPos + this.rect.X), 0);
				this.EmitInvalidate();
			}
			else if (cursorPixelPos - this.rect.X > this.rect.Width - 15)
			{
				this.scroll += (cursorPixelPos - this.rect.X) - (this.rect.Width - 15);
				this.EmitInvalidate();
			}
		}
Exemplo n.º 18
0
Arquivo: Line.cs Projeto: rinavin/RCJS
        /// <summary>
        /// paint line control
        /// </summary>
        /// <param name="g"></param>
        internal override void paintForeground(Graphics g, Rectangle rect, Color fgColor)
        {
            if (!Visible)
            {
                return;
            }

            Point pt1 = new Point(X1, Y1);
            Point pt2 = new Point(X2, Y2);

#if PocketPC
            BasicControlsManager staticControlsManager = ContainerManager as BasicControlsManager;
            if (staticControlsManager != null)
            {
                Point offset = staticControlsManager.ContainerOffset();
                pt1.Offset(offset.X, offset.Y);
                pt2.Offset(offset.X, offset.Y);
            }
#endif
            ControlRenderer.PaintLineForeGround(g, fgColor, LineHelper.Style, LineHelper.LineWidth, LineHelper.LineStyle, pt1, pt2);
        }
Exemplo n.º 19
0
        public Panel(string title, ControlStyle style, bool scrolls = false, bool moves = false) : base()
        {
            if (style == null)
            {
                throw new NotSupportedException("A style must be provided for this panel.");
            }

            if (moves)
            {
                EnableDragging = true;
            }

            Style  = style;
            Width  = Style.TextureDefault.Width;
            Height = Style.TextureDefault.Height;

            if (!string.IsNullOrEmpty(title))
            {
                label = new Label(title, Style.FontStyle);
                label.AnchorTo(this, PositionType.Inside_Top_Center, 0, 6, AnchorType.Bounds);
            }

            render = new ControlRenderer(this);

            AnchorToArgs arg = new AnchorToArgs(this, PositionType.Inside_Top_Left, 0, 0, AnchorType.Bounds);

            ContentManager = new ContentManager(KVM.Graphics, new AnchoredRectangle(Rectangle.Empty, arg));


            if (scrolls)
            {
                if (Style.ScrollerStyle == null)
                {
                    throw new NotSupportedException("ControlStyle must contain ScrollerStyle to enable scrolling.");
                }
                Scrolls           = true;
                scroller          = new Scroller(this);
                _contentsRenderer = new RenderInScissor(KVM.Graphics);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Renders the supplied "labelled control", i.e., control which has a label.
        /// </summary>
        /// <typeparam name="T">Type of control.</typeparam>
        /// <param name="writer">WpfXmlWriter to use to write the XAML.</param>
        /// <param name="control">Control to render alongside label.</param>
        /// <param name="controlRenderer">Control renderer to use to render the control.</param>
        public static void RenderLabelledControl <T>(WpfXmlWriter writer, T control, ControlRenderer <T> controlRenderer) where T : Control_t
        {
            bool isVertical = ((control as IParentable <StrategyPanel_t>).Parent.Orientation == Orientation_t.Vertical);

            // If this is a vertical StrategyPanel, we don't bother with a containing Grid - this provides nice alignment of labels and controls
            if (isVertical)
            {
                RenderControlLabel(writer, control, new GridCoordinate(control.Index, 0));

                controlRenderer(control, new GridCoordinate(control.Index, 1));
            }
            else
            {
                using (writer.New(WpfXmlWriterTag.Grid))
                {
                    writer.WriteAttribute(WpfXmlWriterAttribute.GridColumn, control.Index.ToString());

                    using (writer.New(WpfXmlWriterTag.GridColumnDefinitions))
                    {
                        for (int n = 0; n < 2; n++)
                        {
                            using (writer.New(WpfXmlWriterTag.ColumnDefinition))
                                writer.WriteAttribute(WpfXmlWriterAttribute.Width, "Auto");
                        }
                    }

                    using (writer.New(WpfXmlWriterTag.GridRowDefinitions))
                    {
                        using (writer.New(WpfXmlWriterTag.RowDefinition))
                            writer.WriteAttribute(WpfXmlWriterAttribute.Height, "Auto");
                    }

                    RenderControlLabel(writer, control, StandardGridCoordinates.Label);

                    controlRenderer(control, StandardGridCoordinates.Control);
                }
            }
        }
Exemplo n.º 21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rectPreview   = this.ClientRectangle;
            Rectangle rectImage     = new Rectangle(rectPreview.X + 1, rectPreview.Y + 1, rectPreview.Width - 2, rectPreview.Height - 2);
            Color     brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
            Color     darkChecker   = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);

            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);
            if (this.prevImage != null)
            {
                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(rectImage.X, rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, rectImage);
            }

            ControlRenderer.DrawBorder(e.Graphics,
                                       rectPreview,
                                       BorderStyle.Simple,
                                       !this.Enabled ? BorderState.Disabled : BorderState.Normal);
        }
Exemplo n.º 22
0
        internal override void DestroyView()
        {
            if (_shadowRef.HasValue)
            {
                ControlRenderer.RemoveRenderObject(_shadowRef.Value);
                _shadowRef = null;
            }

            if (_backgroundRef.HasValue)
            {
                ControlRenderer.RemoveRenderObject(_backgroundRef.Value);
                _backgroundRef = null;
            }

            for (int i = 0; i < _borderRefs.Length; ++i)
            {
                if (_borderRefs[i].HasValue)
                {
                    ControlRenderer.RemoveRenderObject(_borderRefs[i].Value);
                    _borderRefs[i] = null;
                }
            }
        }
Exemplo n.º 23
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rectPreview   = this.ClientRectangle;
            Color     brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
            Color     darkChecker   = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);

            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), this.rectImage);
            if (this.prevImage != null)
            {
                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(this.rectImage.X, this.rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, this.rectImage);
            }

            if (this.prevSoundInst != null)
            {
                e.Graphics.DrawImage(this.prevImageLum > 0.5f ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack,
                                     this.rectPrevSound.X,
                                     this.rectPrevSound.Y);
            }
            else
            {
                e.Graphics.DrawImageAlpha(this.prevImageLum > 0.5f ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack,
                                          0.5f,
                                          this.rectPrevSound.X,
                                          this.rectPrevSound.Y);
            }

            ControlRenderer.DrawBorder(e.Graphics,
                                       rectPreview,
                                       BorderStyle.Simple,
                                       !this.Enabled ? BorderState.Disabled : BorderState.Normal);
        }
Exemplo n.º 24
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Color headerBgColorUpper = ControlRenderer.ColorBackground;
            Color headerBgColorLower = headerBgColorUpper.ScaleBrightness(0.95f);

            GroupedPropertyEditor.DrawGroupHeaderBackground(e.Graphics, this.rectHeader, headerBgColorUpper, GroupedPropertyEditor.GroupHeaderStyle.Emboss);
            GroupedPropertyEditor.DrawGroupHeaderBackground(e.Graphics, this.rectPrefab, headerBgColorLower, GroupedPropertyEditor.GroupHeaderStyle.SmoothSunken);
            if (this.Focused)
            {
                ControlRenderer.DrawBorder(e.Graphics, this.ClientRectangle, AdamsLair.WinForms.Drawing.BorderStyle.Simple, BorderState.Normal);
            }

            CheckBoxState activeState = CheckBoxState.UncheckedDisabled;

            if (!this.ReadOnly && this.Enabled)
            {
                if (!this.active.HasValue)
                {
                    if (this.activeCheckPressed)
                    {
                        activeState = CheckBoxState.MixedPressed;
                    }
                    else if (this.activeCheckHovered)
                    {
                        activeState = CheckBoxState.MixedHot;
                    }
                    else
                    {
                        activeState = CheckBoxState.MixedNormal;
                    }
                }
                else if (this.active.Value)
                {
                    if (this.activeCheckPressed)
                    {
                        activeState = CheckBoxState.CheckedPressed;
                    }
                    else if (this.activeCheckHovered)
                    {
                        activeState = CheckBoxState.CheckedHot;
                    }
                    else
                    {
                        activeState = CheckBoxState.CheckedNormal;
                    }
                }
                else
                {
                    if (this.activeCheckPressed)
                    {
                        activeState = CheckBoxState.UncheckedPressed;
                    }
                    else if (this.activeCheckHovered)
                    {
                        activeState = CheckBoxState.UncheckedHot;
                    }
                    else
                    {
                        activeState = CheckBoxState.UncheckedNormal;
                    }
                }
            }
            else
            {
                if (!this.active.HasValue)
                {
                    activeState = CheckBoxState.MixedDisabled;
                }
                else if (this.active.Value)
                {
                    activeState = CheckBoxState.CheckedDisabled;
                }
                else
                {
                    activeState = CheckBoxState.UncheckedDisabled;
                }
            }
            ControlRenderer.DrawCheckBox(e.Graphics, this.rectCheckActive.Location, activeState);

            Region[] nameLabelRegion = ControlRenderer.MeasureStringLine(e.Graphics, this.displayedName, new[] { new CharacterRange(0, this.displayedName.Length) }, headerNameFont, this.rectLabelName);
            ControlRenderer.DrawStringLine(e.Graphics, this.displayedName, headerNameFont, this.rectLabelName, SystemColors.ControlText);

            if (nameLabelRegion.Length > 0)
            {
                SizeF     nameLabelSize = nameLabelRegion[0].GetBounds(e.Graphics).Size;
                Rectangle extLabelRect  = new Rectangle(
                    this.rectLabelName.X + (int)nameLabelSize.Width,
                    this.rectLabelName.Y,
                    this.rectLabelName.Width - (int)nameLabelSize.Width,
                    this.rectLabelName.Height);
                ControlRenderer.DrawStringLine(e.Graphics, this.displayedNameExt, headerNameExtFont, extLabelRect, SystemColors.ControlText);
            }

            ButtonState buttonStateAdd        = ButtonState.Normal;
            ButtonState buttonStateDefaultAdd = ButtonState.Normal;

            if (this.curButtonPressed)
            {
                buttonStateAdd = ButtonState.Pressed;
            }
            else if (this.curButtonHovered)
            {
                buttonStateAdd = ButtonState.Hot;
            }
            ControlRenderer.DrawButton(e.Graphics, this.rectButtonAddComponent, this.curButton == 4 ? buttonStateAdd : buttonStateDefaultAdd, "+");

            ControlRenderer.DrawStringLine(e.Graphics, "PrefabLink", headerPrefabFont, this.rectLabelPrefab, !this.prefabLinked ? SystemColors.GrayText : (this.prefabLinkAvailable ? Color.Blue : Color.DarkRed));

            ButtonState buttonState             = ButtonState.Disabled;
            ButtonState buttonStateDefault      = ButtonState.Disabled;
            ButtonState buttonStateDefaultBreak = ButtonState.Disabled;

            if (!this.ReadOnly && this.Enabled && this.prefabLinked)
            {
                if (this.prefabLinkAvailable)
                {
                    buttonState        = ButtonState.Normal;
                    buttonStateDefault = ButtonState.Normal;
                }
                buttonStateDefaultBreak = ButtonState.Normal;
            }

            if (this.curButtonPressed)
            {
                buttonState = ButtonState.Pressed;
            }
            else if (this.curButtonHovered)
            {
                buttonState = ButtonState.Hot;
            }

            ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabShow, this.curButton == 0 ? buttonState : buttonStateDefault, "Show");
            ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabRevert, this.curButton == 1 ? buttonState : buttonStateDefault, "Revert");
            ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabApply, this.curButton == 2 ? buttonState : buttonStateDefault, "Apply");
            ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabBreak, this.curButton == 3 ? buttonState : buttonStateDefaultBreak, "Break");
        }
Exemplo n.º 25
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            bool linkBroken = this.ReferenceBroken;

            Color bgColorBright = Color.White;

            if (this.dragHover)
            {
                bgColorBright = bgColorBright.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
            }
            else if (this.multiple)
            {
                bgColorBright = Color.Bisque;
            }
            else if (linkBroken)
            {
                bgColorBright = Color.FromArgb(255, 128, 128);
            }

            bool      darkBg    = false;
            Rectangle rectImage = new Rectangle(this.rectPanel.X + 2, this.rectPanel.Y + 2, this.rectPanel.Width - 4, this.rectPanel.Height - 4);

            if (this.prevImage == null)
            {
                if (this.ReadOnly || !this.Enabled)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, bgColorBright)), rectImage);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(bgColorBright), rectImage);
                }
            }
            else
            {
                Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
                Color darkChecker   = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);

                if (this.dragHover)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                    darkChecker   = darkChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                }
                else if (this.multiple)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                    darkChecker   = darkChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                }
                else if (linkBroken)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                    darkChecker   = darkChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                }

                e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);

                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(rectImage.X, rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, rectImage);

                darkBg = this.prevImageLum > 0.5f;
                if (this.ReadOnly || !this.Enabled)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, SystemColors.Control)), rectImage);
                    darkBg = (this.prevImageLum + SystemColors.Control.GetLuminance()) * 0.5f < 0.5f;
                }
            }

            if (this.prevSound != null)
            {
                if (this.prevSoundInst != null)
                {
                    e.Graphics.DrawImage(darkBg ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack,
                                         this.rectPrevSound.X,
                                         this.rectPrevSound.Y);
                }
                else
                {
                    e.Graphics.DrawImageAlpha(darkBg ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack,
                                              0.5f,
                                              this.rectPrevSound.X,
                                              this.rectPrevSound.Y);
                }
            }

            StringFormat format = StringFormat.GenericDefault;

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming      = StringTrimming.EllipsisPath;
            SizeF textSize = e.Graphics.MeasureString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SizeF(this.rectPanel.Width, this.rectPanel.Height),
                format);

            Rectangle rectText;

            if (this.prevImage == null)
            {
                rectText = this.rectPanel;
            }
            else
            {
                rectText = new Rectangle(
                    this.rectPanel.X, this.rectPanel.Bottom - (int)textSize.Height - 2, this.rectPanel.Width, (int)textSize.Height);
            }

            if (this.prevImage != null)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(192, bgColorBright)),
                                         rectText.X + rectText.Width / 2 - textSize.Width / 2 - 1,
                                         rectText.Y + rectText.Height / 2 - textSize.Height / 2 - 2,
                                         textSize.Width + 1,
                                         textSize.Height + 2);
            }
            e.Graphics.DrawString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SolidBrush(this.Enabled ? SystemColors.ControlText : SystemColors.GrayText),
                rectText,
                format);

            ControlRenderer.DrawBorder(e.Graphics,
                                       this.rectPanel,
                                       BorderStyle.ContentBox,
                                       (this.ReadOnly || !this.Enabled) ? BorderState.Disabled : BorderState.Normal);

            ButtonState buttonStateReset = ButtonState.Disabled;

            if (!this.ReadOnly && this.Enabled && this.ReferenceName != null)
            {
                if (this.buttonResetPressed)
                {
                    buttonStateReset = ButtonState.Pressed;
                }
                else if (this.buttonResetHovered)
                {
                    buttonStateReset = ButtonState.Hot;
                }
                else
                {
                    buttonStateReset = ButtonState.Normal;
                }
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButtonReset,
                buttonStateReset,
                null,
                iconReset);

            ButtonState buttonStateShow = ButtonState.Disabled;

            if (this.Enabled && this.ReferenceName != null)
            {
                if (this.buttonShowPressed)
                {
                    buttonStateShow = ButtonState.Pressed;
                }
                else if (this.buttonShowHovered || this.Focused)
                {
                    buttonStateShow = ButtonState.Hot;
                }
                else
                {
                    buttonStateShow = ButtonState.Normal;
                }
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButtonShow,
                buttonStateShow,
                null,
                iconShow);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Paint the line
 /// </summary>
 /// <param name="e"></param>
 protected override void OnPaint(PaintEventArgs e)
 {
     ControlRenderer.PaintLineForeGround(e.Graphics, LineColor, ControlStyle, LineWidth, CtrlLineType, StartPoint, EndPoint);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Draw the control on the given Graphics at the specified rectangle.
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="rect"></param>
 public void Draw(Graphics graphics, Rectangle rect)
 {
     Point[] linePoints = LineRenderer.GetLinePoints(rect, lineWidth, directionOfLine);
     ControlRenderer.PaintLineForeGround(graphics, LineColor, ControlStyle, LineWidth, CtrlLineType, linePoints[0], linePoints[1]);
 }
Exemplo n.º 28
0
 public FormStatusStrip()
 {
     Renderer   = new ControlRenderer();
     SizingGrip = false;
 }
Exemplo n.º 29
0
        protected void PaintHeader(Graphics g)
        {
            if (this.headerHeight == 0)
            {
                return;
            }
            Rectangle buttonRect = this.ButtonRectangle;

            CheckBoxState activeState  = CheckBoxState.UncheckedDisabled;
            CheckBoxState expandState  = CheckBoxState.UncheckedDisabled;
            bool          parentExpand = this.ParentUseIndentChildExpand;

            if (!parentExpand && (this.Hints & HintFlags.HasExpandCheck) != HintFlags.None)
            {
                if (this.Enabled && this.CanExpand && (this.Hints & HintFlags.ExpandEnabled) != HintFlags.None)
                {
                    if (!this.Expanded)
                    {
                        if (this.expandCheckPressed)
                        {
                            expandState = CheckBoxState.PlusPressed;
                        }
                        else if (this.expandCheckHovered)
                        {
                            expandState = CheckBoxState.PlusHot;
                        }
                        else
                        {
                            expandState = CheckBoxState.PlusNormal;
                        }
                    }
                    else
                    {
                        if (this.expandCheckPressed)
                        {
                            expandState = CheckBoxState.MinusPressed;
                        }
                        else if (this.expandCheckHovered)
                        {
                            expandState = CheckBoxState.MinusHot;
                        }
                        else
                        {
                            expandState = CheckBoxState.MinusNormal;
                        }
                    }
                }
                else
                {
                    if (this.Expanded)
                    {
                        expandState = CheckBoxState.PlusDisabled;
                    }
                    else
                    {
                        expandState = CheckBoxState.MinusDisabled;
                    }
                }
            }
            if ((this.Hints & HintFlags.HasActiveCheck) != HintFlags.None)
            {
                if (this.Enabled && !this.ReadOnly && (this.Hints & HintFlags.ActiveEnabled) != HintFlags.None)
                {
                    if (this.Active)
                    {
                        if (this.activeCheckPressed)
                        {
                            activeState = CheckBoxState.CheckedPressed;
                        }
                        else if (this.activeCheckHovered)
                        {
                            activeState = CheckBoxState.CheckedHot;
                        }
                        else
                        {
                            activeState = CheckBoxState.CheckedNormal;
                        }
                    }
                    else
                    {
                        if (this.activeCheckPressed)
                        {
                            activeState = CheckBoxState.UncheckedPressed;
                        }
                        else if (this.activeCheckHovered)
                        {
                            activeState = CheckBoxState.UncheckedHot;
                        }
                        else
                        {
                            activeState = CheckBoxState.UncheckedNormal;
                        }
                    }
                }
                else
                {
                    if (this.Active)
                    {
                        activeState = CheckBoxState.CheckedDisabled;
                    }
                    else
                    {
                        activeState = CheckBoxState.UncheckedDisabled;
                    }
                }
            }

            Rectangle iconRect;

            if (this.headerIcon != null)
            {
                iconRect = new Rectangle(
                    this.activeCheckRect.Right + 2,
                    this.headerRect.Y + this.headerRect.Height / 2 - this.headerIcon.Height / 2,
                    this.headerIcon.Width,
                    this.headerIcon.Height);
            }
            else
            {
                iconRect = new Rectangle(this.activeCheckRect.Right, this.headerRect.Y, 0, 0);
            }
            Rectangle textRect = new Rectangle(
                iconRect.Right,
                this.headerRect.Y,
                this.headerRect.Width - buttonRect.Width - iconRect.Width - this.expandCheckRect.Width - this.activeCheckRect.Width - 2,
                this.headerRect.Height);
            Rectangle nameTextRect;
            Rectangle valueTextRect;

            if (!string.IsNullOrEmpty(this.PropertyName) && !string.IsNullOrEmpty(this.headerValueText))
            {
                int nameWidth;
                nameWidth     = this.NameLabelWidth - textRect.X;
                nameTextRect  = new Rectangle(textRect.X, textRect.Y, nameWidth, textRect.Height);
                valueTextRect = new Rectangle(textRect.X + nameWidth, textRect.Y, textRect.Width - nameWidth, textRect.Height);
            }
            else if (!string.IsNullOrEmpty(this.headerValueText))
            {
                nameTextRect  = new Rectangle(textRect.X, textRect.Y, 0, 0);
                valueTextRect = textRect;
            }
            else
            {
                nameTextRect  = textRect;
                valueTextRect = new Rectangle(textRect.X, textRect.Y, 0, 0);
            }


            bool focusBg      = this.Focused || (this is IPopupControlHost && (this as IPopupControlHost).IsDropDownOpened);
            bool focusBgColor = this.headerStyle == GroupHeaderStyle.Flat || this.headerStyle == GroupHeaderStyle.Simple;

            ControlRenderer.DrawGroupHeaderBackground(g, this.headerRect, focusBg && focusBgColor ? this.headerColor.Value.ScaleBrightness(0.85f) : this.headerColor.Value, this.headerStyle);
            if (focusBg && !focusBgColor)
            {
                ControlRenderer.DrawBorder(g, this.headerRect, Renderer.BorderStyle.Simple, BorderState.Normal);
            }

            if (!parentExpand && (this.Hints & HintFlags.HasExpandCheck) != HintFlags.None)
            {
                ControlRenderer.DrawCheckBox(g, this.expandCheckRect.Location, expandState);
            }
            if ((this.Hints & HintFlags.HasActiveCheck) != HintFlags.None)
            {
                ControlRenderer.DrawCheckBox(g, this.activeCheckRect.Location, activeState);
            }

            if (this.headerIcon != null)
            {
                g.DrawImage(this.Enabled ? this.headerIcon.Normal : this.headerIcon.Disabled, iconRect);
            }

            ControlRenderer.DrawStringLine(g,
                                           this.PropertyName,
                                           this.ValueModified ? ControlRenderer.DefaultFontBold : ControlRenderer.DefaultFont,
                                           nameTextRect,
                                           this.Enabled && !this.NonPublic ? ControlRenderer.ColorText : ControlRenderer.ColorGrayText);
            ControlRenderer.DrawStringLine(g,
                                           this.headerValueText,
                                           this.ValueModified ? ControlRenderer.DefaultFontBold : ControlRenderer.DefaultFont,
                                           valueTextRect,
                                           this.Enabled ? ControlRenderer.ColorText : ControlRenderer.ColorGrayText);
        }
Exemplo n.º 30
0
        protected void PaintIndentExpandButton(Graphics g, GroupedPropertyEditor childGroup)
        {
            if (childGroup.headerHeight == 0)
            {
                return;
            }
            if ((childGroup.Hints & HintFlags.HasExpandCheck) == HintFlags.None)
            {
                return;
            }

            Rectangle indentExpandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
            Rectangle expandButtonRect = new Rectangle(
                indentExpandRect.X + indentExpandRect.Width / 2 - ControlRenderer.ExpandNodeSize.Width / 2,
                indentExpandRect.Y + indentExpandRect.Height / 2 - ControlRenderer.ExpandNodeSize.Height / 2 - 1,
                ControlRenderer.ExpandNodeSize.Width,
                ControlRenderer.ExpandNodeSize.Height);
            ExpandNodeState expandState = ExpandNodeState.OpenedDisabled;

            if (childGroup.Enabled && childGroup.CanExpand && (childGroup.Hints & HintFlags.ExpandEnabled) != HintFlags.None)
            {
                if (!childGroup.Expanded)
                {
                    if (childGroup.expandCheckPressed)
                    {
                        expandState = ExpandNodeState.ClosedPressed;
                    }
                    else if (childGroup.expandCheckHovered)
                    {
                        expandState = ExpandNodeState.ClosedHot;
                    }
                    else if (childGroup.Focused)
                    {
                        expandState = ExpandNodeState.ClosedHot;
                    }
                    else
                    {
                        expandState = ExpandNodeState.ClosedNormal;
                    }
                }
                else
                {
                    if (childGroup.expandCheckPressed)
                    {
                        expandState = ExpandNodeState.OpenedPressed;
                    }
                    else if (childGroup.expandCheckHovered)
                    {
                        expandState = ExpandNodeState.OpenedHot;
                    }
                    else if (childGroup.Focused)
                    {
                        expandState = ExpandNodeState.OpenedHot;
                    }
                    else
                    {
                        expandState = ExpandNodeState.OpenedNormal;
                    }
                }
            }
            else
            {
                if (childGroup.Expanded)
                {
                    expandState = ExpandNodeState.OpenedDisabled;
                }
                else
                {
                    expandState = ExpandNodeState.ClosedDisabled;
                }
            }

            ControlRenderer.DrawExpandNode(g, expandButtonRect.Location, expandState);
        }