예제 #1
0
파일: Wire.cs 프로젝트: Micevski/LCE
        public override void Draw(Graphics g)
        {
            Pen pen;

            if (Value == State.Undefined)
            {
                pen = new Pen(Color.Magenta, WIRE_WIDTH);
            }
            else if (Value == State.True)
            {
                pen = new Pen(Color.Red, WIRE_WIDTH);
            }
            else
            {
                pen = new Pen(Color.Black, WIRE_WIDTH);
            }
            WireHandle from = initial;

            foreach (WireHandle to in inner)
            {
                g.DrawLine(pen, from.Location, to.Location);
                from = to;
            }
            g.DrawLine(pen, from.Location, terminal.Location);

            pen.Dispose();
        }
예제 #2
0
파일: WireBuilder.cs 프로젝트: Micevski/LCE
 public void Init(Element source, WireHandle initial)
 {
     this.Source  = source;
     this.Initial = initial;
     this.Inner   = new List <WireHandle>();
     this.Free    = false;
 }
예제 #3
0
파일: Wire.cs 프로젝트: Micevski/LCE
 public Wire(Element source, WireHandle initial, List <WireHandle> inner, WireHandle terminal)
 {
     Component     = false;
     this.Source   = source;
     this.initial  = initial;
     this.inner    = inner;
     this.terminal = terminal;
     this.color    = Color.Black;
 }
예제 #4
0
파일: WireBuilder.cs 프로젝트: Micevski/LCE
        public Wire Finalize(WireHandle terminal)
        {
            this.Terminal        = terminal;
            this.Terminal.Source = this.Source;
            Wire wire = new Wire(this.Source, this.Initial, this.Inner, this.Terminal);

            this.Dismiss();
            return(wire);
        }
예제 #5
0
파일: Scene.cs 프로젝트: Micevski/LCE
 // Retruns the Input WireHandle on cursor or null
 public WireHandle ClickedInHandle(Point p)
 {
     foreach (Element e in Elements)
     {
         WireHandle w = e.HookInHandle(p);
         if (w != null)
         {
             return(w);
         }
     }
     return(null);
 }
예제 #6
0
파일: WireBuilder.cs 프로젝트: Micevski/LCE
        public void Draw(Graphics g)
        {
            if (this.Free)
            {
                return;
            }
            Pen        pen  = new Pen(BUILDER_COLOR, BUILDER_WIDTH);
            WireHandle from = Initial;

            foreach (WireHandle to in Inner)
            {
                g.DrawLine(pen, from.Location, to.Location);
                from = to;
            }
            g.DrawLine(pen, from.Location, EndPosition);

            pen.Dispose();
        }
예제 #7
0
 private void Simulator_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (CurrentMouseState == MouseState.Default)
         {
             WireHandle wh       = Scene.ClickedOutHandle(e.Location);
             Component  selected = Scene.ClickSelect(e.Location);
             if (wh != null)
             {
                 WireBuilder.Init(wh.Source, wh);
                 CurrentMouseState = MouseState.Wire;
             }
             else if (selected != null)
             {
                 SelectedElement   = selected;
                 CurrentMouseState = MouseState.Drag;
                 ClickedPosition   = e.Location;
                 SelectionOffset   = GeometryUtil.GetOffset(selected.TopLeft, e.Location);
             }
         }
         else if (CurrentMouseState == MouseState.Wire)
         {
             WireHandle wh = Scene.ClickedInHandle(e.Location);
             if (wh != null)
             {
                 Wire w = WireBuilder.Finalize(wh);
                 Scene.AddElement(w);
                 CurrentMouseState = MouseState.Default;
             }
             else
             {
                 WireBuilder.AddPoint(e.Location);
             }
         }
     }
     Invalidate(true);
 }