Ejemplo n.º 1
0
        // Equals implementation
        public override bool Equals(object obj)
        {
            FileStatsViewModel item = obj as FileStatsViewModel;

            if (item == null)
            {
                return(false);
            }

            return(this.fileStats.Equals(item.fileStats));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Fills the Words table with words.
 /// </summary>
 /// <param name="fileStatsVM"></param>
 public void ShowWords(FileStatsViewModel fileStatsVM)
 {
     currentFile = fileStatsVM;
     if (!ProjectSelectable)
     {
         return;
     }
     foreach (var item in model.GetUnknownWords(fileStatsVM.FileStats))
     {
         Words.Add(new WordViewModel {
             Word = item.Key, Quantity = item.Value
         });
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Prepares viewModel for new file selection.
 /// </summary>
 public void FileRowIsAboutToChange()
 {
     currentFile = null;
     Words.Clear();
 }
Ejemplo n.º 4
0
        // Constructors
        public MainViewModel(IUIMainWindowService windowService)
        {
            this.windowService = windowService;
            // Configure the model before usage.
            ModelConfigurator.Configure(windowService);
            model = MainModel.Instance;
            L.Logger.Debug("MainView is starting.");

            Languages = new ObservableCollection <LingvaViewModel>();
            CollectionBinder <Lingva> langBinder = new CollectionBinder <Lingva>(
                newLang => Languages.Add(new LingvaViewModel(newLang)),
                oldLang => Languages.Remove(new LingvaViewModel(oldLang)),
                windowService
                );

            model.Languages.CollectionChanged += langBinder.Connect;

            Projects = new ObservableCollection <string>();
            CollectionBinder <string> projectBinder = new CollectionBinder <string>(
                newProject => Projects.Add(newProject),
                oldProject => Projects.Remove(oldProject),
                windowService
                );

            model.Projects.CollectionChanged += projectBinder.Connect;

            Dictionaries = new ObservableCollection <DictViewModel>();
            CollectionBinder <Dict> dictBinder = new CollectionBinder <Dict>(
                newDict => Dictionaries.Add(new DictViewModel(windowService, newDict)),
                oldDict => Dictionaries.Remove(new DictViewModel(windowService, oldDict)),
                windowService
                );

            model.Dictionaries.CollectionChanged += dictBinder.Connect;

            Files = new ObservableCollection <FileStatsViewModel>();
            CollectionBinder <FileStats> fileBinder = new CollectionBinder <FileStats>(
                newFile =>
            {
                FileStatsViewModel fsvm = new FileStatsViewModel(windowService, newFile);
                Files.Add(fsvm);
                totalUnknown += fsvm.Unknown.GetValueOrDefault();
                TotalWords   += fsvm.Size.GetValueOrDefault();
            },
                oldFile =>
            {
                FileStatsViewModel fsvm = new FileStatsViewModel(windowService, oldFile);
                Files.Remove(fsvm);
                totalUnknown -= fsvm.Unknown.GetValueOrDefault();
                TotalWords   -= fsvm.Size.GetValueOrDefault();
            },
                windowService);

            model.Files.CollectionChanged += fileBinder.Connect;

            Words          = new ObservableCollection <WordViewModel>();
            WordsInProject = new ObservableCollection <WordViewModel>();

            model.InitializeLanguages();
            ProgressValue = 100;
            L.Logger.Debug("MainView has started.");
        }
Ejemplo n.º 5
0
        // Constructors
        public MainViewModel(IUIMainWindowService windowService)
        {
            IStorage storage = new Storage(windowService.AppDir);
            model = MainModel.CreateModel(storage);
            model.CorpusDir = windowService.CorpusDir;
            model.DicDir = windowService.DicDir;
            model.OutDir = windowService.OutDir;

            this.windowService = windowService;

            L.Logger.Debug("MainView is starting.");

            Languages = new ObservableCollection<LingvaViewModel>();
            model.LanguageAdded += (obj, args) => Languages.Add(new LingvaViewModel(args.Content));
            model.LanguageRemoved += (obj, args) => Languages.Remove(new LingvaViewModel(args.Content));

            Projects = new ObservableCollection<string>();
            model.ProjectAdded += (obj, args) => windowService.BeginInvoke(
                new Action(() => Projects.Add(args.Content)
                ));

            model.ProjectRemoved += (obj, args) => windowService.BeginInvoke(
                new Action(() => Projects.Remove(args.Content)
                ));

            Dictionaries = new ObservableCollection<DictViewModel>();
            model.DictAdded += (obj, args) => windowService.BeginInvoke(
                new Action(() => Dictionaries.Add(new DictViewModel(windowService, args.Content))
                ));
            model.DictRemoved += (obj, args) => windowService.BeginInvoke(
                new Action(() => Dictionaries.Remove(new DictViewModel(windowService, args.Content))
                ));

            Files = new ObservableCollection<FileStatsViewModel>();
            model.FileStatsAdded += (obj, args) => windowService.BeginInvoke(
                new Action(() =>
                {
                    FileStatsViewModel fsvm = new FileStatsViewModel(windowService, args.Content);
                    Files.Add(fsvm);
                    totalUnknown += fsvm.Unknown.GetValueOrDefault();
                    TotalWords += fsvm.Size.GetValueOrDefault();
                }));
            model.FileStatsRemoved += (obj, args) => windowService.BeginInvoke(
                new Action(() =>
                {
                    FileStatsViewModel fsvm = new FileStatsViewModel(windowService, args.Content);
                    Files.Remove(fsvm);
                    totalUnknown -= fsvm.Unknown.GetValueOrDefault();
                    TotalWords -= fsvm.Size.GetValueOrDefault();
                }));

            Words = new ObservableCollection<WordViewModel>();
            WordsInProject = new ObservableCollection<WordViewModel>();

            model.InitializeLanguages();
            ProgressValue = 100;
            L.Logger.Debug("MainView has started.");
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Fills the Words table with words.
 /// </summary>
 /// <param name="fileStatsVM"></param>
 public void ShowWords(FileStatsViewModel fileStatsVM)
 {
     currentFile = fileStatsVM;
     if (!ProjectSelectable) { return; }
     foreach (var item in model.GetUnknownWords(fileStatsVM.FileStats))
     {
         Words.Add(new WordViewModel {Word=item.Key, Quantity=item.Value });
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Prepares viewModel for new file selection.
 /// </summary>
 public void FileRowIsAboutToChange()
 {
     currentFile = null;
     Words.Clear();
 }