private void OnProject_WritingSystemChanged(object sender, WeSayWordsProject.StringPair pair)
		{
			foreach (ICareThatWritingSystemIdChanged task in Tasks)
			{
				task.WritingSystemIdChanged(pair.from, pair.to);
			}
		}
		public DictionaryServiceProvider(LexEntryRepository lexEntryRepository,
										 WeSayApp app,
										 WeSayWordsProject project)
		{
			_app = app;
			_project = project;
			_registeredClientProcessIds = new List<int>();
			_lexEntryRepository = lexEntryRepository;
			_articleMaker = new HtmlArticleMaker(_project.LocateFile("WritingSystemPrefs.xml"),
												 _project.LocateFile("PartsOfSpeech.xml"));
		}
		public Db4oProjectSetupForTesting(string xmlOfEntries)
		{
			_projectDirectory = new ProjectDirectorySetupForTesting(xmlOfEntries);

			_project = new WeSayWordsProject();
			_project.LoadFromLiftLexiconPath(_projectDirectory.PathToLiftFile);
			//CacheBuilder cacheBuilder = new CacheBuilder(_projectDirectory.PathToLiftFile);
			//cacheBuilder.DoWork(new NullProgressState());

			_lexEntryRepository = new LexEntryRepository(_project.PathToRepository);
			// InMemoryRecordListManager();
		}
Beispiel #4
0
		public void MakePLiftForBiatah2()
		{
			using (WeSayWordsProject p = new WeSayWordsProject())
			{
				p.LoadFromProjectDirectoryPath(@"E:\Users\John\Documents\WeSay\biatah");

				using (
						LexEntryRepository lexEntryRepository =
								new LexEntryRepository(p.PathToRepository))
				{
					PLiftMaker maker = new PLiftMaker();
					string path = maker.MakePLiftTempFile(lexEntryRepository, p.DefaultPrintingTemplate);
					Console.WriteLine(path);
				}
			}
		}
Beispiel #5
0
		public SampleTaskBuilder(WeSayWordsProject project, ICurrentWorkTask currentWorkTask, IRecordListManager recordListManager)
		{
			_picoContext = CreateContainer();
			_picoContext.RegisterComponentInstance("Project", project);
			_picoContext.RegisterComponentInstance("Current Task Provider", currentWorkTask);
			_picoContext.RegisterComponentInstance("Record List Manager", recordListManager);

			string[] analysisWritingSystemIds = new string[] { project.WritingSystems.AnalysisWritingSystemDefaultId };
			string[] vernacularWritingSystemIds = new string[] {project.WritingSystems.VernacularWritingSystemDefaultId};
			ViewTemplate viewTemplate = new ViewTemplate();
			viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), vernacularWritingSystemIds));
			viewTemplate.Add(new Field(Field.FieldNames.SenseGloss .ToString(), analysisWritingSystemIds));
			viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), vernacularWritingSystemIds));
			viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(), analysisWritingSystemIds));
			_picoContext.RegisterComponentInstance("Default Field Inventory", viewTemplate);
		}
		public void Setup()
		{
			string entriesXml =
					@"<entry id='foo1'><lexical-unit><form lang='v'><text>fooOne</text></form></lexical-unit></entry>
								<entry id='foo2'><lexical-unit><form lang='v'><text>fooTwo</text></form></lexical-unit></entry>
								<entry id='foo3'><lexical-unit><form lang='v'><text>fooThree</text></form></lexical-unit></entry>";
			_projectDirectory = new ProjectDirectorySetupForTesting(entriesXml);

			_project = new WeSayWordsProject();
			_project.LoadFromLiftLexiconPath(_projectDirectory.PathToLiftFile);
			_tabbedForm = new TabbedForm();
			_project.Tasks = new List<ITask>();
			_dashboardTask = new MockTask("Dashboard", "The control center.", true);
			_project.Tasks.Add(_dashboardTask);
			_dictionaryTask = new MockTask("Dictionary blah blah", "The whole lexicon.", true);
			_project.Tasks.Add(_dictionaryTask);

			_tabbedForm.InitializeTasks(_project.Tasks);
		}
Beispiel #7
0
		public void TestFixtureSetUp()
		{
			_project = new WeSayWordsProject();
			_project.StringCatalogSelector = "en";
			_project.LoadFromProjectDirectoryPath(BasilProject.GetPretendProjectDirectory());

			_project.Tasks = new List<ITask>();
		}
Beispiel #8
0
		public void Run()
		{
			string path = DetermineActualLiftPath(_commandLineArguments.liftPath);
			if (!String.IsNullOrEmpty(path))
			{
				path = path.Replace(Path.DirectorySeparatorChar, '-');
				path = path.Replace(Path.VolumeSeparatorChar, '-');

				_serviceAppSingletonHelper =
						ServiceAppSingletonHelper.CreateServiceAppSingletonHelperIfNeeded(
								"WeSay-" + path, _commandLineArguments.startInServerMode);
				if (_serviceAppSingletonHelper == null)
				{
					return; // there's already an instance of this app running
				}
			}

			try
			{
				DisplaySettings.Default.SkinName = Settings.Default.SkinName;
				using (_project = InitializeProject(_commandLineArguments.liftPath))
				{
					if (_project == null)
					{
						return;
					}


					using (_dictionary =
						   new DictionaryServiceProvider(GetLexEntryRepository(), this, _project))
					{
						if (_project.PathToWeSaySpecificFilesDirectoryInProject.IndexOf("PRETEND") < 0)
						{
							RecoverUnsavedDataIfNeeded();
						}

						StartDictionaryServices();
						_dictionary.LastClientDeregistered +=
							_serviceAppSingletonHelper.OnExitIfInServerMode;

						WireUpChorusEvents();

						_serviceAppSingletonHelper.HandleEventsUntilExit(StartUserInterface);

						_dictionary.LastClientDeregistered -=
							_serviceAppSingletonHelper.OnExitIfInServerMode;

						//do a last backup before exiting
						Logger.WriteEvent("App Exiting Normally.");
					}
				}
			 _project.BackupNow();
		   }
			finally
			{
				if (_serviceLifeTimeHelper != null)
				{
					_serviceLifeTimeHelper.Dispose();
				}
				if (_serviceAppSingletonHelper != null)
				{
					_serviceAppSingletonHelper.Dispose();
				}
			}
			Logger.ShutDown();
			Settings.Default.Save();
		}
