public void deleteIn(Position o)
 {
     DictOfIn[o]--;
 }
 public void addIn(Position o)
 {
     if (DictOfIn.ContainsKey(o))
     {
         DictOfIn[o]++;
     }
     else
     {
         DictOfIn.Add(o, 1);
     }
 }
示例#3
0
 //   void Panel2_MouseEnter(object sender, EventArgs e)
 //   {
 //       throw new NotImplementedException();
 //    }
 void Panel2_MouseDown(object sender, MouseEventArgs e)
 {
     int x = e.X / sc;
     int y = e.Y / sc;
     if (drawing_Field[x, y] > 10 && e.Button.Equals(MouseButtons.Right) && arr_pos[indexpair[drawing_Field[x, y]]].Tokens > 0)
     {
         arr_pos[indexpair[drawing_Field[x, y]]].Tokens--;
         move = 0;
     }
     else
     {
         down = true;
         int val = 0;
         move = drawing_Field[x, y];
         selected = move; //edited
         for (int i = 0; i < 5; i++)
         {
             if (buttons[i].Focused) val = i;
         }
         switch (val)
         {
             case 1:
                 {
                     el_num[val]++;
                     move = el_num[val];
                     //news
                     Position p = new Position(el_num[val]);
                     p.Location = new Point(x, y);
                     arr_pos.Add(p);
                     indexpair.Add(el_num[val], p.ID);
                     //
                     istomove = true;
                     break;
                 }
             case 2:
                 {
                     el_num[val] -= 2;
                     move = el_num[val];
                     //news
                     Transition t = new Transition(el_num[val]);
                     t.Location = new Point(x, y);
                     arr_trans.Add(t);
                     indexpair.Add(el_num[val], t.ID);
                     //
                     istomove = true;
                     break;
                 }
             case 3:
                 {
                     el_num[val] -= 2;
                     move = el_num[val];
                     //
                     Transition t = new Transition(el_num[val]);
                     t.Location = new Point(x, y);
                     arr_trans.Add(t);
                     indexpair.Add(el_num[val], t.ID);
                     //
                     istomove = true;
                     break;
                 }
             case 4:
                 {
                     if (move < 0 || move > 10)
                     {
                         temp = e.Location;
                         el_con_points.Add(new Dictionary<Point, Point>());
                        drlin = true;
                     }
                     break;
                 }
         }
     }
     if (drawing_Field[x, y] ==0)
     {
         bool sel = false;
         foreach (Dictionary<Point, Point>   dline  in el_con_points)
         {
             foreach (KeyValuePair<Point, Point> kvpline in dline)
             {
                 Point p1 = lines.mo(kvpline.Key);
                 Point p2 = lines.mo(kvpline.Value);
                 if (x >= (Math.Min(p1.X, p2.X) - 1)  && x <= (Math.Max(p1.X, p2.X) + 1))
                 {
                     if( y >= (Math.Min(p1.Y, p2.Y) - 1) && y <= (Math.Max(p1.Y, p2.Y) + 1))
                     {
                         selected_point = kvpline.Key; sel = true;
                     }
                 }
             }
         }
         if (!sel) selected_point = new Point(1, 1);
     }
 }