示例#1
0
        /// <summary>
        /// Handles the ListChanged event of the <see cref="Events"/>.
        /// Updates the view of events.
        /// </summary>
        private void Events_ListChanged(object sender, ObservableListChangedEventArgs <Event> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ShowEvent(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                DataGridViewRow deletedRow = FindEvent(e.Item);
                if (deletedRow != null)
                {
                    settingsView.table.Rows.Remove(deletedRow);
                }
                break;

            case ObservableListChangedType.Reset:
                settingsView.ClearRows();
                foreach (Event scriptEvent in Events)
                {
                    ShowEvent(scriptEvent);
                }
                break;
            }
        }
        /// <summary>
        /// Handles the ListChanged event of the Variables of <see cref="ScriptingComponent"/>.
        /// Updates view of named variables.
        /// </summary>
        private void Variables_ListChanged(object sender, ObservableListChangedEventArgs <NamedVariable> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ShowVariable(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                DataGridViewRow row = FindVariable(e.Item);
                if (row != null)
                {
                    settingsView.table.Rows.Remove(row);
                }
                break;

            case ObservableListChangedType.Reset:
                settingsView.ClearRows();
                foreach (NamedVariable variable in ScriptingComponent.Variables)
                {
                    ShowVariable(variable);
                }
                break;
            }
        }
            /// <summary>
            /// Called when the children of the actor types changes.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="PlatformGameCreator.Editor.Common.ObservableListChangedEventArgs&lt;ActorType&gt;"/> instance containing the event data.</param>
            private void Children_ListChanged(object sender, ObservableListChangedEventArgs <ActorType> e)
            {
                switch (e.ListChangedType)
                {
                case ObservableListChangedType.ItemAdded:
                    ShowItem(e.Item);
                    break;

                case ObservableListChangedType.ItemDeleted:
                    ActorTypeTreeNode deletedItem = FindItem(e.Item);
                    if (deletedItem != null)
                    {
                        deletedItem.Remove();
                    }
                    break;

                case ObservableListChangedType.ItemChanged:
                    Debug.Assert(true, "Not supported operation.");
                    break;

                case ObservableListChangedType.Reset:
                    ClearChildren();
                    foreach (ActorType child in actorType.Children)
                    {
                        ShowItem(child);
                    }
                    break;
                }
            }
示例#4
0
        /// <summary>
        /// Handles the ListChanged event of the extensionActions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The MLifter.Generics.ObservableListChangedEventArgs&lt;MLifter.DAL.Interfaces.ExtensionAction&gt; instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-07-06</remarks>
        private void extensionActions_ListChanged(object sender, ObservableListChangedEventArgs <ExtensionAction> e)
        {
            IList <ExtensionAction> eaList = connector.GetExtensionActions(guid);

            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
                eaList.Add(e.Item);
                connector.SetExtensionActions(guid, eaList);
                break;

            case ListChangedType.ItemDeleted:
                eaList.Remove(e.Item);
                connector.SetExtensionActions(guid, eaList);
                break;

            case ListChangedType.Reset:
                IList <ExtensionAction> oldList = (IList <ExtensionAction>)sender;
                connector.SetExtensionActions(guid, oldList);
                break;

            default:
                break;
            }
        }
