/// <summary>
 /// Raises the <see cref="E:FolderContentLoaded"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnContentLoaded(FolderIndexEntry sender, EventArgs e)
 {
     if (ContentLoaded != null)
     {
         ContentLoaded(sender, e);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderListViewItem"/> class.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <remarks>Documented by Dev05, 2009-03-07</remarks>
        public FolderListViewItem(FolderIndexEntry entry)
            : base(entry.DisplayName)
        {
            while (SubItems.Count < 3) SubItems.Add(new ListViewSubItem());

            Folder = entry;

            Folder.FolderAdded += new EventHandler<FolderAddedEventArgs>(Folder_FolderAdded);
            Folder.LearningModuleAdded += new EventHandler<LearningModuleAddedEventArgs>(Folder_LearningModuleAdded);
            UpdateImage();
        }
        private FolderIndexEntry CreateNewFolderEntry(string path)
        {
            FolderIndexEntry entry = new FolderIndexEntry(path, path.Substring(path.LastIndexOf("\\") + 1), Connection, currentUser, SyncedModulesPath, getLogin, dataAccessError, this);

            entry.ContentCleared      += new EventHandler(Folder_ContentCleared);
            entry.ContentLoading      += new EventHandler(Folder_ContentLoading);
            entry.ContentLoaded       += new EventHandler(Folder_ContentLoaded);
            entry.FolderAdded         += new EventHandler <FolderAddedEventArgs>(Folder_SubFolderAdded);
            entry.LearningModuleAdded += new EventHandler <LearningModuleAddedEventArgs>(Folder_SubFolder_LearningModuleAdded);
            entry.BeginLoading();
            return(entry);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderIndexEntry"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="name">The name.</param>
        /// <param name="parentConnection">The parent connection.</param>
        /// <param name="user">The user.</param>
        /// <param name="getLoginDelegate">The get login delegate.</param>
        /// <param name="dataAccessErrorDelegate">The data access error delegate.</param>
        /// <param name="parent">The parent.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private FolderIndexEntry(string path, string name, IConnectionString parentConnection, IUser user, string syncedModulesPath,
                                 GetLoginInformation getLoginDelegate, DataAccessErrorDelegate dataAccessErrorDelegate, FolderIndexEntry parent)
        {
            IsRootNode        = false;
            Path              = path;
            DisplayName       = name;
            Connection        = parentConnection;
            getLogin          = getLoginDelegate;
            dataAccessError   = dataAccessErrorDelegate;
            Parent            = parent;
            SyncedModulesPath = syncedModulesPath;

            Login(user);
        }
 /// <summary>
 /// Raises the <see cref="E:FolderContentLoaded"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnFolderContentLoaded(FolderIndexEntry sender, EventArgs e)
 {
     lock (loadingFolders)
     {
         try
         {
             if (loadingFolders.Contains(sender))
             {
                 loadingFolders.Remove(sender);
             }
         }
         catch (Exception exp) { Trace.WriteLine(exp.ToString()); }
     }
     if (FolderContentLoaded != null)
     {
         FolderContentLoaded(sender, e);
     }
 }
 /// <summary>
 /// Raises the <see cref="E:FolderContentLoading"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnFolderContentLoading(FolderIndexEntry sender, EventArgs e)
 {
     lock (loadingFolders)
     {
         try
         {
             if (!loadingFolders.Contains(sender))
             {
                 loadingFolders.Add(sender);
             }
         }
         catch (Exception exp) { Trace.WriteLine(exp.ToString()); }
         updateTimer.Enabled = true;
     }
     if (FolderContentLoading != null)
     {
         FolderContentLoading(sender, e);
     }
 }
 /// <summary>
 /// Folder was added.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev05, 2009-03-13</remarks>
 public void AddFolder(FolderIndexEntry entry)
 {
     treeViewLearnModules.Folders.Add(entry);
 }
Example #8
0
 private FolderIndexEntry CreateNewFolderEntry(string path)
 {
     FolderIndexEntry entry = new FolderIndexEntry(path, path.Substring(path.LastIndexOf("\\") + 1), Connection, currentUser, SyncedModulesPath, getLogin, dataAccessError, this);
     entry.ContentCleared += new EventHandler(Folder_ContentCleared);
     entry.ContentLoading += new EventHandler(Folder_ContentLoading);
     entry.ContentLoaded += new EventHandler(Folder_ContentLoaded);
     entry.FolderAdded += new EventHandler<FolderAddedEventArgs>(Folder_SubFolderAdded);
     entry.LearningModuleAdded += new EventHandler<LearningModuleAddedEventArgs>(Folder_SubFolder_LearningModuleAdded);
     entry.BeginLoading();
     return entry;
 }
Example #9
0
		private void CreateNewLearningModule()
		{
			try
			{
				if (LearningModulesIndex.WritableConnections.Count <= 0)
					throw new NoWritableConnectionAvailableException();

				//Close the current learning module
				if (LearnLogic.LearningModuleLoaded)
					if (!LearnLogic.CloseLearningModule())
						return;

				//Create the wizard
				Wizard dicWizard = new Wizard();
				dicWizard.HelpFile = MLifter.Classes.Help.HelpPath;
				dicWizard.Text = Resources.NEWDIC_CAPTION;

				SourceSelectionPage sourceSelectionPage = null;
				WelcomePage welcomePage = new WelcomePage();
				SideSettingsPage sideSettingsPage = new SideSettingsPage();

				// only one connection available?
				if (LearningModulesIndex.WritableConnections.Count <= 0)
					throw new NoWritableConnectionAvailableException();
				else if (LearningModulesIndex.WritableConnections.Count > 1)
				{
					sourceSelectionPage = new SourceSelectionPage();
					dicWizard.Pages.Add(sourceSelectionPage);
				}
				dicWizard.Pages.Add(welcomePage);
				dicWizard.Pages.Add(sideSettingsPage);

				//Show the Wizards
				if (dicWizard.ShowDialog() == DialogResult.OK)
				{
					try
					{
						newLM = true;
						IConnectionString connectionString;
						if (sourceSelectionPage != null)
							connectionString = sourceSelectionPage.ConnectionString;
						else
							connectionString = LearningModulesIndex.WritableConnections[0];

						string dicName = welcomePage.DictionaryName;

						if (!LearningModulesIndex.ConnectionUsers.ContainsKey(connectionString))
						{
							FolderIndexEntry folderEntry = new FolderIndexEntry(connectionString is UncConnectionStringBuilder ? connectionString.ConnectionString : string.Empty,
								connectionString.Name, connectionString, null, Setup.SyncedModulesPath, LearnLogic.GetLoginDelegate, LearnLogic.DataAccessErrorDelegate);
							LearningModulesIndex.ConnectionUsers[connectionString] = folderEntry.CurrentUser;
						}
						LearnLogic.User.SetBaseUser(LearningModulesIndex.ConnectionUsers[connectionString]);
						ConnectionStringStruct connectionStringStruct;
						using (MLifter.DAL.Interfaces.IDictionary newDic = LearnLogic.User.CreateLearningModule(welcomePage.DictionaryCategory.Id, welcomePage.DictionaryName))
						{
							newDic.Author = welcomePage.DictionaryAuthor;
							newDic.Category = welcomePage.DictionaryCategory;
							newDic.Description = welcomePage.DictionaryDescription;

							newDic.DefaultSettings.AnswerCaption = sideSettingsPage.AnswerTitle;
							newDic.DefaultSettings.QuestionCaption = sideSettingsPage.QuestionTitle;
							newDic.DefaultSettings.AnswerCulture = sideSettingsPage.AnswerCulture;
							newDic.DefaultSettings.QuestionCulture = sideSettingsPage.QuestionCulture;
							newDic.Save();

							connectionStringStruct = new ConnectionStringStruct(connectionString.ConnectionType == DatabaseType.Unc ? DatabaseType.MsSqlCe : connectionString.ConnectionType,
								newDic.Connection, newDic.Id, LearnLogic.User.SessionId);
							connectionStringStruct.LearningModuleFolder = connectionString.ConnectionString;
						}
						LearningModulesIndexEntry entry = new LearningModulesIndexEntry();
						entry.ConnectionString = connectionStringStruct;
						entry.Author = welcomePage.DictionaryAuthor;
						entry.DisplayName = welcomePage.DictionaryName;
						entry.Description = welcomePage.DictionaryDescription;
						entry.Connection = connectionString;
						entry.User = LearningModulesIndex.ConnectionUsers[connectionString];

						OpenLearningModule(entry);

						LearnLogic.SaveLearningModule();
						this.Activate(); //[ML-763] Window is not focused after creation of a new dictionary
						OnLMOptionsChanged();

						newLM = false;
					}
					catch (Exception exp)
					{
						Trace.WriteLine(exp.ToString());
						TaskDialog.MessageBox(Resources.NEW_DICT_CAPTION, Resources.NEW_DICT_CAPTION, Resources.NEW_DICT_TEXT, exp.ToString(),
							string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
					}
				}
				else
					ShowLearningModulesPage();
			}
			catch (NoWritableConnectionAvailableException)
			{
				TaskDialog.MessageBox(Resources.NEW_DIC_NO_CONNECTION_CAPTION, Resources.NEW_DIC_NO_CONNECTION_CAPTION, Resources.NEW_DIC_NO_CONNECTION_TEXT, TaskDialogButtons.OK, TaskDialogIcons.Error);
			}
		}
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FolderAddedEventArgs"/> class.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev05, 2009-03-06</remarks>
 public FolderAddedEventArgs(FolderIndexEntry entry)
 {
     Folder = entry;
 }
Example #11
0
 /// <summary>
 /// Raises the <see cref="E:FolderContentLoading"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnContentLoading(FolderIndexEntry sender, EventArgs e)
 {
     if (ContentLoading != null)
         ContentLoading(sender, e);
 }
        private void LoadContent()
        {
            try
            {
                lock (content)
                    content.Clear();

                if (Connection is UncConnectionStringBuilder && Directory.Exists(Path))
                {
                    foreach (string file in Directory.GetFiles(Path, "*" + DAL.Helper.EmbeddedDbExtension, SearchOption.TopDirectoryOnly))
                    {
                        try
                        {
                            LearningModulesIndexEntry entry;
                            try
                            {
                                entry = CreateNewEmbeddedDbLearningModuleEntry(file);
                            }
                            catch (DatabaseVersionNotSupported e)
                            {
                                Trace.WriteLine("FolderIndexEntry.LoadContent() found an old version db - use File->Open to convert the DB.");

                                if (!e.CanUpdate)
                                {
                                    continue;
                                }
                                else
                                {
                                    entry = CreateNewEmbeddedDbLearningModuleEntry(file);
                                }
                            }
                            catch (System.Data.SqlServerCe.SqlCeException ex)
                            {
                                //probably an  invalid db file
                                Trace.WriteLine("FolderIndexEntry.LoadContent() found an invalid db - " + ex.Message);
                                continue;
                            }
                            lock (content)
                                content.Add(entry);
                            OnLearningModuleAdded(new LearningModuleAddedEventArgs(entry));
                        }
                        catch (IOException exp) { Trace.WriteLine(exp.ToString()); }
                    }
                    foreach (string file in Directory.GetFiles(Path, "*" + DAL.Helper.OdxExtension, SearchOption.TopDirectoryOnly))
                    {
                        try
                        {
                            LearningModulesIndexEntry entry = CreateNewOdxLearningModuleEntry(file);
                            lock (content)
                                content.Add(entry);
                            OnLearningModuleAdded(new LearningModuleAddedEventArgs(entry));
                        }
                        catch (IOException exp) { Trace.WriteLine(exp.ToString()); }
                    }
                    foreach (string folder in Directory.GetDirectories(Path, "*", SearchOption.TopDirectoryOnly))
                    {
                        try
                        {
                            FolderIndexEntry entry = CreateNewFolderEntry(folder);
                            lock (content)
                                content.Add(entry);
                            OnFolderAdded(new FolderAddedEventArgs(entry));
                        }
                        catch (IOException exp) { Trace.WriteLine(exp.ToString()); }
                    }
                }
                else
                {
                    foreach (IDictionary dic in currentUser.List().Dictionaries)
                    {
                        try
                        {
                            LearningModulesIndexEntry entry = CreateLerningModuleEntry(dic, currentUser);
                            lock (content)
                                content.Add(entry);
                            OnLearningModuleAdded(new LearningModuleAddedEventArgs(entry));
                        }
                        catch (IOException exp) { Trace.WriteLine(exp.ToString()); }
                    }
                }
            }
            catch (Exception exp)
            {
                OnContentLoadException(this, exp);
            }
            finally
            {
                IsLoading = false;
                OnContentLoaded(this, EventArgs.Empty);
            }
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderIndexEntry"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="name">The name.</param>
        /// <param name="parentConnection">The parent connection.</param>
        /// <param name="user">The user.</param>
        /// <param name="getLoginDelegate">The get login delegate.</param>
        /// <param name="dataAccessErrorDelegate">The data access error delegate.</param>
        /// <param name="parent">The parent.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        private FolderIndexEntry(string path, string name, IConnectionString parentConnection, IUser user, string syncedModulesPath,
            GetLoginInformation getLoginDelegate, DataAccessErrorDelegate dataAccessErrorDelegate, FolderIndexEntry parent)
        {
            IsRootNode = false;
            Path = path;
            DisplayName = name;
            Connection = parentConnection;
            getLogin = getLoginDelegate;
            dataAccessError = dataAccessErrorDelegate;
            Parent = parent;
            SyncedModulesPath = syncedModulesPath;

            Login(user);
        }
Example #14
0
        /// <summary>
        /// Sets the folder.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <remarks>Documented by Dev05, 2009-03-12</remarks>
        public void SetFolder(FolderIndexEntry entry)
        {
            connection = entry.Connection;
            Folder = entry;
            Folder.ContentLoading += new EventHandler(Folder_ContentLoading);
            Folder.ContentLoaded += new EventHandler(Folder_ContentLoaded);
            Folder.ContentLoadException += new FolderIndexEntry.ContentLoadExceptionEventHandler(Folder_ContentLoadException);
            Folder.LearningModuleAdded += new EventHandler<LearningModuleAddedEventArgs>(Folder_LearningModuleAdded);
            Folder.FolderAdded += new EventHandler<FolderAddedEventArgs>(Folder_FolderAdded);

            Text = entry.IsRootNode ? entry.Connection.Name : entry.Path.Remove(0, entry.Parent.Path.Length).Trim('\\');
            UpdateDetails();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FolderAddedEventArgs"/> class.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev05, 2009-03-06</remarks>
 public FolderAddedEventArgs(FolderIndexEntry entry)
 {
     Folder = entry;
 }
 /// <summary>
 /// Raises the <see cref="E:FolderContentLoading"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnFolderContentLoading(FolderIndexEntry sender, EventArgs e)
 {
     lock (loadingFolders)
     {
         try
         {
             if (!loadingFolders.Contains(sender))
                 loadingFolders.Add(sender);
         }
         catch (Exception exp) { Trace.WriteLine(exp.ToString()); }
         updateTimer.Enabled = true;
     }
     if (FolderContentLoading != null)
         FolderContentLoading(sender, e);
 }
 /// <summary>
 /// Raises the <see cref="E:FolderContentLoaded"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev05, 2009-03-10</remarks>
 protected virtual void OnFolderContentLoaded(FolderIndexEntry sender, EventArgs e)
 {
     lock (loadingFolders)
     {
         try
         {
             if (loadingFolders.Contains(sender))
                 loadingFolders.Remove(sender);
         }
         catch (Exception exp) { Trace.WriteLine(exp.ToString()); }
     }
     if (FolderContentLoaded != null)
         FolderContentLoaded(sender, e);
 }
        /// <summary>
        /// Gets the folder of a connection.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev05, 2009-03-06</remarks>
        public FolderIndexEntry GetFolderOfConnection(IConnectionString connection)
        {
            if (connection == null)
                return null;

            FolderIndexEntry entry = Folders.Find(f => f.Connection == connection);
            if (entry != null)
                return entry;

            entry = new FolderIndexEntry(connection is UncConnectionStringBuilder ? connection.ConnectionString : string.Empty, connection.Name, connection, null, SyncedModulesPath, getLogin, dataAccessError);
            ConnectionUsers[connection] = entry.CurrentUser;
            Users.Add(entry.CurrentUser);

            Folders.Add(entry);
            OnFolderAdded(new FolderAddedEventArgs(entry));

            entry.ContentCleared += new EventHandler(Folder_ContentCleared);
            entry.ContentLoading += new EventHandler(Folder_ContentLoading);
            entry.ContentLoaded += new EventHandler(Folder_ContentLoaded);
            entry.FolderAdded += new EventHandler<FolderAddedEventArgs>(Folder_SubFolderAdded);
            entry.LearningModuleAdded += new EventHandler<LearningModuleAddedEventArgs>(Folder_LearningModuleAdded);

            entry.BeginLoading();

            if (entry.IsOffline)
            {
                entry.GetContainingEntries(true).ForEach(e => learningModules.Add(e as LearningModulesIndexEntry));
                throw new ServerOfflineException();
            }

            return entry;
        }
 /// <summary>
 /// Removes the folder.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev05, 2009-04-01</remarks>
 public void RemoveFolder(FolderIndexEntry entry)
 {
     treeViewLearnModules.Folders.Remove(entry);
 }
 /// <summary>
 /// Sets and expands the selected folder.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev08, 2009-03-09</remarks>
 public void SetSelectedFolder(FolderIndexEntry entry)
 {
     treeViewLearnModules.SelectedFolder = entry;
 }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FolderTreeNode"/> class.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <remarks>Documented by Dev05, 2009-03-12</remarks>
 public FolderTreeNode(FolderIndexEntry entry)
 {
     SetFolder(entry);
 }
Example #22
0
 private void AddFolderToParent(FolderIndexEntry parent, FolderTreeNode entry)
 {
     BeginUpdate();
     lock (Nodes)
     {
         Nodes.Find(n => n.Folder == parent).Nodes.Add(entry);
     }
     EndUpdate();
 }