private void fontList_SelectionChanged(object sender, SelectionChangedEventArgs e) { string familyName = (string)fontList.SelectedItem; this.Title = String.Format("System Font Family - {0}", familyName); bool isChild = false; string key = String.Empty; string[] cmds = Environment.GetCommandLineArgs(); if (cmds.Length == 2) { string cmd = cmds[1]; if (cmd.ToLower().StartsWith("/key:")) { key = cmd.Substring(cmd.IndexOf(':') + 1); if (!String.IsNullOrEmpty(key)) { isChild = true; } } } if (isChild) { Clipboard.SetText(String.Format("{0}={1}", key, familyName)); } else { Clipboard.SetText(familyName); } if (unifog.Children.Count >= fontFamilies.Count) { foreach (Border pool in pools) { Border inner = (pool.Child as Border); if (inner != null) { inner.BorderBrush = Brushes.Transparent; } } pools.Clear(); Border outer = unifog.Children[fontList.SelectedIndex] as Border; if (outer != null) { if (outer.Child != null) { Border inner = outer.Child as Border; if (inner != null) { inner.BorderBrush = new SolidColorBrush(Color.FromRgb(0x33, 0x99, 0xff)); outer.BringIntoView(); pools.Add(outer); } } } } }
private void OnTreeViewItemExpandCollapse(object sender, MouseEventArgs e) { LibraryItemViewModel libraryItem = null; TreeViewItem treeViewItem = ((Border)sender).TemplatedParent as TreeViewItem; if (treeViewItem != null) { libraryItem = treeViewItem.Header as LibraryItemViewModel; } if (libraryItem == null) { return; } libraryItem.IsSelected = true; if (libraryItem.Children != null && libraryItem.Children.Count > 0) { if (libraryItem.IsExpanded && libraryItem.IsChildVisible) { libraryItem.IsExpanded = false; } else { libraryItem.IsExpanded = true; // make the filtered out item visible ExpandChildItem(libraryItem); } } //Request Bring into View if (libraryItem.IsExpanded && libraryItem.Level == 0) { internalRequestBeingIntoView = true; treeViewItem.BringIntoView(); // to ensure the header of the item is shown Border bd = FindVisualChild <Border>(treeViewItem, "Exp"); if (bd != null) { internalRequestBeingIntoView = true; bd.BringIntoView(); } } e.Handled = true; }