示例#5
0
        /// <summary>
        /// Updates the scene content list that changes in the specified node.
        /// </summary>
        /// <typeparam name="T">Type of the scene content.</typeparam>
        private void BasicListChanged <T>(Node node, ObservableListChangedEventArgs <T> e) where T : class, IName, IVisible
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                node.Nodes.Insert(e.Index, CreateNodeByType(e.Item));
                break;

            case ObservableListChangedType.ItemDeleted:
                Clear((BaseSceneTreeNode)node.Nodes[e.Index]);
                node.Nodes.RemoveAt(e.Index);
                break;

            case ObservableListChangedType.ItemChanged:
                ((BaseSceneTreeNode)node.Nodes[e.Index]).Dispose();
                node.Nodes.RemoveAt(e.Index);
                node.Nodes.Add(CreateNodeByType(e.Item));
                break;

            case ObservableListChangedType.Reset:
                foreach (BaseSceneTreeNode child in node.Nodes)
                {
                    Clear(child);
                }
                node.Nodes.Clear();
                break;
            }
        }
        /// <summary>
        /// Handles the ListChanged event of the itemsToChooseFrom.
        /// Updates the items to choose from.
        /// </summary>
        private void itemsToChooseFrom_ListChanged(object sender, ObservableListChangedEventArgs <State> e)
        {
            if (DataGridView == null)
            {
                return;
            }

            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                Items.Add(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                Items.Remove(e.Item);
                transition_StateToChanged(null, null);
                break;

            case ObservableListChangedType.Reset:
                Items.Clear();
                foreach (State stateItem in itemsToChooseFrom)
                {
                    if (transition.StateFrom != stateItem)
                    {
                        Items.Add(stateItem);
                    }
                }
                transition_StateToChanged(null, null);
                break;
            }
        }
        /// <summary>
        /// Called when the manager of drawable assets changes.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="PlatformGameCreator.Editor.Common.ObservableListChangedEventArgs&lt;DrawableAssetType&gt;"/> instance containing the event data.</param>
        void DrawableAssets_ListChanged(object sender, ObservableListChangedEventArgs <DrawableAssetType> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ShowItem(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                ListViewItem deletedItem = FindDrawableAsset(e.Item);
                if (deletedItem != null)
                {
                    deletedItem.Remove();
                }
                break;

            case ObservableListChangedType.ItemChanged:
                Debug.Assert(true, "Operation not supported.");
                break;

            case ObservableListChangedType.Reset:
                ListViewClear();
                foreach (DrawableAssetType drawableAsset in DrawableAssets)
                {
                    ShowItem(drawableAsset);
                }
                break;
            }
        }
        /// <summary>
        /// Called when the container of prototypes changes.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="PlatformGameCreator.Editor.Common.ObservableListChangedEventArgs&lt;Actor&gt;"/> instance containing the event data.</param>
        private void Prototypes_ListChanged(object sender, ObservableListChangedEventArgs<Actor> e)
        {
            switch (e.ListChangedType)
            {
                case ObservableListChangedType.ItemAdded:
                    ShowItem(e.Item);
                    break;

                case ObservableListChangedType.ItemDeleted:
                    ListViewItem deletedItem = FindItem(e.Item);
                    if (deletedItem != null) deletedItem.Remove();
                    break;

                case ObservableListChangedType.ItemChanged:
                    Debug.Assert(true, "Operation not supported.");
                    break;

                case ObservableListChangedType.Reset:
                    listView.Clear();
                    foreach (Actor prototype in Prototypes)
                    {
                        ShowItem(prototype);
                    }
                    break;
            }
        }
示例#9
0
        /// <summary>
        /// Handles the ListChanged event of the Transitions of the State.
        /// Updates transitions of the state.
        /// </summary>
        private void Transitions_ListChanged(object sender, ObservableListChangedEventArgs <Transition> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                transitions.Add(new TransitionView(this, e.Item));
                break;

            case ObservableListChangedType.ItemDeleted:
                transitions.RemoveAt(e.Index);
                break;

            case ObservableListChangedType.Reset:
                foreach (TransitionView transitionView in transitions)
                {
                    transitionView.Dispose();
                }

                transitions.Clear();

                foreach (Transition transition in State.Transitions)
                {
                    transitions.Add(new TransitionView(this, transition));
                }
                break;
            }

            Refresh();
        }
        /// <summary>
        /// Handles the ListChanged event of the Transitions os the <see cref="State"/>.
        /// Updates the view of transitions.
        /// </summary>
        private void Transitions_ListChanged(object sender, ObservableListChangedEventArgs <Transition> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ShowTransition(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                DataGridViewRow deletedRow = FindTransition(e.Item);
                if (deletedRow != null)
                {
                    settingsView.table.Rows.Remove(deletedRow);
                }
                break;

            case ObservableListChangedType.Reset:
                settingsView.ClearRows();
                foreach (Transition transition in State.Transitions)
                {
                    ShowTransition(transition);
                }
                break;
            }
        }
