Exemplo n.º 1
0
        // PreComputing MaxItemHeight and MaxItemWidth as the Measure algorithms of parent panels of Items will need it already
        // If it is in InRibbonGalleryMode.
        private void PreComputeMaxRibbonGalleryItemWidthAndHeight()
        {
            UIElementCollection children = InternalChildren;
            Size   childConstraint       = new Size(double.PositiveInfinity, double.PositiveInfinity);
            double maxItemHeight         = 0;
            int    childrenCount         = children.Count;
            double maxColumnWidth        = 0;

            for (int i = 0; i < childrenCount; i++)
            {
                RibbonGalleryCategory   child     = children[i] as RibbonGalleryCategory;
                RibbonGalleryItemsPanel itemPanel = child.ItemsHostSite as RibbonGalleryItemsPanel;
                if (itemPanel != null)
                {
                    int itemPanelChildrenCount = itemPanel.Children.Count;
                    for (int j = 0; j < itemPanelChildrenCount; j++)
                    {
                        RibbonGalleryItem item = (RibbonGalleryItem)itemPanel.Children[j];
                        item.Measure(childConstraint);
                        Size itemSize = item.DesiredSize;
                        maxColumnWidth = Math.Max(maxColumnWidth, itemSize.Width);
                        maxItemHeight  = Math.Max(maxItemHeight, itemSize.Height);
                    }
                }
            }

            RibbonGallery gallery = this.Gallery;

            if (gallery != null)
            {
                gallery.MaxItemHeight  = maxItemHeight;
                gallery.MaxColumnWidth = maxColumnWidth;
            }
        }
Exemplo n.º 2
0
        private void RibbonGallery_SelectionChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            // Application.Current.ApplyTheme("ShinyDarkTeal");
            ResourceDictionary resource = null;
            //  ComboBoxItem cbi = (ComboBoxItem)comboBox1.SelectedItem;

            RibbonGalleryItem cbi   = (RibbonGalleryItem)cb.SelectedItem;
            string            sitem = cbi.Content.ToString();

            try
            {
                resource = Application.LoadComponent((new Uri("/PresentationFramework.Royale, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/Royale.normalcolor.xaml", UriKind.Relative))) as ResourceDictionary;
                // resource = Application.LoadComponent((new Uri("/PresentationFramework.Luna, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/luna.homestead.xaml", UriKind.Relative))) as ResourceDictionary;
                //resource = Application.LoadComponent((new Uri("/PresentationFramework.Luna, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/luna.metallic.xaml", UriKind.Relative))) as ResourceDictionary;
                // resource = Application.LoadComponent((new Uri("/PresentationFramework.Classic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/classic.xaml", UriKind.Relative))) as ResourceDictionary;
                // resource = Application.LoadComponent(new Uri(@"Themes\" + sitem + ".xaml", UriKind.Relative)) as ResourceDictionary;
            }
            catch
            {
            }

            if (resource != null)
            {
                if (Application.Current.Resources.MergedDictionaries.Count > 0)
                {
                    Application.Current.Resources.MergedDictionaries.Clear();
                }
                Application.Current.Resources.MergedDictionaries.Add(resource);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// call wrapper.BringIntoView
        /// </summary>
        void IScrollItemProvider.ScrollIntoView()
        {
            RibbonGalleryItem ribbonGalleryItem = GetOwningRibbonGalleryItem();

            if (ribbonGalleryItem != null)
            {
                ribbonGalleryItem.BringIntoView();
            }
        }
        /// <summary>
        /// call wrapper.BringIntoView
        /// </summary>
        void IScrollItemProvider.ScrollIntoView()
        {
            RibbonGalleryItem ribbonGalleryItem = GetWrapper() as RibbonGalleryItem;

            if (ribbonGalleryItem != null)
            {
                ribbonGalleryItem.BringIntoView();
            }
        }
        private void OnItemPointerExit(object sender, RibbonRoutedEventArgs e)
        {
            RibbonGalleryItem selecteditem = (RibbonGalleryItem)(sender as RibbonGallery).SelectedItem;

            if (selecteditem != null)
            {
                viewModel.FontSize   = selecteditem.FontSize;
                viewModel.FontWeight = selecteditem.FontWeight;
            }
        }
        private void OnItemPointerEnter(object sender, RibbonRoutedEventArgs e)
        {
            RibbonGalleryItem selecteditem = (e.Source) as RibbonGalleryItem;

            if (selecteditem != null)
            {
                viewModel.FontSize   = selecteditem.FontSize;
                viewModel.FontWeight = selecteditem.FontWeight;
            }
        }
Exemplo n.º 7
0
        private RibbonGalleryItem CreateFileRibbionItem(string file)
        {
            RibbonGalleryItem ribbonGalleryItem = new RibbonGalleryItem();

            ribbonGalleryItem.Content     = file.Substring(file.LastIndexOf('\\', file.LastIndexOf('\\') - 1) + 1);
            ribbonGalleryItem.ToolTip     = file;
            ribbonGalleryItem.DataContext = file;
            ribbonGalleryItem.Selected   += new RoutedEventHandler(this.OpenRecentFileClick);
            return(ribbonGalleryItem);
        }
Exemplo n.º 8
0
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     //
     this.m_RibbonGalleryItem = base.Component as RibbonGalleryItem;
     if (this.m_RibbonGalleryItem == null)
     {
         GISShare.Controls.WinForm.WFNew.Forms.TBMessageBox.Show("RibbonGalleryItem == null");
         return;
     }
 }
