/// <summary> /// Construct a user i/o gate. Note that the txtName textbox is created /// but NOT added to the canvas. (Otherwise it would end up below the /// decoration for the specific instance). So each subclass must /// add the txtName to the canvas when appropriate (in the constructor /// after adding the decoration). /// </summary> /// <param name="gate"></param> /// <param name="termids"></param> public UserIO(Gates.IOGates.UserIO gate, TerminalID[] termids) : base(gate, termids) { _uio = gate; //gate.PropertyChanged += EventDispatcher.CreateDispatchedHandler(Dispatcher, _ui_PropertyChanged); _gate.PropertyChanged += EventDispatcher.CreateBatchDispatchedHandler(_gate, _ui_PropertyChanged); txtFirstLetter = new TextBlock(); txtFirstLetter.Margin = // new System.Windows.Thickness(28, 25, 22, 22); new System.Windows.Thickness(26, 20, 22, 22); txtFirstLetter.Width = 20; txtFirstLetter.Height = 20; txtFirstLetter.IsHitTestVisible = false; txtFirstLetter.Background = new SolidColorBrush(Colors.Transparent); txtFirstLetter.FontWeight = FontWeights.Bold; txtFirstLetter.FontSize = 18; txtName = new TextBox(); txtName.Visibility = System.Windows.Visibility.Hidden; txtName.Width = 54; txtName.Height = 20; txtName.LostFocus += new System.Windows.RoutedEventHandler(txtName_LostFocus); txtName.KeyDown += new System.Windows.Input.KeyEventHandler(txtName_KeyDown); txtFirstLetter.Visibility = System.Windows.Visibility.Visible; ContextMenu = new System.Windows.Controls.ContextMenu(); MenuItem rename = new MenuItem(); rename.Header = "Rename..."; rename.Click += new System.Windows.RoutedEventHandler(rename_Click); ContextMenu.Items.Add(rename); }