/// <summary> /// Adds the Text. /// </summary> /// <param name="Text">The Text.</param> /// <remarks>Documented by Dev05, 2007-09-27</remarks> private void AddText(string text) { if (!text.Contains("\t") && !text.Contains(";")) AddWord(text); else { string[] lines = text.Split(new string[] { "\n\r", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); bool statusmessageenabled = lines.Length > 100; MLifter.Controls.LoadStatusMessage message = new MLifter.Controls.LoadStatusMessage(Properties.Resources.COLLECTOR_STATUSMESSAGE, lines.Length, true); if (statusmessageenabled) message.Show(); int linecount = 0; foreach (string line in lines) { linecount++; if (linecount % 10 == 0) message.SetProgress(linecount); AddLine(line); } message.Close(); if (checkBoxBeep.Checked) Beep(); } }
/// <summary> /// Initializes the profile environment. /// </summary> /// <remarks>Documented by Dev05, 2007-11-15</remarks> public static void InitializeProfile(bool copyDemoDictionary, string dictionaryParentPath) { MLifter.Controls.LoadStatusMessage progress = new MLifter.Controls.LoadStatusMessage(Resources.UNPACK_TLOADMSG, 100, true); try { if (!Directory.Exists(dictionaryParentPath)) Directory.CreateDirectory(dictionaryParentPath); if (!copyDemoDictionary) return; string zipFilePath = Path.Combine(Application.StartupPath, Resources.SETUP_STARTUP_FOLDERS); if (!File.Exists(zipFilePath)) return; progress.SetProgress(0); Cursor.Current = Cursors.WaitCursor; progress.Show(); long zCount = 0; ZipFile zFile = null; try { zFile = new ZipFile(zipFilePath); zCount = zFile.Count; } catch (Exception ex) { throw ex; } finally { if (zFile != null) zFile.Close(); } if (zCount == 0) return; using (ZipInputStream zipFile = new ZipInputStream(File.OpenRead(zipFilePath))) { ZipEntry entry; int zCounter = 1; while ((entry = zipFile.GetNextEntry()) != null) { string directoryName = Path.GetDirectoryName(entry.Name); string fileName = Path.GetFileName(entry.Name); if (directoryName.Length > 0) Directory.CreateDirectory(Path.Combine(dictionaryParentPath, directoryName)); if (fileName.Length > 0) { using (FileStream stream = File.Open(Path.Combine(Path.Combine(dictionaryParentPath, directoryName), fileName), FileMode.Create, FileAccess.Write, FileShare.None)) { int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; while (bufferSize > 0) { bufferSize = zipFile.Read(buffer, 0, buffer.Length); if (bufferSize > 0) stream.Write(buffer, 0, bufferSize); } } } if ((Path.GetExtension(fileName) == MLifter.DAL.Helper.OdxExtension) || (Path.GetExtension(fileName) == MLifter.DAL.Helper.EmbeddedDbExtension)) { string dicPath = Path.Combine(Path.Combine(dictionaryParentPath, directoryName), fileName); LearningModulesIndexEntry indexEntry = new LearningModulesIndexEntry(); indexEntry.DisplayName = "StartUp"; indexEntry.ConnectionString = new MLifter.DAL.Interfaces.ConnectionStringStruct(MLifter.DAL.DatabaseType.MsSqlCe, dicPath, false); Setup.AddRecentLearningModule(indexEntry); } progress.SetProgress((int)Math.Floor(100.0 * (zCounter++) / zCount)); } } Settings.Default.Save(); } catch { MessageBox.Show(Properties.Resources.INITIALIZE_ENVIRONMENT_ERROR_TEXT, Properties.Resources.INITIALIZE_ENVIRONMENT_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { progress.Dispose(); Cursor.Current = Cursors.Default; } }
/// <summary> /// Initializes the profile environment. /// </summary> /// <remarks>Documented by Dev05, 2007-11-15</remarks> public static void InitializeProfile(bool copyDemoDictionary, string dictionaryParentPath) { MLifter.Controls.LoadStatusMessage progress = new MLifter.Controls.LoadStatusMessage(Resources.UNPACK_TLOADMSG, 100, true); try { if (!Directory.Exists(dictionaryParentPath)) { Directory.CreateDirectory(dictionaryParentPath); } if (!copyDemoDictionary) { return; } string zipFilePath = Path.Combine(Application.StartupPath, Resources.SETUP_STARTUP_FOLDERS); if (!File.Exists(zipFilePath)) { return; } progress.SetProgress(0); Cursor.Current = Cursors.WaitCursor; progress.Show(); long zCount = 0; ZipFile zFile = null; try { zFile = new ZipFile(zipFilePath); zCount = zFile.Count; } catch (Exception ex) { throw ex; } finally { if (zFile != null) { zFile.Close(); } } if (zCount == 0) { return; } using (ZipInputStream zipFile = new ZipInputStream(File.OpenRead(zipFilePath))) { ZipEntry entry; int zCounter = 1; while ((entry = zipFile.GetNextEntry()) != null) { string directoryName = Path.GetDirectoryName(entry.Name); string fileName = Path.GetFileName(entry.Name); if (directoryName.Length > 0) { Directory.CreateDirectory(Path.Combine(dictionaryParentPath, directoryName)); } if (fileName.Length > 0) { using (FileStream stream = File.Open(Path.Combine(Path.Combine(dictionaryParentPath, directoryName), fileName), FileMode.Create, FileAccess.Write, FileShare.None)) { int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; while (bufferSize > 0) { bufferSize = zipFile.Read(buffer, 0, buffer.Length); if (bufferSize > 0) { stream.Write(buffer, 0, bufferSize); } } } } if ((Path.GetExtension(fileName) == MLifter.DAL.Helper.OdxExtension) || (Path.GetExtension(fileName) == MLifter.DAL.Helper.EmbeddedDbExtension)) { string dicPath = Path.Combine(Path.Combine(dictionaryParentPath, directoryName), fileName); LearningModulesIndexEntry indexEntry = new LearningModulesIndexEntry(); indexEntry.DisplayName = "StartUp"; indexEntry.ConnectionString = new MLifter.DAL.Interfaces.ConnectionStringStruct(MLifter.DAL.DatabaseType.MsSqlCe, dicPath, false); Setup.AddRecentLearningModule(indexEntry); } progress.SetProgress((int)Math.Floor(100.0 * (zCounter++) / zCount)); } } Settings.Default.Save(); } catch { MessageBox.Show(Properties.Resources.INITIALIZE_ENVIRONMENT_ERROR_TEXT, Properties.Resources.INITIALIZE_ENVIRONMENT_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { progress.Dispose(); Cursor.Current = Cursors.Default; } }