fBaseXtensions.Settings.UIControl.InstallSettingsButton C# (CSharp) Method

InstallSettingsButton() static private method

static private InstallSettingsButton ( ) : void
return void
        internal static void InstallSettingsButton()
        {
            Application.Current.Dispatcher.Invoke(
                new Action(
                    () =>
                    {
                        Window mainWindow = Application.Current.MainWindow;
                        var tab = mainWindow.FindName("tabControlMain") as TabControl;
                        if (tab == null) return;
                        var infoDumpTab = tab.Items[0] as TabItem;
                        if (infoDumpTab == null) return;
                        var grid = infoDumpTab.Content as Grid;
                        if (grid == null) return;

                        SplitButton FunkyButton = grid.FindName("Funky") as SplitButton;
                        if (FunkyButton != null)
                        {
                            Logger.DBLog.DebugFormat("Funky Button handler added");
                        }
                        else
                        {
                            SplitButton[] splitbuttons = grid.Children.OfType<SplitButton>().ToArray();
                            if (splitbuttons.Any())
                            {

                                foreach (var item in splitbuttons)
                                {
                                    if (item.Name.Contains("Funky"))
                                    {
                                        FunkyButton = item;
                                        break;
                                    }
                                }
                            }
                        }

                        if (FunkyButton==null)
                        {
                            SplitButton btn = new SplitButton
                            {
                                Width = 125,
                                Height = 20,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                VerticalAlignment = VerticalAlignment.Top,
                                Margin = new Thickness(425, 10, 0, 0),
                                IsEnabled = true,
                                Content = "Funky",
                                Name = "Funky",
                            };
                            btn.Click += lblFunky_Click;

                            lblDebug_OpenLog = new Label
                            {
                                Content = "Open DB LogFile",
                                Width = 100,
                                Height = 25,
                                HorizontalAlignment = HorizontalAlignment.Stretch,
                            };
                            lblDebug_OpenLog.MouseDown += lblDebug_OpenDBLog;

                            lblDebug_FunkyLog = new Label
                            {
                                Content = "Open Funky LogFile",
                                Width = 100,
                                Height = 25,
                                HorizontalAlignment = HorizontalAlignment.Stretch,
                            };
                            lblDebug_FunkyLog.MouseDown += lblDebug_OpenFunkyLog;

                            Label OpenTrinityFolder = new Label
                            {
                                Content = "Open Funky Folder",
                                Width = 100,
                                Height = 25,
                                HorizontalAlignment = HorizontalAlignment.Stretch,

                            };
                            OpenTrinityFolder.MouseDown += lblDebug_OpenTrinityFolder;

                            Label Recompile = new Label
                            {
                                Content = "Recompile Funky",
                                Width = 100,
                                Height = 25,
                                HorizontalAlignment = HorizontalAlignment.Stretch,

                            };
                            Recompile.MouseDown += lblCompile_Click;

                            menuItem_Debug = new MenuItem
                            {
                                Header = "Debuging",
                                Width = 125
                            };
                            menuItem_Debug.Items.Add(lblDebug_OpenLog);
                            menuItem_Debug.Items.Add(lblDebug_FunkyLog);
                            menuItem_Debug.Items.Add(OpenTrinityFolder);
                            menuItem_Debug.Items.Add(Recompile);
                            btn.ButtonMenuItemsSource.Add(menuItem_Debug);
                            btn.Click += buttonFunkySettingDB_Click;
                            grid.Children.Add(btn);
                        }
                    }
                )
            );
        }