Exemplo n.º 1
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (draw)
     {
         g.Clear(Color.White);
         f = flist.Last();
         f.Change(x + panX, y + panY, e.X + panX, e.Y + panY);
         flist.Draw(g, panX, panY);
     }
     else if (pan)
     {
         panX = -(e.X - x);
         panY = -(e.Y - y);
         this.Refresh();
         textBox_PanX.Text = panX.ToString();
         textBox_PanY.Text = panY.ToString();
     }
     else if ((CurrentInstrument == "Selection") && (selectionMode > 0))
     {
         FigureResize(e.X, e.Y);
         this.Refresh();
     }
 }
Exemplo n.º 2
0
 private void Form1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         switch (CurrentInstrument)
         {
             case "Selection":
                 if (selectedIndex > -1)
                 {
                     selectionMode = flist[selectedIndex].SelectionMode(e.X+panX, e.Y+panY);
                     if (selectionMode == -1)
                     {
                         selectedIndex = -1;
                         for (int i = flist.Count - 1; i >= 0; i--)
                         {
                             if (flist[i].Select(e.X + panX, e.Y + panY))
                             {
                                 selectedIndex = i;
                                 selectionMode = 0;
                                 needFilling = enabledFillingToolStripMenuItem.Checked = flist[selectedIndex].needFilling;
                                 needOutline = enabledOutlineToolStripMenuItem.Checked = flist[selectedIndex].needOutline;
                                 break;
                             }
                         }
                         if ((selectionMode == -1) && (selectedIndex == -1))
                         {
                             this.Refresh();
                             return;
                         }
                     }
                     else
                     {
                         BeforeFigureResizing();
                     }
                 }
                 else
                 {
                     for (int i = flist.Count - 1; i >= 0; i--)
                     {
                         if (flist[i].Select(e.X + panX, e.Y + panY))
                         {
                             selectedIndex = i;
                             selectionMode = 0;
                             needFilling = enabledFillingToolStripMenuItem.Checked = flist[selectedIndex].needFilling;
                             needOutline = enabledOutlineToolStripMenuItem.Checked = flist[selectedIndex].needOutline;
                             break;
                         }
                     }
                 }
                 this.Refresh();
                 break;
             case "Pan":
                 pan = true;
                 x = e.X;
                 y = e.Y;
                 break;
             default:
                 try
                 {
                     outlineWidth = Convert.ToUInt16(textBox_Width.Text);
                 }
                 catch
                 {
                     MessageBox.Show("Error! " + "" + textBox_Width.Text + "" + " is not a valid value for outline width!");
                     return;
                 }
                 draw = true;
                 x = e.X;
                 y = e.Y;
                 currentType = TypeList.First(SomeType => SomeType.Name == CurrentInstrument);
                 f = (Figure)Activator.CreateInstance(currentType);
                 f.Init();
                 f.Change(x+panX, y+panY, x+panX, y+panY);
                 f.ChangeTransparency(needFilling, needOutline);
                 if (needFilling)
                     f.ChangeFillingColor(FillColor);
                 if (needOutline)
                     f.ChangeOutline(OutlineColor, outlineWidth);
                 flist.Add(f);
                 f.Draw(g,panX,panY);
                 break;
         }
     }
 }