private static void OnIsHighlightedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RibbonGalleryItem galleryItem = (RibbonGalleryItem)d; bool isHighlighted = (bool)e.NewValue; RibbonGalleryCategory category = galleryItem.RibbonGalleryCategory; if (category != null) { RibbonGallery gallery = category.RibbonGallery; if (gallery != null) { // Give the RibbonGallery a reference to this container and its data object item = category.ItemContainerGenerator.ItemFromContainer(galleryItem); gallery.ChangeHighlight(item, galleryItem, isHighlighted); } } }
/// <summary> /// Called when the container is being attached to the parent ItemsControl /// </summary> /// <param name="element"></param> /// <param name="item"></param> protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { RibbonGalleryItem galleryItem = (RibbonGalleryItem)element; galleryItem.RibbonGalleryCategory = this; RibbonGallery gallery = RibbonGallery; if (gallery != null) { object selectedItem = gallery.SelectedItem; if (selectedItem != null) { // Set IsSelected to true on GalleryItems that match the SelectedItem if (RibbonGallery.VerifyEqual(item, selectedItem)) { galleryItem.IsSelected = true; } } else if (galleryItem.IsSelected) { // If a GalleryItem is marked IsSelected true then synchronize SelectedItem with it gallery.SelectedItem = item; } else { object selectedValue = gallery.SelectedValue; if (selectedValue != null) { // Set SelectedItem if the item's value matches the SelectedValue object itemValue = gallery.GetSelectableValueFromItem(item); if (RibbonGallery.VerifyEqual(selectedValue, itemValue)) { galleryItem.IsSelected = true; } } } } galleryItem.SyncKeyTipAndContent(); base.PrepareContainerForItemOverride(element, item); }
/// <summary> /// Called when the container is being detached from the parent ItemsControl /// </summary> /// <param name="element"></param> /// <param name="item"></param> protected override void ClearContainerForItemOverride(DependencyObject element, object item) { RibbonGalleryItem galleryItem = (RibbonGalleryItem)element; // Turn off selection and highlight on GalleryItems that are being cleared. // Note that we directly call Change[Selection/Highlight] instead of setting // Is[Selected/Highlighted] because we aren't able to get ItemFromContainer // in OnIs[Selected/Highlighted]Changed because the ItemContainerGenerator // has already detached this container. if (galleryItem.IsHighlighted) { galleryItem.RibbonGallery.ChangeHighlight(item, galleryItem, false); } if (galleryItem.IsSelected) { galleryItem.RibbonGallery.ChangeSelection(item, galleryItem, false); } galleryItem.RibbonGalleryCategory = null; base.ClearContainerForItemOverride(element, item); }
private void OnCurrentItemChanged() { Debug.Assert(RibbonGallery == null || RibbonGallery.IsSynchronizedWithCurrentItemInternal, "We shouldn't be listening for currency changes if IsSynchronizedWithCurrentItemInternal is false"); if (RibbonGallery == null || CollectionView == null || RibbonGallery.IsSelectionChangeActive) { return; } RibbonGalleryItem galleryItem = this.ItemContainerGenerator.ContainerFromItem(CollectionView.CurrentItem) as RibbonGalleryItem; if (galleryItem != null) { // This is fast path to have the SelectedItem set galleryItem.IsSelected = true; } else { // This is to handle UI virtualization scenarios where the // container for the CurrentItem may not have been generated. RibbonGallery.SelectedItem = CollectionView.CurrentItem; } }
// This method is called when trying to navigate pages within a RibbonGallery. // We approximate the RibbonGalleryItem that is a page away from the currently // focused item based upon the precomputed MaxColumnWidth and MaxRowHeight values. internal static bool NavigatePageAndHighlightRibbonGalleryItem( RibbonGallery gallery, RibbonGalleryItem galleryItem, FocusNavigationDirection direction, out RibbonGalleryItem highlightedGalleryItem) { highlightedGalleryItem = null; RibbonGalleryCategoriesPanel categoriesPanel = gallery.ItemsHostSite as RibbonGalleryCategoriesPanel; if (categoriesPanel != null) { double viewportWidth = categoriesPanel.ViewportWidth; double viewportHeight = categoriesPanel.ViewportHeight; RibbonGalleryCategory category, prevCategory = null; if (galleryItem != null) { category = galleryItem.RibbonGalleryCategory; } else { category = gallery.Items.Count > 0 ? gallery.ItemContainerGenerator.ContainerFromIndex(0) as RibbonGalleryCategory : null; galleryItem = category != null && category.Items.Count > 0 ? category.ItemContainerGenerator.ContainerFromIndex(0) as RibbonGalleryItem : null; } if (category != null) { Debug.Assert(category.RibbonGallery == gallery, "The reference RibbongalleryItem and the RibbonGallery must be related."); int startCatIndex = gallery.ItemContainerGenerator.IndexFromContainer(category); int endCatIndex, incr; if (direction == FocusNavigationDirection.Up) { endCatIndex = -1; incr = -1; } else { endCatIndex = gallery.Items.Count; incr = 1; } for (int catIndex = startCatIndex; catIndex != endCatIndex && highlightedGalleryItem == null; catIndex += incr) { category = gallery.ItemContainerGenerator.ContainerFromIndex(catIndex) as RibbonGalleryCategory; RibbonGalleryItemsPanel galleryItemsPanel = category.ItemsHostSite as RibbonGalleryItemsPanel; // We want to skip over filtered categories if (category.Visibility != Visibility.Visible) { continue; } int startItemIndex, endItemIndex, startColumnIndex, endColumnIndex, columnCount; columnCount = (int)(viewportWidth / galleryItemsPanel.MaxColumnWidth); if (direction == FocusNavigationDirection.Up) { startItemIndex = galleryItem != null ? category.ItemContainerGenerator.IndexFromContainer(galleryItem) : category.Items.Count - 1; endItemIndex = -1; if (prevCategory != null) { viewportHeight -= prevCategory.HeaderPresenter.ActualHeight; if (DoubleUtil.LessThanOrClose(viewportHeight, 0)) { highlightedGalleryItem = category.ItemContainerGenerator.ContainerFromIndex(startItemIndex) as RibbonGalleryItem; break; } } // startColumnIndex is the last column in the last row or the column of the anchor item if (columnCount == 1) { startColumnIndex = 0; endColumnIndex = 0; } else { startColumnIndex = (galleryItem != null ? startItemIndex : category.Items.Count - 1) % columnCount; endColumnIndex = 0; } } else { startItemIndex = galleryItem != null ? category.ItemContainerGenerator.IndexFromContainer(galleryItem) : 0; endItemIndex = category.Items.Count; if (prevCategory != null) { viewportHeight -= category.HeaderPresenter.ActualHeight; if (DoubleUtil.LessThanOrClose(viewportHeight, 0)) { highlightedGalleryItem = category.ItemContainerGenerator.ContainerFromIndex(startItemIndex) as RibbonGalleryItem; break; } } // endColumnIndex is the last column in the first row if (columnCount == 1) { startColumnIndex = 0; endColumnIndex = 0; } else { int remainingItems = category.Items.Count; bool isLastRow = remainingItems <= columnCount; startColumnIndex = galleryItem != null ? (startItemIndex % columnCount) : 0; endColumnIndex = isLastRow ? remainingItems - 1 : columnCount - 1; } } galleryItem = null; for (int itemIndex = startItemIndex, columnIndex = startColumnIndex; itemIndex != endItemIndex; itemIndex += incr) { if (columnIndex == endColumnIndex) { // We are at the end of a row viewportHeight -= galleryItemsPanel.MaxRowHeight; if (DoubleUtil.LessThanOrClose(viewportHeight, 0) || (itemIndex == endItemIndex - incr && catIndex == endCatIndex - incr)) { // If we have scrolled a page or have reached the boundary // of the gallery, highlight that item highlightedGalleryItem = category.ItemContainerGenerator.ContainerFromIndex(itemIndex) as RibbonGalleryItem; break; } if (direction == FocusNavigationDirection.Up) { if (columnCount > 1) { startColumnIndex = columnCount - 1; endColumnIndex = 0; } } else { if (columnCount > 1) { int remainingItems = category.Items.Count - itemIndex; bool isLastRow = remainingItems <= columnCount; startColumnIndex = 0; endColumnIndex = isLastRow ? remainingItems - 1 : columnCount - 1; } } columnIndex = startColumnIndex; } else { // We are interating through the cells in a row columnIndex += incr; } } prevCategory = category; } if (highlightedGalleryItem != null) { highlightedGalleryItem.IsHighlighted = true; return true; } } } return false; }
internal static bool NavigatePageAndHighlightRibbonGalleryItem(RibbonGallery gallery, RibbonGalleryItem galleryItem, FocusNavigationDirection direction) { RibbonGalleryItem highlightedGalleryItem; return NavigatePageAndHighlightRibbonGalleryItem(gallery, galleryItem, direction, out highlightedGalleryItem); }
// This method is called when trying to navigate a single step up, down, left or // right within a RibbonGallery. internal static bool NavigateAndHighlightGalleryItem(RibbonGalleryItem focusedElement, FocusNavigationDirection direction) { if (focusedElement != null) { RibbonGalleryItem predictedFocus = focusedElement.PredictFocus(direction) as RibbonGalleryItem; if (predictedFocus != null) { predictedFocus.IsHighlighted = true; return true; } } return false; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 6 "..\..\..\MainWindow.xaml" ((CAGA.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded); #line default #line hidden #line 6 "..\..\..\MainWindow.xaml" ((CAGA.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.RibbonWindow_Closing); #line default #line hidden return; case 2: this.mainGrid = ((System.Windows.Controls.Grid)(target)); return; case 3: this.ribbon = ((Microsoft.Windows.Controls.Ribbon.Ribbon)(target)); return; case 4: this.RibbonMapGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 5: this.OpenMapBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 24 "..\..\..\MainWindow.xaml" this.OpenMapBtn.Click += new System.Windows.RoutedEventHandler(this.OpenMapBtn_Click); #line default #line hidden return; case 6: this.SaveMapBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 25 "..\..\..\MainWindow.xaml" this.SaveMapBtn.Click += new System.Windows.RoutedEventHandler(this.SaveMapBtn_Click); #line default #line hidden return; case 7: this.RibbonLayersGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 8: this.AddLayerBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 29 "..\..\..\MainWindow.xaml" this.AddLayerBtn.Click += new System.Windows.RoutedEventHandler(this.AddLayerBtn_Click); #line default #line hidden return; case 9: this.RemoveLayerBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 30 "..\..\..\MainWindow.xaml" this.RemoveLayerBtn.Click += new System.Windows.RoutedEventHandler(this.RemoveLayerBtn_Click); #line default #line hidden return; case 10: this.RibbonNavGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 11: this.PanMapBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonToggleButton)(target)); #line 33 "..\..\..\MainWindow.xaml" this.PanMapBtn.Checked += new System.Windows.RoutedEventHandler(this.PanMapBtn_Checked); #line default #line hidden #line 33 "..\..\..\MainWindow.xaml" this.PanMapBtn.Unchecked += new System.Windows.RoutedEventHandler(this.PanMapBtn_Unchecked); #line default #line hidden return; case 12: this.ZoomInBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonToggleButton)(target)); #line 34 "..\..\..\MainWindow.xaml" this.ZoomInBtn.Checked += new System.Windows.RoutedEventHandler(this.ZoomInBtn_Checked); #line default #line hidden #line 34 "..\..\..\MainWindow.xaml" this.ZoomInBtn.Unchecked += new System.Windows.RoutedEventHandler(this.ZoomInBtn_Unchecked); #line default #line hidden return; case 13: this.ZoomOutBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonToggleButton)(target)); #line 35 "..\..\..\MainWindow.xaml" this.ZoomOutBtn.Checked += new System.Windows.RoutedEventHandler(this.ZoomOutBtn_Checked); #line default #line hidden #line 35 "..\..\..\MainWindow.xaml" this.ZoomOutBtn.Unchecked += new System.Windows.RoutedEventHandler(this.ZoomOutBtn_Unchecked); #line default #line hidden return; case 14: this.ZoomToExtentBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 36 "..\..\..\MainWindow.xaml" this.ZoomToExtentBtn.Click += new System.Windows.RoutedEventHandler(this.ZoomToExtentBtn_Click); #line default #line hidden return; case 15: this.ZoomToPrevBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 37 "..\..\..\MainWindow.xaml" this.ZoomToPrevBtn.Click += new System.Windows.RoutedEventHandler(this.ZoomToPrevBtn_Click); #line default #line hidden return; case 16: this.ZoomToNextBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 38 "..\..\..\MainWindow.xaml" this.ZoomToNextBtn.Click += new System.Windows.RoutedEventHandler(this.ZoomToNextBtn_Click); #line default #line hidden return; case 17: this.ZoomToLayerBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 39 "..\..\..\MainWindow.xaml" this.ZoomToLayerBtn.Click += new System.Windows.RoutedEventHandler(this.ZoomToLayerBtn_Click); #line default #line hidden return; case 18: this.RibbonSelectionGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 19: this.SelectFeatureBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonSplitButton)(target)); #line 42 "..\..\..\MainWindow.xaml" this.SelectFeatureBtn.Click += new System.Windows.RoutedEventHandler(this.SelectFeatureBtn_Click); #line default #line hidden return; case 20: this.SelectFeatureGallery = ((Microsoft.Windows.Controls.Ribbon.RibbonGallery)(target)); return; case 21: this.SelByRectItem = ((Microsoft.Windows.Controls.Ribbon.RibbonGalleryItem)(target)); #line 45 "..\..\..\MainWindow.xaml" this.SelByRectItem.Selected += new System.Windows.RoutedEventHandler(this.SelectFeatureItem_Selected); #line default #line hidden return; case 22: this.SelByPolyItem = ((Microsoft.Windows.Controls.Ribbon.RibbonGalleryItem)(target)); #line 46 "..\..\..\MainWindow.xaml" this.SelByPolyItem.Selected += new System.Windows.RoutedEventHandler(this.SelectFeatureItem_Selected); #line default #line hidden return; case 23: this.SelByCircleItem = ((Microsoft.Windows.Controls.Ribbon.RibbonGalleryItem)(target)); #line 47 "..\..\..\MainWindow.xaml" this.SelByCircleItem.Selected += new System.Windows.RoutedEventHandler(this.SelectFeatureItem_Selected); #line default #line hidden return; case 24: this.SelByLineItem = ((Microsoft.Windows.Controls.Ribbon.RibbonGalleryItem)(target)); #line 48 "..\..\..\MainWindow.xaml" this.SelByLineItem.Selected += new System.Windows.RoutedEventHandler(this.SelectFeatureItem_Selected); #line default #line hidden return; case 25: this.SelectByGraphicsBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 52 "..\..\..\MainWindow.xaml" this.SelectByGraphicsBtn.Click += new System.Windows.RoutedEventHandler(this.SelectByGraphicsBtn_Click); #line default #line hidden return; case 26: this.UnselectFeatureBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 53 "..\..\..\MainWindow.xaml" this.UnselectFeatureBtn.Click += new System.Windows.RoutedEventHandler(this.UnselectFeatureBtn_Click); #line default #line hidden return; case 27: this.RibbonToolsGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 28: this.IdentifyFeatureBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonToggleButton)(target)); #line 56 "..\..\..\MainWindow.xaml" this.IdentifyFeatureBtn.Checked += new System.Windows.RoutedEventHandler(this.IdentifyFeatureBtn_Checked); #line default #line hidden #line 56 "..\..\..\MainWindow.xaml" this.IdentifyFeatureBtn.Unchecked += new System.Windows.RoutedEventHandler(this.IdentifyFeatureBtn_Unchecked); #line default #line hidden return; case 29: this.AttrTableBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 57 "..\..\..\MainWindow.xaml" this.AttrTableBtn.Click += new System.Windows.RoutedEventHandler(this.AttrTableBtn_Click); #line default #line hidden return; case 30: this.RibbonDrawingGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 31: this.DrawPolygonBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonToggleButton)(target)); #line 60 "..\..\..\MainWindow.xaml" this.DrawPolygonBtn.Checked += new System.Windows.RoutedEventHandler(this.DrawPolygonBtn_Checked); #line default #line hidden #line 60 "..\..\..\MainWindow.xaml" this.DrawPolygonBtn.Unchecked += new System.Windows.RoutedEventHandler(this.DrawPolygonBtn_Unchecked); #line default #line hidden return; case 32: this.RibbonDlgMgrGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 33: this.ToggleDlgBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 66 "..\..\..\MainWindow.xaml" this.ToggleDlgBtn.Click += new System.Windows.RoutedEventHandler(this.ToggleDlgBtn_Click); #line default #line hidden return; case 34: this.RibbonSpeechRecGrp = ((Microsoft.Windows.Controls.Ribbon.RibbonGroup)(target)); return; case 35: this.ToggleSpeechBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 69 "..\..\..\MainWindow.xaml" this.ToggleSpeechBtn.Click += new System.Windows.RoutedEventHandler(this.ToggleSpeechBtn_Click); #line default #line hidden return; case 36: this.SimSpeechBtn = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)(target)); #line 70 "..\..\..\MainWindow.xaml" this.SimSpeechBtn.Click += new System.Windows.RoutedEventHandler(this.SimSpeechBtn_Click); #line default #line hidden return; case 37: this.dockManager = ((AvalonDock.DockingManager)(target)); return; case 38: this.LayersPanel = ((AvalonDock.DockableContent)(target)); return; case 39: this.tocGrid = ((System.Windows.Controls.Grid)(target)); return; case 40: #line 84 "..\..\..\MainWindow.xaml" ((AvalonDock.DocumentPane)(target)).SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.DocumentPane_SelectionChanged); #line default #line hidden return; case 41: this.MapPanel = ((AvalonDock.DocumentContent)(target)); return; case 42: this.mapGrid = ((System.Windows.Controls.Grid)(target)); return; case 43: this.LayoutPanel = ((AvalonDock.DocumentContent)(target)); return; case 44: this.layoutGrid = ((System.Windows.Controls.Grid)(target)); return; case 45: this.KinectCtrlPanel = ((AvalonDock.DockablePane)(target)); return; case 46: this.ColorDisplayPanel = ((AvalonDock.DockableContent)(target)); return; case 47: this.colorDisplay = ((System.Windows.Controls.Image)(target)); return; case 48: this.skeletonCanvas = ((System.Windows.Controls.Canvas)(target)); return; case 49: this.DepthDisplayPanel = ((AvalonDock.DockableContent)(target)); return; case 50: this.depthDisplay = ((System.Windows.Controls.Image)(target)); return; case 51: this.DevCtrlPanel = ((AvalonDock.DockablePane)(target)); return; case 52: this.statusTB = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
// To find out if the RibbonGallery contains the specified value // in any of the available items. If ignoreItemContainerGeneratorStatus // is true then skip the container generation check. private bool ContainsValue( object value, bool ignoreItemContainerGeneratorStatus, out object item, out RibbonGalleryCategory category, out RibbonGalleryItem galleryItem) { item = null; category = null; galleryItem = null; if (!ignoreItemContainerGeneratorStatus && ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { return true; } ContentControl dummyElement = new ContentControl(); foreach (object current in Items) { category = ItemContainerGenerator.ContainerFromItem(current) as RibbonGalleryCategory; if (category != null) { for (int index=0; index<category.Items.Count; index++) { item = category.Items[index]; object itemValue = GetSelectableValueFromItem(item, dummyElement); if (VerifyEqual(value, itemValue)) { galleryItem = category.ItemContainerGenerator.ContainerFromIndex(index) as RibbonGalleryItem; return true; } item = null; } category = null; } } return false; }
// To find out if the RibbonGallery contains the specified item. // If ignoreItemContainerGeneratorStatus is true then skip the // container generation check. private bool ContainsItem( object item, bool ignoreItemContainerGeneratorStatus, out RibbonGalleryCategory category, out RibbonGalleryItem galleryItem) { category = null; galleryItem = null; int index = -1; if (!ignoreItemContainerGeneratorStatus && ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { return true; } foreach (object current in Items) { category = ItemContainerGenerator.ContainerFromItem(current) as RibbonGalleryCategory; if (category != null) { index = category.Items.IndexOf(item); if (index > -1) { galleryItem = category.ItemContainerGenerator.ContainerFromIndex(index) as RibbonGalleryItem; break; } category = null; } } return index > -1; }
// Update all selection properties viz. // - SelectedItem // - SelectedValue // - CurrentItem // - IsSelected // - SelectedContainers internal void ChangeSelection(object item, RibbonGalleryItem container, bool isSelected) { if (IsSelectionChangeActive) { return; } object oldItem = SelectedItem; object newItem = item; bool selectedItemChanged = !VerifyEqual(oldItem, newItem); try { IsSelectionChangeActive = true; if (isSelected == selectedItemChanged) { // Deselecting a single container. This can only happen // when setting IsSelected to false on a specific container. // Note that neither SelectedItem nor CurrentItem are updated // in this case. We only updated the _selectedContainers and // ContainsSelection properties both of which are specific to // the containers in view. if (!isSelected && container != null) { container.IsSelected = false; int index = _selectedContainers.IndexOf(container); if (index > -1) { _selectedContainers.RemoveAt(index); container.OnUnselected(new RoutedEventArgs(RibbonGalleryItem.UnselectedEvent, container)); } } else { // This is the case where SelectedItem is changing. // We start the processing by deselecting all existing // containers. for (int i = 0; i < _selectedContainers.Count; i++) { RibbonGalleryItem galleryItem = _selectedContainers[i]; galleryItem.IsSelected = false; galleryItem.OnUnselected(new RoutedEventArgs(RibbonGalleryItem.UnselectedEvent, galleryItem)); if (!isSelected) { MoveCurrentToPosition(galleryItem.RibbonGalleryCategory.CollectionView, -1); } } _selectedContainers.Clear(); if (!isSelected) { SelectedItem = null; SelectedValue = null; MoveCurrentToPosition(CollectionView, -1); MoveCurrentToPosition(SourceCollectionView, -1); } } // Select the item if (isSelected) { SelectedItem = item; SelectedValue = GetSelectableValueFromItem(item); // Synchronize currency with the specified SelectedItem. if (container != null) { // This is the case where a single container is selected SynchronizeWithCurrentItem(container.RibbonGalleryCategory, item); } else { // This is the case where the selected item is directly // set in which case we need to additionally find the category // that contains it to perform the currency synchronization SynchronizeWithCurrentItem(); } } } // Select the container and synchronize currency if (isSelected && container != null && !_selectedContainers.Contains(container)) { _selectedContainers.Add(container); container.IsSelected = true; container.OnSelected(new RoutedEventArgs(RibbonGalleryItem.SelectedEvent, container)); } } finally { IsSelectionChangeActive = false; } if (selectedItemChanged) { RoutedPropertyChangedEventArgs<object> args = new RoutedPropertyChangedEventArgs<object>(oldItem, isSelected ? newItem : null, SelectionChangedEvent); this.OnSelectionChanged(args); } }
// Update all highlighting properties viz. // - HighlightedItem // - IsHighlighted // - HighlightedContainer internal void ChangeHighlight(object item, RibbonGalleryItem container, bool isHighlighted) { if (IsHighlightChangeActive) { return; } try { IsHighlightChangeActive = true; if (_highlightedContainer != null) { _highlightedContainer.IsHighlighted = false; } if (!isHighlighted) { _highlightedContainer = null; HighlightedItem = null; } else { _highlightedContainer = container; HighlightedItem = item; if (container != null) { container.IsHighlighted = true; } } } finally { IsHighlightChangeActive = false; } }
/// public RibbonGalleryItemAutomationPeer(RibbonGalleryItem owner) : base(owner) { }
/// <summary> /// Funkction is called, when the drop-down of the main file menu is opened. The function reads the recently-opened-files file and generates items to be shown in the menu. /// </summary> private void fileMenu_DropDownOpened(object sender, EventArgs e) { string[] recent; if (ini.IniReadValue("Options", "useAppDataFolder").Equals("true")) { recent = File.ReadAllLines(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\recent.txt"); } else { recent = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "recent.txt"); } RecentFiles rf = (RecentFiles)this.Resources["MostRecentFiles"]; rf.Clear(); foreach (string s in recent) { RibbonGalleryItem recentFileItem = new RibbonGalleryItem(); String str = s; recentFileItem.Content = str.Substring(str.LastIndexOf('\\') + 1); recentFileItem.Tag = str; recentFileItem.ToolTip = str; recentFileItem.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(recentFileItem_MouseDown); recentFileItem.PreviewKeyDown += new KeyEventHandler(recentFileItem_KeyDown); rf.AddItem(recentFileItem); } }