示例#1
0
        private void btnSave_As_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".gcg";
            dlg.Filter     = "Gate Circuit Groups (.gcg)|*.gcg";
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                CircuitXML cxml = new CircuitXML(icl);
                try
                {
                    cxml.Save(dlg.FileName, gateCanvas);
                    _filename         = dlg.FileName;
                    btnSave.IsEnabled = true;
                    UpdateTitle();

                    ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to save circuit as requested: " + ex.ToString());
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            CircuitXML cxml = new CircuitXML(icl);

            cxml.Save(_filename, gateCanvas);

            ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
        }
示例#3
0
 private void btnCopy_Click(object sender, RoutedEventArgs e)
 {
     if (gateCanvas.selected.Count > 0)
     {
         UIGates.IC ic      = gateCanvas.CreateIC("(clipboard)", GateCanvas.SELECTED_GATES.SELECTED);
         CircuitXML cx      = new CircuitXML(icl);
         DataObject clipobj = new DataObject();
         Clipboard.SetData("IC", cx.CreateCircuitXML(ic).ToString());
         btnPaste.IsEnabled = true;
     }
 }
示例#4
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            if (!QuerySave())
            {
                return;
            }

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".gcg";
            dlg.Filter     = "Gate Circuit Groups (.gcg)|*.gcg|All Files|*.*";
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                btnUserMode.IsChecked = false;

                foreach (Window w in Application.Current.Windows)
                {
                    if (w != this)
                    {
                        w.Close();
                    }
                }
                gateCanvas.ClearSelection();

                icl.Clear();
                CircuitXML cxml = new CircuitXML(icl);

                try
                {
                    slZoom.Value = 1;
                    RefreshGateCanvas(cxml.Load(dlg.FileName, icl.Add));



                    btnSave.IsEnabled = true;
                    _filename         = dlg.FileName;
                    UpdateTitle();

                    ((UndoRedo.UndoManager)Resources["undoManager"]).Clear();
                    ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to load circuit as requested: " + ex.ToString());
                }
            }
        }
示例#5
0
        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());
                }
            }
        }
示例#6
0
 private void btnPaste_Click(object sender, RoutedEventArgs e)
 {
     if (Clipboard.ContainsData("IC"))
     {
         string     xml = Clipboard.GetData("IC") as string;
         CircuitXML cx  = new CircuitXML(icl);
         try
         {
             UIGates.IC ic = cx.LoadCircuit(System.Xml.Linq.XElement.Parse(xml));
             gateCanvas.PasteIC(ic);
         }
         catch (Exception)
         {
             MessageBox.Show("Unable to complete paste; maybe you deleted a needed IC?");
         }
     }
 }
示例#7
0
        private void btnImportIC_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".ic";
            dlg.Filter     = "IC (.ic)|*.ic|All Files (*.*)|*.*";
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                CircuitXML cxml = new CircuitXML(icl);
                try
                {
                    cxml.Load(dlg.FileName, icl.Add);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to load circuit as requested: " + ex.ToString());
                }
            }
        }
示例#8
0
        private void btnImportIC_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".ic";
            dlg.Filter = "IC (.ic)|*.ic|All Files (*.*)|*.*";
            bool? result = dlg.ShowDialog();

            if (result == true)
            {
                CircuitXML cxml = new CircuitXML(icl);
                try
                {
                    cxml.Load(dlg.FileName, icl.Add);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to load circuit as requested: " + ex.ToString());
                }

            }
        }
示例#9
0
        private void btnSave_As_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".gcg";
            dlg.Filter = "Gate Circuit Groups (.gcg)|*.gcg";
            bool? result = dlg.ShowDialog();

            if (result == true)
            {
                CircuitXML cxml = new CircuitXML(icl);
                try
                {
                    cxml.Save(dlg.FileName, gateCanvas);
                    _filename = dlg.FileName;
                    btnSave.IsEnabled = true;
                    UpdateTitle();

                    ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to save circuit as requested: " + ex.ToString());
                }
            }
        }
示例#10
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            
            CircuitXML cxml = new CircuitXML(icl);
            cxml.Save(_filename, gateCanvas);

            ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
            
        }
示例#11
0
        //BOKANG 
        public Window1() : this(EditLevel.EDIT)
        {

            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());
                }

            }
            
        }
示例#12
0
 private void btnPaste_Click(object sender, RoutedEventArgs e)
 {
     if (Clipboard.ContainsData("IC"))
     {
         string xml = Clipboard.GetData("IC") as string;
         CircuitXML cx = new CircuitXML(icl);
         try
         {
             UIGates.IC ic = cx.LoadCircuit(System.Xml.Linq.XElement.Parse(xml));
             gateCanvas.PasteIC(ic);
         }
         catch (Exception)
         {
             MessageBox.Show("Unable to complete paste; maybe you deleted a needed IC?");
         }
     }
 }
