Пример #1
0
 private void AddFolderToParent(FolderIndexEntry parent, FolderTreeNode entry)
 {
     BeginUpdate();
     lock (Nodes)
     {
         Nodes.Find(n => n.Folder == parent).Nodes.Add(entry);
     }
     EndUpdate();
 }
Пример #2
0
 private void AddFolderToMainNode(FolderTreeNode entry)
 {
     BeginUpdate();
     lock (Nodes)
     {
         Nodes.Find(n => n.IsMainNode).Nodes.Add(entry);
     }
     EndUpdate();
 }
Пример #3
0
        /// <summary>
        /// Handles the TreeViewSelectionChanged event of the learningModulesTreeViewControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-03-04</remarks>
        private void learningModulesTreeViewControl_TreeViewSelectionChanged(object sender, TreeViewEventArgs e)
        {
            FolderTreeNode safeNode = selectedTreeViewNode;
            if (e.Node is FolderTreeNode)
            {
                SetFeedVisible(false, null);

                selectedTreeViewNode = e.Node as FolderTreeNode;
                if (UpdateActualItems())
                {
                    UpdateSearchAndRefreshList();
                    buttonLevelUp.Enabled = !selectedTreeViewNode.IsMainNode;
                }
                else
                    learningModulesTreeViewControl.SetSelectedFolder(safeNode.Folder);
            }
            else if (e.Node is FeedTreeNode)
            {
                FeedTreeNode node = e.Node as FeedTreeNode;
                if (node.IsListLoaded)
                {
                    if (learningModulesTreeViewControl.ShowLearningModulesOfSubFolder)
                        SetFeedVisible(true, node.Modules);
                    else
                    {
                        List<ListViewItem> items = new List<ListViewItem>();
                        foreach (FeedCategoryTreeNode subNode in node.Nodes)
                            items.Add(GetCategoryListViewItem(subNode));
                        SetFeedVisible(true, items);
                    }
                }
                else if (!node.IsLoading)
                {
                    FeedIsVisible = true;
                    node.ContentLoaded += new EventHandler(node_ContentLoaded);
                    node.BeginLoadWebContent(UserConfigurationPath);
                }
            }
            else if (e.Node is FeedCategoryTreeNode)
            {
                if (learningModulesTreeViewControl.ShowLearningModulesOfSubFolder)
                {
                    List<ListViewItem> modules = new List<ListViewItem>((e.Node as FeedCategoryTreeNode).Modules);
                    foreach (ListViewItem item in (e.Node as FeedCategoryTreeNode).SubCategoryModules)
                    {
                        bool exists = false;
                        foreach (ModuleCategory category in (e.Node as FeedCategoryTreeNode).Categories)
                        {
                            if (((ModuleInfo)item.Tag).Categories.Contains(category.Id.ToString()))
                            {
                                exists = true;
                                break;
                            }
                        }
                        if (!exists)
                            modules.Add(item);
                    }

                    SetFeedVisible(true, modules);
                }
                else
                {
                    List<ListViewItem> items = new List<ListViewItem>();
                    foreach (FeedCategoryTreeNode subNode in e.Node.Nodes)
                        items.Add(GetCategoryListViewItem(subNode));
                    items.AddRange((e.Node as FeedCategoryTreeNode).OwnModules);
                    SetFeedVisible(true, items);
                }
            }
        }
 /// <summary>
 /// Imports the learning module.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="targetEntry">The target entry.</param>
 /// <remarks>Documented by Dev03, 2009-03-10</remarks>
 private void ImportLearningModule(string file, FolderTreeNode targetEntry)
 {
     if (targetEntry.Level == 0)
         OpenLearningModule(file);
     else
         if (OnImportLearningModule != null)
             OnImportLearningModule(treeViewLearnModules, new ImportLearningModuleEventArgs(targetEntry,
                 new LearningModulesIndexEntry(
                         new ConnectionStringStruct(
                             (Path.GetExtension(file) == DAL.Helper.OdxExtension ||
                                 Path.GetExtension(file) == DAL.Helper.DzpExtension ||
                                 Path.GetExtension(file) == DAL.Helper.OdfExtension)
                                 ? DatabaseType.Xml : DatabaseType.MsSqlCe, file, false)
                 )));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportLearningModuleEventArgs"/> class.
 /// </summary>
 /// <param name="treeNode">The the tree node to which the learning module should be imported.</param>
 /// <remarks>Documented by Dev05, 2008-12-03</remarks>
 public ImportLearningModuleEventArgs(FolderTreeNode treeNode, LearningModulesIndexEntry learningModule)
 {
     this.treeNode = treeNode;
     this.learningModule = learningModule;
 }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
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;
        }
Пример #10
0
 private void AddFolderToParent(FolderIndexEntry parent, FolderTreeNode entry)
 {
     BeginUpdate();
     lock (Nodes)
     {
         Nodes.Find(n => n.Folder == parent).Nodes.Add(entry);
     }
     EndUpdate();
 }
Пример #11
0
 private void AddFolderToMainNode(FolderTreeNode entry)
 {
     BeginUpdate();
     lock (Nodes)
     {
         Nodes.Find(n => n.IsMainNode).Nodes.Add(entry);
     }
     EndUpdate();
 }