示例#11
0
        /// <summary>
        /// Handles the ListChanged event of the <see cref="Scenes.Scene.Layers"/> at the scene.
        /// Called when the list of layers changes (the layer is added or removed). Adds or removes the actor from the layer.
        /// </summary>
        private void Layers_ListChanged(object sender, ObservableListChangedEventArgs <Layer> e)
        {
            IList <Layer> layers = sender as IList <Layer>;

            if (layers != null)
            {
                switch (e.ListChangedType)
                {
                case ObservableListChangedType.ItemAdded:
                    e.Item.ListChanged += new ObservableList <Actor> .ListChangedEventHandler(Layer_ListChanged);

                    foreach (Actor actor in e.Item)
                    {
                        Nodes.Add(actor);
                    }

                    break;

                case ObservableListChangedType.ItemDeleted:
                    e.Item.ListChanged -= new ObservableList <Actor> .ListChangedEventHandler(Layer_ListChanged);

                    foreach (Actor actor in e.Item)
                    {
                        Nodes.Remove(actor);
                    }

                    break;
                }
            }
        }
示例#12
0
        /// <summary>
        /// Called when the manager of sounds changes.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="PlatformGameCreator.Editor.Common.ObservableListChangedEventArgs&lt;Sound&gt;"/> instance containing the event data.</param>
        private void Sounds_ListChanged(object sender, ObservableListChangedEventArgs <Sound> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ShowItem(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                SoundTreeNode deletedItem = FindItem(e.Item);
                if (deletedItem != null)
                {
                    deletedItem.Remove();
                }
                break;

            case ObservableListChangedType.ItemChanged:
                Debug.Assert(true, "Not supported operation.");
                break;

            case ObservableListChangedType.Reset:
                TreeViewClear();
                foreach (Sound sound in Sounds)
                {
                    ShowItem(sound);
                }
                break;
            }
        }
示例#13
0
        /// <summary>
        /// Handles the ListChanged event of the <see cref="Scenes.Scene.Paths"/> at the scene.
        /// Called when the list of paths changes (the path is added or removed).
        /// </summary>
        private void Paths_ListChanged(object sender, ObservableListChangedEventArgs <Path> e)
        {
            IList <Path> paths = sender as IList <Path>;

            if (paths != null)
            {
                BasicListChanged(paths, e);
            }
        }
示例#14
0
        /// <summary>
        /// Handles the ListChanged event of the <see cref="Layer"/>.
        /// Called when the layer changes (the actor is added or removed).
        /// </summary>
        private void Layer_ListChanged(object sender, ObservableListChangedEventArgs <Actor> e)
        {
            Layer layer = sender as Layer;

            if (layer != null)
            {
                BasicListChanged(layer, e);
            }
        }
        /// <summary>
        /// Handles the ListChanged event of the children of the actor.
        /// Updates the actor children (child is added or removed).
        /// </summary>
        private void Children_ListChanged(object sender, ObservableListChangedEventArgs <Actor> e)
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                ActorView addedActorView = (ActorView)Children.Add(e.Item);
                addedActorView.Parent = this;
                break;

            case ObservableListChangedType.ItemDeleted:
                Children.Remove(e.Item);
                break;
            }
        }
示例#16
0
        /// <summary>
        /// Handles the ListChanged event of the extensions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The MLifter.Generics.ObservableListChangedEventArgs&lt;MLifter.DAL.Interfaces.IExtension&gt; instance containing the event data.</param>
        /// <remarks>Documented by Dev02, 2009-07-03</remarks>
        void extensions_ListChanged(object sender, ObservableListChangedEventArgs <IExtension> e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
                extensionconnector.SetExtensionLM(e.Item.Id, this.Id);
                break;

            case ListChangedType.ItemDeleted:
                extensionconnector.DeleteExtension(e.Item.Id);
                break;

            default:
                break;
            }
        }
