Exemplo n.º 1
0
        public void InitData(Color penForeColor, Color penBackColor, int width, int hemm, DrawMethod.PEN_TYPE type)
        {
            foreColor = penForeColor;
            backColor = penBackColor;
            penWidth = width;
            hemmWidth = hemm;
            penType = type;
            string itemPenWidth = String.Format("{0:d}pt", penWidth);
            string itemHemmWidth = (hemmWidth == 0) ? "None" : String.Format("{0:d}pt", hemmWidth);
            int idx = 0;

            cmbPenSize.Items.Clear();
            cmbPenSize.Items.AddRange(penWidthItems);
            cmbHemmSize.Items.Clear();
            cmbHemmSize.Items.AddRange(hemmWidthItems);
            UpdatePenImage();

            switch (penType)
            {
                case DrawMethod.PEN_TYPE.NOMAL:
                    idx = cmbPenSize.Items.IndexOf(itemPenWidth);
                    cmbPenSize.SelectedIndex = idx;
                    cmbHemmSize.SelectedIndex = 0;
                    break;
                case DrawMethod.PEN_TYPE.HEMMED:
                    idx = cmbPenSize.Items.IndexOf(itemPenWidth);
                    cmbPenSize.SelectedIndex = idx;
                    idx = cmbHemmSize.Items.IndexOf(itemHemmWidth);
                    cmbHemmSize.SelectedIndex = idx;
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 2
0
        public void InitData(Color penForeColor, Color penBackColor, int width, DrawMethod.PEN_TYPE type)
        {
            foreColor = penForeColor;
            backColor = penBackColor;
            penWidth = width;
            penType = type;

            InitPenImages();

            switch(penType)
            {
                case DrawMethod.PEN_TYPE.NOMAL:
                    switch (penWidth)
                    {
                        case 3:
                            radioButtonPenSize1.Select();
                            break;
                        case 5:
                            radioButtonPenSize2.Select();
                            break;
                        case 7:
                            radioButtonPenSize3.Select();
                            break;
                        case 9:
                            radioButtonPenSize4.Select();
                            break;
                        case 11:
                            radioButtonPenSize5.Select();
                            break;
                    }
                    break;
                case DrawMethod.PEN_TYPE.HEMMED:
                    switch (penWidth)
                    {
                        case 3:
                            radioButtonHummPenSize1.Select();
                            break;
                        case 5:
                            radioButtonHummPenSize2.Select();
                            break;
                        case 7:
                            radioButtonHummPenSize3.Select();
                            break;
                        case 9:
                            radioButtonHummPenSize4.Select();
                            break;
                        case 11:
                            radioButtonHummPenSize5.Select();
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 3
0
 private void Canvas_OnMouseUp(object sender, MouseEventArgs e)
 {
     if (drawmethod != null)
     {
         if (operation == OPERATION.DRAWING)
         {
             if(drawmethod.GetDrawDeviceType() == DrawMethod.DEVICE_TYPE.BRUSH)
             {
                 if(DrawMethod.BrushType == DrawMethod.BRUSH_TYPE.LINEAR_GRADIENT)
                 {
                     Color cs = Color.Empty;
                     Color ce = Color.Empty;
                     toolStripLabel1.Text = "グラデーションの開始色を選択してください。";
                     if(colorDialog1.ShowDialog() != DialogResult.OK) return;
                     cs = colorDialog1.Color;
                     toolStripLabel1.Text = "グラデーションの終了色を選択してください。";
                     if(colorDialog1.ShowDialog() != DialogResult.OK) return;
                     ce = colorDialog1.Color;
                     DrawMethod.SetGradientColors(cs, ce);
                     DrawMethod.UpdateDevice();
                     toolStripLabel1.Text = "グラデーションの開始点を選択してください。";
                     operation = OPERATION.SEL_GRAD_PT_ST;
                 }
             }
             drawmethod.OnMouseUp(sender, e, bmp);
         }
         else if(operation == OPERATION.SEL_GRAD_PT_ST)
         {
             this.ptGradStart = new Point(e.X, e.Y);
             toolStripLabel1.Text = "グラデーションの終了点を選択してください。";
             operation = OPERATION.SEL_GRAD_PT_EN;
         }
         else if(operation == OPERATION.SEL_GRAD_PT_EN)
         {
             this.ptGradEnd = new Point(e.X, e.Y);
             DrawMethod.SetGradientLine(this.ptGradStart, this.ptGradEnd);
             DrawMethod.UpdateDevice();
             drawmethod.UpdateImage(sender, bmp);
             toolStripLabel1.Text = "マウスをドラッグして描画します。";
             operation = OPERATION.DRAWING;
         }
         else if(operation == OPERATION.PASTE_IMG_SELECTED)
         {
             // ドラッグしない
             drawmethod.OnMouseUp(sender, e, bmp);
             operation = OPERATION.NONE;
             toolStripLabel1.Text = "描画するツールを選択してください。";
             drawmethod = null;
         }
         else if(operation == OPERATION.PASTE_IMG_DRAG)
         {
             // ドラッグ完了
             drawmethod.OnMouseUp(sender, e, bmp);
             operation = OPERATION.NONE;
             toolStripLabel1.Text = "描画するツールを選択してください。";
             drawmethod = null;
         }
         else if(operation == OPERATION.COPY_IMG_DRAG)
         {
             // 選択完了
             drawmethod.OnMouseUp(sender, e, bmp);
             operation = OPERATION.COPY_IMG_SELECTED;
             toolStripLabel1.Text = "メニューからコピーを選択してください。";
         }
     }
 }
Exemplo n.º 4
0
 private void Canvas_OnMouseDown(object sender, MouseEventArgs e)
 {
     if (drawmethod != null)
     {
         if (operation == OPERATION.PASTE_IMG_SELECTED)
         {
             DragPastedImage dragimage = (DragPastedImage)drawmethod;
             // もしイメージの上だったら
             if (dragimage.isMouseOnTheImage(new Point(e.X, e.Y)))
             {
                 toolStripLabel1.Text = "イメージをドラッグして移動します。";
                 operation = OPERATION.PASTE_IMG_DRAG;
                 dragimage.OnMouseDown(sender, e, bmp);
             }
             else
             // そうでなければ、ドラッグの選択をやめる
             {
                 // イメージを本体に描画する
                 dragimage.UpdateImage(sender, bmp);
                 // 選択をやめる
                 operation = OPERATION.NONE;
                 drawmethod = null;
                 return;
             }
         }
         else
         {
             drawmethod.OnMouseDown(sender, e, bmp);
         }
     }
 }
Exemplo n.º 5
0
        private void btnStringDraw_Click(object sender, EventArgs e)
        {
            operation = OPERATION.SET_TEXT_POS;
            toolStripLabel1.Text = "文字を書く位置をクリックしてください。";
            drawmethod = stringdraw;
            dropdown.Items.Clear();
            dropdown.Items.Add(btnSolidBrush);
            dropdown.Items.Add(btnHatchBrush);
            dropdown.Items.Add(btnTextureBrush);
            dropdown.Items.Add(btnLinearGradientBrush);
            toolStripSplitBtnDevice.ToolTipText = drawmethod.GetDrawDeviceName();
            DrawMethod.UpdateDevice();
            toolStripSplitBtnDevice.Invalidate();

            ToolStripButton btn = (ToolStripButton)sender;
            if (btnSelected != null) btnSelected.Checked = false;
            btnSelected = btn;
            btnSelected.Checked = true;
        }
Exemplo n.º 6
0
        private void btnRectDraw_Click(object sender, EventArgs e)
        {
            operation = OPERATION.DRAWING;
            toolStripLabel1.Text = "マウスをドラッグして描画します。";
            drawmethod = rectdraw;
            dropdown.Items.Clear();
            dropdown.Items.Add(btnSolidBrush);
            dropdown.Items.Add(btnHatchBrush);
            dropdown.Items.Add(btnTextureBrush);
            dropdown.Items.Add(btnLinearGradientBrush);
            toolStripSplitBtnDevice.ToolTipText = drawmethod.GetDrawDeviceName();
            DrawMethod.UpdateDevice();
            toolStripSplitBtnDevice.Invalidate();

            ToolStripButton btn = (ToolStripButton)sender;
            if (btnSelected != null) btnSelected.Checked = false;
            btnSelected = btn;
            btnSelected.Checked = true;
        }
Exemplo n.º 7
0
        private void btnCopyRect_Click(object sender, EventArgs e)
        {
            operation = OPERATION.COPY_IMG_SEL_ST;
            toolStripLabel1.Text = "マウスをドラッグして選択します。";
            drawmethod = copyrect;
            dropdown.Items.Clear();
            toolStripSplitBtnDevice.ToolTipText = drawmethod.GetDrawDeviceName();
            DrawMethod.UpdateDevice();
            toolStripSplitBtnDevice.Invalidate();

            ToolStripButton btn = (ToolStripButton)sender;
            if (btnSelected != null) btnSelected.Checked = false;
            btnSelected = btn;
            btnSelected.Checked = true;
        }