Пример #1
0
 protected ViewModelBaseEx(IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IMessenger messenger = null)
 {
     MessengerInstance = messenger;
     ViewServices      = viewServices ?? App.ViewServices;
     Session           = App.Session;
     Settings          = settingsRepo ?? App.Settings;
 }
Пример #2
0
		public ProjectListViewModel( IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IProjectRepository projectRepo = null, IMessenger messenger = null )
			: base( viewServices, settingsRepo, messenger )
		{
			ProjectRepo = projectRepo ?? new ProjectRepository( Session );

			Projects = new ObservableCollection<ProjectViewModel>( ProjectRepo.GetAll().OrderBy( p => p.Name ).Select( p => new ProjectViewModel( p ) ) );

			var last = Settings.GetById( SettingKeys.LastProject );
			CurrentProject = Projects.FirstOrDefault( p => p.Model.Id == last.Get<int>() ) ?? Projects.FirstOrDefault();

			foreach( var proj in Projects )
			{
				proj.CurrentChanged += Proj_CurrentChanged;
			}

			if( CurrentProject != null )
			{
				CurrentProject.IsCurrent = true;
			}

			ProjectNames = new List<string>();

			Validate( nameof( NewProjectName ) ).Check( () => !string.IsNullOrWhiteSpace( NewProjectName ) ).Message( Strings.ProjectMustHaveName );
			Validate( nameof( NewProjectName ) ).Check( () => !ProjectNames.Contains( NewProjectName ) ).Message( Strings.ThisNameIsAlreadyUsed );
			Reset();
		}
Пример #3
0
        public ProjectListViewModel(IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IProjectRepository projectRepo = null, IMessenger messenger = null)
            : base(viewServices, settingsRepo, messenger)
        {
            ProjectRepo = projectRepo ?? new ProjectRepository(Session);

            Projects = new ObservableCollection <ProjectViewModel>(ProjectRepo.GetAll().OrderBy(p => p.Name).Select(p => new ProjectViewModel(p)));

            var last = Settings.GetById(SettingKeys.LastProject);

            CurrentProject = Projects.FirstOrDefault(p => p.Model.Id == last.Get <int>()) ?? Projects.FirstOrDefault();

            foreach (var proj in Projects)
            {
                proj.CurrentChanged += Proj_CurrentChanged;
            }

            if (CurrentProject != null)
            {
                CurrentProject.IsCurrent = true;
            }

            ProjectNames = new List <string>();

            Validate(nameof(NewProjectName)).Check(() => !string.IsNullOrWhiteSpace(NewProjectName)).Message(Strings.ProjectMustHaveName);
            Validate(nameof(NewProjectName)).Check(() => !ProjectNames.Contains(NewProjectName)).Message(Strings.ThisNameIsAlreadyUsed);
            Reset();
        }
Пример #4
0
 protected ViewModelBaseEx( IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IMessenger messenger = null )
 {
     MessengerInstance = messenger;
     ViewServices = viewServices ?? App.ViewServices;
     Session = App.Session;
     Settings = settingsRepo ?? App.Settings;
 }
Пример #5
0
        public ViewModelContainer( IViewServiceRepository viewServices, IMessenger messenger,
			 IBackgroundRunner backgroundRunner, ILanguageProvider languageProvider )
        {
            ViewServices = viewServices;
            Messenger = messenger;
            BackgroundRunner = backgroundRunner;
            LanguageProvider = languageProvider;
        }
Пример #6
0
		public SettingsViewModel( IViewServiceRepository viewServices, ISettingsRepository settingsRepo = null,
			IAppThemes themes = null, IStartupConfigurator startup = null )
			: base( viewServices, settingsRepo )
		{
			Themes = themes ?? new AppThemes();
			Startup = startup ?? new StartupConfigurator();

			AvailableAccents = Themes.Accents.ToList();
			AvailableThemes = Themes.Themes.ToList();

			ResxLocalizationProvider.Instance.UpdateCultureList( GetType().Assembly.FullName, "Strings" );
			IEnumerable<CultureInfo> languages = ResxLocalizationProvider.Instance.AvailableCultures;
			languages = languages.Where( l => !Equals( l, CultureInfo.InvariantCulture ) );

			AvailableLanguages = new List<CultureInfo>( languages.OrderBy( l => l.NativeName ) );
		}