Exemplo n.º 9
0
 static public RibbonGalleryItem CmbPick(RibbonGalleryCategory cat, string tag)
 {
     if (tag == null)
         return null;
     for (int i = 0; i < cat.Items.Count; i++)
     {
         RibbonGalleryItem item = (cat.Items[i] as RibbonGalleryItem);
         if (item.Tag != null && item.Tag.ToString().Equals(tag))
             return item;
     }
     return null;
 }
Exemplo n.º 10
0
        void ISelectionItemProvider.RemoveFromSelection()
        {
            RibbonGalleryItem ribbonGalleryItem = GetOwningRibbonGalleryItem();

            if (ribbonGalleryItem != null)
            {
                ribbonGalleryItem.IsSelected = false;
            }
            else
            {
                throw new ElementNotAvailableException();
            }
        }
Exemplo n.º 11
0
        void AddView(string view)
        {
            var fields      = view.Split(',');
            var viewDesc    = $"{fields[0]} by {fields[1]} and {fields[2]}";
            var viewTitle   = $"{fields[1]}";
            var gallaryItem = new RibbonGalleryItem();

            gallaryItem.Text        = viewTitle;
            gallaryItem.Description = viewDesc;
            gallaryItem.ToolTip     = viewDesc;
            gallaryItem.Tag         = view;
            ribbonGallery1.Items.Add(gallaryItem);
        }
        void ISelectionItemProvider.Select()
        {
            RibbonGalleryItem ribbonGalleryItem = GetWrapper() as RibbonGalleryItem;

            if (ribbonGalleryItem != null)
            {
                ribbonGalleryItem.IsSelected = true;
            }
            else
            {
                throw new ElementNotAvailableException();
            }
        }
Exemplo n.º 13
0
        void SetupRibbon()
        {
            backstageViewTab1.Control = panel1;
            rGallery.AllowZooming     = true;
            foreach (var view in pivotView1.Views)
            {
                var gi = new RibbonGalleryItem(view.Name)
                {
                    GroupName = view.GroupName, ID = view.Name, ToolTip = view.Name
                };
                rGallery.Items.Add(gi);
            }

            cbShowPanel.Checked = pivotView1.ShowFlexPivotPanel;
        }
