예제 #1
0
        void _splitButtonGallery_ItemsSourceReady(object sender, EventArgs e)
        {
            // set label
            _splitButtonGallery.Label = "Brushes";

            // prepare helper classes for commands
            _buttons = new RibbonButton[imageListBrushes.Images.Count];
            uint i;

            for (i = 0; i < _buttons.Length; ++i)
            {
                _buttons[i] = new RibbonButton(_ribbon, 2000 + i)
                {
                    Label      = "Label " + i.ToString(),
                    LargeImage = _ribbon.ConvertToUIImage((Bitmap)imageListBrushes.Images[(int)i])
                };
            }

            // set _splitButtonGallery items
            IUICollection itemsSource = _splitButtonGallery.ItemsSource;

            itemsSource.Clear();
            i = 0;
            foreach (Image image in imageListBrushes.Images)
            {
                itemsSource.Add(new GalleryCommandPropertySet()
                {
                    CommandID   = 2000 + i++,
                    CommandType = CommandType.Action,
                    CategoryID  = 1
                });
            }
        }
예제 #2
0
        public QatCommands(RibbonQuickAccessToolbar qat)
        {
            if (qat == null)
            {
                throw new ArgumentNullException(nameof(qat));
            }
            IUICollection qatitemsSource = qat.ItemsSource;

            if (qatitemsSource == null)
            {
                throw new ArgumentException("Qat not initialized");
            }
            _collectionChanged = new UICollectionChangedEvent();
            _collectionChanged.ChangedEvent += CollectionChanged_ChangedEvent;
            _collectionChanged.Attach(qatitemsSource);
            uint   count;
            object item;

            qatitemsSource.GetCount(out count);
            for (uint i = 0; i < count; i++)
            {
                qatitemsSource.GetItem(i, out item);
                GalleryCommandPropertySet galleryItem = GetCommandPropertySet(item);
                _controlCommands.Add(galleryItem);
            }
        }
예제 #3
0
        private void InRibbonGallery_ItemsSourceReady(object sender, EventArgs e)
        {
            // set _inRibbonGallery items
            IUICollection itemsSource = InRibbonGallery.ItemsSource;

            InRibbonGallery.ExecuteEvent += InRibbonGallery_ExecuteEvent;
            itemsSource.Clear();
            Font font = new Font("Segoe UI", 9f);

            for (int i = 0; i < 64; i++)
            {
                Bitmap   image = new Bitmap(32, 32);
                Graphics g     = Graphics.FromImage(image);
                g.FillRectangle(Brushes.Red, new Rectangle(new Point(3, 3), new Size(26, 26)));
                g.DrawString((i + 1).ToString(), font, Brushes.White, 10f, 10f);
                g.Dispose();

                itemsSource.Add(new GalleryItemPropertySet()
                {
                    ItemImage  = Ribbon.ConvertToUIImage((Bitmap)image),
                    CategoryID = (uint)(i + 1),
                    //Label = (i + 1).ToString(),
                });
                uint count;
                itemsSource.GetCount(out count);
                object item;
                itemsSource.GetItem(count - 1, out item);
                GalleryItemPropertySet set = item as GalleryItemPropertySet;
                if (set != null)
                {
                }
            }
        }
예제 #4
0
        private void MakeComboItems()
        {
            IUICollection itemsSource = ComboSelect.ItemsSource;

            if (DataManager.Instance.Session == null)
            {
                ComboSelect.SelectedItem = Constants.UI_Collection_InvalidIndex;
                itemsSource.Clear();
                return;
            }
            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "Session", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            if (DataManager.Instance.LapManager.Count > 1)
            {
                for (int i = 0; i < DataManager.Instance.LapManager.Count; i++)
                {
                    itemsSource.Add(new GalleryItemPropertySet()
                    {
                        Label = "Lap " + (i + 1).ToString(), CategoryID = Constants.UI_Collection_InvalidIndex
                    });
                }
            }
            ComboSelect.SelectedItem = 0;
        }
        public int LoadItemsSource(GalleryItems items, PropVariantRef currentValue, ref PropVariant newValue)
        {
            if (currentValue != null && currentValue.PropVariant.Value is IUICollection)
            {
                IUICollection collection = (IUICollection)currentValue.PropVariant.Value;
                collection.Clear();

                foreach (GalleryItem item in items)
                {
                    SimplePropertySet sps;
                    LoadSimplePropertySet(item, out sps);
                    collection.Add(sps);
                }
                newValue.SetIUnknown(collection);
                return(HRESULT.S_OK);
            }

            List <IUISimplePropertySet> list = new List <IUISimplePropertySet>();

            foreach (GalleryItem item in items)
            {
                SimplePropertySet sps;
                LoadSimplePropertySet(item, out sps);
                list.Add(sps);
            }
            newValue.SetIUnknown(new BasicCollection(list));
            return(HRESULT.S_OK);
        }
