protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); string[] lastOpenedPanelID = SD.PropertyService.Get("TreeViewOptionsDialog.LastOpenedPanelID", "UIOptions/SelectCulture").Split('/'); OptionPanelNode lastOpenedPanelNode = null; for (int i = 0; i < lastOpenedPanelID.Length; i++) { IEnumerable <OptionPanelNode> currentList; if (lastOpenedPanelNode == null) { currentList = (IEnumerable <OptionPanelNode>)treeView.ItemsSource; } else { currentList = lastOpenedPanelNode.Children; } var nextNode = currentList.FirstOrDefault(op => lastOpenedPanelID[i].Equals(op.ID, StringComparison.Ordinal)); if (nextNode == null) { break; } lastOpenedPanelNode = nextNode; } if (lastOpenedPanelNode != null) { lastOpenedPanelNode.IsSelected = true; } }
void SelectNode(OptionPanelNode node) { while (!node.OptionPanelDescriptor.HasOptionPanel && node.Children.Count > 0) { node = node.Children[0]; } if (node == activeNode) { return; } while (activeNode != null) { activeNode.IsActive = false; activeNode.IsExpanded = false; activeNode = activeNode.Parent; } activeNode = node; optionPanelTitle.Text = node.Title; if (node.Content is System.Windows.Forms.Control) { optionPanelScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; } else { optionPanelScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; } SD.WinForms.SetContent(optionPanelContent, node.Content); node.IsExpanded = true; node.IsActive = true; }
void SelectNode(OptionPanelNode node) { while (!node.OptionPanelDescriptor.HasOptionPanel && node.Children.Count > 0) node = node.Children[0]; if (node == activeNode) return; while (activeNode != null) { activeNode.IsActive = false; activeNode.IsExpanded = false; activeNode = activeNode.Parent; } activeNode = node; optionPanelTitle.Text = node.Title; if (node.Content is System.Windows.Forms.Control) { optionPanelScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; } else { optionPanelScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; } optionPanelContent.SetContent(node.Content); node.IsExpanded = true; node.IsActive = true; }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); string[] lastOpenedPanelID = SD.PropertyService.Get(LastOpenedPanelIDSetting, "UIOptions/SelectCulture").Split('/'); var topLevelList = (IEnumerable <OptionPanelNode>)treeView.ItemsSource; OptionPanelNode lastOpenedPanelNode = null; for (int i = 0; i < lastOpenedPanelID.Length; i++) { IEnumerable <OptionPanelNode> currentList; if (lastOpenedPanelNode == null) { currentList = topLevelList; } else { currentList = lastOpenedPanelNode.Children; } var nextNode = currentList.FirstOrDefault(op => lastOpenedPanelID[i].Equals(op.ID, StringComparison.Ordinal)); if (nextNode == null) { break; } lastOpenedPanelNode = nextNode; } if (lastOpenedPanelNode != null) { lastOpenedPanelNode.IsSelected = true; } else { // If even default panel is not available, activate first item on first level var firstPanel = topLevelList.FirstOrDefault(); if (firstPanel != null) { firstPanel.IsSelected = true; } } }
public OptionPanelNode(IOptionPanelDescriptor optionPanel, OptionPanelNode parent) { this.OptionPanelDescriptor = optionPanel; this.Parent = parent; this.dialog = parent.dialog; }