示例#13
0
 private void btnCopy_Click(object sender, RoutedEventArgs e)
 {
     if (gateCanvas.selected.Count > 0) {
         UIGates.IC ic = gateCanvas.CreateIC("(clipboard)", GateCanvas.SELECTED_GATES.SELECTED);
         CircuitXML cx = new CircuitXML(icl);
         DataObject clipobj = new DataObject();
         Clipboard.SetData("IC", cx.CreateCircuitXML(ic).ToString());
         btnPaste.IsEnabled = true;
     }
 }
示例#14
0
 public void loadXMLElement(XElement circuit)
 {
     gateCanvas.ClearSelection();
     icl.Clear();
     CircuitXML cxml = new CircuitXML(icl);
     try
     {
         slZoom.Value = 1;
         RefreshGateCanvas(cxml.LoadCircuit(circuit));
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to load circuit as requested: " + ex.ToString());
     }
 }
示例#15
0
        private void AddDragDropGate(int pos, UIGates.IC g)
        {
            g.DataContext = g.CreateUserInstance();
            

            DragDrop.DragDropHelper.SetIsDragSource(g, true);
            DragDrop.DragDropHelper.SetDragDropControl(g, new DragDrop.GateDragDropAdorner());
            DragDrop.DragDropHelper.SetDropTarget(g, "gateCanvas");
            DragDrop.DragDropHelper.SetAdornerLayer(g, "adornerLayer");


            g.PreviewICNameChanged += (object sender2, string newname, ref bool cancel) =>
            {
                if (newname == "")
                    cancel = true;

                foreach (Gate g2 in icl)
                {
                    if (newname == g2.AbGate.Name)
                        cancel = true;
                }
            };

            g.ICNameChanged += (sender2, newname) =>
            {
                UIGates.IC oic = icl.GetIC((g.AbGate.Name));
                UIGates.IC nic = g.CreateUserInstance(newname);
                icl[icl.IndexOf(oic)] = nic;
                if (undoProvider != null)
                    undoProvider.Add(new UndoRedo.ReplaceIC(icl, oic, nic));

            };

            ScaleTransform st = new ScaleTransform();
            st.CenterX = g.Width / 2.0;
            st.CenterY = g.Height / 2.0;
            double fac = 1.0;
            if (g.Width > MAX_SIZE)
                fac = Math.Min(MAX_SIZE / g.Width, fac);

            if (g.Height > MAX_SIZE)
                fac = Math.Min(MAX_SIZE / g.Height, fac);
            st.ScaleY = fac;
            st.ScaleX = fac;
            g.LayoutTransform = st;


            g.ContextMenu = new ContextMenu();
            MenuItem exp = new MenuItem();
            exp.Header = "Export...";
            exp.Click += (sender2, e2) =>
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.DefaultExt = ".ic";
                dlg.Filter = "IC (.ic)|*.ic";
                bool? result = dlg.ShowDialog();

                if (result == true)
                {
                    CircuitXML cxml = new CircuitXML(icl);
                    try
                    {
                        cxml.Save(dlg.FileName, g);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to save IC: " + ex.ToString());
                    }
                }
            };
            g.ContextMenu.Items.Add(exp);
            MenuItem del = new MenuItem();
            del.Header = "Delete";
            del.Click += (sender2, e2) =>
            {
                if (MessageBox.Show("All instances of this IC in all circuits will be removed.  This operation cannot be undone.  Proceed?", "Danger Zone", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    UIGates.IC todel = icl.GetIC(g.AbGate.Name);

                    icl.Remove(todel);
                    if (undoProvider != null)
                        undoProvider.Clear();
                }
            };
            g.ContextMenu.Items.Add(del);
            MenuItem hid = new MenuItem();
            hid.Header = "Hide";
            hid.Click += (sender2, e2) =>
            {
                g.Visibility = Visibility.Collapsed;
            };
            //g.ContextMenu.Items.Add(hid);

            spGates.Children.Insert(pos, g);
            g.MouseDoubleClick += new MouseButtonEventHandler(g_MouseDoubleClick);
            expUserGates.IsExpanded = true;
            g.BringIntoView();
            g.IsReadOnly = _ro;
            g.ContextMenu.IsEnabled = !_ro;


            if (!string.IsNullOrEmpty(_icname))
                if (((Gates.IC)g.AbGate).DeepIncludes(_icname))
                    g.Visibility = Visibility.Collapsed;

            ((Gates.IC)g.AbGate).Circuit.Start();

            SetInfoLine(g);
            
        }
