Beispiel #1
0
        private bool Output_led_OnPinMouseDwon(QOutput_LED sender, CQPin pin, Point pt)
        {
            CQGateBaseUI gateui = sender.DataContext as CQGateBaseUI;

            this.m_Line                 = new Line();
            this.m_Line.Fill            = Brushes.Gray;
            this.m_Line.X1              = this.m_Line.X2 = pin.ConnectPoint.X;
            this.m_Line.Y1              = this.m_Line.Y2 = pin.ConnectPoint.Y;
            this.m_Line.Stroke          = Brushes.Gray;
            this.m_Line.StrokeThickness = 1;
            this.m_IsConnect            = true;
            CQSaveFile_Line save_line = new CQSaveFile_Line()
            {
                Line = this.m_Line
            };

            if (this.m_LineDatas.ContainsKey(save_line.Line) == false)
            {
                this.m_LineDatas.Add(save_line.Line, save_line);
            }
            else
            {
            }
            this.m_LineDatas[this.m_Line].Begin.GateID = gateui.ID;
            this.m_LineDatas[this.m_Line].Begin.Index  = pin.Index;
            this.m_LineDatas[this.m_Line].Begin.Type   = pin.Type;

            this.m_LineDatas[this.m_Line].Begin.EndType = CQSaveFile_LinePoint.EndTypes.Start;
            this.canvas.Children.Add(this.m_Line);
            return(true);
        }
Beispiel #2
0
 private void canvas_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.Source is QGate)
     {
         this.m_DragGate   = e.Source as QGate;
         this.m_IsDrag     = true;
         this.m_DragOffset = e.GetPosition(this.m_DragGate);
         this.canvas.CaptureMouse();
     }
     else if (e.Source is QInput_Switch)
     {
         this.m_DragInputSwitch = e.Source as QInput_Switch;
         this.m_IsDrag          = true;
         this.m_DragOffset      = e.GetPosition(this.m_DragInputSwitch);
         this.canvas.CaptureMouse();
     }
     else if (e.Source is QOutput_LED)
     {
         this.m_DragOutputLED = e.Source as QOutput_LED;
         this.m_IsDrag        = true;
         this.m_DragOffset    = e.GetPosition(this.m_DragOutputLED);
         this.canvas.CaptureMouse();
     }
     else
     {
         this.m_SelectPt   = e.GetPosition(this.canvas);
         this.m_SelectRect = new Rectangle();
         //rectangle.Width = 100;
         //rectangle.Height = 100;
         this.m_SelectRect.Stroke = Brushes.Black;
         this.m_SelectRect.StrokeDashArray.Add(6);
         this.m_SelectRect.StrokeDashCap = PenLineCap.Square;
         this.canvas.Children.Add(this.m_SelectRect);
         Canvas.SetLeft(this.m_SelectRect, this.m_SelectPt.X);
         Canvas.SetTop(this.m_SelectRect, this.m_SelectPt.Y);
         this.m_IsSelect = true;
         this.canvas.CaptureMouse();
     }
 }
Beispiel #3
0
        void Add_LED(double x = 0, double y = 0, string id = "")
        {
            CQOutput_LedUI cc         = null;
            QOutput_LED    output_led = null;

            cc          = new CQOutput_LedUI();
            cc.GateName = "LED";
            cc.Type     = "LED";
            cc.Pin_in.Add(new CQPin()
            {
                Type = CQPin.Types.IN, Index = 0
            });
            output_led        = new QOutput_LED();
            output_led.Height = 50;
            output_led.Width  = 80;
            cc.ID             = id;
            Canvas.SetLeft(output_led, x);
            Canvas.SetTop(output_led, y);
            output_led.DataContext     = cc;
            output_led.OnPinMouseDwon += Output_led_OnPinMouseDwon;
            output_led.OnPinMouseUp   += Output_led_OnPinMouseUp;
            output_led.OnGateMove     += Output_led_OnGateMove;
            this.canvas.Children.Add(output_led);
        }
Beispiel #4
0
        private void button_load_Click(object sender, RoutedEventArgs e)
        {
            this.togglebutton_simulation.IsChecked = false;
            CQSaveFile sv = null;

            if (File.Exists("QQ.txt") == true)
            {
                XmlSerializer xml = new XmlSerializer(typeof(CQSaveFile));
                using (FileStream fs = new FileStream("QQ.txt", FileMode.Open))
                {
                    sv = (CQSaveFile)xml.Deserialize(fs);
                }
            }
            if (sv != null)
            {
                this.ClearGate();
                foreach (CQSaveFile_Gate gate in sv.Gates)
                {
                    switch (gate.Type)
                    {
                    case "AND":
                    {
                        this.Add_AND(gate.X, gate.Y, gate.ID);
                    }
                    break;

                    case "NOT":
                    {
                        this.Add_NOT(gate.X, gate.Y, gate.ID);
                    }
                    break;

                    case "OR":
                    {
                        this.Add_OR(gate.X, gate.Y, gate.ID);
                    }
                    break;

                    case "Switch":
                    {
                        this.Add_Input_Switch(gate.X, gate.Y, gate.ID);
                    }
                    break;

                    case "LED":
                    {
                        this.Add_LED(gate.X, gate.Y, gate.ID);
                    }
                    break;
                    }
                }
                foreach (CQSaveFile_Line line in sv.Lines)
                {
                    line.Line      = new Line();
                    line.Line.Fill = Brushes.Gray;
                    //this.m_Line.X1 = this.m_Line.X2 = pin.ConnectPoint.X;
                    //this.m_Line.Y1 = this.m_Line.Y2 = pin.ConnectPoint.Y;
                    line.Line.Stroke          = Brushes.Gray;
                    line.Line.StrokeThickness = 1;
                    this.m_LineDatas.Add(line.Line, line);
                    this.canvas.Children.Add(line.Line);
                }
                this.canvas.UpdateLayout();
                foreach (FrameworkElement child in this.canvas.Children)
                {
                    QGate gate = child as QGate;
                    if (gate != null)
                    {
                        gate.RefreshLocation();
                    }
                    QInput_Switch input_switch = child as QInput_Switch;
                    if (input_switch != null)
                    {
                        input_switch.RefreshLocation();
                    }
                    QOutput_LED output_led = child as QOutput_LED;
                    if (output_led != null)
                    {
                        output_led.RefreshLocation();
                    }
                    this.ChangeLine(child);
                }
            }
        }
Beispiel #5
0
 private bool Output_led_OnPinMouseUp(QOutput_LED sender, CQPin pin, Point pt)
 {
     this.ConnectEnd(sender, pin, pt);
     return(true);
 }
Beispiel #6
0
 private bool Output_led_OnGateMove(QOutput_LED gate)
 {
     this.ChangeLine(gate);
     return(true);
 }