예제 #6
0
        private void SetComboValues(RibbonComboBox comboBox)
        {
            IUICollection itemsSource = comboBox.ItemsSource;

            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "0", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "3", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "10", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "15", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource.Add(new GalleryItemPropertySet()
            {
                Label = "30", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            comboBox.SelectedItem = GetSelectedItem(comboBox);
        }
예제 #7
0
        public Size MeasureOverrideHorizontal(IStackBase stack, Size constraint)
        {
            //var padding = panelStack.Padding;

            double measuredWidth  = 0;
            double measuredHeight = 0;

            IUICollection <IUIElement> children = stack.Children;
            int count = stack.Children.Count;

            for (int i = 0; i < count; i++)
            {
                IUIElement child = children[i];
                if (!child.Visible)
                {
                    continue;
                }

                child.Measure(new Size(double.PositiveInfinity, constraint.Height));
                var desiredSize = child.DesiredSize;
                measuredWidth += desiredSize.Width;
                measuredHeight = Math.Max(measuredHeight, desiredSize.Height);
            }

            measuredWidth += MeasureTotalSpacing(stack);
            //measuredWidth += padding.HorizontalThickness;
            //measuredHeight += padding.VerticalThickness;

            var finalWidth  = ResolveWidthConstraints(stack, constraint.Width, measuredWidth);
            var finalHeight = ResolveHeightConstraints(stack, constraint.Height, measuredHeight);

            return(new Size(finalWidth, finalHeight));
        }
예제 #8
0
        public GalleryCategories(IRibbonControl ribbonControl, IUICollection fromGallery)
        {
            if (ribbonControl == null)
            {
                throw new ArgumentNullException(nameof(ribbonControl));
            }
            _ribbonControl = ribbonControl;
            if (fromGallery == null)
            {
                throw new ArgumentException(ribbonControl.ToString() + " not initialized");
            }
            _collectionChanged = new UICollectionChangedEvent();
            _collectionChanged.ChangedEvent += CollectionChanged_ChangedEvent;
            _collectionChanged.Attach(fromGallery);
            uint   count;
            object item;

            fromGallery.GetCount(out count);
            for (uint i = 0; i < count; i++)
            {
                fromGallery.GetItem(i, out item);
                GalleryItemPropertySet galleryItem = GetItemPropertySet(item);
                _controlItems.Add(galleryItem);
            }
        }
예제 #9
0
 /// <summary>
 /// Detach from the previous IUICollection object events
 /// </summary>
 public void Detach()
 {
     if (_collection != null)
     {
         UnregisterComEvent(_collection, _cookie);
         _collection = null;
         _cookie = 0;
     }
 }
        public IUICollection <TStandardUIElement> ToStandardUIElementCollection()
        {
            if (_standardUIElementCollection == null)
            {
                _standardUIElementCollection = new StandardUIElementCollection(this);
            }

            return(_standardUIElementCollection);
        }
 /// <summary>
 /// Detach from the previous IUICollection object events
 /// </summary>
 public void Detach()
 {
     if (_collection != null)
     {
         UnregisterComEvent(_collection, _cookie);
         _collection = null;
         _cookie     = 0;
     }
 }
        private int RegisterComEvent(IUICollection collection)
        {
            IConnectionPoint connectionPoint = GetConnectionPoint(collection);

            int cookie;

            connectionPoint.Advise(this, out cookie);

            return(cookie);
        }
예제 #13
0
        /// <summary>
        /// Attach to an IUICollection object events
        /// </summary>
        /// <param name="collection">IUICollection object</param>
        public void Attach(IUICollection collection)
        {
            if (_collection != null)
            {
                Detach();
            }

            _collection = collection;

            _cookie = RegisterComEvent(_collection);
        }
예제 #14
0
        void _splitButtonGallery_CategoriesReady(object sender, EventArgs e)
        {
            // set _splitButtonGallery categories
            IUICollection categories = _splitButtonGallery.Categories;

            categories.Clear();
            categories.Add(new GalleryItemPropertySet()
            {
                Label = "Category 1", CategoryID = 1
            });
        }
        /// <summary>
        /// Attach to an IUICollection object events
        /// </summary>
        /// <param name="collection">IUICollection object</param>
        public void Attach(IUICollection collection)
        {
            if (_collection != null)
            {
                Detach();
            }

            _collection = collection;

            _cookie = RegisterComEvent(_collection);
        }
예제 #16
0
        void _buttonDropE_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            IUICollection itemsSource1 = _comboBox1.ItemsSource;
            uint          count;

            itemsSource1.GetCount(out count);
            ++count;
            itemsSource1.Add(new GalleryItemPropertySet()
            {
                Label = "Label " + count.ToString(), CategoryID = Constants.UI_Collection_InvalidIndex
            });
        }
예제 #17
0
        private IConnectionPoint GetConnectionPoint(IUICollection collection)
        {
            // get connection point container
            IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)collection;

            // get connection point for IUICollectionChangedEvent
            Guid guid = new Guid(RibbonIIDGuid.IUICollectionChangedEvent);
            IConnectionPoint connectionPoint;
            connectionPointContainer.FindConnectionPoint(ref guid, out connectionPoint);

            return connectionPoint;
        }
        private IConnectionPoint GetConnectionPoint(IUICollection collection)
        {
            // get connection point container
            IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)collection;

            // get connection point for IUICollectionChangedEvent
            Guid             guid = new Guid(RibbonIIDGuid.IUICollectionChangedEvent);
            IConnectionPoint connectionPoint;

            connectionPointContainer.FindConnectionPoint(ref guid, out connectionPoint);

            return(connectionPoint);
        }