示例#17
0
        /// <summary>
        /// Handles the ListChanged event of the Connections control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifter.Components.ObservableListChangedEventArgs&lt;MLifter.BusinessLayer.IConnectionString&gt;"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private void Connections_ListChanged(object sender, ObservableListChangedEventArgs<IConnectionString> e)
        {
            switch (e.ListChangedType)
            {
                case ListChangedType.ItemAdded:
                    if (Folders.Find(f => f.Connection == e.Item) == null)
                    {
                        FolderTreeNode entry = new FolderTreeNode(e.Item);
                        entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                        lock (Nodes)
                        {
                            Nodes.Add(entry);
                        }
                        if (InvokeRequired)
                            Invoke((MethodInvoker)delegate { AddFolderToMainNode(entry); });
                        else
                            AddFolderToMainNode(entry);
                        entry.UpdateDetails();
                    }
                    break;
                case ListChangedType.ItemDeleted:
                    if (InvokeRequired)
                        Invoke((MethodInvoker)delegate
                        {
                            lock (Nodes)
                            {
                                Nodes.FindAll(f => f.Connection == e.Item).ForEach(f => base.Nodes.Remove(f));
                                Nodes.RemoveAll(f => f.Connection == e.Item);
                            }
                        });
                    else
                    {
                        lock (Nodes)
                        {
                            Nodes.FindAll(f => f.Connection == e.Item).ForEach(f => base.Nodes.Remove(f));
                            Nodes.RemoveAll(f => f.Connection == e.Item);
                        }
                    }
                    break;
                case ListChangedType.ItemChanged:
                    break;
                case ListChangedType.Reset:
                    foreach (IConnectionString item in Connections)
                    {
                        if (Folders.Find(f => f.Connection == item) == null)
                        {
                            FolderTreeNode entry = new FolderTreeNode(item);
                            entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                            lock (Nodes)
                            {
                                Nodes.Add(entry);
                            }
                            if (InvokeRequired)
                                Invoke((MethodInvoker)delegate { AddFolderToMainNode(entry); });
                            else
                                AddFolderToMainNode(entry);
                            entry.UpdateDetails();
                        }
                    }
                    break;
                case ListChangedType.ItemMoved:
                default:
                    throw new NotSupportedException();
            }

            updateTimer.Enabled = true;
        }
示例#18
0
 /// <summary>
 /// Called when the layer changes (actor is added or removed).
 /// </summary>
 private void Value_ListChanged(object sender, ObservableListChangedEventArgs <Actor> e)
 {
     SceneTree.BasicListChanged(this, e);
 }
示例#19
0
文件: DbSettings.cs 项目: hmehr/OSS
 void list_ListChanged(object sender, ObservableListChangedEventArgs<int> e)
 {
     SelectedLearnChapters = sender as IList<int>;
 }
示例#20
0
 /// <summary>
 /// Handles the ListChanged event of the <see cref="Scenes.Scene.Paths"/> at the scene.
 /// Updates paths of the scene in the tree.
 /// </summary>
 private void Paths_ListChanged(object sender, ObservableListChangedEventArgs <Path> e)
 {
     BasicListChanged(pathsNode, e);
 }
示例#21
0
 void list_ListChanged(object sender, ObservableListChangedEventArgs <int> e)
 {
     SelectedLearnChapters = sender as IList <int>;
 }
示例#22
0
 /// <summary>
 /// Handles the ListChanged event of the <see cref="Scenes.Scene.Layers"/> at the scene.
 /// Updates layers of the scene in the tree.
 /// </summary>
 private void Layers_ListChanged(object sender, ObservableListChangedEventArgs <Layer> e)
 {
     BasicListChanged(layersNode, e);
 }
        /// <summary>
        /// Handles the ListChanged event of the Connections control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifter.Components.ObservableListChangedEventArgs&lt;MLifter.BusinessLayer.IConnectionString&gt;"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private void Connections_ListChanged(object sender, ObservableListChangedEventArgs <IConnectionString> e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
                if (Folders.Find(f => f.Connection == e.Item) == null)
                {
                    FolderTreeNode entry = new FolderTreeNode(e.Item);
                    entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                    lock (Nodes)
                    {
                        Nodes.Add(entry);
                    }
                    if (InvokeRequired)
                    {
                        Invoke((MethodInvoker) delegate { AddFolderToMainNode(entry); });
                    }
                    else
                    {
                        AddFolderToMainNode(entry);
                    }
                    entry.UpdateDetails();
                }
                break;

            case ListChangedType.ItemDeleted:
                if (InvokeRequired)
                {
                    Invoke((MethodInvoker) delegate
                    {
                        lock (Nodes)
                        {
                            Nodes.FindAll(f => f.Connection == e.Item).ForEach(f => base.Nodes.Remove(f));
                            Nodes.RemoveAll(f => f.Connection == e.Item);
                        }
                    });
                }
                else
                {
                    lock (Nodes)
                    {
                        Nodes.FindAll(f => f.Connection == e.Item).ForEach(f => base.Nodes.Remove(f));
                        Nodes.RemoveAll(f => f.Connection == e.Item);
                    }
                }
                break;

            case ListChangedType.ItemChanged:
                break;

            case ListChangedType.Reset:
                foreach (IConnectionString item in Connections)
                {
                    if (Folders.Find(f => f.Connection == item) == null)
                    {
                        FolderTreeNode entry = new FolderTreeNode(item);
                        entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                        lock (Nodes)
                        {
                            Nodes.Add(entry);
                        }
                        if (InvokeRequired)
                        {
                            Invoke((MethodInvoker) delegate { AddFolderToMainNode(entry); });
                        }
                        else
                        {
                            AddFolderToMainNode(entry);
                        }
                        entry.UpdateDetails();
                    }
                }
                break;

            case ListChangedType.ItemMoved:
            default:
                throw new NotSupportedException();
            }

            updateTimer.Enabled = true;
        }
