public SEToolStripButtonDev(ToolStripItemAbstract item) { ToolStripButtonEntity entity = (ToolStripButtonEntity)item; this.Text = entity.Text; this.DisplayStyle = (ToolStripItemDisplayStyle)Enum.Parse(typeof(ToolStripItemDisplayStyle), ((int)entity.DisplayStyle).ToString()); this.TextImageRelation = (TextImageRelation)Enum.Parse(typeof(TextImageRelation), ((int)entity.TextImageRelation).ToString()); this.Alignment = (ToolStripItemAlignment)Enum.Parse(typeof(ToolStripItemAlignment), ((int)entity.Aligment).ToString()); this.ToolTipText = entity.ToolTipText; if (entity.Image != null && entity.Image != String.Empty) { FileInfo fi = new FileInfo(entity.Image); Image image; if (fi.Exists) { image = DrawingTool.GetImage(fi.FullName); } else { image = new Bitmap(16, 16); using (Graphics g = Graphics.FromImage(image)) { g.DrawRectangle(Pens.Red, 0, 0, image.Width - 1, image.Height - 1); g.DrawLine(Pens.Red, 0, 0, image.Width, image.Height); g.DrawLine(Pens.Red, image.Width, 0, 0, image.Height); } } this.Image = image; } }
public static void Main() { var input = Console.ReadLine(); Figure figure = null; switch (input.ToLower()) { case "square": int width = int.Parse(Console.ReadLine()); figure = new Square(width); break; case "rectangle": int rWidth = int.Parse(Console.ReadLine()); int rHeight = int.Parse(Console.ReadLine()); figure = new Rectangle(rWidth, rHeight); break; default: break; } var tool = new DrawingTool(figure); tool.Draw(); }
private void initializeTools() { DirectoryInfo d = new DirectoryInfo(@".\Tools"); FileInfo[] Files = d.GetFiles("*.dll"); string str = ""; foreach (FileInfo file in Files) { var ass = Assembly.LoadFrom(file.FullName); foreach (Type t in ass.GetTypes()) { if (t.IsClass && t.IsPublic && t.GetInterface("iDrawer.Plugins.DrawingTool") != null) { DrawingTool plugin = (DrawingTool)Activator.CreateInstance(t); if (plugin != null) { tools.Add(plugin); ToolStripItem item = plugin.getItem(); item.BackColor = SystemColors.ControlDark; toolbar.Items.Add(item); plugin.registerOnToolChangedListener(this); } } } } if (tools.Count > 0) { currentTool = tools[0]; toolStripLabel1.Text = "Selected tool: " + currentTool.getName(); } }
static void Main(string[] args) { string command = Console.ReadLine(); if (command == "Square") { int size = int.Parse(Console.ReadLine()); Square currSq = new Square() { Size = size }; DrawingTool newDraw = new DrawingTool(currSq); newDraw.Square.Draw(); } else if (command == "Rectangle") { int width = int.Parse(Console.ReadLine()); int length = int.Parse(Console.ReadLine()); Rectangle currRectangle = new Rectangle() { Width = width, Length = length }; DrawingTool newDraw = new DrawingTool(currRectangle); newDraw.Rectangle.Draw(); } }
static void Main() { var figure = Console.ReadLine(); var width = int.Parse(Console.ReadLine()); DrawingTool drawingTool; if (figure == "Square") { var square = new Square(width); drawingTool = new DrawingTool(square); } else { var height = int.Parse(Console.ReadLine()); var rectangle = new Rectangle(width, height); drawingTool = new DrawingTool(rectangle); } drawingTool.Draw(); }
void Awake() { if (_instance == null) { _instance = this; } }
protected virtual void OnAddTool(DrawingTool tool) { tool.RedrawEvent += (sender, args) => { InvalidateRect((sender as DrawingTool).Tracker.SurroundingRect); }; }
private void OnDrawingToolChanged(DrawingTool newTool) { DrawingToolChanged?.Invoke(this, new DrawingToolChangedEventArgs { NewDrawingTool = newTool }); if (newTool == DrawingTool.FillCell) { SelectedToolIndex = 0; } else if (newTool == DrawingTool.Pen) { SelectedToolIndex = 1; } else if (newTool == DrawingTool.Pencil) { SelectedToolIndex = 2; } else { // Eraser SelectedToolIndex = 3; } }
public ExplorerView() { InitializeComponent(); this.Single = true; this.SingleKey = SINGLEKEY; this.HideOnClose = true; this.Icon = DrawingTool.ImageToIcon(IconsLibrary.Form); this.TabText = Language.Current.ExplorerView_TabText; if (DesignMode) { return; } _treeView = new ExplorerTreeView(); _treeView.PadAreas = PadAreas.DockLeft; _treeView.HideOnClose = true; _treeView.AfterSelect += new ExplorerTreeView.OnAfterSelectHandler(_treeView_AfterSelect); _treeView.NodeAdded += new ExplorerTreeView.OnNodeAddedHandler(_treeView_NodeAdded); _propertyView = new ExplorerPropertyView(); _propertyView.PadAreas = PadAreas.DockLeft; _propertyView.HideOnClose = true; _gridView = new ExplorerGridView(); _gridView.DockAreas = DockAreas.Document; _gridView.GridDoubleClick += new ExplorerGridContainer.OnGridDoubleClickHandler(_gridView_GridDoubleClick); _gridView.GridSelectedItemChanged += new ExplorerGridContainer.OnGridSelectedItemChangedHandler(_gridView_GridSelectedItemChanged); }
public void Paint(System.Drawing.Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle) { if (value == null) { return; } if ((value is Image) == false) { Debug.Assert(false, "value 不是 Image"); return; } Image image = (Image)value; bool scaleImage = false; if (image.Width > cellBounds.Width || image.Height > cellBounds.Height) { scaleImage = true; int imageWidth = cellBounds.Width - 2; int imageHeight = cellBounds.Height - 2; image = DrawingTool.GetScaleImage(image, imageWidth, imageHeight); } Point drawInPoint = new Point(cellBounds.X + cellBounds.Width / 2 - image.Width / 2, cellBounds.Y + cellBounds.Height / 2 - image.Height / 2); graphics.DrawImage(image, new Rectangle(drawInPoint, image.Size)); if (scaleImage) { image.Dispose(); } }
public EnumView() { InitializeComponent(); UIHelper.ProcessDataGridView(this.dataGridViewEnum); UIHelper.ProcessDataGridView(this.dataGridViewEnumItem); this.Single = true; this.SingleKey = SINGLEKEY; this.HideOnClose = true; this.Icon = DrawingTool.ImageToIcon(Resources.Enum); this.TabText = Language.Current.DictionaryView_TabText; //DesignMode 拿不到 ServiceUnity.Container,报错 if (DesignMode) { return; } //初始化命令 InitCommands(); //初始化菜单 InitContextMenu(); //初始化 DataGridView 控制器 InitController(); SubscribeEvent(); }
public void WrongData() { DrawingTool cnv = new DrawingTool(20, 4); string result = string.Empty; while (true) { if (!cnv.DrawCanvas()) { break; } if (!cnv.DrawLine(new string[] { "1", "2", "6", "2" })) { break; } if (!cnv.DrawLine(new string[] { "6", "3", "25", "4" })) { break; } if (!cnv.DrawRectangle(new string[] { "16", "1", "20", "50" })) { break; } if (!cnv.FillCanvas(10, 3, "o")) { break; } } Console.WriteLine(cnv.dtObj.Result); }
private void SetDrawingTool(Button selectButton, DrawingTool drawingTool) { if (_drawingTool == drawingTool) { return; } DrawingInfo.SelectFontVisible(drawingTool == DrawingTool.TextTool); Selector.SetIsSelected(_selectedButton, false); _selectedButton = selectButton; Selector.SetIsSelected(_selectedButton, true); _drawingTool = drawingTool; if (drawingTool == DrawingTool.ArrowTool) { DrawingInfo.LeftRadioBtnContent = "箭头"; DrawingInfo.RightRadioBtnContent = "直线"; } else { DrawingInfo.LeftRadioBtnContent = "绘制"; DrawingInfo.RightRadioBtnContent = "填充"; } if (drawingTool == DrawingTool.PenTool && !DrawingInfo.SelectedLeftRadioBtn) { DrawingInfo.RightSliderLblContent = "填充偏离度:"; DrawingInfo.SetLeftSliderRange(0.0, 255.0); } else { DrawingInfo.RightSliderLblContent = "画笔大小:"; DrawingInfo.SetLeftSliderRange(1.0, 20.0); } }
protected override void OnPaint(PaintEventArgs e) { imageLocationX = 8; imageLocationY = (int)Math.Round((float)(this.ClientRectangle.Height - (int)Math.Round(this.Font.SizeInPoints)) / 2); imageLocationY = imageLocationY - 2; textLocationX = 26; textLocationY = (int)Math.Round((float)(this.ClientRectangle.Height - (int)Math.Round(this.Font.SizeInPoints)) / 2); textLocationY = textLocationY - 1; fillRect = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height); drawRect = new Rectangle(0, 0, this.Bounds.Width - 2, this.Bounds.Height - 2); textBrush = new SolidBrush(this.ForeColor); imageRect = new Rectangle(imageLocationX, imageLocationY, 16, 16); backBrush = new LinearGradientBrush(drawRect, Color.White, Color.FromArgb(236, 233, 217), LinearGradientMode.ForwardDiagonal); backBrush_Selected = new LinearGradientBrush(drawRect, Color.FromArgb(241, 243, 236), Color.FromArgb(188, 196, 166), LinearGradientMode.ForwardDiagonal); drawPen = new Pen(SystemColors.ActiveCaption); drawPen_Selected = new Pen(SystemColors.ActiveCaption); if (this.Selected) { e.Graphics.FillPath(backBrush_Selected, DrawingTool.RoundedRect(fillRect, 3)); e.Graphics.DrawPath(drawPen_Selected, DrawingTool.RoundedRect(drawRect, 3)); } else { e.Graphics.FillPath(backBrush, DrawingTool.RoundedRect(fillRect, 3)); e.Graphics.DrawPath(drawPen, DrawingTool.RoundedRect(drawRect, 3)); } if (this.Image != null) { e.Graphics.DrawImage(this.Image, imageRect); e.Graphics.DrawString(this.Text, this.Font, textBrush, new Point(textLocationX + 14, textLocationY), stringFormat); } e.Graphics.DrawString(this.ShowText, this.Font, textBrush, new Point(textLocationX, textLocationY), stringFormat); }
public FormDesignSurfaceHosting(WindowEntity windowEntity, SEDesignSurface designSurface, FormHostingContainer hostingContainer) { InitializeComponent(); if (DesignMode) { return; } this._windowEntity = windowEntity; this.Icon = DrawingTool.ImageToIcon(IconsLibrary.Form); this.SetTabText(); this.HideOnClose = false; this._undoEngine = new SEUndoEngineFormDesigner(this); this._designSurface = designSurface; this.HostingContainer = hostingContainer; this.TabPageContextMenuStrip = HostingTabPageContextMenuStrip.Instance.MenuStrip; //初始化DesignSurface //在此初始化,保证FormHostingContainer中的dockPanel_ActiveDocumentChanged执行时 //能拿到DesignSurface中的服务 this._designSurface = InitialseDesignSurface(); }
/// <summary> /// 获取文件的缩略图 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public Image GetThumbNail(string fileName) { Bitmap bmp; try { bmp = (Bitmap)DrawingTool.GetImage(fileName); } catch { bmp = new Bitmap(ThumbNailSize, ThumbNailSize); //If we cant load the image, create a blank one with ThumbSize } bmp = (Bitmap)DrawingTool.GetScaleImage(bmp, ThumbNailSize, ThumbNailSize); if (bmp.Width < ThumbNailSize || bmp.Height < ThumbNailSize) { Bitmap bitmap2 = new Bitmap(ThumbNailSize, ThumbNailSize); Graphics g = Graphics.FromImage(bitmap2); Point point = new Point(); point.X = (ThumbNailSize - bmp.Width) / 2; point.Y = (ThumbNailSize - bmp.Height) / 2; g.DrawImage(bmp, point); g.Dispose(); bmp.Dispose(); return(bitmap2); } return(bmp); }
protected void AddTool(DrawingTool tool) { OnAddTool(tool); DrawingTools.Add(tool); tool.OnAdded(); }
protected override void OnMouseDown(MouseEventArgs pArgs) { if (pArgs.Button == MouseButtons.Left) { Point lLocation = GetScrollablePoint(pArgs.Location); DrawingTool lTool = HitTest(lLocation); if (lTool == null) { base.FullDragMode = SelectedToolboxItem == null; } else { lTool.Tracker.StartResize(lLocation); } SelectedTool = lTool; Size lDragSize = GraphicsMapper.Instance.TransformSize(SystemInformation.DragSize); DragBoxFromMouseDown = new Rectangle(lLocation, lDragSize); DraggingPoint = lLocation; } base.OnMouseDown(pArgs); }
private void ChangeTol(object param) { switch (Int32.Parse((string)param)) { case 0: drawingTool = DrawingTool.Rectangle; break; case 1: drawingTool = DrawingTool.Ellipse; break; case 2: drawingTool = DrawingTool.Triangle; break; case 3: drawingTool = DrawingTool.Line; break; case 4: drawingTool = DrawingTool.Eraser; break; case 5: drawingTool = DrawingTool.Pencil; break; case 6: drawingTool = DrawingTool.Paintbrush; break; } }
private void btnDraw_Click(object sender, EventArgs e) { string[] commands = txtCommands.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToArray(); DrawingTool dt = new DrawingTool(); txtOutput.Text = dt.Draw(commands); }
/// <summary> /// Draws an arc. /// </summary> /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param> /// <param name="tag">A user defined unique id used to reference the draw object</param> /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param> /// <param name="startTime">The starting time where the draw object will be drawn.</param> /// <param name="startY">The starting y value coordinate where the draw object will be drawn</param> /// <param name="endTime">The end time where the draw object will terminate</param> /// <param name="endY">The end y value coordinate where the draw object will terminate</param> /// <param name="brush">The brush used to color draw object</param> /// <param name="dashStyle">The dash style used for the lines of the object.</param> /// <param name="width">The width of the draw object</param> /// <param name="drawOnPricePanel">Determines if the draw-object should be on the price panel or a separate panel</param> /// <returns></returns> public static Arc Arc(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel) { return(DrawingTool.DrawToggledPricePanel(owner, drawOnPricePanel, () => ArcCore(owner, isAutoScale, tag, int.MinValue, startTime, startY, int.MinValue, endTime, endY, brush, dashStyle, width, false, null))); }
/// <summary> /// Draws an arc. /// </summary> /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param> /// <param name="tag">A user defined unique id used to reference the draw object</param> /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param> /// <param name="startBarsAgo">The starting bar (x axis coordinate) where the draw object will be drawn. For example, a value of 10 would paint the draw object 10 bars back.</param> /// <param name="startY">The starting y value coordinate where the draw object will be drawn</param> /// <param name="endBarsAgo">The end bar (x axis coordinate) where the draw object will terminate</param> /// <param name="endY">The end y value coordinate where the draw object will terminate</param> /// <param name="brush">The brush used to color draw object</param> /// <param name="dashStyle">The dash style used for the lines of the object.</param> /// <param name="width">The width of the draw object</param> /// <param name="drawOnPricePanel">Determines if the draw-object should be on the price panel or a separate panel</param> /// <returns></returns> public static Arc Arc(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel) { return(DrawingTool.DrawToggledPricePanel(owner, drawOnPricePanel, () => ArcCore(owner, isAutoScale, tag, startBarsAgo, Core.Globals.MinDate, startY, endBarsAgo, Core.Globals.MinDate, endY, brush, dashStyle, width, false, null))); }
/// <summary> /// Handles the Drag event which raises a DoDragDrop event used by the /// DesignSurface to drag items from the Toolbox to the DesignSurface. /// If the currently selected item is the pointer item then the drag drop /// operation is not started. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemDrag(object sender, ItemDragEventArgs e) { if (e.Button == MouseButtons.Left && e.Item.GetType() == typeof(ListViewItem)) { ToolboxItem lItem = (e.Item as ListViewItem).Tag as ToolboxItem; if (lItem.TypeName != NameConsts.Pointer) { mIsDragging = true; IToolboxService lToolboxService = mToolboxService as IToolboxService; object lDataObject = lToolboxService.SerializeToolboxItem(lItem); DrawingTool lTool = lItem.CreateComponents().FirstOrDefault() as DrawingTool; lTool.CreatePersistence(); Rectangle lRect = lTool.SurroundingRect; using (DragImage image = new DragImage(lTool.DefaultImage, lRect.Width / 2, lRect.Height / 2)) { DoDragDrop(lDataObject, DragDropEffects.All); } mIsDragging = false; } } }
static void Main() { // 100/100 Но това ли е най-доброто решение?! Все пак интересно! var input = Console.ReadLine(); var drawingTool = new DrawingTool(input); }
public FormToolbox(FormHostingContainer container) { InitializeComponent(); _container = container; _container.ActiveHostingChanged += new FormHostingContainer.OnActiveHostingChangedHandler(_container_ActiveHostingChanged); this.Icon = DrawingTool.ImageToIcon(IconsLibrary.Toolbox); this.TabText = Language.Current.FormToolbox_TabText; }
// // Public methods // public void SetDrawingTool(DrawingTool drawingTool) { DeactivateDrawingTool(); this.drawingTool = drawingTool; ActivateDrawingTool(); }
private void btn_clear_Click(object sender, EventArgs e) { shapes.Clear(); bDrawPolygon = false; canvas = new Bitmap(drawPanel.Width, drawPanel.Height); drawPanel.Image = canvas; tool = DrawingTool.None; }
public ExplorerView() { InitializeComponent(); this.Single = true; this.SingleKey = SINGLEKEY; this.HideOnClose = true; this.Icon = DrawingTool.ImageToIcon(IconsLibrary.Image2); this.TabText = Language.Current.ExplorerView_TabText; }
private IEnumerable <DrawingTool> GetOverlappedTools(DrawingTool tool) { Graphics graph = Graphics.FromHwnd(Handle); return(from t in DrawingTools where t != tool && t.IsOverlapped(tool, graph) select t); }
protected DrawingTracker(DrawingTool tool) { DrawingTool = tool; _Pen = new Pen(Brushes.Blue, 2.0f); _Pen.DashPattern = new float[] { 4.0F, 2.0F, 1.0F, 3.0F }; _Margin = GraphicsMapper.Instance.TransformInt(2); _MarginAmendForAntiAlias = GraphicsMapper.Instance.TransformInt(1); }
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e) { _startPos = e.GetPosition(canvas); if ((Keyboard.Modifiers & ModifierKeys.Control) != 0 | (Keyboard.Modifiers & ModifierKeys.Alt) != 0) { if ((Keyboard.Modifiers & ModifierKeys.Control ) != 0) { _tool = DrawingTool.Ellipsis; _currShape = new Ellipse(); } else { _tool = DrawingTool.Rectangle; _currShape = new Rectangle(); } Canvas.SetLeft(_currShape, _startPos.X); Canvas.SetTop(_currShape, _startPos.Y); _currShape.Width = 2; _currShape.Height = 2; _currShape.Fill = new SolidColorBrush(_drawColor); } else { _tool = DrawingTool.Line; var l = new Line { Stroke = new SolidColorBrush(_drawColor), StrokeThickness = 2.0, X1 = _startPos.X, Y1 = _currPos.Y, X2 = _currPos.X + 1, Y2 = _currPos.Y + 1 }; _currShape = l; } CaptureMouse(); canvas.Children.Add(_currShape); _isDrawing = true; }
private SecondMenuButton GetButtonByTool(DrawingTool byTool) { switch (byTool) { case DrawingTool.Pencil: return toolPencil; case DrawingTool.Line: return toolLine; case DrawingTool.Fill: return toolFill; case DrawingTool.Symbol: return toolSymbol; } return toolPencil; }
private void PickCircleTool(object sender, RoutedEventArgs e) { actualTool = DrawingTool.DrawVertex; }
private void Tool_MouseUp(object sender, MouseButtonEventArgs e) { if (ToolMouseDown[(int)GetToolByButton(sender)]) { if (GetToolByButton(sender) == DrawingTool.Symbol) { spw = new SymbolPickerWindow(symbol, spw); spw.Owner = this; if (spw.ShowDialog() == true) { symbol = spw.Symbol; iFont.Title = "Font " + Symbol.Font; iFontSize.Title = "Font Size " + Symbol.Size.ToString("F"); UpdateBoard(); } spw.Close(); } else { GetButtonByTool(Tool).Selected = false; Tool = GetToolByButton(sender); ((SecondMenuButton)sender).Selected = true; ToolMouseDown[(int)Tool] = false; } } }
private void PickEdgeTool(object sender, RoutedEventArgs e) { actualTool = DrawingTool.DrawEdge; }