Beispiel #9
0
		//private static LiftUpdateService SetupUpdateService(LexEntryRepository lexEntryRepository)
		//{
		//    LiftUpdateService liftUpdateService;
		//    liftUpdateService = new LiftUpdateService(lexEntryRepository);
		//    return liftUpdateService;
		//}

		private static WeSayWordsProject InitializeProject(string liftPath)
		{
			WeSayWordsProject project = new WeSayWordsProject();
			liftPath = DetermineActualLiftPath(liftPath);
			if (liftPath == null)
			{
				ErrorReport.ReportNonFatalMessage(
						"WeSay was unable to figure out what lexicon to work on. Try opening the LIFT file by double clicking on it. If you don't have one yet, run the WeSay Configuration Tool to make a new WeSay project.");
				return null;
			}

			liftPath = project.UpdateFileStructure(liftPath);

			if (project.LoadFromLiftLexiconPath(liftPath))
			{
				Settings.Default.PreviousLiftPath = liftPath;
			}
			else
			{
				return null;
			}

			try
			{
				project.MigrateConfigurationXmlIfNeeded();
			}
			catch
			{
				ErrorReport.ReportNonFatalMessage(
						"WeSay was unable to migrate the WeSay configuration file for the new version of WeSay. This may cause WeSay to not function properly. Try opening the project in the WeSay Configuration Tool to fix this.");
			}

			return project;
		}
Beispiel #10
0
		/// <summary>
		/// See comment on BasilProject.InitializeForTests()
		/// </summary>
		public new static void InitializeForTests()
		{
			WeSayWordsProject project = new WeSayWordsProject();

			try
			{
				File.Delete(PathToPretendLiftFile);
			}
			catch (Exception) {}

			Directory.CreateDirectory(Path.GetDirectoryName(PathToPretendLiftFile));
			Utilities.CreateEmptyLiftFile(PathToPretendLiftFile, "InitializeForTests()", true);

			//setup writing systems
			WritingSystemCollection wsc = new WritingSystemCollection();
			wsc.Add(wsc.TestWritingSystemVernId,
					new WritingSystem(wsc.TestWritingSystemVernId, new Font("Courier", 10)));
			wsc.Add(wsc.TestWritingSystemAnalId,
					new WritingSystem(wsc.TestWritingSystemAnalId, new Font("Arial", 15)));
			if (File.Exists(PathToPretendWritingSystemPrefs))
			{
				File.Delete(PathToPretendWritingSystemPrefs);
			}
			wsc.Write(XmlWriter.Create(PathToPretendWritingSystemPrefs));

			project.SetupProjectDirForTests(PathToPretendLiftFile);


		}
Beispiel #11
0
		public void OpenProject(string path)
		{
			//System.Configuration.ConfigurationManager.AppSettings["LastConfigFilePath"] = path;

			//strip off any trailing '\'
			if (path[path.Length - 1] == Path.DirectorySeparatorChar ||
				path[path.Length - 1] == Path.AltDirectorySeparatorChar)
			{
				path = path.Substring(0, path.Length - 1);
			}

			try
			{
				Project = new WeSayWordsProject();

				//just open the accompanying lift file.
				path = path.Replace(".WeSayConfig", ".lift");

				if (path.Contains(".lift"))
				{
					path = Project.UpdateFileStructure(path);
					if (!Project.LoadFromLiftLexiconPath(path))
					{
						Project = null;
						return;
					}
				}
						//                else if (path.Contains(".WeSayConfig"))
						//                {
						//                    this.Project.LoadFromConfigFilePath(path);
						//                }
				else if (Directory.Exists(path))
				{
					Project.LoadFromProjectDirectoryPath(path);
				}
				else
				{
					throw new ApplicationException(path +
												   " is not named as a .lift file or .WeSayConfig file.");
				}
			}
			catch (Exception e)
			{
				ErrorReport.ReportNonFatalMessage("WeSay was not able to open that project. \r\n" +
												  e.Message);
				return;
			}

			IContainer container = _project.Container.CreateInnerContainer();
			var containerBuilder = new Autofac.Builder.ContainerBuilder();
			containerBuilder.Register(typeof(Tasks.TaskListView));
			containerBuilder.Register(typeof(Tasks.TaskListPresentationModel));
			containerBuilder.Build(container);

			SetupProjectControls(container);

			if (Project != null)
			{
				Settings.Default.MruConfigFilePaths.AddNewPath(Project.PathToConfigFile);
			}
		}