예제 #19
0
        void _inRibbonGallery_ItemsSourceReady(object sender, EventArgs e)
        {
            // set _inRibbonGallery items
            IUICollection itemsSource = _inRibbonGallery.ItemsSource;

            itemsSource.Clear();
            foreach (Image image in imageListShapes.Images)
            {
                itemsSource.Add(new GalleryItemPropertySet()
                {
                    ItemImage = _ribbon.ConvertToUIImage((Bitmap)image)
                });
            }
        }
예제 #20
0
        void _comboBox2_CategoriesReady(object sender, EventArgs e)
        {
            // set _comboBox2 categories
            IUICollection categories2 = _comboBox2.Categories;

            categories2.Clear();
            categories2.Add(new GalleryItemPropertySet()
            {
                Label = "Category 1", CategoryID = 1
            });
            categories2.Add(new GalleryItemPropertySet()
            {
                Label = "Category 2", CategoryID = 2
            });
        }
예제 #21
0
        void _dropDownGallery_ItemsSourceReady(object sender, EventArgs e)
        {
            // set label
            _dropDownGallery.Label = "Size";

            // set _dropDownGallery items
            IUICollection itemsSource = _dropDownGallery.ItemsSource;

            itemsSource.Clear();
            foreach (Image image in imageListLines.Images)
            {
                itemsSource.Add(new GalleryItemPropertySet()
                {
                    ItemImage = _ribbon.ConvertToUIImage((Bitmap)image)
                });
            }
        }
예제 #22
0
        void _comboBox2_ItemsSourceReady(object sender, EventArgs e)
        {
            // set _comboBox2 items
            IUICollection itemsSource2 = _comboBox2.ItemsSource;

            itemsSource2.Clear();
            itemsSource2.Add(new GalleryItemPropertySet()
            {
                Label = "Label 1", CategoryID = 1
            });
            itemsSource2.Add(new GalleryItemPropertySet()
            {
                Label = "Label 2", CategoryID = 1
            });
            itemsSource2.Add(new GalleryItemPropertySet()
            {
                Label = "Label 3", CategoryID = 2
            });
        }
