public void Set_EventsRaisedWithCorrectArgumentsAndItemSet() { int index = 0, newValue = 3, previousValue = 1; var subject = new NotifyingList <int>(); subject.Setting += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.Value, Is.EqualTo(previousValue)); Assert.That(e.NewValue, Is.EqualTo(newValue)); Assert.That(e.IsCancelled, Is.False); }; subject.Set += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.OldValue, Is.EqualTo(previousValue)); Assert.That(e.Value, Is.EqualTo(newValue)); }; subject.Add(previousValue); subject[index] = newValue; Assert.That(subject.Count, Is.EqualTo(1)); Assert.That(subject[index], Is.EqualTo(newValue)); }
public void RemoveAt_EventsRaisedWithCorrectArgumentsAndItemRemoved() { int index = 0, item = 3; var subject = new NotifyingList <int> { 3 }; subject.Removing += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.Value, Is.EqualTo(item)); Assert.That(e.IsCancelled, Is.False); }; subject.Removed += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.Value, Is.EqualTo(item)); }; subject.RemoveAt(0); Assert.That(subject.Count, Is.EqualTo(0)); }
public void Set_OutOfBounds_Exception() { var subject = new NotifyingList <int> { 1 }; Assert.That(() => subject[2] = 3, Throws.InstanceOf <ArgumentOutOfRangeException>()); }
public void RemoveAt_OutOfBounds_Exception() { var subject = new NotifyingList <int> { 3 }; Assert.That(() => subject.RemoveAt(2), Throws.InstanceOf <ArgumentOutOfRangeException>()); }
public void RemoveAt_OutOfBounds_ReturnsFalse() { var subject = new NotifyingList <int> { 3 }; Assert.That(subject.Remove(2), Is.False); }
public void Clear_EventsRaisedWithCorrectArgumentsAndItemAdded() { var subject = new NotifyingList <int>(); subject.Clearing += ((sender, e) => Assert.That(e.IsCancelled, Is.False)); subject.Cleared += (sender, args) => { }; subject.Clear(); Assert.That(subject.Count, Is.EqualTo(0)); }
/// <summary> /// Called when we want to edit the value of a property. Shows the ActionsEditor form. /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { List <Otter.UI.Actions.Action> actions = value as List <Otter.UI.Actions.Action>; if (actions == null) { return(value); } GUIScene scene = null; GUIControl control = context.Instance as GUIControl; if (control != null) { scene = control.Scene; } MainChannelFrame mainChannelFrame = context.Instance as MainChannelFrame; if (mainChannelFrame != null) { scene = mainChannelFrame.Animation.Scene; } if (scene == null) { return(value); } ActionsEditor actionsEditor = new ActionsEditor(scene); actionsEditor.Actions = actions; if (actionsEditor.ShowDialog() == DialogResult.OK) { if (control != null) { return(actionsEditor.Actions); } NotifyingList <Otter.UI.Actions.Action> list = new NotifyingList <UI.Actions.Action>(); list.AddRange(actionsEditor.Actions); return(list); } return(actions); } return(value); }
public void Clear_EventsRaised() { bool clearingRaised = false, clearedRaised = false; var subject = new NotifyingList <int>(); subject.Clearing += (sender, args) => clearingRaised = true; subject.Cleared += (sender, args) => clearedRaised = true; subject.Clear(); Assert.That(clearingRaised, Is.True); Assert.That(clearedRaised, Is.True); }
public void Insert_CanCancelInsertion() { bool insertedRaised = false; var subject = new NotifyingList <int>(); subject.Inserting += ((sender, e) => e.Cancel()); subject.Inserted += (sender, args) => insertedRaised = true; subject.Insert(0, 3); Assert.That(insertedRaised, Is.False); }
public void Add_EventsRaised() { bool insertingRaised = false, insertedRaised = false; var subject = new NotifyingList <int>(); subject.Inserting += (sender, args) => insertingRaised = true; subject.Inserted += (sender, args) => insertedRaised = true; subject.Add(3); Assert.That(insertingRaised, Is.True); Assert.That(insertedRaised, Is.True); }
public void Clear_CanCancelClearance() { bool clearedRaised = false; var subject = new NotifyingList <int>(); subject.Clearing += ((sender, e) => e.Cancel()); subject.Cleared += (sender, args) => clearedRaised = true; subject.Clear(); Assert.That(clearedRaised, Is.False); }
public void Set_CanCancelSetting() { bool setRaised = false; var subject = new NotifyingList <int>(); subject.Setting += ((sender, e) => e.Cancel()); subject.Set += (sender, args) => setRaised = true; subject.Insert(0, 1); subject[0] = 3; Assert.That(setRaised, Is.False); }
public void Set_EventsRaised() { bool settingRaised = false, setRaised = false; var subject = new NotifyingList <int>(); subject.Setting += (sender, args) => settingRaised = true; subject.Set += (sender, args) => setRaised = true; subject.Add(1); subject[0] = 3; Assert.That(settingRaised, Is.True); Assert.That(setRaised, Is.True); }
public NotificationsControl() { InitializeComponent(); _currentNotifications = new NotifyingList <Notification>(); _currentNotifications.ItemPropertyChanged += (sender, e) => this.Dispatcher.BeginInvoke((NotifyCollectionChangedEventHandler)_OnNotificationsChanged, this, null); CommandBindings.Add(new CommandBinding(CloseCommand, new ExecutedRoutedEventHandler((sender, e) => IsDisplayed = false))); Loaded += (sender, e) => ServiceProvider.ViewManager.Notifications.CollectionChanged += _OnNotificationsChanged; Unloaded += (sender, e) => { ServiceProvider.ViewManager.Notifications.CollectionChanged -= _OnNotificationsChanged; _currentNotifications.Clear(); }; }
public void RemoveAt_EventsRaised() { bool removingRaised = false, removedRaised = false; var subject = new NotifyingList <int> { 3 }; subject.Removing += (sender, args) => removingRaised = true; subject.Removed += (sender, args) => removedRaised = true; subject.RemoveAt(0); Assert.That(removingRaised, Is.True); Assert.That(removedRaised, Is.True); }
public void Remove_CanCancelDeletion() { bool removedRaised = false; var subject = new NotifyingList <int> { 3 }; subject.Removing += ((sender, e) => e.Cancel()); subject.Removed += (sender, args) => removedRaised = true; Assert.That(subject.Remove(3), Is.False); Assert.That(removedRaised, Is.False); Assert.That(subject[0], Is.EqualTo(3)); }
/// <summary> /// Deletes the currently selected item /// </summary> private void DeleteSelectedItem() { List <TreeNodeAdv> nodesToRemove = new List <TreeNodeAdv>(mSceneTreeView.SelectedNodes); if (nodesToRemove.Count == 0) { return; } if (MessageBox.Show("Are you sure you want to delete these items?", "Warning", MessageBoxButtons.YesNo) == DialogResult.No) { return; } foreach (TreeNodeAdv node in nodesToRemove) { GUIControl control = (node.Tag as SceneNode).Control; GUIView view = control as GUIView; if (view != null) { if (BeforeViewRemove != null) { BeforeViewRemove(this, view); } CommandManager.AddCommand(new DeleteViewCommand(mScene, view), true); View = null; } else if (control != null) { if (BeforeControlRemove != null) { BeforeControlRemove(this, control); } CommandManager.AddCommand(new DeleteControlCommand(control.ParentView, control), true); SelectedControls = new NotifyingList <GUIControl>(); } (node.Tag as SceneNode).Parent = null; } }
public HierarchyNode() { Id = System.Threading.Interlocked.Increment(ref Counter); allItems.Add(this); Children = new NotifyingList <HierarchyNode>(); Properties = new PropertiesList(); Commands = new CommandsList(this); Children.ItemAdded += (s, a) => { a.Item.Parent = this; this.NotifyChildAdded(a.Item); }; Children.ItemRemoved += (s, a) => { this.NotifyChildRemoved(a.Item); a.Item.Parent = null; }; }
/// <summary> /// Called when we want to edit the value of a property. Shows the ActionsEditor form. /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { List<Otter.UI.Actions.Action> actions = value as List<Otter.UI.Actions.Action>; if (actions == null) return value; GUIScene scene = null; GUIControl control = context.Instance as GUIControl; if (control != null) scene = control.Scene; MainChannelFrame mainChannelFrame = context.Instance as MainChannelFrame; if (mainChannelFrame != null) scene = mainChannelFrame.Animation.Scene; if(scene == null) return value; ActionsEditor actionsEditor = new ActionsEditor(scene); actionsEditor.Actions = actions; if (actionsEditor.ShowDialog() == DialogResult.OK) { if(control != null) return actionsEditor.Actions; NotifyingList<Otter.UI.Actions.Action> list = new NotifyingList<UI.Actions.Action>(); list.AddRange(actionsEditor.Actions); return list; } return actions; } return value; }
public void Add_EventsRaisedWithCorrectArgumentsAndItemAdded() { int index = 0, item = 3; var subject = new NotifyingList <int>(); subject.Inserting += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.Value, Is.EqualTo(item)); Assert.That(e.IsCancelled, Is.False); }; subject.Inserted += (sender, e) => { Assert.That(e.Index, Is.EqualTo(index)); Assert.That(e.Value, Is.EqualTo(item)); }; subject.Add(item); Assert.That(subject.Count, Is.EqualTo(1)); Assert.That(subject[index], Is.EqualTo(item)); }
/// <summary> /// Occurs after a node has been selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mSceneTreeView_SelectionChanged(object sender, EventArgs e) { TreeNodeAdv treeNode = mSceneTreeView.SelectedNode; SceneNode node = (treeNode != null) ? treeNode.Tag as SceneNode : null; if (node == null) { return; } if (node.Control is GUIView) { SelectedControls = new NotifyingList <GUIControl>(); View = node.Control as GUIView; // Reset the selection, as setting SelectedControls to null reset the selection mSceneTreeView.SelectedNode = treeNode; } else { SelectedControls = new NotifyingList <GUIControl>(mSceneTreeView.SelectedNodes.Select((a) => (a.Tag as SceneNode).Control)); } }
public CommanderTool(Main main) : base(main) { Text = "Act"; Panel = new TableLayoutPanel(); Panel.Dock = DockStyle.Fill; Panel.BackColor = Color.White; Panel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; Controls.Add(Panel); InputBox = new TextBox(); InputBox.Dock = DockStyle.Top; InputBox.Font = Main.Consolas975; InputBox.TextChanged += (tcs, tca) => { ApplyFilter(); }; Panel.Controls.Add(InputBox); InternalList = new NotifyingList <Command>(); InternalList.ItemAdded += (ias, iaa) => BindCommandToListView(iaa.Item); InternalList.ItemRemoved += (ias, iaa) => UnbindCommandToListView(iaa.Item); main.Commands.ItemAdded += (ias, iaa) => InternalList.Add(iaa.Item); main.Commands.ItemRemoved += (ias, iaa) => InternalList.Remove(iaa.Item); foreach (var it in main.Commands) { InternalList.Add(it); } main.HierarchyChanged += (s, a) => { main.Hierarchy.SelectedNodeChanged += Hierarchy_SelectedItemChanged; }; }
private string mName = ""; // Name of the Main Channel Frame #endregion Fields #region Constructors public MainChannelFrame() { Actions = new NotifyingList<Actions.Action>(); }
public MainChannelFrame() { Actions = new NotifyingList <Actions.Action>(); }
public Flow() { Locations = new NotifyingList <Location>(); }
/// <summary> /// Selects a list of controls, and updates all views to reflect that selection /// </summary> /// <param name="control"></param> private void SelectControls(object source, GUIView view, List<GUIControl> controls) { mIgnoreSelectionChanges = true; { NotifyingList<GUIControl> selectedControls = new NotifyingList<GUIControl>(controls); // Set the current scene's selected control, as well as the properties and // the scene hierarchy SceneView sceneView = mDockPanel.ActiveDocument as SceneView; if (source != sceneView && sceneView != null && sceneView.ActiveView == view) { sceneView.SelectedControls = selectedControls; } if (source != Globals.TimelineView) Globals.TimelineView.SelectedControls = selectedControls; if (source != Globals.SceneHierarchyView) Globals.SceneHierarchyView.SelectedControls = selectedControls; if (source != Globals.PropertiesView) Globals.PropertiesView.PropertyGrid.SelectedObjects = selectedControls.ToArray(); } mIgnoreSelectionChanges = false; }
/// <summary> /// Deletes the currently selected item /// </summary> private void DeleteSelectedItem() { List<TreeNodeAdv> nodesToRemove = new List<TreeNodeAdv>(mSceneTreeView.SelectedNodes); if (nodesToRemove.Count == 0) return; if (MessageBox.Show("Are you sure you want to delete these items?", "Warning", MessageBoxButtons.YesNo) == DialogResult.No) return; foreach (TreeNodeAdv node in nodesToRemove) { GUIControl control = (node.Tag as SceneNode).Control; GUIView view = control as GUIView; if (view != null) { if (BeforeViewRemove != null) BeforeViewRemove(this, view); CommandManager.AddCommand(new DeleteViewCommand(mScene, view), true); View = null; } else if (control != null) { if (BeforeControlRemove != null) BeforeControlRemove(this, control); CommandManager.AddCommand(new DeleteControlCommand(control.ParentView, control), true); SelectedControls = new NotifyingList<GUIControl>(); } (node.Tag as SceneNode).Parent = null; } }
/// <summary> /// Occurs after a node has been selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mSceneTreeView_SelectionChanged(object sender, EventArgs e) { TreeNodeAdv treeNode = mSceneTreeView.SelectedNode; SceneNode node = (treeNode != null) ? treeNode.Tag as SceneNode : null; if (node == null) return; if (node.Control is GUIView) { SelectedControls = new NotifyingList<GUIControl>(); View = node.Control as GUIView; // Reset the selection, as setting SelectedControls to null reset the selection mSceneTreeView.SelectedNode = treeNode; } else { SelectedControls = new NotifyingList<GUIControl>(mSceneTreeView.SelectedNodes.Select((a) => (a.Tag as SceneNode).Control )); } }