Ejemplo n.º 1
0
        public void SelectItem(ToolBoxItemControl item)
        {
            Logger.MethodCalled();

            if (!ToolBoxItems.ContainsKey(item.ItemId))
            {
                Logger.ErrorF("Invalid item provided for selection => [{0}]. Item is not registered yet", item.ItemId);
                throw new ArgumentException(string.Format("Invalid item provided for selection => [{0}]. Item is not registered yet", item.ItemId));
            }

            if (SelectedItem == null)
            {
                selectedItem            = item;
                SelectedItem.IsSelected = true;

                Logger.SelectionChanged(item);
            }
            else if (SelectedItem.ItemId == item.ItemId)
            {
                Logger.DebugF("Item [{0}, Type={1}] is already selected", item, item.GetType().Name);
                return;
            }
            else
            {
                UnselectAllItems();
                selectedItem            = item;
                SelectedItem.IsSelected = true;

                Logger.SelectionChanged(item);
            }
        }
Ejemplo n.º 2
0
        static void OnIconKindChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ToolBoxItemControl ctrl = (ToolBoxItemControl)d;

            ctrl.Logger.MethodCalled();
            ctrl.Logger.PropertyValue("IconUri", ctrl.IconUri);
            ctrl.Logger.PropertyValue("IconKind", ctrl.IconKind);

            if (string.IsNullOrEmpty(ctrl.IconUri) && ctrl.IconKind != null)
            {
                ctrl.Logger.Debug("IconUri is empty & IconKind is not null");

                PackIconModern packIcon = (PackIconModern)ctrl.FindName("PackIcon");
                if (packIcon != null)
                {
                    packIcon.Visibility = Visibility.Visible;
                    ctrl.Logger.Debug("PackIcon shown");
                }

                Image icon = (Image)ctrl.FindName("ImageIcon");
                if (icon != null)
                {
                    icon.Visibility = Visibility.Collapsed;
                    ctrl.Logger.Debug("ImageIcon shown");
                }
            }
            else
            {
                ctrl.Logger.Debug("Either IconUri is not null or IconKind is null");
            }
        }
Ejemplo n.º 3
0
 public void RegisterItem(ToolBoxItemControl item)
 {
     if (!ToolBoxItems.ContainsKey(item.ItemId))
     {
         ToolBoxItems.Add(item.ItemId, item);
         Logger.DebugF("ToolBoxItem with Guid [{0}] registered", item.ItemId);
     }
     else
     {
         Logger.WarnF("ToolBoxItem with Guid [{0}] is already registered", item.ItemId);
     }
 }
Ejemplo n.º 4
0
        static void OnIconUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ToolBoxItemControl ctrl = (ToolBoxItemControl)d;

            ctrl.Logger.MethodCalled();
            ctrl.Logger.PropertyValue("IconUri", ctrl.IconUri);
            ctrl.Logger.PropertyValue("IconKind", ctrl.IconKind);

            if (!string.IsNullOrEmpty(ctrl.IconUri))
            {
                ctrl.Logger.Debug("IconUri contains value; PackIcon will be collapsed & ImageIcon will be shown");

                PackIconModern packIcon = (PackIconModern)ctrl.FindName("PackIcon");
                if (packIcon != null)
                {
                    packIcon.Visibility = Visibility.Collapsed;
                    ctrl.Logger.Debug("PackIcon collapsed");
                }

                Image icon = (Image)ctrl.FindName("ImageIcon");
                if (icon != null)
                {
                    icon.Visibility = Visibility.Visible;
                    ctrl.Logger.Debug("ImageIcon shown");
                }
            }
            else
            {
                ctrl.Logger.Debug("IconUri is empty; ImageIcon will be collapsed & PackIcon will be shown");

                PackIconModern packIcon = (PackIconModern)ctrl.FindName("PackIcon");
                if (packIcon != null)
                {
                    packIcon.Visibility = Visibility.Visible;
                    ctrl.Logger.Debug("PackIcon shown");
                }

                Image icon = (Image)ctrl.FindName("ImageIcon");
                if (icon != null)
                {
                    icon.Visibility = Visibility.Collapsed;
                    ctrl.Logger.Debug("ImageIcon collapsed");
                }
            }
        }