示例#24
0
 /// <summary>
 /// Handles the ListChanged event of the extensions control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The MLifter.Generics.ObservableListChangedEventArgs&lt;MLifter.DAL.Interfaces.IExtension&gt; instance containing the event data.</param>
 /// <remarks>Documented by Dev02, 2009-07-03</remarks>
 void extensions_ListChanged(object sender, ObservableListChangedEventArgs<IExtension> e)
 {
     switch (e.ListChangedType)
     {
         case ListChangedType.ItemAdded:
             extensionconnector.SetExtensionLM(e.Item.Id, this.Id);
             break;
         case ListChangedType.ItemDeleted:
             extensionconnector.DeleteExtension(e.Item.Id);
             break;
         default:
             break;
     }
 }
        /// <summary>
        /// Handles the ListChanged event of the Folders list.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifter.Components.ObservableListChangedEventArgs&lt;MLifter.BusinessLayer.FolderIndexEntry&gt;"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private void Folders_ListChanged(object sender, ObservableListChangedEventArgs <FolderIndexEntry> e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
                if (!Connections.Contains(e.Item.Connection))
                {
                    Connections.Add(e.Item.Connection);
                }
                if (e.Item.Parent != null)
                {
                    try
                    {
                        FolderTreeNode entry = new FolderTreeNode(e.Item);
                        entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                        lock (Nodes)
                        {
                            Nodes.Add(entry);
                        }
                        while (Nodes.Find(n => n.Folder == e.Item.Parent) == null)
                        {
                            Thread.Sleep(10);
                        }
                        if (InvokeRequired)
                        {
                            Invoke((MethodInvoker) delegate { AddFolderToParent(e.Item.Parent, entry); });
                        }
                        else
                        {
                            entry.UpdateDetails();
                        }
                    }
                    catch (Exception exp) { Trace.WriteLine("Folder-Added: " + exp.ToString()); }
                }
                else
                {
                    FolderTreeNode node = Nodes.Find(n => n.Connection == e.Item.Connection);
                    if (node != null)
                    {
                        node.SetFolder(e.Item);
                    }
                    else
                    {
                        FolderTreeNode entry = new FolderTreeNode(e.Item);
                        entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                        lock (Nodes)
                        {
                            Nodes.Add(entry);
                        }
                        Delegate add = (MethodInvoker) delegate
                        {
                            BeginUpdate();
                            lock (Nodes)
                            {
                                Nodes.Find(n => n.IsMainNode).Nodes.Add(entry);
                            }
                            EndUpdate();
                        };
                        if (InvokeRequired)
                        {
                            Invoke((MethodInvoker)add);
                        }
                        else
                        {
                            add.DynamicInvoke();
                        }
                        entry.UpdateDetails();
                    }
                }
                e.Item.ContentLoading += new EventHandler(Folder_ContentLoading);
                break;

            case ListChangedType.ItemDeleted:
                throw new NotImplementedException();

            case ListChangedType.ItemChanged:
                break;

            case ListChangedType.Reset:
            case ListChangedType.ItemMoved:
            default:
                throw new NotSupportedException();
            }

            updateTimer.Enabled = true;
        }