Exemplo n.º 14
0
        internal RibbonGalleryItem GetOwningRibbonGalleryItem()
        {
            RibbonGalleryItem          owningRibbonGalleryItem    = null;
            ItemsControlAutomationPeer itemsControlAutomationPeer = ItemsControlAutomationPeer;

            if (itemsControlAutomationPeer != null)
            {
                RibbonGalleryCategory containingCategory = (RibbonGalleryCategory)(itemsControlAutomationPeer.Owner);
                if (containingCategory != null)
                {
                    owningRibbonGalleryItem = (RibbonGalleryItem)containingCategory.ItemContainerGenerator.ContainerFromItem(Item);
                }
            }
            return(owningRibbonGalleryItem);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Prepares the localisation.
        /// </summary>
        private void PrepareLocalisation()
        {
            foreach (string lang in Settings.Default.AvailableLanguages.Split(';'))
            {
                CultureInfo       culture = new CultureInfo(lang);
                RibbonGalleryItem item    = new RibbonGalleryItem();
                item.Content   = culture.Parent.NativeName + " (" + culture.Parent.EnglishName + ")";
                item.Tag       = culture;
                item.Selected += new RoutedEventHandler(language_Selected);
                ribbonGalleryCategoryLanguages.Items.Add(item);

                if (culture.TwoLetterISOLanguageName == Settings.Default.SelectedLanguage)
                {
                    SetUICulture(culture);
                }
            }
        }
Exemplo n.º 16
0
        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);
                }
            }
        }
Exemplo n.º 17
0
        /// <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);
        }
Exemplo n.º 18
0
        private void DoBorderStyle(RibbonGalleryItem rgi)
        {
            UIAction a;

            if (!TryGetAction(rgi.Tag as string, out a))
            {
                return;
            }

            Doc.DashStyle borderStyle;
            try
            {
                borderStyle = (Doc.DashStyle)a.Value;
            }
            catch
            {
                return;
            }
            _flexDesigner.DoSetBorderStyle(borderStyle);
        }
Exemplo n.º 19
0
        /// <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);
        }
Exemplo n.º 20
0
 private bool SelectCompnentMouseUp(RibbonGalleryItem ribbonGalleryItem, Point point)
 {
     if (ribbonGalleryItem == null)
     {
         return(false);
     }
     //
     foreach (BaseItem one in ribbonGalleryItem.BaseItems)
     {
         if (this.SelectCompnentMouseUp(one as ButtonGroupItem, point))
         {
             return(true);
         }
         //
         if (one.DesignMouseClickRectangleContainsEx(point))
         {
             ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
             if (pSelectionService != null)
             {
                 this.m_Item2 = one;
                 if (ribbonGalleryItem.BaseItems.ExchangeItem(this.m_Item1, this.m_Item2))
                 {
                     pSelectionService.SetSelectedComponents(new Component[] { this.m_Item1 as Component }, SelectionTypes.Primary);
                     this.m_RibbonGalleryRow.Refresh();
                     return(true);
                 }
                 else
                 {
                     pSelectionService.SetSelectedComponents(new Component[] { one as Component }, SelectionTypes.Primary);
                     this.m_RibbonGalleryRow.Refresh();
                     return(true);
                 }
             }
         }
     }
     //
     return(false);
 }
Exemplo n.º 21
0
 private bool SelectCompnentMouseDown(RibbonGalleryItem ribbonGalleryItem, Point point)
 {
     if (ribbonGalleryItem == null)
     {
         return(false);
     }
     //
     foreach (BaseItem one in ribbonGalleryItem.BaseItems)
     {
         if (this.SelectCompnentMouseDown(one as ButtonGroupItem, point))
         {
             return(true);
         }
         //
         if (one.DesignMouseClickRectangleContainsEx(point))
         {
             ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
             if (pSelectionService != null)
             {
                 this.m_Item1 = one;
                 pSelectionService.SetSelectedComponents(new Component[] { one as Component }, SelectionTypes.Primary);
                 this.m_RibbonGalleryRow.Refresh();
                 return(true);
             }
         }
     }
     //
     if (ribbonGalleryItem.ScrollUpButtonRectangle.Contains(point))
     {
         ribbonGalleryItem.TopViewItemIndex++;
     }
     if (ribbonGalleryItem.ScrollDownButtonRectangle.Contains(point))
     {
         ribbonGalleryItem.TopViewItemIndex--;
     }
     //
     return(false);
 }
Exemplo n.º 22
0
        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;
            }
        }
Exemplo n.º 23
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var items  = new List <RibbonGalleryItem>();
            var values = value as IList <string>;

            if (values != null)
            {
                var empty = new RibbonGalleryItem();
                empty.Content = FILTER_ALL;
                items.Add(empty);
                var orderedValues = values.OrderBy(item => item);
                foreach (var v in orderedValues)
                {
                    if (!string.IsNullOrEmpty(v))
                    {
                        var item = new RibbonGalleryItem();
                        item.Content = v;
                        items.Add(item);
                    }
                }
            }
            return(items);
        }
