示例#1
0
        public static int Compare(Behavior behavior1, Behavior behavior2)
        {
            var orderAttribute1 = behavior1.GetType().GetAttribute<OrderAttribute>();
            var categoryAttribute1 = behavior1.GetType().GetAttribute<CategoryAttribute>();
            var orderAttribute2 = behavior2.GetType().GetAttribute<OrderAttribute>();
            var categoryAttribute2 = behavior2.GetType().GetAttribute<CategoryAttribute>();

            if (orderAttribute2 == null || categoryAttribute2 == null)
            {
                return 1;
            }

            if (orderAttribute1 == null || categoryAttribute1 == null)
            {
                return -1;
            }

            var categoryIndex1 = GetCategoryIndex(categoryAttribute1.Category);
            var categoryIndex2 = GetCategoryIndex(categoryAttribute2.Category);

            if (categoryIndex1 == categoryIndex2)
            {
                return orderAttribute1.Order.CompareTo(orderAttribute2.Order);
            }

            return categoryIndex1.CompareTo(categoryIndex2);
        }
示例#2
0
文件: Ribbon.cs 项目: ondrej11/o106
 public BehaviorToolButton AddToolButton(Behavior behavior)
 {
     BehaviorToolButton button = behavior.CreateToolButton();
     string category = BehaviorOrderer.GetCategory(behavior);
     AddToolButton(button, category);
     return button;
 }
示例#3
0
        public BehaviorToolButton(Behavior behavior)
        {
            ParentBehavior = behavior;
            behavior.PropertyChanged += behavior_PropertyChanged;

            buttonGrid = new ButtonGrid(behavior.Icon, behavior.Name);
            buttonGrid.IconTextGap = IconTextGap;
            Content = buttonGrid;
            buttonGrid.MouseLeftButtonDown += buttonGrid_MouseLeftButtonDown;
        }
示例#4
0
        public static string GetCategory(Behavior behavior)
        {
            if (behavior is UserDefinedTool)
            {
                return BehaviorCategories.Custom;
            }

            var result = BehaviorCategories.Misc;
            var categoryAttribute = behavior.GetType().GetAttribute<CategoryAttribute>();
            if (categoryAttribute != null)
            {
                result = categoryAttribute.Category;
            }
            return result;
        }
示例#5
0
 protected virtual void mCurrentDrawing_BehaviorChanged(Behavior newBehavior)
 {
     Ribbon.SelectBehavior(newBehavior);
     var help = newBehavior.HintText;
     if (!help.IsEmpty())
     {
         ShowHint(help);
     }
     ShowProperties(newBehavior.PropertyBag);
 }
示例#6
0
 protected virtual void Behavior_NewBehaviorCreated(Behavior behavior)
 {
     AddToolButton(behavior);
 }
示例#7
0
 protected virtual void Behavior_BehaviorDeleted(Behavior behavior)
 {
     RemoveToolButton(behavior);
 }
示例#8
0
 public BehaviorToolButton AddToolButton(Behavior behavior)
 {
     return Ribbon.AddToolButton(behavior);
 }
示例#9
0
 public void RemoveToolButton(Behavior behavior)
 {
     Ribbon.RemoveToolButton(behavior);
 }
示例#10
0
 protected virtual void Behavior_NewBehaviorCreated(Behavior behavior)
 {
     AddToolButton(behavior);
 }
示例#11
0
 /// <summary>
 /// Informs the clients that the current behavior of the drawing
 /// was set to a new behavior.
 /// </summary>
 /// <param name="behavior">The new behavior of the drawing.</param>
 void RaiseBehaviorChanged(Behavior behavior)
 {
     if (BehaviorChanged != null)
     {
         BehaviorChanged(behavior);
     }
 }
        public static void AddFromString(string macro)
        {
            UserDefinedTool tool = new UserDefinedTool(macro);

            Behavior.Add(tool);
        }
示例#13
0
文件: Ribbon.cs 项目: ondrej11/o106
 public BehaviorToolButton FindButton(Behavior behavior)
 {
     var panel = FindPanel(behavior);
     var button = panel.FindButton(behavior);
     return button;
 }
示例#14
0
文件: Ribbon.cs 项目: ondrej11/o106
 public void RemoveToolButton(Behavior behavior)
 {
     var panel = FindPanel(behavior);
     var button = FindButton(behavior);
     button.CommandRemoved();
     panel.ResetSelectedToolButton();
 }
示例#15
0
文件: Ribbon.cs 项目: ondrej11/o106
 public void SelectBehavior(Behavior behavior)
 {
     var panel = FindPanel(behavior);
     if (panel == null) return;
     SelectedItem = panel;
     var button = panel.FindButton(behavior);
     if (button != null)
     {
         button.Click();
     }
 }
示例#16
0
 public BehaviorToolButton AddToolButton(Behavior behavior)
 {
     return(Ribbon.AddToolButton(behavior));
 }
示例#17
0
文件: TabPanel.cs 项目: ondrej11/o106
 public BehaviorToolButton FindButton(Behavior behavior)
 {
     return BehaviorToolButtons.FirstOrDefault(t => t.ParentBehavior == behavior);
 }
示例#18
0
 protected virtual void Behavior_BehaviorDeleted(Behavior behavior)
 {
     RemoveToolButton(behavior);
 }
 public void Delete()
 {
     Parent.AbortAndSetDefaultTool();
     Behavior.Delete(Parent);
 }
示例#20
0
文件: Ribbon.cs 项目: ondrej11/o106
 public TabPanel FindPanel(Behavior behavior)
 {
     foreach (var panel in Panels)
     {
         BehaviorToolButton button = panel.FindButton(behavior);
         if (button != null)
         {
             return panel;
         }
     }
     return null;
 }
示例#21
0
 public void SetDefaultBehavior()
 {
     Behavior = Behavior.Default;
 }
示例#22
0
 public void RemoveToolButton(Behavior behavior)
 {
     Ribbon.RemoveToolButton(behavior);
 }