public override DataTemplate SelectTemplate(object item, DependencyObject container) { ProfileExplorerTreeItem listItem = item as ProfileExplorerTreeItem; FrameworkElement element = container as FrameworkElement; if (listItem != null && element != null) { if (listItem.ItemType == ProfileExplorerTreeItemType.Binding) { if (listItem.Parent.ItemType == ProfileExplorerTreeItemType.Action) { return(element.FindResource("InputBindingNodeTemplate") as DataTemplate); } else { return(element.FindResource("OutputBindingNodeTemplate") as DataTemplate); } } else if (listItem.ItemType == ProfileExplorerTreeItemType.Action) { return(element.FindResource("ActionNodeTemplate") as DataTemplate); } else if (listItem.ItemType == ProfileExplorerTreeItemType.Trigger) { return(element.FindResource("TriggerNodeTemplate") as DataTemplate); } else { return(element.FindResource("ContainerNodeTemplate") as DataTemplate); } } return(null); }
private void LoadBindings() { if (BindingObject != null) { ClearBindings(); BindingItems = new ProfileExplorerTreeItemCollection(); if (BindingType == BindingPanelType.Input) { ProfileExplorerTreeItem inputBindings = new ProfileExplorerTreeItem(BindingObject, ProfileExplorerTreeItemType.Action | ProfileExplorerTreeItemType.Binding); if (inputBindings.HasChildren) { foreach (ProfileExplorerTreeItem item in inputBindings.Children) { BindingItems.Add(item); } } } else if (BindingType == BindingPanelType.Output) { ProfileExplorerTreeItem outputBindings = new ProfileExplorerTreeItem(BindingObject, ProfileExplorerTreeItemType.Trigger | ProfileExplorerTreeItemType.Binding); if (outputBindings.HasChildren) { foreach (ProfileExplorerTreeItem item in outputBindings.Children) { BindingItems.Add(item); } } } } else { BindingItems = null; } }
public void OnDropCompleted(IDataObject obj, Point dropPoint) { ProfileExplorerTreeItem dropItem = GetExplorerTreeItem(_targetTreeView, dropPoint); IBindingAction action; IBindingTrigger trigger; if (dropItem.ItemType.HasFlag(ProfileExplorerTreeItemType.Trigger)) { action = (IBindingAction)obj.GetData("Helios.Action"); trigger = (IBindingTrigger)dropItem.ContextItem; } else { trigger = (IBindingTrigger)obj.GetData("Helios.Trigger"); action = (IBindingAction)dropItem.ContextItem; } AddNewBinding(trigger, action); if (!dropItem.HasChildren) { // can happen when dragging onto something configured not to show bindings return; } ProfileExplorerTreeItem newTreeItem = dropItem.Children.Last(); newTreeItem.IsSelected = true; }
private void Delete_Executed(object sender, ExecutedRoutedEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; if (item != null) { if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Visual)) { HeliosVisual visual = item.ContextItem as HeliosVisual; HeliosVisualContainer container = visual.Parent as HeliosVisualContainer; if (container != null) { ConfigManager.UndoManager.AddUndoItem(new ControlDeleteUndoEvent(container, new List <HeliosVisual> { visual }, new List <int> { container.Children.IndexOf(visual) })); OnDeleting(visual); container.Children.Remove(visual); } } else if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface)) { HeliosInterface interfaceItem = item.ContextItem as HeliosInterface; if (interfaceItem != null) { DeleteInterface(interfaceItem); } } } }
private void Delete_CanExecute(object sender, CanExecuteRoutedEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; e.CanExecute = (item != null && (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Visual) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface))); }
private void LoadItems() { ProfileExplorerItems.Disconnect(); ProfileExplorerItems.Clear(); if (Profile != null) { ProfileExplorerTreeItemType types = ProfileExplorerTreeItemType.Interface | ProfileExplorerTreeItemType.Monitor | ProfileExplorerTreeItemType.Panel; ProfileExplorerTreeItem item = new ProfileExplorerTreeItem(Profile, types); item.ExpandAll(); ProfileExplorerItems = item.Children; } }
private void TreeView_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; if (item != null && (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Monitor) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface))) { ProfileEditorCommands.OpenProfileItem.Execute(item.ContextItem, this); } e.Handled = true; }
private void BindingsTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { ProfileExplorerTreeItem selectedItem = e.NewValue as ProfileExplorerTreeItem; if (selectedItem != null && selectedItem.ItemType.HasFlag(ProfileExplorerTreeItemType.Binding)) { SelectedBinding = (HeliosBinding)selectedItem.ContextItem; UpdateValueEditor(); } else { SelectedBinding = null; } }
private void ClearSources() { if (_actionsList != null) { _actionsList.Disconnect(); _actionsList = null; } if (_triggerList != null) { _triggerList.Disconnect(); _triggerList = null; } }
public DataObject GetDataObject(UIElement draggedElement, Point location) { DataObject obj = null; ProfileExplorerTreeItem item = GetExplorerTreeItem(_sourceTreeView, location); if (item != null) { obj = new DataObject(); string dataType = "Helios." + item.ItemType.ToString(); obj.SetData(dataType, item.ContextItem); } return(obj); }
public bool IsValidDataObject(IDataObject Object, Point dropPoint) { ProfileExplorerTreeItem dropTarget = GetExplorerTreeItem(_targetTreeView, dropPoint); if (dropTarget != null) { if (Object.GetDataPresent("Helios.Trigger") && dropTarget.ItemType.HasFlag(ProfileExplorerTreeItemType.Action)) { return(true); } if (Object.GetDataPresent("Helios.Action") && dropTarget.ItemType.HasFlag(ProfileExplorerTreeItemType.Trigger)) { return(true); } } return(false); }
private void LoadSources() { ProfileExplorerTreeItemType triggerTypes = ProfileExplorerTreeItemType.Interface | ProfileExplorerTreeItemType.Monitor | ProfileExplorerTreeItemType.Panel | ProfileExplorerTreeItemType.Visual | ProfileExplorerTreeItemType.Trigger; ProfileExplorerTreeItemType actionTypes = ProfileExplorerTreeItemType.Interface | ProfileExplorerTreeItemType.Monitor | ProfileExplorerTreeItemType.Panel | ProfileExplorerTreeItemType.Visual | ProfileExplorerTreeItemType.Action; if (BindingObject != null) { if (BindingObject.Profile != _actionTriggerProfile) { ClearSources(); HeliosProfile newProfile = BindingObject.Profile; if (newProfile != null) { _actionsList = new ProfileExplorerTreeItem(newProfile, actionTypes); _triggerList = new ProfileExplorerTreeItem(newProfile, triggerTypes); } _actionTriggerProfile = newProfile; } } if (BindingType == BindingPanelType.Input) { if (_triggerList == null) { ProfileExplorerItems = null; } else { ProfileExplorerItems = _triggerList.Children; } } else if (BindingType == BindingPanelType.Output) { if (_actionsList == null) { ProfileExplorerItems = null; } else { ProfileExplorerItems = _actionsList.Children; } } }
private static void LoadBindings(BindingsPanel p) { if (p.BindingObject != null) { if (p.BindingItems != null) { p.BindingItems.Disconnect(); } p.BindingItems = new ProfileExplorerTreeItemCollection(); if (p.BindingType == BindingPanelType.Input) { ProfileExplorerTreeItem inputBindings = new ProfileExplorerTreeItem(p.BindingObject, ProfileExplorerTreeItemType.Action | ProfileExplorerTreeItemType.Binding); if (inputBindings.HasChildren) { foreach (ProfileExplorerTreeItem item in inputBindings.Children) { p.BindingItems.Add(item); } } } else if (p.BindingType == BindingPanelType.Output) { ProfileExplorerTreeItem outputBindings = new ProfileExplorerTreeItem(p.BindingObject, ProfileExplorerTreeItemType.Trigger | ProfileExplorerTreeItemType.Binding); if (outputBindings.HasChildren) { foreach (ProfileExplorerTreeItem item in outputBindings.Children) { p.BindingItems.Add(item); } } } } else { p.BindingItems = null; } }
private void Delete_Executed(object sender, ExecutedRoutedEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; if (item != null) { if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Visual)) { HeliosVisual visual = item.ContextItem as HeliosVisual; HeliosVisualContainer container = visual.Parent as HeliosVisualContainer; if (container != null) { ConfigManager.UndoManager.AddUndoItem(new ControlDeleteUndoEvent(container, new List <HeliosVisual> { visual }, new List <int> { container.Children.IndexOf(visual) })); OnDeleting(visual); container.Children.Remove(visual); } } else if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface)) { HeliosInterface interfaceItem = item.ContextItem as HeliosInterface; if (interfaceItem != null) { if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to remove the " + interfaceItem.Name + " interface from the profile. This will remove all bindings associated with this interface.", "Remove Interface", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.None) == MessageBoxResult.Yes) { ConfigManager.UndoManager.AddUndoItem(new InterfaceDeleteUndoEvent(Profile, interfaceItem)); OnDeleting(interfaceItem); Profile.Interfaces.Remove(interfaceItem); } } } } }
public void OnDropCompleted(IDataObject obj, Point dropPoint) { ProfileExplorerTreeItem dropItem = GetExplorerTreeItem(_targetTreeView, dropPoint); IBindingAction action; IBindingTrigger trigger; if (dropItem.ItemType.HasFlag(ProfileExplorerTreeItemType.Trigger)) { action = (IBindingAction)obj.GetData("Helios.Action"); trigger = (IBindingTrigger)dropItem.ContextItem; } else { trigger = (IBindingTrigger)obj.GetData("Helios.Trigger"); action = (IBindingAction)dropItem.ContextItem; } AddNewBinding(trigger, action); ProfileExplorerTreeItem newTreeItem = dropItem.Children.Last(); newTreeItem.IsSelected = true; }
public bool IsDraggable(UIElement dragElement, Point location) { ProfileExplorerTreeItem item = GetExplorerTreeItem(_sourceTreeView, location); return(item != null && (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Action) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Trigger))); }