public static bool IsFrontChangeable(StandardComponent component) { if (component is SequentialComponent.FlipFlop) { return(true); } else if (component is SequentialComponent.programmablRegister) { return(true); } else if (component is SequentialComponent.CirculerRegister) { return(true); } else if (component is SequentialComponent.Registre) { return(true); } else if (component is SequentialComponent.JK) { return(true); } else { return(false); } }
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(); }
public static bool IsCompteur(StandardComponent component) { if (component is SequentialComponent.compteurN) { return(true); } else if (component is SequentialComponent.CompteurModN) { return(true); } else if (component is SequentialComponent.DecompteurN) { return(true); } else if (component is SequentialComponent.DecompteurModN) { return(true); } else { return(false); } }
public static bool IsInputChangeable(StandardComponent component) { if (component is AND) { return(true); } else if (component is NAND) { return(true); } else if (component is NOR) { return(true); } else if (component is OR) { return(true); } else { return(false); } }
public List <StandardComponent> parcourir_copier() { UIElement[] tableau = new UIElement[1000]; List <StandardComponent> liste = new List <StandardComponent>(); int length = canvas.Children.Count; canvas.Children.CopyTo(tableau, 0); for (int i = 0; i < length; i++) { StandardComponent newChild = null; if (!(typeof(Line) == tableau[i].GetType()) && ((tableau[i] as StandardComponent).IsSelect)) { if (typeof(AND) == tableau[i].GetType()) { newChild = new AND((tableau[i] as AND).nbrInputs()); for (int j = 0; j < (tableau[i] as AND).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as AND).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as AND).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(OR) == tableau[i].GetType()) { newChild = new OR((tableau[i] as OR).nbrInputs()); for (int j = 0; j < (tableau[i] as OR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as OR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as OR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(NAND) == tableau[i].GetType()) { newChild = new NAND((tableau[i] as NAND).nbrInputs()); for (int j = 0; j < (tableau[i] as NAND).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as NAND).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as NAND).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(NOR) == tableau[i].GetType()) { newChild = new NOR((tableau[i] as NOR).nbrInputs()); for (int j = 0; j < (tableau[i] as NOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as NOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as NOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(Not) == tableau[i].GetType()) { newChild = new Not(); Terminal terminal_1 = (Terminal)((tableau[i] as Not).inputStack.Children[0]); Terminal terminal_2 = (Terminal)((newChild as Not).inputStack.Children[0]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } else if (typeof(Output) == tableau[i].GetType()) { newChild = new Output(); } else if (typeof(Input) == tableau[i].GetType()) { newChild = new Input(); (newChild as Input).state = (tableau[i] as Input).state; } else if (typeof(XNOR) == tableau[i].GetType()) { newChild = new XNOR((tableau[i] as XNOR).nbrInputs()); for (int j = 0; j < (tableau[i] as XNOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as XNOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as XNOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(XOR) == tableau[i].GetType()) { newChild = new XOR((tableau[i] as XOR).nbrInputs()); for (int j = 0; j < (tableau[i] as XOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as XOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as XOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(Comparateur) == tableau[i].GetType()) { newChild = new Comparateur((tableau[i] as Comparateur).nbrInputs(), (tableau[i] as Comparateur).nbrOutputs()); } else if (typeof(Decodeur) == tableau[i].GetType()) { newChild = new Decodeur((tableau[i] as Decodeur).nbrInputs(), (tableau[i] as Decodeur).nbrOutputs()); } else if (typeof(Demultiplexer) == tableau[i].GetType()) { newChild = new Demultiplexer((tableau[i] as Demultiplexer).nbrInputs(), (tableau[i] as Demultiplexer).nbrOutputs(), (tableau[i] as Demultiplexer).nbrSelections()); } else if (typeof(Encodeur) == tableau[i].GetType()) { newChild = new Encodeur((tableau[i] as Encodeur).nbrInputs(), (tableau[i] as Encodeur).nbrOutputs()); } else if (typeof(FullAdder) == tableau[i].GetType()) { newChild = new FullAdder((tableau[i] as FullAdder).nbrInputs(), (tableau[i] as FullAdder).nbrOutputs()); } else if (typeof(FullSub) == tableau[i].GetType()) { newChild = new FullSub((tableau[i] as FullSub).nbrInputs(), (tableau[i] as FullSub).nbrOutputs()); } else if (typeof(HalfAdder) == tableau[i].GetType()) { newChild = new HalfAdder((tableau[i] as HalfAdder).nbrInputs(), (tableau[i] as HalfAdder).nbrOutputs()); } else if (typeof(HalfSub) == tableau[i].GetType()) { newChild = new HalfSub((tableau[i] as HalfSub).nbrInputs(), (tableau[i] as HalfSub).nbrOutputs()); } else if (typeof(Multiplexer) == tableau[i].GetType()) { newChild = new Multiplexer((tableau[i] as Multiplexer).nbrInputs(), (tableau[i] as Multiplexer).nbrOutputs(), (tableau[i] as Multiplexer).nbrSelections()); } else if (typeof(SequentialComponent.Clock) == tableau[i].GetType()) { newChild = new SequentialComponent.Clock((tableau[i] as SequentialComponent.Clock).LowLevelms, (tableau[i] as SequentialComponent.Clock).HighLevelms, MainWindow.Delay); } liste.Add(newChild); newChild.AllowDrop = true; newChild.PreviewMouseLeftButtonDown += fenetre.MouseLeftButtonDown; newChild.PreviewMouseMove += fenetre.MouseMove; newChild.PreviewMouseLeftButtonUp += fenetre.PreviewMouseLeftButtonUp; newChild.SetValue(Canvas.LeftProperty, tableau[i].GetValue(Canvas.LeftProperty)); newChild.SetValue(Canvas.TopProperty, tableau[i].GetValue(Canvas.TopProperty)); (newChild as StandardComponent).PosX = (tableau[i] as StandardComponent).PosX; (newChild as StandardComponent).PosY = (tableau[i] as StandardComponent).PosY; try { StandardComponent component = newChild as StandardComponent; component.recalculer_pos(); } catch { }; } } return(liste); }
public static void deSelectElement(StandardComponent component) { component.typeComponenet.Stroke = Brushes.RoyalBlue; component.IsSelect = false; }
public static void selectElement(StandardComponent component) { component.typeComponenet.StrokeThickness = 2; component.typeComponenet.Stroke = Brushes.Black; }