protected override void OnPaint(PaintEventArgs e) { e.Graphics.Clear(SkinManager.GetApplicationBackgroundColor()); Brush LineBrush = (MouseState == MouseState.HOVER ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetDividersBrush()); using (Brush b = new SolidBrush(this.BackColor)) { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), ClientRectangle); } e.Graphics.DrawLine(new Pen(LineBrush), new Point(0, ClientRectangle.Bottom - 1), new Point(ClientRectangle.Right, ClientRectangle.Bottom - 1)); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; if (Enabled) { PointF p1 = new Point(ClientRectangle.Right - 5, (int)(ClientRectangle.Height * 0.33)); PointF p2 = new Point(ClientRectangle.Right - 15, (int)(ClientRectangle.Height * 0.33)); PointF p3 = new Point(ClientRectangle.Right - 10, (int)(ClientRectangle.Height * 0.66)); PointF[] curvePoints = { p1, p2, p3 }; e.Graphics.FillPolygon(LineBrush, curvePoints, FillMode.Winding); } TextRenderer.DrawText(e.Graphics, _Text, SkinManager.ROBOTO_MEDIUM_11, this.AnchorClientBounds, SkinManager.ColorScheme.TextColor, TextFormatFlags.WordEllipsis); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index < 0) { return; } base.OnDrawItem(e); var g = e.Graphics; var bounds = new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); const int spacing = 24; var rect = new Rectangle(spacing, bounds.Top, bounds.Width - spacing, bounds.Height); if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) { g.FillRectangle(SkinManager.GetCmsSelectedItemBrush(), bounds); } else { g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), bounds); } g.DrawString( Items[e.Index].ToString(), SkinManager.ROBOTO_REGULAR_11, SkinManager.GetPrimaryTextBrush(), rect, new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center } ); }
protected override void OnDrawItem(DrawListViewItemEventArgs e) { //We draw the current line of items (= item with subitems) on a temp bitmap, then draw the bitmap at once. This is to reduce flickering. var b = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height); var g = Graphics.FromImage(b); //always draw default background g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); if (e.State.HasFlag(ListViewItemStates.Selected)) { //selected background g.FillRectangle(SkinManager.GetFlatButtonPressedBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER) { //hover background g.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } //Draw separator g.DrawLine(new Pen(SkinManager.GetDividersColor()), e.Bounds.Left, 0, e.Bounds.Right, 0); foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems) { //Draw text g.DrawString(subItem.Text, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new Rectangle(subItem.Bounds.X + ITEM_PADDING, ITEM_PADDING, subItem.Bounds.Width - 2 * ITEM_PADDING, subItem.Bounds.Height - 2 * ITEM_PADDING), getStringFormat()); } e.Graphics.DrawImage((Image)b.Clone(), new Point(0, e.Item.Bounds.Location.Y)); g.Dispose(); b.Dispose(); }
private void GetAllMessages(int groupID, string groupName) { TabPage tp = new TabPage(groupName) { Name = groupName, Tag = groupID }; if (tcGroups.TabPages.ContainsKey(groupName)) { return; } tcGroups.TabPages.Add(tp); tp.Controls.Add(new ucChatWindow() { ParentForm = this, BackColor = SkinManager.GetApplicationBackgroundColor(), Dock = DockStyle.Fill }); tcGroups.SelectedTab = tp; var currentGroup = _db.Groups .Include("Messages.User") .SingleOrDefault(g => g.ID == groupID); foreach (var item in currentGroup.Messages.OrderBy(m => m.Timestamp)) { WriteMessage(item.User.UserName, item.Data, groupName); } UpdateUsersInGroup(groupName); }
public MaterialListView() { GridLines = false; FullRowSelect = true; HeaderStyle = ColumnHeaderStyle.Nonclickable; View = View.Details; OwnerDraw = true; ResizeRedraw = true; BorderStyle = BorderStyle.None; SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); //Fix for hovers, by default it doesn't redraw //TODO: should only redraw when the hovered line changed, this to reduce unnecessary redraws MouseLocation = new Point(-1, -1); MouseState = MouseState.OUT; MouseEnter += delegate { MouseState = MouseState.HOVER; }; MouseLeave += delegate { MouseState = MouseState.OUT; MouseLocation = new Point(-1, -1); HoveredItem = null; Invalidate(); }; MouseDown += delegate { MouseState = MouseState.DOWN; }; MouseUp += delegate { MouseState = MouseState.HOVER; }; MouseMove += MouseMoved; MouseWheel += MouseMoved; BackColor = SkinManager.GetApplicationBackgroundColor(); }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { var g = e.Graphics; g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), e.Item.Bounds); g.DrawLine(new Pen(SkinManager.GetDividersColor()), new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), new Point(e.Item.Bounds.Right, e.Item.Bounds.Height / 2)); }
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { var g = e.Graphics; g.Clear(SkinManager.GetApplicationBackgroundColor()); //Draw background var itemRect = GetItemRect(e.Item); g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.GetCmsSelectedItemBrush() : new SolidBrush(SkinManager.GetApplicationBackgroundColor()), itemRect); //Ripple animation var toolStrip = e.ToolStrip as WaraContextMenuStrip; if (toolStrip != null) { var animationManager = toolStrip.animationManager; var animationSource = toolStrip.animationSource; if (toolStrip.animationManager.IsAnimating() && e.Item.Bounds.Contains(animationSource)) { for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.Black)); var rippleSize = (int)(animationValue * itemRect.Width * 2.5); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, itemRect.Y - itemRect.Height, rippleSize, itemRect.Height * 3)); } } } }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { e.Graphics.Clear(SkinManager.GetApplicationBackgroundColor()); e.Graphics.FillRectangle(SkinManager.GetDisabledOrHintBrush(), 0, 0, Width, Height); int doneProgress = (int)(Width * ((double)Value / Maximum)); if (OnRight) { e.Graphics.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, Width - doneProgress, 0, Width, Height); } else { e.Graphics.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, 0, 0, doneProgress, Height); } if (animationManager.IsAnimating()) { for (int i = 0; i < animationManager.GetAnimationCount(); i++) { double animationValue = animationManager.GetProgress(i); bool animationDirection = (bool)animationManager.GetData(i)[0]; int animationData = (int)animationManager.GetData(i)[1]; if (animationDirection) { int oldProgress = (int)(((float)(animationData - _value) / Maximum) * Width); if (OnRight) { if (DecreaseHighlight) { e.Graphics.FillRectangle(SkinManager.Theme == MaterialSkinManager.Themes.DARK ? SkinManager.ColorScheme.DarkPrimaryBrush : SkinManager.ColorScheme.LightPrimaryBrush, Width - doneProgress - oldProgress, 0, oldProgress, Height); } e.Graphics.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, (float)(Width - doneProgress - oldProgress + (oldProgress * animationValue)), 0, (float)(oldProgress - oldProgress * animationValue), Height); } else { if (DecreaseHighlight) { e.Graphics.FillRectangle(SkinManager.Theme == MaterialSkinManager.Themes.DARK ? SkinManager.ColorScheme.DarkPrimaryBrush : SkinManager.ColorScheme.LightPrimaryBrush, doneProgress, 0, oldProgress, Height); } e.Graphics.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height); } } else { int oldProgress = (int)(((float)(_value - animationData) / Maximum) * Width); if (OnRight) { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), Width - doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height); e.Graphics.FillRectangle(SkinManager.GetDisabledOrHintBrush(), Width - doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height); } else { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), doneProgress - oldProgress + (float)(oldProgress * animationValue), 0, (float)(oldProgress - oldProgress * animationValue), Height); e.Graphics.FillRectangle(SkinManager.GetDisabledOrHintBrush(), doneProgress - oldProgress + (float)(oldProgress * animationValue), 0, (float)(oldProgress - oldProgress * animationValue), Height); } } } } this.DrawChildShadow(e.Graphics); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.Clear(SkinManager.GetApplicationBackgroundColor()); g.SmoothingMode = SmoothingMode.AntiAlias; // Paint shadow on element to blend with the parent shadow DrawHelper.DrawRoundShadow(g, fabBounds); // draw fab g.FillEllipse(SkinManager.ColorScheme.AccentBrush, fabBounds); if (_animationManager.IsAnimating()) { GraphicsPath regionPath = new GraphicsPath(); regionPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 2)); Region fabRegion = new Region(regionPath); GraphicsContainer gcont = g.BeginContainer(); g.SetClip(fabRegion, CombineMode.Replace); for (int i = 0; i < _animationManager.GetAnimationCount(); i++) { var animationValue = _animationManager.GetProgress(i); var animationSource = _animationManager.GetSource(i); var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White)); var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } g.EndContainer(gcont); } if (Icon != null) { g.DrawImage(Icon, new Rectangle(fabBounds.Width / 2 - 11, fabBounds.Height / 2 - 11, 24, 24)); } if (_showAnimationManager.IsAnimating()) { int target = Convert.ToInt32((_mini ? FAB_MINI_SIZE : FAB_SIZE) * _showAnimationManager.GetProgress()); fabBounds.Width = target == 0 ? 1 : target; fabBounds.Height = target == 0 ? 1 : target; fabBounds.X = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); fabBounds.Y = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); } // Clip to a round shape with a 1px padding GraphicsPath clipPath = new GraphicsPath(); clipPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 3)); Region = new Region(clipPath); }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawString(e.Header.Text, new Font("微软雅黑", 9f), SkinManager.GetPrimaryTextBrush(), new Rectangle(e.Header.Text == "操作" ? e.Bounds.X + ITEM_PADDING + 25 : e.Bounds.X + ITEM_PADDING, e.Bounds.Y + ITEM_PADDING, e.Bounds.Width - ITEM_PADDING * 2, e.Bounds.Height - ITEM_PADDING * 2), getStringFormat()); }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawString(e.Header.Text, SkinManager.NazanintarMedium12, SkinManager.GetSecondaryTextBrush(), new Rectangle(e.Bounds.X + ItemPadding, e.Bounds.Y + ItemPadding, e.Bounds.Width - ItemPadding * 2, e.Bounds.Height - ItemPadding * 2), GetStringFormat()); }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawString(e.Header.Text, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetSecondaryTextBrush(), new Rectangle(e.Bounds.X + ITEM_PADDING, e.Bounds.Y + ITEM_PADDING, e.Bounds.Width - ITEM_PADDING * 2, e.Bounds.Height - ITEM_PADDING * 2), getStringFormat()); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.TreeView.DrawNode" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.DrawTreeNodeEventArgs" /> that contains the event data.</param> protected override void OnDrawNode(DrawTreeNodeEventArgs e) { if (e.Node.Bounds.X != 0) { e.Graphics.FillRectangle(Brushes.Black, e.Bounds); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; if (ExpandButtonPen == null) { ExpandButtonPen = new Pen(SkinManager.GetPrimaryTextBrush(), 1); } e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(-2, e.Node.Bounds.Y - 2, Width + 4, e.Node.Bounds.Height + 4)); Rectangle nodeRect = e.Node.Bounds; Rectangle ExpandIconRect = new Rectangle(e.Node.Bounds.X - e.Node.Bounds.Height * (CheckBoxes ? 2 : 1), e.Node.Bounds.Y + 2, e.Node.Bounds.Height - 4, e.Node.Bounds.Height - 4); if (e.Node.IsExpanded) { PointF pntTopLeft, pntTopRight, pntBottom; pntTopLeft = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.2), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.3)); pntTopRight = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.8), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.3)); pntBottom = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.5), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.6)); e.Graphics.DrawPolygon(ExpandButtonPen, new PointF[] { pntBottom, pntTopLeft }); e.Graphics.DrawPolygon(ExpandButtonPen, new PointF[] { pntBottom, pntTopRight }); } else if (e.Node.GetNodeCount(false) > 0) { PointF pntTop, pntRight, pntBottom; pntTop = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.5), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.2)); pntRight = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.8), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.5)); pntBottom = new PointF(ExpandIconRect.X + (float)(ExpandIconRect.Width * 0.5), ExpandIconRect.Y + (float)(ExpandIconRect.Height * 0.8)); e.Graphics.DrawPolygon(ExpandButtonPen, new PointF[] { pntBottom, pntRight }); e.Graphics.DrawPolygon(ExpandButtonPen, new PointF[] { pntRight, pntTop }); } Font nodeFont = SkinManager.ROBOTO_MEDIUM_10; Brush textBrush = SkinManager.GetPrimaryTextBrush(); //to highlight the text when selected if ((e.State & TreeNodeStates.Focused) != 0) { e.Graphics.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(0, e.Node.Bounds.Y, Width, e.Node.Bounds.Height)); } e.Graphics.DrawString(e.Node.Text, nodeFont, textBrush, NodeBounds(e.Node)); DrawCheckbox(e); } }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawString(e.Header.Text, SkinManager.FONT_CONTROL_LARGE, SkinManager.GetPrimaryTextBrush(), new Rectangle(e.Bounds.X + ITEM_PADDING, e.Bounds.Y + ITEM_PADDING, e.Bounds.Width - ITEM_PADDING * 2, e.Bounds.Height - ITEM_PADDING * 2), getStringFormat()); }
public MaterialListBox() { BackColor = SkinManager.GetApplicationBackgroundColor(); BorderStyle = BorderStyle.None; DrawMode = DrawMode.OwnerDrawVariable; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); ResizeRedraw = true; MouseLocation = new Point(-1, -1); ItemRectangles = new HashSet <Rectangle>(); ActualItemRectangle = new Rectangle(-1, -1, 0, 0); MouseHover += delegate { MouseState = MouseState.HOVER; MouseLocation = new Point(-1, -1); Invalidate(); }; MouseLeave += delegate { MouseState = MouseState.OUT; MouseLocation = new Point(-1, -1); Invalidate(); }; MouseMove += delegate(object sender, MouseEventArgs args) { MouseLocation = args.Location; // if mouse is out of rectangle if (!ActualItemRectangle.Contains(MouseLocation)) { // redraw actual hovered item Invalidate(ActualItemRectangle); // reset ActualItemRectangle before assign - kills flickering ActualItemRectangle = new Rectangle(-1, -1, 0, 0); // cycle foreach (Rectangle r in ItemRectangles) { // this is correct rectangle if (r.Contains(MouseLocation)) { // set as actual ActualItemRectangle = r; // invalidate region Invalidate(r); break; } } } }; MouseDown += delegate { MouseState = MouseState.DOWN; }; MouseUp += delegate { MouseState = MouseState.HOVER; }; Resize += delegate { ItemRectangles.Clear(); }; }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { base.OnDrawColumnHeader(e); e.Graphics.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawRectangle(new Pen(SkinManager.GetFlatButtonHoverBackgroundBrush()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height)); e.Graphics.DrawString(e.Header.Text, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetSecondaryTextBrush(), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), getStringFormat()); }
public MaterialContextMenuStrip() { Renderer = new MaterialToolStripRender(); animationManager = new AnimationManager(false) { Increment = 0.07, AnimationType = AnimationType.Linear }; animationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationFinished += sender => OnItemClicked(delayesArgs); BackColor = SkinManager.GetApplicationBackgroundColor(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(SkinManager.GetApplicationBackgroundColor()); foreach (Control objChild in Controls) { if (typeof(IShadowedMaterialControl).IsAssignableFrom(objChild.GetType())) { IShadowedMaterialControl objCurrent = (IShadowedMaterialControl)objChild; DrawHelper.drawShadow(e.Graphics, objCurrent.ShadowBorder, objCurrent.Elevation, SkinManager.GetApplicationBackgroundColor()); } } }
protected void DrawCombobox() { SuspendLayout(); Graphics g = this.CreateGraphics(); Pen p = new Pen(SkinManager.GetPrimaryTextColor(), 1); g.Clear(SkinManager.GetApplicationBackgroundColor()); // Draw the background of the dropdown button Rectangle rect = new Rectangle(this.Width - 15, 3, 12, this.Height - 6); g.FillRectangle(DropButtonBrush, rect); // Create the path for the arrow System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); PointF TopLeft = new PointF(this.Width - 13, (this.Height - 5) / 2); PointF TopRight = new PointF(this.Width - 6, (this.Height - 5) / 2); PointF Bottom = new PointF(this.Width - 9, (this.Height + 2) / 2); pth.AddLine(TopLeft, TopRight); pth.AddLine(TopRight, Bottom); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Determine the arrow's color. if (this.DroppedDown) { ArrowBrush = SkinManager.ColorScheme.AccentBrush; } else { ArrowBrush = SkinManager.GetPrimaryTextBrush(); } // Draw the arrow g.FillPath(ArrowBrush, pth); // Text if (DropDownStyle == ComboBoxStyle.DropDownList) { using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1), SkinManager.GetPrimaryTextColor(), ClientRectangle.Location, ClientRectangle.Size, NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); } } ResumeLayout(); }
/// <summary> /// The DrawCombobox /// </summary> protected void DrawCombobox() { SuspendLayout(); Graphics g = this.CreateGraphics(); Pen p = new Pen(SkinManager.GetPrimaryTextColor(), 1); BorderBrush = new SolidBrush(SkinManager.GetApplicationBackgroundColor()); g.Clear(SkinManager.GetApplicationBackgroundColor()); g.FillRectangle(BorderBrush, this.ClientRectangle); g.DrawRectangle(new Pen(SkinManager.GetApplicationBackgroundColor(), 1), this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1); // Draw the background of the dropdown button Rectangle rect = new Rectangle(this.Width - 15, 3, 12, this.Height - 6); g.FillRectangle(DropButtonBrush, rect); // Create the path for the arrow System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); PointF TopLeft = new PointF(this.Width - 13, (this.Height - 5) / 2); PointF TopRight = new PointF(this.Width - 6, (this.Height - 5) / 2); PointF Bottom = new PointF(this.Width - 9, (this.Height + 2) / 2); pth.AddLine(TopLeft, TopRight); pth.AddLine(TopRight, Bottom); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; // Determine the arrow's color. if (this.DroppedDown) { ArrowBrush = SkinManager.ColorScheme.AccentBrush; } else { ArrowBrush = SkinManager.GetPrimaryTextBrush(); } // Draw the arrow g.FillPath(ArrowBrush, pth); if (DropDownStyle == ComboBoxStyle.DropDownList) { g.DrawString(this.Text, this.Font, SkinManager.GetPrimaryTextBrush(), ClientRectangle.X + 2, ClientRectangle.Y + 3); } ResumeLayout(); }
public MaterialComboBox() { BackColor = SkinManager.GetApplicationBackgroundColor(); animationManager = new AnimationManager { Increment = 0.06, AnimationType = AnimationType.EaseInOut, InterruptAnimation = false }; this.GotFocus += (sender, args) => animationManager.StartNewAnimation(AnimationDirection.In); this.LostFocus += (sender, args) => animationManager.StartNewAnimation(AnimationDirection.Out); this.Font = SkinManager.ROBOTO_MEDIUM_10; this.ForeColor = SkinManager.GetPrimaryTextColor(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.TextRenderingHint = TextRenderingHint.AntiAlias; Color NonColor = SkinManager.GetDisabledOrHintColor(); var PicBG = DrawHelper.CreateRoundRect(1, 1, 292, 164, 1); var UpRoundedRec = DrawHelper.CreateRoundRect(1, 1, 291, 164, 1); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1); var ShadowBG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2); G.FillPath(new SolidBrush(NonColor), ShadowBG); G.DrawPath(new Pen(NonColor), ShadowBG); //if (MouseState == MouseState.HOVER) //{ // Color c = SkinManager.GetApplicationBackgroundColor(); // G.FillPath(new SolidBrush(Color.FromArgb((int)(0.7*c.A), c.RemoveAlpha())), BG); //} //else //{ G.FillPath(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), BG); //} G.DrawPath(new Pen(SkinManager.GetDividersColor()), BG); G.DrawString(Text, SkinManager.ROBOTO_MEDIUM_15, Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetPrimaryTextBrush(), 12, 176); G.SmoothingMode = SmoothingMode.None; G.FillRectangle(SkinManager.GetDividersBrush(), 16, InfoLabel.Bottom + 14, 261, 1); if (_image != null) { G.SetClip(PicBG); G.DrawImage(_image, 0, 0, 293, 166); } else { G.FillPath(new SolidBrush(NonColor), UpRoundedRec); G.DrawPath(new Pen(NonColor), UpRoundedRec); } G.DrawPath(new Pen(SkinManager.GetDividersColor()), BG); this.DrawChildShadow(G); }
public MaterialContextMenuStrip() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); Renderer = new MaterialToolStripRender(); animationManager = new AnimationManager(false) { Increment = 0.07, AnimationType = AnimationType.Linear }; animationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationFinished += sender => OnItemClicked(delayesArgs); BackColor = SkinManager.GetApplicationBackgroundColor(); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Bounds.Height == 0) { return; } var b = new Bitmap(e.Bounds.Width, e.Bounds.Height); var g = Graphics.FromImage(b); //always draw default background g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); if (e.State.HasFlag(DrawItemState.ComboBoxEdit)) { g.DrawString(this.Text, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new Rectangle(e.Bounds.X + ITEM_PADDING, ITEM_PADDING, e.Bounds.Width - 2 * ITEM_PADDING, e.Bounds.Height), getStringFormat()); } if (e.State.HasFlag(DrawItemState.Selected)) { //selected background g.FillRectangle(SkinManager.GetFlatButtonPressedBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER) { //hover background g.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } if (e.Index >= 0) { String itemText = this.Items[e.Index].ToString(); g.DrawString(itemText, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new Rectangle(e.Bounds.X + ITEM_PADDING, ITEM_PADDING, e.Bounds.Width - 2 * ITEM_PADDING, e.Bounds.Height - 2 * ITEM_PADDING), getStringFormat()); } e.Graphics.DrawImage((Image)b.Clone(), new Point(0, e.Bounds.Location.Y)); e.DrawFocusRectangle(); g.Dispose(); b.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.TextRenderingHint = TextRenderingHint.AntiAlias; Color NonColor = SkinManager.GetDisabledOrHintColor(); var PicBG = DrawHelper.CreateRoundRect(1, 1, 292, 164, 1); var UpRoundedRec = DrawHelper.CreateRoundRect(1, 1, 291, 164, 1); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1); var ShadowBG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2); G.FillPath(new SolidBrush(NonColor), ShadowBG); G.DrawPath(new Pen(NonColor), ShadowBG); if (animationManager.IsAnimating()) { G.FillPath(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), BG); G.SetClip(BG); G.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var animationSource = animationManager.GetSource(i); using (Brush rippleBrush = new SolidBrush(SkinManager.ColorScheme.PrimaryColor)) { var rippleSize = (int)(animationValue * Math.Max(Width, Height) * 2.5); G.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } G.ResetClip(); G.SmoothingMode = SmoothingMode.None; } else { G.FillPath(new SolidBrush(Primary ? SkinManager.ColorScheme.PrimaryColor : SkinManager.GetApplicationBackgroundColor()), BG); } G.DrawPath(new Pen(SkinManager.GetDividersColor()), BG); this.DrawChildShadow(G); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; GraphicsPath objPath = new GraphicsPath(); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.Clear(SkinManager.GetApplicationBackgroundColor()); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.FillRectangle(PrimaryDark, TopDark); g.FillRectangle(Primary, TopDefault); DrawHelper.drawShadow(g, DrawHelper.CreateCircle(Fab.X - 1, Fab.Y - 1, 20), 2, Color.Black); g.FillEllipse(Accent, Fab); g.DrawString( PreviewPreset.Name, SkinManager.ROBOTO_REGULAR_11, Text, TopDefault); g.ResetClip(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); var ThumbnailBG = DrawHelper.CreateLeftRoundRect(1, 1, 50, 49, 1); G.FillPath(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), BG); //Hover Color c = SkinManager.GetFlatButtonHoverBackgroundColor(); using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha()))) G.FillRectangle(b, ClientRectangle); G.DrawPath(new Pen(SkinManager.GetDividersColor()), BG); G.FillPath(SkinManager.ColorScheme.PrimaryBrush, ThumbnailBG); G.DrawPath(SkinManager.ColorScheme.PrimaryPen, ThumbnailBG); if (image != null) { G.DrawImage(image, 3, 3, 48, 47); } if (Enabled) { G.DrawString(Text, SkinManager.ROBOTO_MEDIUM_10, Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetPrimaryTextBrush(), new PointF(58.6f, 9f)); } else { G.DrawString(Text, SkinManager.ROBOTO_MEDIUM_10, new SolidBrush(SkinManager.GetDisabledOrHintColor()), new PointF(58.6f, 9f)); } G.TextRenderingHint = TextRenderingHint.AntiAlias; G.DrawString(info, SkinManager.ROBOTO_REGULAR_9, new SolidBrush(SkinManager.GetSecondaryTextColor()), new PointF(59.1f, 26f)); this.DrawChildShadow(G); }
protected override void OnPaint(PaintEventArgs e) { var g = e.Graphics; g.TextRenderingHint = TextRenderingHint.AntiAlias; //colores del header g.Clear(SkinManager.GetApplicationBackgroundColor()); // g.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, statusBarBounds); g.FillRectangle(SkinManager.ColorScheme.PrimaryPen.Brush, statusBarBounds); g.FillRectangle(SkinManager.ColorScheme.LightPrimaryBrush, actionBarBounds); //Draw border using (var borderPen = new Pen(SkinManager.GetDividersColor(), 0)) { // g.DrawLine(borderPen, new Point(0, actionBarBounds.Bottom), new Point(0, Height - 2)); // g.DrawLine(borderPen, new Point(Width - 1, actionBarBounds.Bottom), new Point(Width - 1, Height - 2)); // g.DrawLine(borderPen, new Point(0, Height - 1), new Point(Width - 1, Height - 1)); } //titulo g.DrawString(Text, SkinManager.ROBOTO_MEDIUM_12, SkinManager.ColorScheme.TextBrush, new Rectangle(SkinManager.FORM_PADDING, STATUS_BAR_HEIGHT, Width, ACTION_BAR_HEIGHT), new StringFormat { LineAlignment = StringAlignment.Center }); }
protected override void OnPaint(PaintEventArgs e) { Bitmap bmp = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(bmp); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.Clear(BackColor); Color LineColor; Brush DisabledBrush; Color BalloonColor; if (SkinManager.Theme == MaterialSkinManager.Themes.DARK) { LineColor = Color.FromArgb((int)(2.55 * 30), 255, 255, 255); } else { LineColor = Color.FromArgb((int)(2.55 * (hovered ? 38 : 26)), 0, 0, 0); } DisabledBrush = new SolidBrush(LineColor); BalloonColor = Color.FromArgb((int)(2.55 * 30), (Value == 0 ? Color.Gray : SkinManager.ColorScheme.AccentColor)); Pen LinePen = new Pen(LineColor, 2); g.DrawLine(LinePen, IndicatorSize / 2, Height / 2 + (Height - IndicatorSize) / 2, Width - IndicatorSize / 2, Height / 2 + (Height - IndicatorSize) / 2); if (Enabled) { g.DrawLine(SkinManager.ColorScheme.AccentPen, IndicatorSize / 2, Height / 2 + (Height - IndicatorSize) / 2, IndicatorRectangleNormal.X, Height / 2 + (Height - IndicatorSize) / 2); if (MousePressed) { if (Value > MinValue) { g.FillEllipse(SkinManager.ColorScheme.AccentBrush, IndicatorRectanglePressed); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectanglePressed); g.DrawEllipse(LinePen, IndicatorRectanglePressed); } } else { if (Value > MinValue) { g.FillEllipse(SkinManager.ColorScheme.AccentBrush, IndicatorRectangleNormal); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.DrawEllipse(LinePen, IndicatorRectangleNormal); } if (hovered) { g.FillEllipse(new SolidBrush(BalloonColor), IndicatorRectangle); } } } else { if (Value > MinValue) { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.FillEllipse(DisabledBrush, IndicatorRectangleDisabled); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.DrawEllipse(LinePen, IndicatorRectangleDisabled); } } g.DrawString(MinValue.ToString(), SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new PointF(0, 0)); g.DrawString(MaxValue.ToString(), SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new PointF(Width - g.MeasureString(MaxValue.ToString(), SkinManager.ROBOTO_MEDIUM_10).Width, 0f)); g.DrawString(Value.ToString(), SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(), new PointF(Width / 2 - g.MeasureString(Value.ToString(), SkinManager.ROBOTO_MEDIUM_10).Width / 2, 0f)); e.Graphics.DrawImage((Image)bmp.Clone(), 0, 0); }
protected override void OnPaint(PaintEventArgs e) { Bitmap bmp = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.Clear(SkinManager.GetCardsColor()); Color LineColor; Brush DisabledBrush; Color BalloonColor; Brush AccentBrush = new SolidBrush(AccentColor); Pen AccentPen = new Pen(AccentBrush, 2); if (SkinManager.Theme == MaterialSkinManager.Themes.DARK) { LineColor = Color.FromArgb((int)(2.55 * 30), 255, 255, 255); } else { LineColor = Color.FromArgb((int)(2.55 * (hovered ? 38 : 26)), 0, 0, 0); } DisabledBrush = new SolidBrush(LineColor); BalloonColor = Color.FromArgb((int)(2.55 * 30), (Value == 0 ? Color.Gray : AccentColor)); Pen LinePen = new Pen(LineColor, 2); g.DrawLine(LinePen, SliderRectangle.X + (IndicatorSize / 2), Height / 2, SliderRectangle.Right - (IndicatorSize / 2), Height / 2); if (Enabled) { g.DrawLine(AccentPen, IndicatorSize / 2 + SliderRectangle.X, Height / 2, IndicatorRectangleNormal.X, Height / 2); if (MousePressed) { if (Value > MinValue) { g.FillEllipse(AccentBrush, IndicatorRectanglePressed); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectanglePressed); g.DrawEllipse(LinePen, IndicatorRectanglePressed); } } else { if (Value > MinValue) { g.FillEllipse(AccentBrush, IndicatorRectangleNormal); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.DrawEllipse(LinePen, IndicatorRectangleNormal); } if (hovered) { g.FillEllipse(new SolidBrush(BalloonColor), IndicatorRectangle); } } } else { if (Value > MinValue) { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.FillEllipse(DisabledBrush, IndicatorRectangleDisabled); } else { g.FillEllipse(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), IndicatorRectangleNormal); g.DrawEllipse(LinePen, IndicatorRectangleDisabled); } } g.DrawString(Beschreibung, SkinManager.FONT_CONTROL_SMALL, SkinManager.GetPrimaryTextBrush(), DescriptioRectangle, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); g.DrawString(Value.ToString(), SkinManager.FONT_CONTROL_SMALL, SkinManager.GetPrimaryTextBrush(), ValueRectangle, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); e.Graphics.DrawImage((Image)bmp.Clone(), 0, 0); }