コード例 #1
0
ファイル: SplitComboBoxItem.cs プロジェクト: odnodn/mscui
        /// <summary>
        /// Updates the computed header visibility.
        /// </summary>
        /// <param name="obj">The headered list box item.</param>
        /// <param name="args">Dependency Property Changed Event Args.</param>
        private static void Header_Changed(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SplitComboBoxItem splitComboBoxItem = obj as SplitComboBoxItem;

            if (args.NewValue != null)
            {
                splitComboBoxItem.SetValue(SplitComboBoxItem.ComputedHeaderVisibilityProperty, Visibility.Visible);
            }
            else
            {
                splitComboBoxItem.SetValue(SplitComboBoxItem.ComputedHeaderVisibilityProperty, Visibility.Collapsed);
            }
        }
コード例 #2
0
ファイル: SplitComboBoxItem.cs プロジェクト: odnodn/mscui
        /// <summary>
        /// Updates the visual state of the control.
        /// </summary>
        /// <param name="obj">The CascadingListBoxItem.</param>
        /// <param name="args">Dependency Property Changed Event Args.</param>
        private static void IsSelectedValue_Changed(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SplitComboBoxItem splitComboBoxItem = obj as SplitComboBoxItem;

            splitComboBoxItem.UpdateVisualState(true);
        }
コード例 #3
0
        /// <summary>
        /// Updates the items source of a split items control.
        /// </summary>
        /// <param name="splitItemsControl">The split items control.</param>
        public static void UpdateItemsSource(ISplitItemsControl splitItemsControl)
        {
#if !SILVERLIGHT
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(splitItemsControl as DependencyObject))
            {
                return;
            }
#endif

            List <object> items = new List <object>();
            if (splitItemsControl.PrimaryItemsSource != null)
            {
                items.AddRange(IEnumerableHelper.GetItems(splitItemsControl.PrimaryItemsSource));
                if (items.Count > 0)
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (splitItemsControl.PrimaryItemsSourceHeader != null)
                        {
                            splitItemsControl.AddItemHeader(items[i], null);
                        }

                        if (splitItemsControl.AddShortcutKeysToPrimaryItems && i <= 10)
                        {
                            splitItemsControl.AddItemShortcutKey(items[i], ShortcutKeyHelper.GetKeyFromIndex(i));
                        }
                        else
                        {
                            splitItemsControl.RemoveItemShortcutKey(items[i], ShortcutKeyHelper.GetKeyFromIndex(i));
                        }

                        splitItemsControl.RemoveItemSplit(items[i]);
                    }

                    splitItemsControl.AddItemHeader(items[0], splitItemsControl.PrimaryItemsSourceHeader);
                }
            }

            if (splitItemsControl.SecondaryItemsSource != null)
            {
                if (items.Count > 0)
                {
                    splitItemsControl.AddItemSplit(items[items.Count - 1]);
                }

                int itemCount = items.Count;
                items.AddRange(IEnumerableHelper.GetItems(splitItemsControl.SecondaryItemsSource));

                if (splitItemsControl.SecondaryItemsSourceHeader != null && items.Count > itemCount)
                {
                    for (int i = itemCount; i < items.Count; i++)
                    {
                        splitItemsControl.AddItemHeader(items[i], null);
                        splitItemsControl.RemoveItemSplit(items[i]);
                    }

                    splitItemsControl.AddItemHeader(items[itemCount], splitItemsControl.SecondaryItemsSourceHeader);
                }
            }

            if (splitItemsControl.ShowCustomValueOption && splitItemsControl.CustomValueItem != null)
            {
                if (items.Count > 0)
                {
                    splitItemsControl.AddItemSplit(items[items.Count - 1]);
                }

                items.Add(splitItemsControl.CustomValueItem);
            }

            if (splitItemsControl.OtherItemsSource != null && splitItemsControl.ShowOtherItems)
            {
                if (items.Count > 0)
                {
                    splitItemsControl.AddItemSplit(items[items.Count - 1]);
                }

                int itemCount = items.Count;
                items.AddRange(IEnumerableHelper.GetItems(splitItemsControl.OtherItemsSource));
                if (splitItemsControl.OtherItemsSourceHeader != null && items.Count > itemCount)
                {
                    for (int i = itemCount; i < items.Count; i++)
                    {
                        splitItemsControl.AddItemHeader(items[i], null);
                        splitItemsControl.RemoveItemSplit(items[i]);
                    }

                    splitItemsControl.AddItemHeader(items[itemCount], splitItemsControl.OtherItemsSourceHeader);
                }
            }
            else if (splitItemsControl.ShowOtherOption)
            {
                if (items.Count > 0)
                {
                    splitItemsControl.AddItemSplit(items[items.Count - 1]);
                }

                items.Add(splitItemsControl.OtherItem);
            }

            splitItemsControl.ItemsSource = items;

#if !SILVERLIGHT
            if (splitItemsControl is SplitComboBox)
            {
                object selectedItem = null;
                foreach (object item in items)
                {
                    SplitComboBoxItem splitComboBoxItem = item as SplitComboBoxItem;
                    if (splitComboBoxItem != null && splitComboBoxItem.IsSelected)
                    {
                        selectedItem = item;
                        break;
                    }
                }

                if (selectedItem != null)
                {
                    splitItemsControl.SelectedItem = selectedItem;
                }
            }
#endif
        }
コード例 #4
0
 /// <summary>
 /// SplitListBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitComboBoxItem">The split combo box item instance.</param>
 /// <param name="parent">The parent selector peer.</param>
 public SplitComboBoxItemAutomationPeer(SplitComboBoxItem splitComboBoxItem, SelectorAutomationPeer parent)
     : base(splitComboBoxItem, parent)
 {
     this.splitComboBoxItem = splitComboBoxItem;
     this.parent            = parent;
 }
コード例 #5
0
 /// <summary>
 /// SplitComboBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitComboBoxItem">The split combo box item instance.</param>
 public SplitComboBoxItemAutomationPeer(SplitComboBoxItem splitComboBoxItem)
     : base(splitComboBoxItem)
 {
     this.splitComboBoxItem = splitComboBoxItem;
 }
コード例 #6
0
 /// <summary>
 /// SplitComboBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitComboBoxItem">The split combo box item instance.</param>
 public SplitComboBoxItemAutomationPeer(SplitComboBoxItem splitComboBoxItem)
     : base(splitComboBoxItem)
 {
     this.splitComboBoxItem = splitComboBoxItem;
 }
コード例 #7
0
 /// <summary>
 /// SplitListBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitComboBoxItem">The split combo box item instance.</param>
 /// <param name="parent">The parent selector peer.</param>
 public SplitComboBoxItemAutomationPeer(SplitComboBoxItem splitComboBoxItem, SelectorAutomationPeer parent)
     : base(splitComboBoxItem, parent)
 {
     this.splitComboBoxItem = splitComboBoxItem;
     this.parent = parent;
 }