예제 #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);
     }
 }
예제 #12
0
        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);
 }
예제 #19
0
 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);
 }