예제 #23
0
        void _comboBox3_ItemsSourceReady(object sender, EventArgs e)
        {
            // set combobox3 items
            IUICollection itemsSource3 = _comboBox3.ItemsSource;

            itemsSource3.Clear();
            itemsSource3.Add(new GalleryItemPropertySet()
            {
                Label = "Label 1", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource3.Add(new GalleryItemPropertySet()
            {
                Label = "Label 2", CategoryID = Constants.UI_Collection_InvalidIndex
            });
            itemsSource3.Add(new GalleryItemPropertySet()
            {
                Label = "Label 3", CategoryID = Constants.UI_Collection_InvalidIndex
            });
        }
예제 #24
0
        void _buttonNew_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // changing QAT commands list
            IUICollection itemsSource = _ribbonQuickAccessToolbar.ItemsSource;

            itemsSource.Clear();
            itemsSource.Add(new GalleryCommandPropertySet()
            {
                CommandID = (uint)RibbonMarkupCommands.cmdButtonNew
            });
            itemsSource.Add(new GalleryCommandPropertySet()
            {
                CommandID = (uint)RibbonMarkupCommands.cmdButtonOpen
            });
            itemsSource.Add(new GalleryCommandPropertySet()
            {
                CommandID = (uint)RibbonMarkupCommands.cmdButtonSave
            });
        }
예제 #25
0
        /// <summary>
        ///
        /// </summary>
        public HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
        {
            if (key == RibbonProperties.ItemsSource)
            {
                if (_itemsSource != null)
                {
                    IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value;

                    itemsSource.Clear();
                    uint count;
                    _itemsSource.GetCount(out count);
                    for (uint i = 0; i < count; ++i)
                    {
                        object item;
                        _itemsSource.GetItem(i, out item);
                        itemsSource.Add(item);
                    }
                }
            }
            return(HRESULT.S_OK);
        }
 protected void WaitForItemToGetLoaded(IUICollection uiCollection, string itemCss, int indexOfTheItem = 0, int waitTimeInMilliseconds = 5000)
 {
     Driver.WaitUntil(() => uiCollection.Count > 0 && uiCollection.GetItemByIndex(indexOfTheItem, itemCss) != null, waitTimeInMilliseconds);
 }
예제 #27
0
        private void ComboSelect_ItemsSourceReady(object sender, EventArgs e)
        {
            IUICollection itemsSource1 = ComboSelect.ItemsSource;

            itemsSource1.Clear();
        }
예제 #28
0
        private void UnregisterComEvent(IUICollection collection, int cookie)
        {
            IConnectionPoint connectionPoint = GetConnectionPoint(collection);

            connectionPoint.Unadvise(cookie);
        }
예제 #29
0
        private int RegisterComEvent(IUICollection collection)
        {
            IConnectionPoint connectionPoint = GetConnectionPoint(collection);

            int cookie;
            connectionPoint.Advise(this, out cookie);

            return cookie;
        }
예제 #30
0
 public GalleryItems(IRibbonControl ribbonControl, IUICollection fromGallery) : base(ribbonControl, fromGallery)
 {
 }
        private void UnregisterComEvent(IUICollection collection, int cookie)
        {
            IConnectionPoint connectionPoint = GetConnectionPoint(collection);

            connectionPoint.Unadvise(cookie);
        }
            public GridStructure(IGrid grid, double widthConstraint, double heightConstraint)
            {
                _grid = grid;

                _gridWidthConstraint  = widthConstraint;
                _gridHeightConstraint = heightConstraint;

                _explicitGridHeight = _grid.Height;
                _explicitGridWidth  = _grid.Width;
                _gridMaxHeight      = _grid.MaxHeight;
                _gridMinHeight      = _grid.MinHeight;
                _gridMaxWidth       = _grid.MaxWidth;
                _gridMinWidth       = _grid.MinWidth;


                // Cache these GridLayout properties so we don't have to keep looking them up via _grid
                // (Property access via _grid may have performance implications for some SDKs.)
                //_padding = grid.Padding;
                _columnSpacing     = grid.ColumnSpacing;
                _rowSpacing        = grid.RowSpacing;
                _rowDefinitions    = grid.RowDefinitions;
                _columnDefinitions = grid.ColumnDefinitions;

                if (_rowDefinitions.Count == 0)
                {
                    // Since no rows are specified, we'll create an implied row 0
                    _rows    = new Row[1];
                    _rows[0] = new Row(new ImpliedRow());
                }
                else
                {
                    _rows = new Row[_rowDefinitions.Count];

                    for (int n = 0; n < _rowDefinitions.Count; n++)
                    {
                        _rows[n] = new Row(_rowDefinitions[n]);
                    }
                }

                if (_columnDefinitions.Count == 0)
                {
                    // Since no columns are specified, we'll create an implied column 0
                    _columns    = new Column[1];
                    _columns[0] = new Column(new ImpliedColumn());
                }
                else
                {
                    _columns = new Column[_columnDefinitions.Count];

                    for (int n = 0; n < _columnDefinitions.Count; n++)
                    {
                        _columns[n] = new Column(_columnDefinitions[n]);
                    }
                }

                IUICollection <IUIElement> gridChildren = grid.Children;

                // We could work out the _childrenToLayOut array (with the Collapsed items filtered out) with a Linq 1-liner
                // but doing it the hard way means we don't allocate extra enumerators, especially if we're in the
                // happy path where _none_ of the children are Collapsed.
                var gridChildCount = gridChildren.Count;

                _childrenToLayOut = new IUIElement[gridChildCount];
                int currentChild = 0;

                for (int n = 0; n < gridChildCount; n++)
                {
                    IUIElement child = gridChildren[n];

                    if (child.Visible)
                    {
                        _childrenToLayOut[currentChild] = child;
                        currentChild += 1;
                    }
                }

                if (currentChild < gridChildCount)
                {
                    Array.Resize(ref _childrenToLayOut, currentChild);
                }

                // We'll ignore any collapsed child views during layout
                _cells = new Cell[_childrenToLayOut.Length];

                InitializeCells();

                MeasureCells();
            }