示例#26
0
        /// <summary>
        /// Updates the specified <see cref="GameObject"/> when the container changes (<see cref="GameObject"/> is added or removed).
        /// Added or removed <see cref="SceneNode"/> for the specified <see cref="GameObject"/>.
        /// </summary>
        /// <typeparam name="GameObjectType">The type of <see cref="GameObject"/> stored in the container.</typeparam>
        private void BasicListChanged <GameObjectType>(IList <GameObjectType> container, ObservableListChangedEventArgs <GameObjectType> e) where GameObjectType : GameObject
        {
            switch (e.ListChangedType)
            {
            case ObservableListChangedType.ItemAdded:
                Nodes.Add(e.Item);
                break;

            case ObservableListChangedType.ItemDeleted:
                Nodes.Remove(e.Item);
                break;

            case ObservableListChangedType.Reset:
                break;
            }
        }
示例#27
0
        /// <summary>
        /// Handles the ListChanged event of the Folders list.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifter.Components.ObservableListChangedEventArgs&lt;MLifter.BusinessLayer.FolderIndexEntry&gt;"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private void Folders_ListChanged(object sender, ObservableListChangedEventArgs<FolderIndexEntry> e)
        {
            switch (e.ListChangedType)
            {
                case ListChangedType.ItemAdded:
                    if (!Connections.Contains(e.Item.Connection))
                        Connections.Add(e.Item.Connection);
                    if (e.Item.Parent != null)
                    {
                        try
                        {
                            FolderTreeNode entry = new FolderTreeNode(e.Item);
                            entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                            lock (Nodes)
                            {
                                Nodes.Add(entry);
                            }
                            while (Nodes.Find(n => n.Folder == e.Item.Parent) == null) Thread.Sleep(10);
                            if (InvokeRequired)
                                Invoke((MethodInvoker)delegate { AddFolderToParent(e.Item.Parent, entry); });
                            else
                                entry.UpdateDetails();
                        }
                        catch (Exception exp) { Trace.WriteLine("Folder-Added: " + exp.ToString()); }
                    }
                    else
                    {
                        FolderTreeNode node = Nodes.Find(n => n.Connection == e.Item.Connection);
                        if (node != null)
                            node.SetFolder(e.Item);
                        else
                        {
                            FolderTreeNode entry = new FolderTreeNode(e.Item);
                            entry.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
                            lock (Nodes)
                            {
                                Nodes.Add(entry);
                            }
                            Delegate add = (MethodInvoker)delegate
                                {
                                    BeginUpdate();
                                    lock (Nodes)
                                    {
                                        Nodes.Find(n => n.IsMainNode).Nodes.Add(entry);
                                    }
                                    EndUpdate();
                                };
                            if (InvokeRequired)
                                Invoke((MethodInvoker)add);
                            else
                                add.DynamicInvoke();
                            entry.UpdateDetails();
                        }
                    }
                    e.Item.ContentLoading += new EventHandler(Folder_ContentLoading);
                    break;
                case ListChangedType.ItemDeleted:
                    throw new NotImplementedException();
                case ListChangedType.ItemChanged:
                    break;
                case ListChangedType.Reset:
                case ListChangedType.ItemMoved:
                default:
                    throw new NotSupportedException();
            }

            updateTimer.Enabled = true;
        }
示例#28
0
文件: DbExtension.cs 项目: hmehr/OSS
        /// <summary>
        /// Handles the ListChanged event of the extensionActions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The MLifter.Generics.ObservableListChangedEventArgs&lt;MLifter.DAL.Interfaces.ExtensionAction&gt; instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-07-06</remarks>
        private void extensionActions_ListChanged(object sender, ObservableListChangedEventArgs<ExtensionAction> e)
        {
            IList<ExtensionAction> eaList = connector.GetExtensionActions(guid);

            switch (e.ListChangedType)
            {
                case ListChangedType.ItemAdded:
                    eaList.Add(e.Item);
                    connector.SetExtensionActions(guid, eaList);
                    break;
                case ListChangedType.ItemDeleted:
                    eaList.Remove(e.Item);
                    connector.SetExtensionActions(guid, eaList);
                    break;
                case ListChangedType.Reset:
                    IList<ExtensionAction> oldList = (IList<ExtensionAction>)sender;
                    connector.SetExtensionActions(guid, oldList);
                    break;
                default:
                    break;
            }
        }