Пример #7
0
        public ScheduleItem(SchedulerJob job, UserViewModel user, IScheduler scheduler, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Job          = job;
            User         = user;
            Scheduler    = scheduler;
            ViewServices = viewServices;

            Entities = new Entities
            {
                HashTagEntities     = EntityParser.ExtractHashtags(job.Text),
                MediaEntities       = new List <MediaEntity>(),
                SymbolEntities      = new List <SymbolEntity>(),
                UrlEntities         = new List <UrlEntity>(),
                UserMentionEntities = EntityParser.ExtractMentions(job.Text)
            };
        }
Пример #8
0
        public SettingsViewModel(IViewServiceRepository viewServices, ISettingsRepository settingsRepo = null,
                                 IAppThemes themes = null, IStartupConfigurator startup = null)
            : base(viewServices, settingsRepo)
        {
            Themes  = themes ?? new AppThemes();
            Startup = startup ?? new StartupConfigurator();

            AvailableAccents = Themes.Accents.ToList();
            AvailableThemes  = Themes.Themes.ToList();

            ResxLocalizationProvider.Instance.UpdateCultureList(GetType().Assembly.FullName, "Strings");
            IEnumerable <CultureInfo> languages = ResxLocalizationProvider.Instance.AvailableCultures;

            languages = languages.Where(l => !Equals(l, CultureInfo.InvariantCulture));

            AvailableLanguages = new List <CultureInfo>(languages.OrderBy(l => l.NativeName));
        }
Пример #9
0
        public ScheduleItem(SchedulerJob job, UserViewModel user, IScheduler scheduler, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Job          = job;
            User         = user;
            Scheduler    = scheduler;
            ViewServices = viewServices;

            Entities = new Entities
            {
                HashTagEntities     = EntityParser.ExtractHashtags(job.Text),
                MediaEntities       = new List <MediaEntity>(),
                SymbolEntities      = new List <SymbolEntity>(),
                UrlEntities         = new List <UrlEntity>(),
                UserMentionEntities = EntityParser.ExtractMentions(job.Text)
            };

            BlockUserCommand  = new LogMessageCommand("Tried to block user from ScheduleItem", LogLevel.Warn);
            ReportSpamCommand = new LogMessageCommand("Tried to report user from ScheduleItem", LogLevel.Warn);
        }
Пример #10
0
        public Notifier(IConfig config, IMessenger messenger, IDispatcher dispatcher, IViewServiceRepository viewServices)
        {
            Dispatcher        = dispatcher;
            MessengerInstance = messenger;
            Config            = config;
            ViewServices      = viewServices;

            if (config.Notifications.SoundEnabled)
            {
                Player = new MediaPlayer();
                string soundFileName = File.Exists(config.Notifications.SoundFileName)
                                        ? config.Notifications.SoundFileName
                                        : ResourceHelper.GetDefaultNotificationSound();

                Player.Open(new Uri(soundFileName));
            }

            if (config.Notifications.PopupEnabled)
            {
                PopupNotify = new NotifyIcon();
            }
        }
Пример #11
0
        public StatusViewModel(Status model, IContextEntry context, IConfig config, IViewServiceRepository viewServiceRepo)
            : base(config, viewServiceRepo)
        {
            Context = context;

            Model          = model;
            OriginalStatus = Model;
            if (OriginalStatus.RetweetedStatus != null && OriginalStatus.RetweetedStatus.StatusID != 0)
            {
                Model      = OriginalStatus.RetweetedStatus;
                SourceUser = new UserViewModel(OriginalStatus.User);
            }
            else
            {
                Model      = OriginalStatus;
                SourceUser = null;
            }

            HasSensibleContent = config?.General?.FilterSensitiveTweets == true && Model.PossiblySensitive;
            User        = new UserViewModel(Model.User);
            Dispatcher  = new DispatcherHelperWrapper();
            RetweetedBy = new SmartCollection <UserViewModel>();
        }
Пример #12
0
        public StatusViewModel(Status model, IContextEntry context, IConfig config, IViewServiceRepository viewServiceRepo)
        {
            Config  = config;
            Context = context;
            ViewServiceRepository = viewServiceRepo;

            Model          = model;
            OriginalStatus = Model;
            if (OriginalStatus.RetweetedStatus != null && OriginalStatus.RetweetedStatus.StatusID != 0)
            {
                Model      = OriginalStatus.RetweetedStatus;
                SourceUser = new UserViewModel(OriginalStatus.User);
            }
            else
            {
                Model      = OriginalStatus;
                SourceUser = null;
            }

            User        = new UserViewModel(Model.User);
            Dispatcher  = new DispatcherHelperWrapper();
            RetweetedBy = new SmartCollection <UserViewModel>();
        }
