Beispiel #1
0
 private void Window_MouseButtonPressed(object sender, MouseButtonEventArgs e)
 {
     if (Program.window.HasFocus() && !Program.placingMode && !parent.GetEditingMode() && e.Button == Mouse.Button.Right)
     {
         Vector2f pos      = Program.window.MapPixelToCoords(Mouse.GetPosition(Program.window));
         float    distance = (float)Math.Sqrt((pos.X - GetGlobalPos().X) * (pos.X - GetGlobalPos().X) + (pos.Y - GetGlobalPos().Y) * (pos.Y - GetGlobalPos().Y));
         if (distance <= 7)
         {
             if (selected == this)
             {
                 selected = null;
             }
             else
             {
                 selected = this;
                 if (InPort.selected != null)
                 {
                     if (InPort.selected.connexion == selected)
                     {
                         InPort.selected.connexion = null;
                     }
                     else
                     {
                         InPort.selected.connexion = selected;
                     }
                     selected        = null;
                     InPort.selected = null;
                 }
             }
         }
     }
 }
Beispiel #2
0
 public XorGate() : base(2, 1)
 {
     inPorts[0]  = new InPort(new Vector2f(-25, -15), this);
     inPorts[1]  = new InPort(new Vector2f(-25, 15), this);
     outPorts[0] = new OutPort(new Vector2f(25, 0), this);
     Texture     = Textures.gatesTextures[4];
 }
Beispiel #3
0
 public InPort(Vector2f pos, Gate par)
 {
     position  = pos;
     connexion = null;
     parent    = par;
     Program.window.MouseButtonPressed += Window_MouseButtonPressed;
 }
Beispiel #4
0
 public MInput() : base(0, 1)
 {
     outPorts[0] = new OutPort(new Vector2f(25, 0), this);
     Texture     = Textures.gatesTextures[0];
     FillColor   = new Color(127, 100, 127);
     Texture     = Textures.gatesTextures[5];
     Program.window.MouseButtonReleased += Window_MouseButtonReleased;
 }
Beispiel #5
0
 public Input() : base(0, 1)
 {
     outPorts[0] = new OutPort(new Vector2f(25, 0), this);
     Texture     = Textures.gatesTextures[0];
     FillColor   = new Color(127, 127, 127);
 }
Beispiel #6
0
 public NotGate() : base(1, 1)
 {
     inPorts[0]  = new InPort(new Vector2f(-25, 0), this);
     outPorts[0] = new OutPort(new Vector2f(25, 0), this);
     Texture     = Textures.gatesTextures[1];
 }