public override void AddSelectionHandles(DiagramSelection sel, DiagramShape selectedObj) { if (!this.CanResize() || !this.CanReshape()) { base.AddSelectionHandles(sel, selectedObj); } else { System.Windows.Forms.Orientation orientation1 = this.Orientation; PointF tf2 = new PointF(); PointF tf3 = new PointF(); PointF tf4 = new PointF(); PointF tf5 = new PointF(); bool flag1 = this.A.X <= this.B.X; bool flag2 = this.A.Y <= this.D.Y; sel.RemoveHandles(this); if (flag1 && flag2) { tf2 = this.A; tf3 = this.B; tf4 = this.D; tf5 = this.C; } else if (!flag1 && flag2) { tf2 = this.B; tf3 = this.A; tf4 = this.C; tf5 = this.D; } else if (flag1 && !flag2) { tf2 = this.D; tf3 = this.C; tf4 = this.A; tf5 = this.B; } else { tf2 = this.C; tf3 = this.D; tf4 = this.B; tf5 = this.A; } PointF tf1 = new PointF((tf2.X + tf4.X) / 2f, (tf2.Y + tf4.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, tf1, 0x100, true); tf1 = new PointF((tf3.X + tf5.X) / 2f, (tf3.Y + tf5.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, tf1, 0x40, true); tf1 = new PointF((tf2.X + tf3.X) / 2f, (tf2.Y + tf3.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, tf1, 0x20, true); tf1 = new PointF((tf4.X + tf5.X) / 2f, (tf4.Y + tf5.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, tf1, 0x80, true); sel.CreateResizeHandle(this, selectedObj, this.A, 0x40a, true); sel.CreateResizeHandle(this, selectedObj, this.B, 0x40b, true); sel.CreateResizeHandle(this, selectedObj, this.C, 0x40c, true); sel.CreateResizeHandle(this, selectedObj, this.D, 0x40d, true); } }
public CtrlLine() { SetStyle(System.Windows.Forms.ControlStyles.UserPaint | System.Windows.Forms.ControlStyles.AllPaintingInWmPaint | System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer, true); lineWidth = 1; topLineColor = System.Drawing.SystemColors.ControlDark; bottomLineColor = System.Drawing.SystemColors.ControlLightLight; orientation = System.Windows.Forms.Orientation.Horizontal; blend = false; angle = 90; TabStop = false; }
private void UpdateDropDown() { _drawDropDown.Visible = _dropDown; _drawSplitBorder.Visible = _splitter & _dropDown; _drawOuterSeparator.Visible = !_splitter & _dropDown; _drawCanvas.Splitter = _splitter & _dropDown; ViewDockStyle dockStyle = ViewDockStyle.Right; System.Windows.Forms.Orientation splitOrientation = System.Windows.Forms.Orientation.Vertical; switch (_dropDownPosition) { case VisualOrientation.Top: dockStyle = ViewDockStyle.Top; splitOrientation = System.Windows.Forms.Orientation.Horizontal; break; case VisualOrientation.Bottom: dockStyle = ViewDockStyle.Bottom; splitOrientation = System.Windows.Forms.Orientation.Horizontal; break; case VisualOrientation.Left: dockStyle = ViewDockStyle.Left; splitOrientation = System.Windows.Forms.Orientation.Vertical; break; case VisualOrientation.Right: dockStyle = ViewDockStyle.Right; splitOrientation = System.Windows.Forms.Orientation.Vertical; break; } _drawSplitBorder.Orientation = splitOrientation; _drawSplitBorder.VisualOrientation = Orientation; _layoutDocker.SetDock(_drawSplitBorder, dockStyle); _layoutDocker.SetDock(_drawDropDown, dockStyle); _layoutDocker.SetDock(_drawOuterSeparator, dockStyle); }
private void UpdateOrientation(System.Windows.Forms.Orientation newOrientation) { if (newOrientation != this.orientation) { Size size = CommonProperties.GetSpecifiedBounds(this).Size; this.orientation = newOrientation; this.SetupGrip(); } }
public static extern int GetScrollPos(IntPtr hWnd, System.Windows.Forms.Orientation nBar);
public static extern int SetScrollPos(IntPtr hWnd, System.Windows.Forms.Orientation nBar, int nPos, bool bRedraw);
public static void Draw3ColorBar(System.Drawing.Graphics dc, System.Drawing.RectangleF r, System.Windows.Forms.Orientation orientation, System.Drawing.Color c1, System.Drawing.Color c2, System.Drawing.Color c3) { // to draw a 3 color bar 2 gradient brushes are needed // one from c1 - c2 and c2 - c3 var lr1 = r; var lr2 = r; float angle = 0; if (orientation == System.Windows.Forms.Orientation.Vertical) { angle = 270; lr1.Height = lr1.Height / 2; lr2.Height = r.Height - lr1.Height; lr2.Y += lr1.Height; } if (orientation == System.Windows.Forms.Orientation.Horizontal) { angle = 0; lr1.Width = lr1.Width / 2; lr2.Width = r.Width - lr1.Width; lr1.X = lr2.Right; } if (lr1.Height > 0 && lr1.Width > 0) { using (System.Drawing.Drawing2D.LinearGradientBrush lb2 = new System.Drawing.Drawing2D.LinearGradientBrush(lr2, c1, c2, angle, false), lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(lr1, c2, c3, angle, false)) { dc.FillRectangle(lb1, lr1); dc.FillRectangle(lb2, lr2); } } // with some sizes the first pixel in the gradient rectangle shows the opposite color // this is a workaround for that problem if (orientation == System.Windows.Forms.Orientation.Vertical) { using (System.Drawing.Pen pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1)) { dc.DrawLine(pc3, lr1.Left, lr1.Top, lr1.Right - 1, lr1.Top); dc.DrawLine(pc2, lr2.Left, lr2.Top, lr2.Right - 1, lr2.Top); } } if (orientation == System.Windows.Forms.Orientation.Horizontal) { using (System.Drawing.Pen pc1 = new System.Drawing.Pen(c1, 1), pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1)) { dc.DrawLine(pc1, lr2.Left, lr2.Top, lr2.Left, lr2.Bottom - 1); dc.DrawLine(pc2, lr2.Right, lr2.Top, lr2.Right, lr2.Bottom - 1); dc.DrawLine(pc3, lr1.Right, lr1.Top, lr1.Right, lr1.Bottom - 1); } } }
public static void Draw2ColorBar(System.Drawing.Graphics dc, System.Drawing.RectangleF r, System.Windows.Forms.Orientation orientation, System.Drawing.Color c1, System.Drawing.Color c2) { var lr1 = r; float angle = 0; if (orientation == System.Windows.Forms.Orientation.Vertical) { angle = 270; } if (orientation == System.Windows.Forms.Orientation.Horizontal) { angle = 0; } if (lr1.Height > 0 && lr1.Width > 0) { using (var lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(lr1, c1, c2, angle, false)) { dc.FillRectangle(lb1, lr1); } } }
/// <summary> /// /// </summary> /// <param name="G"></param> /// <param name="Rect"></param> /// <param name="BaseColor"></param> /// <param name="BorderColor"></param> /// <param name="InnerBorderColor"></param> /// <param name="Style"></param> /// <param name="RoundWidth"></param> /// <param name="basePosition"></param> /// <param name="DrawBorder"></param> /// <param name="DrawGlass"></param> /// <param name="Mode"></param> internal static void RenderBackgroundInternal( Graphics G, Rectangle Rect, Color BaseColor, Color BorderColor, Color InnerBorderColor, FormRoundStyle Style, int RoundWidth, float basePosition, bool DrawBorder, bool DrawGlass, LinearGradientMode Mode, System.Windows.Forms.Orientation Orientation) { if (DrawBorder) { Rect.Width--; Rect.Height--; } using (LinearGradientBrush brush = new LinearGradientBrush(Rect, Color.Transparent, Color.Transparent, Mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(BaseColor, 0, 35, 24, 9); colors[1] = GetColor(BaseColor, 0, 13, 8, 3); colors[2] = BaseColor; colors[3] = GetColor(BaseColor, 0, 35, 24, 9); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; if (Style != FormRoundStyle.None) { using (GraphicsPath path = FormGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { G.FillPath(brush, path); } if (BaseColor.A > 80) { Rectangle rectTop = Rect; if (Mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(Rect.Width * basePosition); } using (GraphicsPath pathTop = FormGraphicsPathHelper.CreatePath(rectTop, RoundWidth, FormRoundStyle.Top, false)) { using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { G.FillPath(brushAlpha, pathTop); } } } if (DrawGlass) { RectangleF glassRect = Rect; if (Mode == LinearGradientMode.Vertical) { glassRect.Y = Rect.Y + Rect.Height * basePosition; glassRect.Height = (Rect.Height - Rect.Height * basePosition) * 2; } else { glassRect.X = Rect.X + Rect.Width * basePosition; glassRect.Width = (Rect.Width - Rect.Width * basePosition) * 2; } FormControlPaintEx.DrawGlass(G, glassRect, 170, 0, Orientation); } if (DrawBorder) { using (GraphicsPath path = FormGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { using (Pen pen = new Pen(BorderColor)) { G.DrawPath(pen, path); } } Rect.Inflate(-1, -1); using (GraphicsPath path = FormGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { using (Pen pen = new Pen(InnerBorderColor)) { G.DrawPath(pen, path); } } } } else { G.FillRectangle(brush, Rect); if (BaseColor.A > 80) { Rectangle rectTop = Rect; if (Mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(Rect.Width * basePosition); } using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { G.FillRectangle(brushAlpha, rectTop); } } if (DrawGlass) { RectangleF glassRect = Rect; if (Mode == LinearGradientMode.Vertical) { glassRect.Y = Rect.Y + Rect.Height * basePosition; glassRect.Height = (Rect.Height - Rect.Height * basePosition) * 2; } else { glassRect.X = Rect.X + Rect.Width * basePosition; glassRect.Width = (Rect.Width - Rect.Width * basePosition) * 2; } FormControlPaintEx.DrawGlass(G, glassRect, 200, 0, Orientation); } if (DrawBorder) { using (Pen pen = new Pen(BorderColor)) { G.DrawRectangle(pen, Rect); } Rect.Inflate(-1, -1); using (Pen pen = new Pen(InnerBorderColor)) { G.DrawRectangle(pen, Rect); } } } } }
/// <summary> /// Creates a SplitterPanel with Horizontal orientation and two buttons as the default /// controls. The default size of the splitter is set to 5. /// </summary> public SplitterPanelSupport() : base() { System.Windows.Forms.Button button1 = new System.Windows.Forms.Button(); System.Windows.Forms.Button button2 = new System.Windows.Forms.Button(); button1.Text = "button1"; button2.Text = "button2"; this.lastSplitterLocation = -1; this.orientation = System.Windows.Forms.Orientation.Horizontal; this.splitterSize = 5; this.defaultFirstControl = button1; this.defaultSecondControl = button2; this.firstControl = this.defaultFirstControl; this.secondControl = this.defaultSecondControl; this.splitterLocation = this.firstControl.Size.Width; this.splitter = new System.Windows.Forms.Splitter(); this.SuspendLayout(); // // panel1 // this.Controls.Add(this.splitter); this.Controls.Add(this.firstControl); this.Controls.Add(this.secondControl); // // firstControl // this.firstControl.Dock = System.Windows.Forms.DockStyle.Left; this.firstControl.Name = "firstControl"; this.firstControl.TabIndex = 0; // // secondControl // this.secondControl.Name = "secondControl"; this.secondControl.TabIndex = 1; this.secondControl.Size = new System.Drawing.Size((this.Size.Width - this.firstControl.Size.Width) + this.splitterSize, this.Size.Height); this.secondControl.Location = new System.Drawing.Point((this.firstControl.Location.X + this.firstControl.Size.Width + this.splitterSize), 0); // // splitter // this.splitter.Name = "splitter"; this.splitter.TabIndex = 2; this.splitter.TabStop = false; this.splitter.MinExtra = 10; this.splitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.splitter.Size = new System.Drawing.Size(this.splitterSize, this.Size.Height); this.splitter.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitter_SplitterMoved); this.SizeChanged += new System.EventHandler(SplitterPanel_SizeChanged); this.ResumeLayout(false); }