Exemplo n.º 24
0
        private void UpdateRendererList()
        {
            var list = from value in Plugin.Manager.PluginManager.PluginRendererList
                       orderby value.Group.Name ascending
                       group value by value.Group;

            foreach (var group in list)
            {
                RibbonGroup rgGroup = new RibbonGroup();
                rgGroup.Header           = group.Key.Name;
                rgGroup.SmallImageSource = group.Key.Image.Source;
                rgGroup.Tag = group.Key;

                rtRenderer.Items.Add(rgGroup);


                /* Effects */
                IEnumerator <IRenderer> renderers = group.GetEnumerator();
                while (renderers.MoveNext())
                {
                    if (renderers.Current.DefaultCount > 0)
                    {
                        RibbonMenuButton btn = new RibbonMenuButton();
                        btn.Label            = renderers.Current.Name;
                        btn.SmallImageSource = renderers.Current.Icon.Source;

                        btn.ToolTipTitle             = renderers.Current.Name;
                        btn.ToolTipImageSource       = BitmapFrame.Create(new Uri("pack://application:,,, /Effect FX;component/Resources/Info.ico"));
                        btn.ToolTipDescription       = renderers.Current.Description;
                        btn.ToolTipFooterTitle       = renderers.Current.Group.Name;
                        btn.ToolTipFooterImageSource = renderers.Current.Group.Image.Source;
                        btn.ToolTipFooterDescription = renderers.Current.Group.Description;

                        btn.Tag = renderers.Current;

                        RibbonGallery gallery = new RibbonGallery();
                        gallery.MaxHeight = 500;
                        gallery.Command   = (ICommand)Resources["cmdImageNull"];
                        RibbonGalleryCategory cat = new RibbonGalleryCategory();
                        gallery.Items.Add(cat);

                        for (int i = 0; i < renderers.Current.DefaultCount; i++)
                        {
                            RibbonGalleryItem item  = new RibbonGalleryItem();
                            Image             image = new Image();
                            image.Width               = 230;
                            image.Height              = 124;
                            image.Stretch             = Stretch.UniformToFill;
                            image.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                            image.Source              = BitmapFrame.Create(new Uri("pack://application:,,, /Effect FX;component/Resources/preview.png"));
                            image.Source              = renderers.Current.GenerateImage(image.Source as BitmapSource, i);
                            image.Tag = new KeyValuePair <int, IRenderer>(i, renderers.Current);
                            previewImageList.Add(image);
                            item.Content = image;
                            cat.Items.Add(item);

                            int finalIndex = i;
                            image.MouseDown += (s, e) =>
                            {
                                //Console.WriteLine("OK: " + finalIndex);
                                manager.AddAction((btn.Tag as IRenderer).Name, imgPicture.Source as BitmapFrame);
                                imgPicture.Source = (btn.Tag as IRenderer).GenerateImage(
                                    imgPicture.Source as BitmapFrame, finalIndex);
                                UpdatePreviewImages();

                                gallery.SelectedItem = null;
                            };
                        }

                        btn.Items.Add(gallery);
                        rgGroup.Items.Add(btn);
                    }
                    else
                    {
                        RibbonButton btn = new RibbonButton();
                        btn.Label            = renderers.Current.Name;
                        btn.SmallImageSource = renderers.Current.Icon.Source;

                        btn.ToolTipTitle             = renderers.Current.Name;
                        btn.ToolTipImageSource       = BitmapFrame.Create(new Uri("pack://application:,,, /Effect FX;component/Resources/Info.ico"));
                        btn.ToolTipDescription       = renderers.Current.Description;
                        btn.ToolTipFooterTitle       = renderers.Current.Group.Name;
                        btn.ToolTipFooterImageSource = renderers.Current.Group.Image.Source;
                        btn.ToolTipFooterDescription = renderers.Current.Group.Description;

                        btn.Tag = renderers.Current;

                        rgGroup.Items.Add(btn);
                    }
                } //while
            }     //for
        }
 ///
 public RibbonGalleryItemAutomationPeer(RibbonGalleryItem owner)
     : base(owner)
 {
 }