示例#1
0
 private void imgOut_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (graph.Selected != null)
         {
             graph.Selected.Location = graph.Selected.Location.Add(e.Location.F().Subtract(lastPt).Scale(1f / 30f / scale));
             graph.Selected.Locked   = false;
             //graph.fixCamera = false;
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (graph.Selected != null && S1 != null)
         {
             if (graph.Selected == S1)
             {
                 return;
             }
             if (graph.GetOther(S1).Select(b => b.GetOther(S1)).Contains(graph.Selected))
             {
                 Rendering.Bond bd = graph.Bonds.Where(b => b.GetOther(S1) == graph.Selected).First();
                 if (bd.Type == BondType.Triple)
                 {
                     graph.Bonds.Remove(bd);
                 }
                 else
                 {
                     bd.Type = (BondType)((int)bd.Type + 1);
                 }
             }
             else
             {
                 graph.Bonds.Add(new Rendering.Bond(S1, graph.Selected, BondType.Single));
                 S1 = null;
             }
         }
     }
     else if (e.Button == MouseButtons.Middle)
     {
         if (graph.Selected != null)
         {
             graph.Bonds.RemoveAll(b => b.GetOther(graph.Selected) != null);
             graph.Nodes.Remove(graph.Selected);
             graph.Selected = null;
         }
     }
 }
示例#2
0
 private void imgOut_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (graph.Selected != null)
         {
             graph.Selected.Locked = true;
             //graph.fixCamera = true;
             lastPt = e.Location.F();
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (graph.Selected != null)
         {
             S1 = graph.Selected;
         }
     }
 }