예제 #1
0
        public void relier(object sender, MouseButtonEventArgs e)
        {
            Terminal          terminal      = UserClass.TryFindParent <Terminal>((Ellipse)sender);
            StandardComponent componentPere = UserClass.TryFindParent <StandardComponent>((Ellipse)sender);
            Canvas            canvas        = UserClass.TryFindParent <Canvas>((terminal));

            Wireclass wire = new Wireclass();

            wire.relier();
        }
예제 #2
0
        private new void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Ellipse img    = sender as Ellipse;
            Canvas  canvas = UserClass.TryFindParent <Canvas>(img);

            MainWindow.sourceEllipse            = sender as Ellipse;
            MainWindow.wire                     = new Wireclass();
            MainWindow.SelectedTerminalIsSource = this.IsOutpt;
            Mouse.Capture(canvas);
        }
예제 #3
0
        private void Delete(object sender, RoutedEventArgs e)
        {
            //StandardComponent component =UserClass.TryFindParent<StandardComponent>((((MenuItem)sender).Parent as ContextMenu).PlacementTarget);
            foreach (StandardComponent component in MainWindow.elementsSelected)
            {
                fenetre.miseAJourPile();
                foreach (Terminal terminal in component.inputStack.Children)
                {
                    try
                    {
                        for (int i = 0; i < terminal.wires.Count; i++)
                        {
                            ((Wireclass)terminal.wires[i]).Destroy();
                        }
                    }
                    catch (ArgumentOutOfRangeException) { }

                    /*foreach (Wireclass wire in terminal.wires)
                     * {
                     *  wire.Destroy();
                     * }*/
                }
                foreach (Terminal terminal in component.OutputStack.Children)
                {
                    for (int i = terminal.wires.Count - 1; i >= 0; i--)
                    {
                        ((Wireclass)terminal.wires[i]).Destroy();
                    }

                    /*       foreach (Wireclass wire in terminal.wires)
                     *     {
                     *         wire.Destroy();
                     *     }*/
                }
                canvas.Children.Remove(component);
                MainWindow window = UserClass.TryFindParent <MainWindow>(canvas);
                window.desactiveProp();
            }


            //Control component =(Control)sender;
            //StandardComponent test = UserClass.TryFindParent<StandardComponent>();
            // test.typeComponenet.Height = 100;
            //MessageBox.Show();

            ///canvas.Children.Remove(UserClass.TryFindParent<StandardComponent>(text));
        }
예제 #4
0
        private void standardcomponent_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (MainWindow.elementsSelected != null && !(Mouse.RightButton == MouseButtonState.Pressed))
            {
                if (!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.RightCtrl))       //Une selection simple
                {
                    if (!MainWindow.elementsSelected.Contains((StandardComponent)sender))          //si ce n'est pas un clic sur le meme element
                    {
                        foreach (StandardComponent elementSelected in MainWindow.elementsSelected) //Deslectionner tout les elements selectionner
                        {
                            deSelectElement(elementSelected);
                        }
                        MainWindow.elementsSelected.Clear();
                        MainWindow.elementsSelected.Add(this);
                        this.IsSelect = true;
                        selectElement(this);
                    }
                    else
                    {
                        int i = MainWindow.elementsSelected.IndexOf((StandardComponent)sender);
                        deSelectElement(MainWindow.elementsSelected[i]);
                        MainWindow.elementsSelected.Remove((StandardComponent)sender);
                    }
                }
                else
                {
                    if (MainWindow.elementsSelected.Contains((StandardComponent)sender))
                    {
                        int i = MainWindow.elementsSelected.IndexOf((StandardComponent)sender);
                        deSelectElement(MainWindow.elementsSelected[i]);
                        MainWindow.elementsSelected.Remove((StandardComponent)sender);
                    }
                    else
                    {
                        MainWindow.elementsSelected.Add(this);
                        this.IsSelect = true;
                        selectElement(this);
                    }
                }
            }



            MainWindow window = UserClass.TryFindParent <MainWindow>(canvas);

            if (UserClass.IsInputChangeable((StandardComponent)sender))
            {
                window.activeProp();
                window.modifieProperties();
                if (sender is XOR || sender is XNOR)
                {
                    window.NbrEntreText.Visibility       = Visibility.Collapsed;
                    window.ComboBoxProperties.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                window.desactiveProp();
                window.modifieProperties();
            }
        }
예제 #5
0
        public void relier()
        {
            Ellipse select;

            destination = UserClass.TryFindParent <Terminal>(selection2);
            source      = UserClass.TryFindParent <Terminal>(selection1);

            if (source.IsOutpt == false)
            {
                if (destination.IsOutpt == true)
                {
                    select     = selection2;
                    selection2 = selection1;
                    selection1 = select;
                    Terminal temp = destination;
                    destination = source;
                    source      = temp;
                }
                else
                {
                    //selected = false;
                    return;
                }
            }
            else
            {
                if (destination.IsOutpt == true)
                {
                    //selected = false;
                    return;
                }
            }

            if (destination.wires.Count >= 1)
            {
                //selected = false;
                return;
            }

            btn111 = selection1;
            btn222 = selection2;
            destination.wires.Add(this);
            destination.etat = this._state;
            source.wires.Add(this);


            btn2Point = selection2.TransformToAncestor(myCanvas).Transform(new Point(0, 0));
            btn1Point = selection1.TransformToAncestor(myCanvas).Transform(new Point(0, 0));


            l1.Stroke          = new SolidColorBrush(Colors.Black);
            l1.StrokeThickness = 2.0;
            l1.X1 = btn1Point.X;
            l1.X2 = (btn1Point.X + btn2Point.X + 2 * selection1.ActualWidth) / 2;
            l1.Y1 = btn1Point.Y + selection1.ActualHeight / 2;
            l1.Y2 = btn1Point.Y + selection1.ActualHeight / 2;
            if (!myCanvas.Children.Contains(l1))
            {
                myCanvas.Children.Add(l1);
            }


            l2.Stroke          = new SolidColorBrush(Colors.Black);
            l2.StrokeThickness = 2.0;
            l2.X1 = l1.X2;
            l2.X2 = l1.X2;
            l2.Y1 = l1.Y1;
            l2.Y2 = btn2Point.Y - selection2.ActualHeight / 2;
            if (!myCanvas.Children.Contains(l2))
            {
                myCanvas.Children.Add(l2);
            }


            l3.Stroke          = new SolidColorBrush(Colors.Black);
            l3.StrokeThickness = 2.0;
            l3.X1 = l2.X2;
            l3.X2 = (btn2Point.X);
            l3.Y1 = l2.Y2;
            l3.Y2 = l2.Y2;
            if (!myCanvas.Children.Contains(l3))
            {
                myCanvas.Children.Add(l3);
            }


            UserClass.TryFindParent <StandardComponent>(source).Run();
            //selected = false;
            UserClass.TryFindParent <StandardComponent>(destination).Run();
            destinations.Add(UserClass.TryFindParent <StandardComponent>(destination));

            if (source.wires.Count <= 1)
            {
                source.logestWire = this;
            }
            else
            {
                if (Math.Abs((source.logestWire).l1.X1 - (source.logestWire).l1.X2) < Math.Abs(this.l1.X1 - this.l1.X2))
                {
                    source.logestWire = this;
                }
            }
            dessinernoued();
        }