Пример #13
0
        public MainViewModel(IDatabaseConnector connector, IViewServiceRepository viewServices = null, ITaskRunner taskRunner = null,
                             IProcessStarter procStarter      = null, IMessenger messenger = null, IProjectListViewModel projectList = null,
                             ISettingsRepository settingsRepo = null)
            : base(viewServices, settingsRepo, messenger)
        {
            var dbConnector = connector ?? Application.Current as IDatabaseConnector;

            Debug.Assert(dbConnector != null);

            var runner = taskRunner ?? new TaskRunner();

            ProcStarter = procStarter ?? new ProcessStarter();

            IsLoading = true;
            runner.Run(() =>
            {
                dbConnector.ConnectToDatabase();

                ProjectList = projectList ?? new ProjectListViewModel(ViewServices, Settings);
                TagList     = new TagListViewModel(ProjectList);
                Searcher    = new EntrySearcher(ProjectList);
            }).ContinueWith(t =>
            {
                ExpandEntries = Settings.GetById(SettingKeys.ExpandEntries).Get <bool>();

                // ReSharper disable ExplicitCallerInfoArgument
                RaisePropertyChanged(nameof(ProjectList));
                RaisePropertyChanged(nameof(TagList));
                RaisePropertyChanged(nameof(Searcher));
                // ReSharper restore ExplicitCallerInfoArgument

                IsLoading = false;

                CommandManager.InvalidateRequerySuggested();
            });
        }
Пример #14
0
		public BackgroundRunner( IViewServiceRepository viewServices )
		{
			ViewServices = viewServices;
		}
Пример #15
0
        public MessageViewModel(DirectMessage model, IContextEntry context, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Model   = model;
            Context = context;

            User    = new UserViewModel(model.Sender);
            Partner = new UserViewModel(model.SenderID == context.UserId
                                ? model.Recipient
                                : model.Sender);

            IsIncoming = Model.SenderID != context.UserId;
        }
Пример #16
0
 protected ValidationViewModel(IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IMessenger messenger = null)
     : base(viewServices, settingsRepo, messenger)
 {
 }
Пример #17
0
 protected ColumnItem(IConfig config, IViewServiceRepository viewServiceRepo)
 {
     Config = config;
     ViewServiceRepository = viewServiceRepo;
 }
Пример #18
0
        public MessageViewModel(DirectMessage model, IContextEntry context, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Model   = model;
            Context = context;

            User    = new UserViewModel(model.Sender);
            Partner = new UserViewModel(model.SenderID == context.UserId
                                ? model.Recipient
                                : model.Sender);

            IsIncoming = Model.SenderID != context.UserId;

            BlockUserCommand  = new LogMessageCommand("Tried to block user from MessageViewModel", LogLevel.Warn);
            ReportSpamCommand = new LogMessageCommand("Tried to report user from MessageViewModel", LogLevel.Warn);
        }
Пример #19
0
 protected ValidationViewModel( IViewServiceRepository viewServices = null, ISettingsRepository settingsRepo = null, IMessenger messenger = null )
     : base(viewServices, settingsRepo, messenger)
 {
 }
Пример #20
0
 public DatabasePathViewModel(IViewServiceRepository viewServiceRepo)
     : base(viewServiceRepo)
 {
     Validate(nameof(Path)).Check(() => !string.IsNullOrWhiteSpace(Path)).Message(Strings.MustEnterValidPath);
     ClearValidationErrors();
 }
Пример #21
0
 private static void SetupViewServices()
 {
     ViewServices = new ViewServiceRepository();
     ViewServices.Register<IConfirmationService>( new ConfirmationService() );
     ViewServices.Register<IInfoService>( new InfoService() );
     ViewServices.Register<IMoveDatabaseService>( new MoveDatabaseService() );
     ViewServices.Register<IBrowseFileService>( new BrowseFileService() );
     ViewServices.Register<IProgressService>( new ProgressService() );
 }
Пример #22
0
		public DatabasePathViewModel( IViewServiceRepository viewServiceRepo )
			: base( viewServiceRepo )
		{
			Validate( nameof( Path ) ).Check( () => !string.IsNullOrWhiteSpace( Path ) ).Message( Strings.MustEnterValidPath );
			ClearValidationErrors();
		}