示例#16
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            if (!QuerySave())
                return;

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".gcg";
            dlg.Filter = "Gate Circuit Groups (.gcg)|*.gcg|All Files|*.*";
            bool? result = dlg.ShowDialog();
            
            if (result == true)
            {
                foreach (Window w in Application.Current.Windows)
                {
                    if (w != this)
                        w.Close();
                }
                gateCanvas.ClearSelection();

                icl.Clear();
                CircuitXML cxml = new CircuitXML(icl);

                try
                {
                    slZoom.Value = 1;
                    RefreshGateCanvas(cxml.Load(dlg.FileName, icl.Add));



                    btnSave.IsEnabled = true;
                    _filename = dlg.FileName;
                    UpdateTitle();

                    ((UndoRedo.UndoManager)Resources["undoManager"]).Clear();
                    ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to load circuit as requested: " + ex.ToString());
                }
                
            }
        }
示例#17
0
        private void AddDragDropGate(int pos, UIGates.IC g)
        {
            g.DataContext = g.CreateUserInstance();


            DragDrop.DragDropHelper.SetIsDragSource(g, true);
            DragDrop.DragDropHelper.SetDragDropControl(g, new DragDrop.GateDragDropAdorner());
            DragDrop.DragDropHelper.SetDropTarget(g, "gateCanvas");
            DragDrop.DragDropHelper.SetAdornerLayer(g, "adornerLayer");


            g.PreviewICNameChanged += (object sender2, string newname, ref bool cancel) =>
            {
                if (newname == "")
                {
                    cancel = true;
                }

                foreach (Gate g2 in icl)
                {
                    if (newname == g2.AbGate.Name)
                    {
                        cancel = true;
                    }
                }
            };

            g.ICNameChanged += (sender2, newname) =>
            {
                UIGates.IC oic = icl.GetIC((g.AbGate.Name));
                UIGates.IC nic = g.CreateUserInstance(newname);
                icl[icl.IndexOf(oic)] = nic;
                if (undoProvider != null)
                {
                    undoProvider.Add(new UndoRedo.ReplaceIC(icl, oic, nic));
                }
            };

            ScaleTransform st = new ScaleTransform();

            st.CenterX = g.Width / 2.0;
            st.CenterY = g.Height / 2.0;
            double fac = 1.0;

            if (g.Width > MAX_SIZE)
            {
                fac = Math.Min(MAX_SIZE / g.Width, fac);
            }

            if (g.Height > MAX_SIZE)
            {
                fac = Math.Min(MAX_SIZE / g.Height, fac);
            }
            st.ScaleY         = fac;
            st.ScaleX         = fac;
            g.LayoutTransform = st;


            g.ContextMenu = new ContextMenu();
            MenuItem exp = new MenuItem();

            exp.Header = "Export...";
            exp.Click += (sender2, e2) =>
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.DefaultExt = ".ic";
                dlg.Filter     = "IC (.ic)|*.ic";
                bool?result = dlg.ShowDialog();

                if (result == true)
                {
                    CircuitXML cxml = new CircuitXML(icl);
                    try
                    {
                        cxml.Save(dlg.FileName, g);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to save IC: " + ex.ToString());
                    }
                }
            };
            g.ContextMenu.Items.Add(exp);
            MenuItem del = new MenuItem();

            del.Header = "Delete";
            del.Click += (sender2, e2) =>
            {
                if (MessageBox.Show("All instances of this IC in all circuits will be removed.  This operation cannot be undone.  Proceed?", "Danger Zone", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    UIGates.IC todel = icl.GetIC(g.AbGate.Name);

                    icl.Remove(todel);
                    if (undoProvider != null)
                    {
                        undoProvider.Clear();
                    }
                }
            };
            g.ContextMenu.Items.Add(del);
            MenuItem hid = new MenuItem();

            hid.Header = "Hide";
            hid.Click += (sender2, e2) =>
            {
                g.Visibility = Visibility.Collapsed;
            };
            //g.ContextMenu.Items.Add(hid);

            spGates.Children.Insert(pos, g);
            g.MouseDoubleClick     += new MouseButtonEventHandler(g_MouseDoubleClick);
            expUserGates.IsExpanded = true;
            g.BringIntoView();
            g.IsReadOnly            = _ro;
            g.ContextMenu.IsEnabled = !_ro;


            if (!string.IsNullOrEmpty(_icname))
            {
                if (((Gates.IC)g.AbGate).DeepIncludes(_icname))
                {
                    g.Visibility = Visibility.Collapsed;
                }
            }

            ((Gates.IC)g.AbGate).Circuit.Start();

            SetInfoLine(g);
        }