/// <summary> /// Create a window based on a given IC and IC List. Provide /// an edit level of either View or Edit as appropriate. /// </summary> /// <param name="IC"></param> /// <param name="useicl"></param> /// <param name="el"></param> public Window1(UIGates.IC IC, ICList useicl, EditLevel el) : this(el) { icl = useicl; gateCanvas.ICL = icl; gateCanvas.UndoProvider = (UndoRedo.UndoManager)Resources["undoManager"]; spGates.ICList = icl; _filename = IC.AbGate.Name; this.Loaded += (sender, e) => { RefreshGateCanvas(IC); spGates.ICName = IC.AbGate.Name; if (el == EditLevel.VIEW) { gateCanvas.IsReadOnly = true; } Dispatcher.BeginInvoke( new Action(() => { Activate(); Focus(); })); }; }
public Window1() : this(EditLevel.FULL) { AssemblyTitleAttribute title; AssemblyCopyrightAttribute copyright; Assembly aAssembly = Assembly.GetExecutingAssembly(); title = (AssemblyTitleAttribute) AssemblyTitleAttribute.GetCustomAttribute( aAssembly, typeof(AssemblyTitleAttribute)); copyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute( aAssembly, typeof(AssemblyCopyrightAttribute)); APP_TITLE = title.Title; APP_VERSION = aAssembly.GetName().Version.ToString(); APP_COPYRIGHT = copyright.Copyright; icl = new ICList(); gateCanvas.ICL = icl; gateCanvas.UndoProvider = (UndoRedo.UndoManager)Resources["undoManager"]; gateCanvas.SetCaptureICLChanges(); spGates.ICList = icl; spGates.UndoProvider = (UndoRedo.UndoManager)Resources["undoManager"]; this.Loaded += (s2, e2) => { Gates.IOGates.Clock.CalculatePrecession(); }; this.Closing += new CancelEventHandler(Window1_Closing); if (!string.IsNullOrEmpty(LOAD_ON_START)) { try { CircuitXML cxml = new CircuitXML(icl); RefreshGateCanvas(cxml.Load(LOAD_ON_START, icl.Add)); btnSave.IsEnabled = true; _filename = LOAD_ON_START; UpdateTitle(); } catch (Exception ex) { MessageBox.Show("Unable to load requested circuit, reason: " + ex.ToString()); } } }
/// <summary> /// Performs a recursive topological sort of a set of ICs. /// The result list may include ICs not in the original ics input /// if they are used somewhere within the ics input. All results /// will be dereferenced against the IC list provided so that /// the result IC instances are "canonical". /// </summary> /// <param name="ics"></param> /// <param name="icl"></param> /// <returns></returns> public List <UIGates.IC> Sort(IEnumerable <UIGates.IC> ics, ICList icl) { List <Gates.IC> gics = new List <Gates.IC>(); foreach (UIGates.IC ic in ics) { gics.Add((Gates.IC)ic.AbGate); } Sort(gics); List <UIGates.IC> res = new List <GatesWpf.UIGates.IC>(); foreach (Gates.IC gic in results) { res.Add(icl.GetIC(gic.Name)); } return(res); }
private void icl_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { // we have to clone these because there could be multiple selectors // operating off of a single master ICList switch (e.ListChangedType) { case ListChangedType.ItemAdded: AddDragDropGate(e.NewIndex, (UIGates.IC)icl[e.NewIndex].CreateUserInstance()); break; case ListChangedType.ItemChanged: // replace the gate as needed spGates.Children.RemoveAt(e.NewIndex); AddDragDropGate(e.NewIndex, (UIGates.IC)icl[e.NewIndex].CreateUserInstance()); break; case ListChangedType.Reset: ICList = icl; break; } }
/// <summary> /// Sort all ICs used within a given IC, deferencing against an IC list /// for canonical instances. /// </summary> /// <param name="ic"></param> /// <param name="icl"></param> /// <returns></returns> public List <UIGates.IC> Sort(UIGates.IC ic, ICList icl) { return(Sort(new UIGates.IC[] { ic }, icl)); }
public CircuitXML(ICList icl) { this.icl = icl; UpdateICNames = new Dictionary <string, string>(); }