private Rectangle GetGuideColorButtonRectangle(GuideColor guideColor) { return(new Rectangle( ToolbarWnd.panelPadding + ToolbarWnd.controlMargin * 2 + ToolbarWnd.gripWidth, ToolbarWnd.panelPadding + ToolbarWnd.controlMargin + ToolbarWnd.guideColorButtonSize * (int)guideColor, ToolbarWnd.guideColorButtonSize, ToolbarWnd.guideColorButtonSize )); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); Cursor cursor = Cursors.Default; if (this.GetGripRectangle().Contains(e.Location)) { cursor = Cursors.SizeAll; } this.hoveredGuideColor = GuideColor.None; for (int i = (int)GuideColor.None + 1; i != (int)GuideColor.Yellow + 1; i++) { if (this.GetGuideColorButtonRectangle((GuideColor)i).Contains(e.Location) && this.mode1ActiveTool == Tool.Default) { this.hoveredGuideColor = (GuideColor)i; cursor = Cursors.Hand; } } this.hoveredTool = Tool.None; for (int i = (int)Tool.None + 1; i != (int)Tool.Visibility + 1; i++) { if (this.GetToolButtonRectangle((Tool)i).Contains(e.Location)) { this.hoveredTool = (Tool)i; cursor = this.GetCursorByTool((Tool)i); if ((i == (int)Tool.HorizontalGuide || i == (int)Tool.VerticalGuide || i == (int)Tool.Image) && this.mode1ActiveTool == Tool.Default) { if (this.ToolSelected != null) { this.ToolSelected(this, new ToolEventArgs((Tool)i)); } } } } if (this.hoveredTool != Tool.HorizontalGuide && this.hoveredTool != Tool.VerticalGuide && this.hoveredTool != Tool.Image) { if (this.ToolDeselected != null) { this.ToolDeselected(this, new ToolEventArgs(Tool.None)); } } this.Cursor = cursor; this.Invalidate(); }
public ToolbarWnd() { this.hoveredGuideColor = GuideColor.None; this.pressedGuideColor = GuideColor.None; this.activeGuideColor = GuideColor.Blue; this.hoveredTool = Tool.None; this.pressedTool = Tool.None; this.mode1ActiveTool = Tool.Default; this.mode2ActiveTool = Tool.None; this.mode3ActiveTool = Tool.Visibility; this.InitializeComponent(); this.SetLayered(); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); if (this.ToolDeselected != null) { this.ToolDeselected(this, new ToolEventArgs(Tool.None)); } this.Cursor = Cursors.Default; this.hoveredGuideColor = GuideColor.None; this.hoveredTool = Tool.None; this.Invalidate(); }
private Bitmap GetGuideColorButtonImage(GuideColor guideColor) { if (guideColor == GuideColor.Blue) { return(this.blue); } if (guideColor == GuideColor.Purple) { return(this.purple); } if (guideColor == GuideColor.Yellow) { return(this.yellow); } return(null); }
private Rectangle GetGuideColorButtonClientRectangle(GuideColor guideColor) { if (this.mode1ActiveTool != Tool.Default) { return(new Rectangle( 0, ToolbarWnd.guideColorButtonSize * 3, ToolbarWnd.guideColorButtonSize, ToolbarWnd.guideColorButtonSize )); } return(new Rectangle( 0, (this.pressedGuideColor == guideColor || this.activeGuideColor == guideColor) ? ToolbarWnd.guideColorButtonSize * 2 : this.hoveredGuideColor == guideColor ? ToolbarWnd.guideColorButtonSize : 0, ToolbarWnd.guideColorButtonSize, ToolbarWnd.guideColorButtonSize )); }
private Color GetColorFromGuideColor(GuideColor colorButton) { if (colorButton == GuideColor.Blue) { return(Color.FromArgb(255 - (int)(255f / 100f * Settings.Default.GuidesTransparency), 0, 255, 255)); } else if (colorButton == GuideColor.Purple) { return(Color.FromArgb(255 - (int)(255f / 100f * Settings.Default.GuidesTransparency), 255, 0, 255)); } else if (colorButton == GuideColor.Yellow) { return(Color.FromArgb(255 - (int)(255f / 100f * Settings.Default.GuidesTransparency), 255, 255, 0)); } return(Color.White); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (this.ToolbarClicked != null) { this.ToolbarClicked(this, EventArgs.Empty); } if (this.GetGripRectangle().Contains(e.Location)) { if (this.ControlSelected != null) { this.ControlSelected(this, new ControlEventArgs(Control.Grip)); } } this.pressedGuideColor = GuideColor.None; for (int i = (int)GuideColor.None + 1; i != (int)GuideColor.Yellow + 1; i++) { if (this.GetGuideColorButtonRectangle((GuideColor)i).Contains(e.Location)) { this.pressedGuideColor = (GuideColor)i; } } this.pressedTool = Tool.None; for (int i = (int)Tool.None + 1; i != (int)Tool.Visibility + 1; i++) { if (this.GetToolButtonRectangle((Tool)i).Contains(e.Location)) { this.pressedTool = (Tool)i; } } this.Invalidate(); }
private void DrawGuideColorButton(Graphics g, GuideColor guideColor) { g.DrawImage(this.GetGuideColorButtonImage(guideColor), this.GetGuideColorButtonRectangle(guideColor), this.GetGuideColorButtonClientRectangle(guideColor), GraphicsUnit.Pixel); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (this.ControlDeselected != null) { this.ControlDeselected(this, new ControlEventArgs(Control.Grip)); } this.pressedGuideColor = GuideColor.None; for (int i = (int)GuideColor.Blue; i != (int)GuideColor.Yellow + 1; i++) { if (this.GetGuideColorButtonRectangle((GuideColor)i).Contains(e.Location) && this.mode1ActiveTool == Tool.Default) { this.activeGuideColor = (GuideColor)i; if (this.GuideColorChanged != null) { this.GuideColorChanged(this, new GuideColorEventArgs((GuideColor)i)); } } } this.pressedTool = Tool.None; for (int i = (int)Tool.Default; i != (int)Tool.Remove + 1; i++) { if (this.GetToolButtonRectangle((Tool)i).Contains(e.Location)) { this.mode1ActiveTool = (Tool)i; if (this.Mode1ToolChanged != null) { this.Mode1ToolChanged(this, new ToolEventArgs((Tool)i)); } } } if (this.GetToolButtonRectangle(Tool.Lock).Contains(e.Location) && (this.mode1ActiveTool == Tool.Move || this.mode1ActiveTool == Tool.Remove)) { this.mode2ActiveTool = this.mode2ActiveTool == Tool.None ? Tool.Lock : Tool.None; if (this.Mode2ToolChanged != null) { this.Mode2ToolChanged(this, new ToolEventArgs(this.mode2ActiveTool)); } } if (this.GetToolButtonRectangle(Tool.Visibility).Contains(e.Location)) { this.mode3ActiveTool = this.mode3ActiveTool == Tool.None ? Tool.Visibility : Tool.None; if (this.Mode3ToolChanged != null) { this.Mode3ToolChanged(this, new ToolEventArgs(this.mode3ActiveTool)); } } this.Invalidate(); }
protected void toolbarWnd_GuideColorChanged(object sender, GuideColorEventArgs e) { this.activeColor = e.GuideColor; }
public GuideColorEventArgs(GuideColor guideColor) { this.GuideColor = guideColor; }