/// <summary> /// this function sets the menu of actions /// </summary> private void SetActionMenu() { // step1: get all actions Dictionary<action.Action, XElement> actionList = new Dictionary<ICE.action.Action, XElement>(); foreach (string actionXml in this.node.Actions) { try { XElement actionElement = XDocument.Parse(actionXml).Root; string actionName = actionElement.Attribute(xml.DataXmlContent.IDRefAttributeOfActionElementName).Value; action.Action action = this.viewManager.Settings.GetAction(actionName); if (action != null && (!action.IsGroupAction)) { actionList.Add(action, actionElement); } } catch (Exception) { /* do nothing*/ } } if (this.node.IsSelected) { action.Action collapse = action.Action.GetCollapseAction(); actionList.Add(collapse, null); } else { action.Action expand = action.Action.GetExpandAction(); actionList.Add(expand, null); } ActionMenu menu = new ActionMenu(); menu.Color = this.viewManager.Settings.ActionsCircleColor; foreach (action.Action action in actionList.Keys) { // step2: create an actionView for each of them List<action.IActionable> targets = new List<IActionable>(); targets.Add(this); ActionView actionView = new ActionView(targets, action); // step3: add the action to a action menu menu.AddActionView(actionView); } // step4: subscribe to the close event menu.Closed += delegate(object sender, EventArgs args) { this.actionMenu = null; }; // step5: display this.actionMenu = menu; this.viewManager.DisplayActionMenu(menu); menu.Open(); }
/// <summary> /// This function adds the actionDrawer in argument to the graph canvas and ask the older one to close. /// </summary> /// <param name="menu">the action menu to display</param> public void DisplayActionMenu(ActionMenu menu) { if (this.currentActionMenu != null && (this.currentActionMenu.IsOpen || this.currentActionMenu.IsOpening)) { this.currentActionMenu.Close(); } this.currentActionMenu = menu; menu.Closed += new EventHandler(this.ActionMenu_Closed); this.graphCanvas.Children.Add(menu); }
/// <summary> /// This function remove the menu in argument /// </summary> /// <param name="menu">the action drawer</param> public void RemoveActionMenu(ActionMenu menu) { this.graphCanvas.Children.Remove(menu); }
/// <summary> /// Initializes a new instance of the ViewManager class. /// </summary> /// <param name="model">the model to observe</param> public ViewManager(model.ModelManager model) { this.InitializeComponent(); this.modelManager = model; this.modelManager.NodeTypesChanged += new EventHandler(this.ModelManager_NodeTypesChanged); this.modelManager.LinkTypesChanged += new EventHandler(this.ModelManager_LinkTypesChanged); this.center = new mathematics.Vector3D(0, 0, 0); this.visualEffectList = new List<ICE.view.visualEffect.IVisualEffect>(); this.Settings = new setting.Settings(); this.splachScreen = new SplashScreen(); this.mouseManager = new MouseManager(this.gripArea); this.mouseManager.DragOnLeftButtonDown += new MouseEventHandler(this.BeginDragAction); this.mouseManager.MouseMovedOnLeftButtonDown += new MouseEventHandler(this.MoveFromMouseMovement); this.mouseManager.WheelMouseDown += new MouseEventHandler(this.WheelMouseDown); this.mouseManager.WheelMouseUp += new MouseEventHandler(this.WheelMouseUp); this.gripArea.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs arg) { if (this.currentActionMenu != null) { this.currentActionMenu.Close(); this.currentActionMenu = null; } }; // create the timer this.timer = new DispatcherTimer(); }