예제 #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
파일: Notifier.cs 프로젝트: ichttt/Twice
        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
파일: ColumnItem.cs 프로젝트: mpvyard/Twice
 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
파일: App.xaml.cs 프로젝트: TheSylence/GSD
 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();
		}