private void menuItem_Click(object sender, RoutedEventArgs e) { var ui = sender as MenuItem; if (ui == null) { return; } if (!m_UrakawaSession.isAudioRecording) { m_UrakawaSession.PerformTreeNodeSelection((TreeNode)ui.Tag); } //selectNode(wrapper.TreeNode, true); CommandFocus.Execute(); }
private void OnBreadCrumbButtonClick(object sender, RoutedEventArgs e) { var ui = sender as Button; if (ui == null) { return; } if (!m_UrakawaSession.isAudioRecording) { m_UrakawaSession.PerformTreeNodeSelection((TreeNode)ui.Tag); CommandFocus.Execute(); } //selectNode((TreeNode)ui.Tag, true); }
private void updateBreadcrumbPanel(Tuple <TreeNode, TreeNode> treeNodeSelection) { bool keyboardFocusWithin = BreadcrumbPanel.IsKeyboardFocusWithin; bool secondIsFocused = keyboardFocusWithin && m_FocusStartElement2.IsKeyboardFocused; // ! m_FocusStartElement.IsKeyboardFocused BreadcrumbPanel.Children.Clear(); BreadcrumbPanel.Children.Add(m_FocusStartElement); BreadcrumbPanel.Children.Add(m_FocusStartElement2); bool firstTime = PathToCurrentTreeNode == null; TreeNode treeNodeSel = treeNodeSelection.Item2 ?? treeNodeSelection.Item1; if (true) // this was too confusing for the user: firstTime || !PathToCurrentTreeNode.Contains(treeNodeSel)) { PathToCurrentTreeNode = new List <TreeNode>(); TreeNode treeNode = treeNodeSel; do { PathToCurrentTreeNode.Add(treeNode); } while ((treeNode = treeNode.Parent) != null); PathToCurrentTreeNode.Reverse(); } int counter = 0; foreach (TreeNode n in PathToCurrentTreeNode) { //TODO: could use Label+Hyperlink+TextBlock instead of button // (not with NavigateUri+RequestNavigate, because it requires a valid URI. // instead we use the Tag property which contains a reference to a TreeNode, // so we can use the Click event) #if ENABLE_SEQ_MEDIA bool withMedia = n.GetManagedAudioMediaOrSequenceMedia() != null; #else bool withMedia = n.GetManagedAudioMedia() != null; #endif var butt = new Button { Tag = n, BorderThickness = new Thickness(0.0), BorderBrush = null, //Padding = new Thickness(2, 4, 2, 4), Background = Brushes.Transparent, Foreground = (withMedia ? SystemColors.HighlightBrush : SystemColors.ControlDarkBrush), Cursor = Cursors.Hand, Style = m_ButtonStyle }; string label = getTreeNodeLabel(n); var run = new Run(label) { }; //run.SetValue(AutomationProperties.NameProperty, str); butt.Content = run; butt.Click += OnBreadCrumbButtonClick; // Doesn't really work from a user experience perspective, because the commands act on the globally-selected tree node, not the item under the mouse click //if (butt.ContextMenu == null) //{ // butt.ContextMenu = (ContextMenu)this.Resources["contextMenu"]; //} ////butt.ContextMenu.PlacementTarget = ui; ////butt.ContextMenu.Placement = PlacementMode.Bottom; ////butt.ContextMenu.IsOpen = true; BreadcrumbPanel.Children.Add(butt); if (counter < PathToCurrentTreeNode.Count && n.Children.Count > 0) { var arrow = (Path)Application.Current.FindResource("Arrow"); var tb = new Button { Content = arrow, Tag = n, BorderBrush = null, BorderThickness = new Thickness(0.0), Background = Brushes.Transparent, Foreground = SystemColors.ControlDarkDarkBrush, //ActiveBorderBrush, Cursor = Cursors.Cross, FontWeight = FontWeights.ExtraBold, Style = m_ButtonStyle, Focusable = true, IsTabStop = true }; // DEFERRED LAZY LOADING ! (see OnBreadCrumbSeparatorClick) //tb.ContextMenu = new ContextMenu(); //foreach (TreeNode child in n.Children.ContentsAs_Enumerable) //{ // bool childIsInPath = PathToCurrentTreeNode.Contains(child); // var menuItem = new MenuItem(); // QualifiedName qnameChild = child.GetXmlElementQName(); // if (qnameChild != null) // { // if (childIsInPath) // { // var runMenuItem = new Run(qnameChild.LocalName) { FontWeight = FontWeights.ExtraBold }; // menuItem.Header = runMenuItem; // } // else // { // menuItem.Header = qnameChild.LocalName; // } // } // else // { // if (childIsInPath) // { // var runMenuItem = new Run("TXT") { FontWeight = FontWeights.ExtraBold }; // menuItem.Header = runMenuItem; // } // else // { // menuItem.Header = "TXT"; // } // } // menuItem.Tag = child; // menuItem.Click += menuItem_Click; // tb.ContextMenu.Items.Add(menuItem); //} tb.Click += OnBreadCrumbSeparatorClick; BreadcrumbPanel.Children.Add(tb); tb.SetValue(AutomationProperties.NameProperty, Tobi_Plugin_StructureTrailPane_Lang.XMLChildren); } bool selected = n == treeNodeSelection.Item2 || n == treeNodeSelection.Item1; if (selected) { run.FontWeight = FontWeights.Heavy; run.Background = SystemColors.ControlDarkDarkBrush; run.Foreground = SystemColors.ControlBrush; } else { run.TextDecorations = TextDecorations.Underline; } butt.SetValue(AutomationProperties.NameProperty, (n.HasXmlProperty ? label : Tobi_Plugin_StructureTrailPane_Lang.NoXMLFound) + (selected ? Tobi_Plugin_StructureTrailPane_Lang.Selected : "") + (withMedia ? Tobi_Plugin_StructureTrailPane_Lang.Audio : "")); //if (keyboardFocusWithin && selected) //{ // butt.Focus(); //} counter++; } if (firstTime || keyboardFocusWithin) { if (secondIsFocused) { FocusHelper.FocusBeginInvoke(m_FocusStartElement2); } else { CommandFocus.Execute(); } } }