コード例 #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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
        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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
        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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            
            CircuitXML cxml = new CircuitXML(icl);
            cxml.Save(_filename, gateCanvas);

            ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
            
        }
コード例 #11
0
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
        //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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
 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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
 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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
 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
ファイル: Window1.xaml.cs プロジェクト: buptkang/LogicPad
        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);
        }