Skip to content

Commit

Permalink
ConfigApp: Don't initialize tabs multiple times
Browse files Browse the repository at this point in the history
Fixes programmatically added tab items showing up multiple times if config has been reset
  • Loading branch information
pongo1231 committed Sep 4, 2023
1 parent 0ac7525 commit 095c121
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions ConfigApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public partial class MainWindow : Window

private Dictionary<string, EffectData> m_EffectDataMap;

private bool m_InitializedTabs = false;

public MainWindow()
{
Init();
Expand All @@ -43,24 +45,29 @@ private void Init()
{
InitializeComponent();

foreach (var tab in m_Tabs)
if (!m_InitializedTabs)
{
var tabItem = new TabItem()
m_InitializedTabs = true;

foreach (var tab in m_Tabs)
{
Header = tab.Key,
Background = new SolidColorBrush(Color.FromRgb(0xF0, 0xF0, 0xF0)),
BorderBrush = new SolidColorBrush(Color.FromRgb(0xD3, 0xD3, 0xD3))
};
var tabItem = new TabItem()
{
Header = tab.Key,
Background = new SolidColorBrush(Color.FromRgb(0xF0, 0xF0, 0xF0)),
BorderBrush = new SolidColorBrush(Color.FromRgb(0xD3, 0xD3, 0xD3))
};

var grid = new Grid();
var grid = new Grid();

tab.Value.Init(grid);
tab.Value.Init(grid);

tabItem.Content = grid;
tabItem.Content = grid;

root_tabcontrol.Items.Add(tabItem);
root_tabcontrol.Items.Add(tabItem);

m_TabItems[tab.Key] = tabItem;
m_TabItems[tab.Key] = tabItem;
}
}

if (!m_bInitializedTitle)
Expand Down

0 comments on commit 095c121

Please sign in to comment.