コード例 #1
0
ファイル: Paint.cs プロジェクト: HongHanh2104/Paint
        private void createNewShapeLayer()
        {
            counterShape.Increase(currentToolName);
            string       nameLayer = string.Format("{0} {1}", currentToolName, counterShape.GetCount(currentToolName));
            ListViewItem item      = new ListViewItem(nameLayer);

            item.Selected = true;

            Bitmap bitmap = new Bitmap(mainDrawingPicture.Width, mainDrawingPicture.Height);
            Layer  layer  = new ShapeLayer(bitmap);

            layer.SetName(nameLayer);
            ChangeLayerSelection(layer);

            item.Tag = layer;

            listView_layer.Items.Insert(0, item);

            //ReDraw();
        }
コード例 #2
0
ファイル: Paint.cs プロジェクト: HongHanh2104/Paint
        private void mainDrawingPicture_MouseMove(object sender, MouseEventArgs e)
        {
            lb_Mouse.Text = String.Format("Mouse Position: X: {0}; Y: {1}", e.X, e.Y);

            if (e.Button == MouseButtons.Left && currentTool != null)
            {
                if (currentTool.Type() == PaintTool.TransformationTool)
                {
                    Transformation currentShape = currentTool.onMouseMove(e, paintParams) as Transformation;
                    if (listView_layer.SelectedItems.Count > 0)
                    {
                        Layer layer = listView_layer.SelectedItems[0].Tag as Layer;
                        layer.Transform(currentShape);
                        ReDraw();
                        layer.ResetMatrix();
                    }
                }
                else if (currentTool.Type() == PaintTool.CDShapeTool)
                {
                    Shape      currentShape = currentTool.onMouseMove(e, paintParams) as Shape;
                    ShapeLayer layer        = listView_layer.SelectedItems[0].Tag as ShapeLayer;
                    layer.setShape(currentShape);
                    ReDraw();
                }
                else if (currentTool.Type() == PaintTool.SelectionTool)
                {
                    ShowVisibleLayers();

                    MyRectangle  currentShape = currentTool.onMouseMove(e, paintParams) as MyRectangle;
                    GraphicsPath path         = currentShape.GetPath();

                    Pen     pen       = new Pen(Color.Black, 0.1f);
                    float[] dashStyle = new float[] { 2, 5, 10, 4 };
                    pen.DashPattern = dashStyle;

                    mainDrawingGraphics.DrawPath(pen, path);
                    mainDrawingPicture.Refresh();
                }
            }
        }