private void CloseState(object sender, EventArgs e) { TabCloseButton btn = (TabCloseButton)sender; StateEditorTabItem tItem = (StateEditorTabItem)btn.tabItem; CloseState(tItem); }
public TabItemHeader(string text, TabItem tabItem) { Text = new TextBlock { Text = text, VerticalAlignment = VerticalAlignment.Center }; TabItem = tabItem; TabCloseButton = new TabCloseButton(TabItem); Orientation = Orientation.Horizontal; Children.Add(Text); Children.Add(TabCloseButton); }
private void SelectOrOpenState(int stateIndex) { foreach (StateEditorTabItem item in stateTabControl.Items) { if (item.StateEditor.StateIndex == stateIndex) { item.IsSelected = true; UpdateStateUi(); return; } } DmiEXState state = (DmiEXState)DmiEx.States[stateIndex]; StateEditor stateEditor = new StateEditor(this, stateIndex, state); StateEditorTabItem tItem = new StateEditorTabItem(stateEditor); stateTabControl.Items.Add(tItem); StackPanel sp = new StackPanel(); TextBlock txt = new TextBlock { Text = $"\"{state.Id}\"", VerticalAlignment = VerticalAlignment.Center }; state.IdChanged += (o, e) => { txt.Text = $"\"{state.Id}\""; }; sp.Orientation = Orientation.Horizontal; sp.Children.Add(txt); TabCloseButton cBtn = new TabCloseButton(tItem); cBtn.Click += CloseState; sp.Children.Add(cBtn); tItem.Header = sp; tItem.IsSelected = true; UpdateStateUi(); }