예제 #1
0
        public virtual void ConfigureWindows <T>(
            Dictionary <string, string> displayItemList,
            Dictionary <string, dynamic> dataItemList,
            bool configureLeftPane = true,
            bool configureHostPane = true)
        {
            _dataItemList = dataItemList;

            if (configureLeftPane)
            {
                ConfigureLeftPane(GetName());
            }
            if (configureHostPane)
            {
                ConfigureHostPane("");
            }

            ConfigureStatusBar();

            MenuBar menubar = null;

            if (displayItemList?.Count > 0)
            {
                var itemListView = GetClassListView <T>(displayItemList);
                LeftPane.Add(itemListView);

                string typeName = dataItemList.FirstOrDefault().Value.GetType().Name;
                switch ((T)dataItemList.FirstOrDefault().Value)
                {
                case Device d:
                case InstalledApp app:
                case SceneSummary s:
                case Subscription sub:
                case CapabilitySummary cs:
                    menubar = MenuHelper.GetStandardMenuBar(Top.ColorScheme, typeName, ExportItem, null);
                    break;

                default:
                    menubar = MenuHelper.GetStandardMenuBar(Top.ColorScheme, typeName, ExportItem, ImportItem);
                    break;
                }
            }
            else
            {
                menubar = MenuHelper.GetStandardMenuBar(Top.ColorScheme);
            }

            if (menubar != null)
            {
                Top.Add(menubar);
            }
            Top.Add(LeftPane);
            if (SettingsPane != null)
            {
                Top.Add(SettingsPane);
            }
            Top.Add(HostPane);
            Top.Add(StatusBar);

            if (displayItemList?.Count > 0)
            {
                dynamic itemToSelect = SelectedItem ?? dataItemList?.FirstOrDefault().Value;
                UpdateJsonView(itemToSelect.ToJson());
                if (SettingsPane != null)
                {
                    UpdateSettings <T>(itemToSelect);
                }
            }
        }