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); }
public BehaviorToolButton AddToolButton(Behavior behavior) { BehaviorToolButton button = behavior.CreateToolButton(); string category = BehaviorOrderer.GetCategory(behavior); AddToolButton(button, category); return button; }
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; }
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; }
protected virtual void mCurrentDrawing_BehaviorChanged(Behavior newBehavior) { Ribbon.SelectBehavior(newBehavior); var help = newBehavior.HintText; if (!help.IsEmpty()) { ShowHint(help); } ShowProperties(newBehavior.PropertyBag); }
protected virtual void Behavior_NewBehaviorCreated(Behavior behavior) { AddToolButton(behavior); }
protected virtual void Behavior_BehaviorDeleted(Behavior behavior) { RemoveToolButton(behavior); }
public BehaviorToolButton AddToolButton(Behavior behavior) { return Ribbon.AddToolButton(behavior); }
public void RemoveToolButton(Behavior behavior) { Ribbon.RemoveToolButton(behavior); }
/// <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); }
public BehaviorToolButton FindButton(Behavior behavior) { var panel = FindPanel(behavior); var button = panel.FindButton(behavior); return button; }
public void RemoveToolButton(Behavior behavior) { var panel = FindPanel(behavior); var button = FindButton(behavior); button.CommandRemoved(); panel.ResetSelectedToolButton(); }
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(); } }
public BehaviorToolButton AddToolButton(Behavior behavior) { return(Ribbon.AddToolButton(behavior)); }
public BehaviorToolButton FindButton(Behavior behavior) { return BehaviorToolButtons.FirstOrDefault(t => t.ParentBehavior == behavior); }
public void Delete() { Parent.AbortAndSetDefaultTool(); Behavior.Delete(Parent); }
public TabPanel FindPanel(Behavior behavior) { foreach (var panel in Panels) { BehaviorToolButton button = panel.FindButton(behavior); if (button != null) { return panel; } } return null; }
public void SetDefaultBehavior() { Behavior = Behavior.Default; }