Exemplo n.º 1
0
        public Comment(Gates.IOGates.Comment cmt) : base(cmt, new TerminalID[0])
        {
            ph = new Path();

            ph.Stroke          = Brushes.Black;
            ph.StrokeThickness = 2;
            ph.Fill            = Brushes.White;
            ph.Margin          = new System.Windows.Thickness(15);
            myCanvas.Children.Add(ph);


            nm      = new TextBox();
            nm.Text = cmt.Value;
            nm.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            nm.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            nm.Margin          = new System.Windows.Thickness(20);
            nm.Width           = this.Width - 40;
            nm.Height          = this.Height - 40;
            nm.BorderThickness = new Thickness(0);

            myCanvas.Children.Add(nm);

            nm.TextChanged += (sender, e) =>
            {
                cmt.Value = nm.Text;
            };
            nm.LostFocus += (sender, e) =>
            {
                // because I don't want to create an undo event
                // for every single keypress!
                if (UndoProvider != null)
                {
                    UndoProvider.Add(new UndoRedo.ChangeUserText(this, prevcmt, nm.Text, txt => { cmt.Value = txt; }));
                }

                prevcmt = nm.Text;
            };
            nm.GotFocus += (sender, e) =>
            {
                if (MyGateCanvas != null)
                {
                    MyGateCanvas.ClearSelection();
                }
            };
            cmt.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "Value")
                {
                    ResizeDueToName();
                }
            };
            ResizeDueToName();
        }
Exemplo n.º 2
0
        void txtName_LostFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            string oldname = _uio.Name;

            _uio.SetName(txtName.Text);

            txtName.Visibility = System.Windows.Visibility.Hidden;
            if (UndoProvider != null)
            {
                UndoProvider.Add(new UndoRedo.ChangeUserText(this, oldname, txtName.Text, _uio.SetName));
            }
        }