예제 #1
0
        /// <summary>
        /// Singleton class has only one instance.
        /// </summary>
        /// <returns></returns>
        public static InfoLine GetInstance()
        {
            if (_inst == null)
                _inst = new InfoLine();

            return _inst;
        }
예제 #2
0
        /// <summary>
        /// Singleton class has only one instance.
        /// </summary>
        /// <returns></returns>
        public static InfoLine GetInstance()
        {
            if (_inst == null)
            {
                _inst = new InfoLine();
            }

            return(_inst);
        }
예제 #3
0
        private void SetInfoLine(UIGates.IC ic)
        {
            string inf = "Left-drag to place";

            if (!_ro)
            {
                inf += ", double-click to edit, type to rename";
            }
            InfoLine.SetInfo(ic, inf);
        }
예제 #4
0
 private void InfoLine_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (String.IsNullOrEmpty(InfoLine.GetInstance().CurrentInfoLine) || !this.IsActive)
     {
         lblInfoLine.Visibility = Visibility.Collapsed;
         spAppInfo.Visibility   = Visibility.Visible;
     }
     else
     {
         lblInfoLine.Text       = InfoLine.GetInstance().CurrentInfoLine;
         lblInfoLine.Visibility = Visibility.Visible;
         spAppInfo.Visibility   = Visibility.Collapsed;
     }
 }
예제 #5
0
        protected Window1(EditLevel e)
        {
            InitializeComponent();
            _myEditLevel = e;

            EventDispatcher.BatchDispatcher = Dispatcher;

            gateCanvas.Circuit.Start();


            // Everybody gets zoom
            sbZoom        = new ShadowBox();
            sbZoom.Margin = new Thickness(20);
            Grid1.Children.Remove(spZoom);
            sbZoom.Children.Add(spZoom);
            spZoom.Background          = Brushes.Transparent;
            sbZoom.VerticalAlignment   = VerticalAlignment.Top;
            sbZoom.HorizontalAlignment = HorizontalAlignment.Right;
            Grid1.Children.Add(sbZoom);
            Grid.SetColumn(sbZoom, 1);
            Grid.SetRow(sbZoom, 1);

            // everybody gets view keys
            this.PreviewKeyDown += new KeyEventHandler(Window1_View_KeyDown);

            Grid1.Children.Remove(spGates);
            if (e == EditLevel.FULL ||
                e == EditLevel.EDIT)
            {
                // delete for edit or full
                this.PreviewKeyDown += new KeyEventHandler(Window1_EditFull_KeyDown);

                this.PreviewKeyUp += (s2, e2) =>
                {
                    // add moves if needed
                    if (moves != null)
                    {
                        ((UndoRedo.UndoManager)Resources["undoManager"]).Add(moves);
                    }

                    moves = null;
                };

                // drag/drop for edit or full
                DragDrop.DragDropHelper.ItemDropped += new EventHandler <DragDrop.DragDropEventArgs>(DragDropHelper_ItemDropped);

                // gates for edit or full

                sbGates        = new ShadowBox();
                sbGates.Margin = new Thickness(20, 20, 20, 20);
                sbGates.Children.Add(spGates);
                spGates.Background          = Brushes.Transparent;
                sbGates.VerticalAlignment   = VerticalAlignment.Center;
                sbGates.HorizontalAlignment = HorizontalAlignment.Left;
                Grid1.Children.Add(sbGates);
                Grid.SetColumn(sbGates, 1);
                Grid.SetRow(sbGates, 1);

                // edit or full get undo and edit
                tbUndo.Visibility = Visibility.Visible;
                tbEdit.Visibility = Visibility.Visible;

                // monitor the clipboard to provide cut/copy/paste visibility
                gateCanvas.selected.ListChanged += (s2, e2) =>
                {
                    btnCopy.IsEnabled        = gateCanvas.selected.Count > 0;
                    btnCut.IsEnabled         = gateCanvas.selected.Count > 0;
                    btnCopyAsImage.IsEnabled = gateCanvas.selected.Count > 0;
                };
                this.Activated += (s2, e2) =>
                {
                    btnPaste.IsEnabled = Clipboard.ContainsData("IC");
                };
            }


            Grid1.Children.Remove(spSpeed);
            if (e == EditLevel.FULL)
            {
                // speed only for the main window
                sbSpeed        = new ShadowBox();
                sbSpeed.Margin = new Thickness(20, 20, 175, 20);
                sbSpeed.Children.Add(spSpeed);
                spSpeed.Background          = Brushes.Transparent;
                sbSpeed.VerticalAlignment   = VerticalAlignment.Top;
                sbSpeed.HorizontalAlignment = HorizontalAlignment.Right;
                Grid1.Children.Add(sbSpeed);
                Grid.SetColumn(sbSpeed, 1);
                Grid.SetRow(sbSpeed, 1);

                // otherwise the defaults mess it up when you open a new window
                slSpeed.ValueChanged += (sender2, e2) =>
                {
                    Gates.PropagationThread.SLEEP_TIME = (int)slSpeed.Value;
                };

                // full also gets file and ic
                tbFile.Visibility = Visibility.Visible;
                tbIC.Visibility   = Visibility.Visible;
            }

            if (e == EditLevel.EDIT)
            {
                // can't edit the user gates in this view
                spGates.IsReadOnly = true;
            }

            this.Loaded += (sender2, e2) =>
            {
                ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                UpdateTitle();
                lblAppTitle.Text     = APP_TITLE;
                lblAppVersion.Text   = APP_VERSION;
                lblAppCopyright.Text = APP_COPYRIGHT;
            };

            // green team: added if statement to determine if ctrl keys are pressed
            // then fires mouse wheel zoom event

            this.PreviewMouseWheel += (sender, e2) =>
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    gateCanvas.UseZoomCenter = true;
                    double centerX = (Mouse.GetPosition(this).X + gateCanvas.GCScroller.HorizontalOffset) / gateCanvas.Zoom;
                    double centerY = (Mouse.GetPosition(this).Y + gateCanvas.GCScroller.VerticalOffset) / gateCanvas.Zoom;
                    gateCanvas.ZoomCenter = new Point(centerX, centerY);

                    if (e2.Delta > 0)
                    {
                        slZoom.Value += 0.1;
                    }
                    else
                    {
                        slZoom.Value -= 0.1;
                    }

                    e2.Handled = true;
                }
            };



            ((UndoRedo.UndoManager)Resources["undoManager"]).PropertyChanged += (sender2, e2) =>
            {
                UpdateTitle(); // look for modified or not
            };

            InfoLine.GetInstance().PropertyChanged += InfoLine_PropertyChanged;
        }