public void LoadSaveGame_FileNotFound_ReturnsFileNotFoundErrorText( [Frozen] IMainModel model, [Frozen] IBackupService backupService, [Frozen] IRemoveWaggonsService removeWaggonsService, [Frozen] IMoveObjectsService moveObjectsService, [Frozen] IMoveTracksService moveTracksService, [Frozen] IMoveWaggonsService moveWaggonsService, string filePath ) { //Arrange var mockedFileSystem = new MockFileSystem(); model.FileName.Returns(filePath); var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem); //Act var result = sut.LoadSavegame(); result.Should().Be($"Error: File {filePath} not Found."); model.FileContent.Should().BeEmpty(); backupService.ReceivedCalls().Should().BeEmpty(); removeWaggonsService.ReceivedCalls().Should().BeEmpty(); }
public MainViewModel(IMainModel mainModel, INavigationService navigationService, IEmailComposeService emailComposeService, ISmsComposeService smsComposeService, IShareStatusService shareStatusService) { _mainModel = mainModel; _navigationService = navigationService; _emailComposeService = emailComposeService; _smsComposeService = smsComposeService; _shareStatusService = shareStatusService; PreviousQuoteCommand = new RelayCommand(OnPreviousQuoteCommand, () => _mainModel.SelectedIndex > 0); NextQuoteCommand = new RelayCommand(OnNextQuoteCommand, () => _mainModel.SelectedIndex < _mainModel.Quotes.Length - 1); RandomQuoteCommand = new RelayCommand(OnRandomQuoteCommand); TodaysQuoteCommand = new RelayCommand(OnTodaysQuoteCommand); ShowAboutCommand = new RelayCommand(OnShowAboutCommand); ShareByEmailCommand = new RelayCommand(OnShareByEmailCommand); ShareBySmsCommand = new RelayCommand(OnShareBySmsCommand); ShareOnSocialNetworkCommand = new RelayCommand(OnShareOnSocialNetworkCommand); }
public void LoadSaveGame_FileCanBeReadWithoutError_ReturnsEmptyString( [Frozen] IMainModel model, [Frozen] IBackupService backupService, [Frozen] IRemoveWaggonsService removeWaggonsService, [Frozen] IMoveObjectsService moveObjectsService, [Frozen] IMoveTracksService moveTracksService, [Frozen] IMoveWaggonsService moveWaggonsService, string fileContent, string filePath ) { //Arrange var mockedFileSystem = new MockFileSystem(); var mockedFileContent = new MockFileData(fileContent); mockedFileSystem.AddFile(filePath, mockedFileContent); model.FileName.Returns(filePath); var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem); //Act var result = sut.LoadSavegame(); result.Should().BeEmpty(); model.FileContent.Should().Be(fileContent); backupService.ReceivedCalls().Should().BeEmpty(); removeWaggonsService.ReceivedCalls().Should().BeEmpty(); }
public void Run() { try { #if DEBUG LogHelper.TryReconfigureLoggerToLevel(LogLevel.Debug); #endif IContainer autofacContiner = AutofacConfigurator.Configure(_logger); using (ILifetimeScope scope = autofacContiner.BeginLifetimeScope()) { IMainViewModel mainWindowViewModel = scope.Resolve <IMainViewModel>(); IMainModel mainWindowModel = scope.Resolve <IMainModel>(TypedParameter.From(mainWindowViewModel)); Window mainWindow = new MainWindow(mainWindowViewModel); Application application = new Application(); AppDomain.CurrentDomain.UnhandledException += _currentDomainOnUnhandledExceptionEventHandler; TaskScheduler.UnobservedTaskException += _taskSchedulerOnUnobservedTaskExceptionEventHandler; application.Dispatcher.UnhandledException += _dispatcherOnUnhandledExceptionEventHandler; application.Exit += _applicationExitEventHandler; mainWindow.Closed += _mainWindowClosedEventHandler; application.Run(mainWindow); } } catch (Exception exception) { HandleException(exception); } }
public static IContainer Configure(ILogger logger) { var builder = new ContainerBuilder(); builder.Register(context => { ILogFolder logFolder = context.Resolve <ILogFolder>(); IMainModel model = MainModel.Create(logFolder, logger); return(model); }).As <IMainModel>(); builder.Register(context => { IMainModel mainModel = context.Resolve <IMainModel>(); IMainViewModel mainWindowViewModel = new MainViewModel(mainModel, logger); return(mainWindowViewModel); }).As <IMainViewModel>(); builder.Register(context => { ILogFolder logFolder = new LogFolder(); return(logFolder); }).As <ILogFolder>(); IContainer container = builder.Build(); return(container); }
public MainViewModel(IMainModel model) { this.model = model; model.notifyPropertyChanged += (object sender, EventArgs e) => { if (e as CSVAnomaliesFileUploadEventArgs != null) { CSVAnomaliesFileUploadEventArgs args = e as CSVAnomaliesFileUploadEventArgs; if (args.Info == PropertyChangedEventArgs.InfoVal.FileUpdated) { notifyPropertyChanged(this, args); } } if (e as XMLFileUploadEventArgs != null) { XMLFileUploadEventArgs args = e as XMLFileUploadEventArgs; if (args.Info == PropertyChangedEventArgs.InfoVal.FileUpdated) { notifyPropertyChanged(this, args); } } // more.... }; learnedData = new Dictionary <string, List <float> >(); CategoriesMenu = new List <MenuItem>(); }
public SettingsViewModel(ISettingsProvider settingsProvider, IMainModel mainModel) { _mainViewModel = mainModel as MainViewModel; _settingsProvider = settingsProvider; TiApiKey = Settings.TiApiKey; TgBotApiKey = Settings.TgBotApiKey; TgChatId = Settings.TgChatId; TgChatIdRu = Settings.TgChatIdRu; MinDayPriceChangePercent = Settings.MinDayPriceChange * 100m; MinXMinutesPriceChangePercent = Settings.MinXMinutesPriceChange * 100m; MinVolumeDeviationFromDailyAveragePercent = Settings.MinVolumeDeviationFromDailyAverage * 100m; MinXMinutesVolPercentChangePercent = Settings.MinXMinutesVolChange * 100m; NumOfMinToCheck = Settings.NumOfMinToCheck; NumOfMinToCheckVol = Settings.NumOfMinToCheckVol; IsTelegramEnabled = Settings.IsTelegramEnabled; USAQuotesEnabled = Settings.USAQuotesEnabled; USAQuotesURL = Settings.USAQuotesURL; USAQuotesLogin = Settings.USAQuotesLogin; USAQuotesPassword = Settings.USAQuotesPassword; TgArbitrageLongUSAChatId = Settings.TgArbitrageLongUSAChatId; TgArbitrageShortUSAChatId = Settings.TgArbitrageShortUSAChatId; SubscribeInstrumentStatus = Settings.SubscribeInstrumentStatus; HideRussianStocks = Settings.HideRussianStocks; ChartUrlTemplate = Settings.ChartUrlTemplate; ResetKeys(); }
public MoveCoWireObjectService( IMainModel model, IParseAndAddFloatValue parseAndAddFloatValue) { _model = model ?? throw new System.ArgumentNullException(nameof(model)); _parseAndAddFloatValue = parseAndAddFloatValue ?? throw new System.ArgumentNullException(nameof(parseAndAddFloatValue)); }
public MainView(IMainModel model) { mainModel = model as MainViewModel ?? throw new ArgumentException(nameof(model)); menu = new Menu <Action>(model); menuList = new MenuList(menu.MenuActionsNames, columns: 3); menuValueRange = new InclusiveValueRange <int>(menu.MenuActionsNames.Length, 1); }
public MainPresenter(IMainView view, Controller controller, IFillView <File> fileView, IFillView <Resource> resourceView, IMainModel model) { _view = view; _controller = controller; _model = model; _fileView = fileView; _resourceView = resourceView; _view.WhileAnalysis += WhileAnalysis; _view.ForAnalysis += ForAnalysis; _view.DivCalculation += DivCalculate; _view.XorCalculation += XorCalculate; _view.AddFile += AddFile; _view.AddResource += AddRes; _view.UpdateFile += UpdateFile; _view.UpdateResource += UpdateResourses; _view.DeleteFile += DeleteFile; _view.DeleteResource += DeleteRes; _view.ExportFiles += ExportFiles; _view.ImportFiles += ImportFiles; _view.ExportRes += ExportResources; _view.ImportRes += ImportResources; _view.UpdateFiles(_model.Files); _view.UpdateResources(_model.Resources); }
public void For_PatternDoesMatch_ReturnsInputStringWithNewCoordinates( [Frozen] IMainModel model, [Frozen] IParseAndAddFloatValue parseAndAddFloatValue, MoveCoWireObjectService sut) { //Arrange model.MoveXAxisValue.Returns(1); model.MoveYAxisValue.Returns(2); model.MoveZAxisValue.Returns(3); var input = "14,co_wire,1,12.68545_2.453807_61.43925,3.329947_138.1346_1.069022E-07,-1,0.5,0,0,0,-1,12.68545_2.453807_61.43925&13.11526_2.416335_60.95963&0.5&2,-1,kcc0:h0:s0:v26:lr50:hr20,0,,%14,"; var expectedResult = "14,co_wire,1,X_Y_Z,3.329947_138.1346_1.069022E-07,-1,0.5,0,0,0,-1,X_Y_Z&A_B_C&0.5&2,-1,kcc0:h0:s0:v26:lr50:hr20,0,,%14,"; parseAndAddFloatValue.For("12.68545", 1).Returns("X"); parseAndAddFloatValue.For("2.453807", 2).Returns("Y"); parseAndAddFloatValue.For("61.43925", 3).Returns("Z"); parseAndAddFloatValue.For("13.11526", 1).Returns("A"); parseAndAddFloatValue.For("2.416335", 2).Returns("B"); parseAndAddFloatValue.For("60.95963", 3).Returns("C"); //Act var result = sut.For(input); //Assert result.Should().Be(expectedResult); }
public void Reformat_ServiceFindsNoQuickMods_EliminatesAllLineBreaks( IMainModel mainModel, ReformatService sut, int randomLineBreakInserter ) { //Arrange var lorizzleIppsle = "Lorizzle ipsum dolor ghetto amizzle, mah nizzle adipiscing elit. You son of a bizzle ut dolizzle.Things magna ligula, dignissim sit amizzle, that's the shizzle eget, the bizzle nec, the bizzle."; var content = lorizzleIppsle; mainModel.FileContent.Returns(content); randomLineBreakInserter = randomLineBreakInserter % 5 + 2; mainModel.FileContent = lorizzleIppsle; var lineBreakCounter = 0; for (var i = randomLineBreakInserter; i < mainModel.FileContent.Length; i = i + randomLineBreakInserter + 1) { mainModel.FileContent.Insert(i, Environment.NewLine); lineBreakCounter++; } //Act sut.Reformat(); //Assert mainModel.FileContent.Should().Be(lorizzleIppsle); lineBreakCounter.Should().NotBe(0); }
public void WriteBackupFile_WritesBackupFile_EveryoneIsHappy( [Frozen] IMainModel model, string fileContent) { var directory = @"C:\Temp\"; var fileName = "temp"; var fileExtension = ".txt"; var filePath = directory + fileName + fileExtension; var mockedFileSystem = new MockFileSystem(); var mockedFileContent = new MockFileData(fileContent); mockedFileSystem.AddDirectory(directory); mockedFileSystem.AddFile(filePath, mockedFileContent); model.FileName = filePath; var sut = new BackupService(model, mockedFileSystem); sut.WriteBackupFile(); var expectedPath = $"{directory}{fileName}_backup_{DateTime.Now:yyyyMMddHHmmss}{fileExtension}"; mockedFileSystem.FileExists(expectedPath).Should().BeTrue(); }
protected GraphCreatingModel(ILog log, IMainModel model, IAssembleClasses graphFactories) { GraphAssembleKeys = graphFactories.ClassesNames.ToList(); this.model = model; graphAssembleClasses = graphFactories; this.log = log; }
public MainController(IMainView view, IMainModel model) { _view = view; _model = model; InitializeViewEvents(); }
public MainViewModel(IMainModel mainModel, ISettingsViewModel settingsViewModel, IDownloadsViewModel downloadsViewModel, ILogger logger) { if (mainModel == null) { throw new ArgumentNullException("mainModel"); } if (settingsViewModel == null) { throw new ArgumentNullException("settingsViewModel"); } if (downloadsViewModel == null) { throw new ArgumentNullException("downloadsViewModel"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.mainModel = mainModel; this.settingsViewModel = settingsViewModel; this.downloadsViewModel = downloadsViewModel; this.logger = logger; }
public void Move_RegExMatchDoesNotContainPercentChar_ReplacesOneLine( [Frozen] IMainModel model, [Frozen] IFindWaggonsRegExService findWaggonsRegExService, [Frozen] IParseAndAddFloatValue parseAndAddFloatValue, MoveWaggonsService sut, string dummyContent, RegexServiceResponseModel regexServiceResponseModel, string dummyRegex) { //Arrange var source = "ct_dynamic,1,16.73281_1.918186_60.32922,0_125.4218_0,43,36,42,0,0,0,0,0,0,0,0,0,0,0,-1,0,,1_0_-2_45_2.9_0_6_22_1_1_12,-1,0,4_0,kcc0:h0:s0:v49:lr50:hr20,,1,"; var expectedResult = "ct_dynamic,1,X_Y_Z,0_125.4218_0,43,36,42,0,0,0,0,0,0,0,0,0,0,0,-1,0,,1_0_-2_45_2.9_0_6_22_1_1_12,-1,0,4_0,kcc0:h0:s0:v49:lr50:hr20,,1,"; model.FileContent.Returns(dummyContent); regexServiceResponseModel.HasMatched = true; regexServiceResponseModel.Content = source; regexServiceResponseModel.MatchingRegEx = dummyRegex; findWaggonsRegExService.MatchRegex(dummyContent).Returns(regexServiceResponseModel); parseAndAddFloatValue.For("16.73281", Arg.Any <float>()).Returns("X"); parseAndAddFloatValue.For("1.918186", Arg.Any <float>()).Returns("Y"); parseAndAddFloatValue.For("60.32922", Arg.Any <float>()).Returns("Z"); //Act sut.Move(); //Assert model.ReceivedCalls().Should().HaveCount(6); findWaggonsRegExService.ReceivedCalls().Should().HaveCount(2); findWaggonsRegExService.Received(1).MatchRegex(dummyContent); findWaggonsRegExService.Received(1).Replace(dummyContent, expectedResult, regexServiceResponseModel.MatchingRegEx); }
public GraphCreatingViewModel(ILog log, IMainModel model, IAssembleClasses graphFactories) : base(log, model, graphFactories) { ConfirmCreateGraphCommand = new RelayCommand(ExecuteConfirmCreateGraphCommand, CanExecuteConfirmCreateGraphCommand); CancelCreateGraphCommand = new RelayCommand(ExecuteCloseWindowCommand); }
public PathFindingViewModel(ILog log, IAssembleClasses pluginsLoader, IMainModel model, BaseEndPoints endPoints) : base(log, pluginsLoader, model, endPoints) { maxAlgorithmKeysNumber = pluginsLoader.ClassesNames.Count; minAlgorithmKeysNumber = 1; }
private void InstantiateModelsAndViews() { _startControl = IoC.Resolve <IStartView>(); _downloadModel = IoC.Resolve <IDownloadModel>(); _downloadView = IoC.Resolve <IDownloadView>(); _patchControl = IoC.Resolve <IPatchView>(); _patchModel = IoC.Resolve <IPatchModel>(); _dfuControl = IoC.Resolve <IDfuView>(); _dfuModel = IoC.Resolve <IDfuModel>(); _dfuSuccessControl = IoC.Resolve <IDfuSuccessControl>(); _tetherSuccessControl = IoC.Resolve <ITetherSuccessControl>(); _mainModel = IoC.Resolve <IMainModel>(); _firmwareVersionModel = IoC.Resolve <IFirmwareVersionModel>(); _tetherView = IoC.Resolve <ITetherView>(); _tetherModel = IoC.Resolve <ITetherModel>(); _firmwareVersionDetector = IoC.Resolve <IFirmwareVersionDetector>(); _freeSpaceModel = IoC.Resolve <IFreeSpaceModel>(); _mainModel.SetFirmwareVersionModel(_firmwareVersionModel); _downloadModel.SetFirmwareVersionModel(_firmwareVersionModel); _patchModel.SetFirmwareVersionModel(_firmwareVersionModel); _dfuModel.SetFirmwareVersionModel(_firmwareVersionModel); _tetherModel.SetFirmwareVersionModel(_firmwareVersionModel); _tetherPresenter = new TetherPresenter(_tetherModel, _tetherView); _tetherPresenter.ProcessFinished += tetherPresenter_ProcessFinished; _patchPresetner = new PatchPresenter(_patchControl, _patchModel); _patchPresetner.Finished += patchPresetner_Finished; _dfuPresenter = new DfuPresenter(_dfuModel, _dfuControl); _dfuPresenter.ProcessFinished += dfuPresenter_ProcessFinished; _downloadPresenter = new DownloadPresenter(_downloadModel, _downloadView); _downloadPresenter.ProcessFinished += downloadPresenter_ProcessFinished; }
public TelegramManager(IServiceProvider serviceProvider, string apiToken, long chatId) { _apiToken = apiToken; _services = serviceProvider; _mainModel = serviceProvider.GetRequiredService <IMainModel>(); Settings = serviceProvider.GetRequiredService <ISettingsProvider>().Settings; _logger = (ILogger <TelegramManager>)serviceProvider.GetService(typeof(ILogger <TelegramManager>)); _eventAggregator = (IEventAggregator2)serviceProvider.GetService(typeof(IEventAggregator2)); try { _bot = new TelegramBotClient(_apiToken); _chatId = chatId; _messageQueueLoopTask = Task.Factory .StartNew(() => BotMessageQueueLoopAsync() .ConfigureAwait(false), _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); } catch (Exception ex) { _logger.LogError("Telegram init error: {exception}", ex.Message); } }
public GraphModel(IMainModel mainModel) { this.mainModel = mainModel; this.CurrCategoryPM = new PlotModel(); CurrCategoryPM.Axes.Add(new LinearAxis { Title = "Time", Minimum = -5, Maximum = 35, Position = AxisPosition.Bottom, IsZoomEnabled = false }); CurrCategoryPM.Axes.Add(new LinearAxis { Title = "", Minimum = 0, Maximum = 0, Position = AxisPosition.Left, IsZoomEnabled = false }); this.CurrCorrelatedCategoryPM = new PlotModel(); CurrCorrelatedCategoryPM.Axes.Add(new LinearAxis { Title = "Time", Minimum = -5, Maximum = 35, Position = AxisPosition.Bottom, IsZoomEnabled = false }); CurrCorrelatedCategoryPM.Axes.Add(new LinearAxis { Title = "", Minimum = 0, Maximum = 0, Position = AxisPosition.Left, IsZoomEnabled = false }); this.CorrelatedAsFuncOfCurrent = new PlotModel(); CorrelatedAsFuncOfCurrent.Axes.Add(new LinearAxis { Title = "", Minimum = 0, Maximum = 0, Position = AxisPosition.Bottom, IsZoomEnabled = false }); CorrelatedAsFuncOfCurrent.Axes.Add(new LinearAxis { Title = "", Minimum = 0, Maximum = 0, Position = AxisPosition.Left, IsZoomEnabled = false }); AnomaliesData = new List <Anomaly>(); }
public RocketMonitoringStrategy(ISettingsProvider settingsProvider, IMainModel mainModel, StocksManager stocksManager, IEventAggregator2 eventAggregator, ILogger <RocketMonitoringStrategy> logger) { StocksManager = stocksManager; Settings = settingsProvider.Settings; MainModel = mainModel; Logger = logger; eventAggregator.SubscribeOnPublishedThread(this); }
public DashboardViewModel(IMainModel model) { this.model = model; model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("VM_" + e.PropertyName); }; }
public FlightDisplayVM(IMainModel main, ISettingsModel settings) { MainModel = main; SettingsModel = settings; // connect the server and client upon initialization ConnectCommand.Execute(null); }
public ProcessMonitorService ( IPerformanceCounterService performanceCounterService, IPerformanceCounterInstanceInfoService performanceCounterInstanceInfoService, IMainModel model ) { _performanceCounterService = performanceCounterService; _performanceCounterInstanceInfoService = performanceCounterInstanceInfoService; _model = model; }
public MainView(IMainModel model) { mainModel = model as MainViewModel; menuActions = GetMenuMethodsAsDelegates <Action>(mainModel); menuActionsKeys = menuActions.Keys.ToArray(); menu = CreateMenu(menuActionsKeys, columns: 3); menuValueRange = new ValueRange(menuActionsKeys.Length, 1); }
private void Application_Startup(object sender, StartupEventArgs e) { view = new MainView(); model = new MainModel(); ctl = new MainController(view, model); ctl.Run(); }
public RemoveWaggonsService( IMainModel model, IReformatService reformatService, IRegExService regexService) { _model = model ?? throw new ArgumentNullException(nameof(model)); _reformatService = reformatService ?? throw new ArgumentNullException(nameof(reformatService)); _regexService = regexService ?? throw new ArgumentNullException(nameof(regexService)); }
/// <summary> /// Presenter of main form /// </summary> /// <param name="serviceDesktopMainForm">Instance of interface main form</param> /// <param name="serviceDesktopModel">Instance of interface model</param> /// <param name="messageBoxService">Instance of interface message services</param> public MainPresenter(IMainView serviceDesktopMainForm, IMainModel serviceDesktopModel, IMessageBoxService messageBoxService) { ServiceDesktopMainForm = serviceDesktopMainForm; ServiceDesktopModel = serviceDesktopModel; MessageBoxService = messageBoxService; SubscribeEvents(); }
public MoveTracksService( IMainModel mainModel, IFindTracksRegExService findTracksRegExService, IParseAndAddFloatValue parseAndAddFloatValue) { _mainModel = mainModel ?? throw new ArgumentNullException(nameof(mainModel)); _findTracksRegExService = findTracksRegExService ?? throw new ArgumentNullException(nameof(findTracksRegExService)); _parseAndAddFloatValue = parseAndAddFloatValue ?? throw new ArgumentNullException(nameof(parseAndAddFloatValue)); }
public MainViewModel(IMainModel mainModel, INavigationService navigationService) { _mainModel = mainModel; _navigationService = navigationService; SolveEquationCommand = new RelayCommand(OnSolveEquationCommand); ShowAboutCommand = new RelayCommand(OnShowAboutCommand); }
public override void TearDown() { m_Provider = null; m_MainModel = null; m_ChangesModel = null; m_View = null; m_Presenter = null; m_Window.rootVisualElement.Clear(); }
public NewFolderViewModel(IMainModel mainModel, INavigationService navigationService, IGoogleDriveService googleDriveService, ISystemTrayService systemTrayService, IMessageBoxService messageBoxService) { _mainModel = mainModel; _navigationService = navigationService; _googleDriveService = googleDriveService; _systemTrayService = systemTrayService; _messageBoxService = messageBoxService; CreateNewFolderCommand = new RelayCommand(CreateNewFolder, () => !IsBusy); }
public RenameFileViewModel(IMainModel mainModel, INavigationService navigationService, IGoogleDriveService googleDriveService, ISystemTrayService systemTrayService, IMessageBoxService messageBoxService) { _mainModel = mainModel; _navigationService = navigationService; _googleDriveService = googleDriveService; _systemTrayService = systemTrayService; _messageBoxService = messageBoxService; RenameFileCommand = new RelayCommand(RenameFile, () => !IsBusy); PageLoadedCommand = new RelayCommand(() => { FileName = _mainModel.SelectedFile.Title; }); }
public AuthorizationViewModel(IMainModel mainModel, IGoogleAuthService googleAuthService, IGoogleOAuth2Service googleOAuth2Service, INavigationService navigationService, IMessageBoxService messageBoxService, ISystemTrayService systemTrayService) { _mainModel = mainModel; _googleAuthService = googleAuthService; _googleOAuth2Service = googleOAuth2Service; _navigationService = navigationService; _messageBoxService = messageBoxService; _systemTrayService = systemTrayService; PageLoadedCommand = new RelayCommand(() => { ShowBrowser = true; WebBrowserSourceUri = _googleAuthService.GetAuthUri(); }); WebBrowserNavigatingCommand = new RelayCommand<NavigatingEventArgs>(e => { if (_showBrowser) { _systemTrayService.SetProgressIndicator(""); } if (e.Uri == null || e.Uri.Host != "localhost") return; ShowBrowser = false; WebBrowserSourceUri = new Uri("https://accounts.google.com/Logout"); var queryString = e.Uri.QueryString(); ExchangeAuthorizationCode(queryString.GetValue("code")); }); WebBrowserNavigatedCommand = new RelayCommand<NavigationEventArgs>(e => { if (_showBrowser) { _systemTrayService.HideProgressIndicator(); } }); WebBrowserNavigationFailedCommand = new RelayCommand<NavigationFailedEventArgs>(e => { _systemTrayService.HideProgressIndicator(); }); }
public MainViewModel(IMainModel mainModel, ISettingsViewModel settingsViewModel, IDownloadsViewModel downloadsViewModel, ILogger logger) { if (mainModel == null) throw new ArgumentNullException("mainModel"); if (settingsViewModel == null) throw new ArgumentNullException("settingsViewModel"); if (downloadsViewModel == null) throw new ArgumentNullException("downloadsViewModel"); if (logger == null) throw new ArgumentNullException("logger"); this.mainModel = mainModel; this.settingsViewModel = settingsViewModel; this.downloadsViewModel = downloadsViewModel; this.logger = logger; }
private void InstantiateModelsAndViews() { startControl = IoC.Resolve<IStartView>(); syncContext = startControl.SyncContext; downloadModel = IoC.Resolve<IDownloadModel>(); downloadView = IoC.Resolve<IDownloadView>(); patchControl = IoC.Resolve<IPatchView>(); patchModel = IoC.Resolve<IPatchModel>(); dfuControl = IoC.Resolve<IDFUView>(); dfuModel = IoC.Resolve<IDFUModel>(); dfuSuccessControl = IoC.Resolve<IDFUSuccessControl>(); tetherSuccessControl = IoC.Resolve<ITetherSuccessControl>(); mainModel = IoC.Resolve<IMainModel>(); firmwareVersionModel = IoC.Resolve<IFirmwareVersionModel>(); tetherView = IoC.Resolve<ITetherView>(); tetherModel = IoC.Resolve<ITetherModel>(); firmwareVersionDetector = IoC.Resolve<IFirmwareVersionDetector>(); freeSpaceModel = IoC.Resolve<IFreeSpaceModel>(); iTunesInfoProvider = IoC.Resolve<IITunesInfoProvider>(); iTunesAutomationModel = IoC.Resolve<IITunesAutomationModel>(); iTunesAutomationModel.FirmwareVersionModel = firmwareVersionModel; iTunesAutomationModel.SyncContext = syncContext; iTunesAutomationModel.ITunesInfoProvider = iTunesInfoProvider; mainModel.SetFirmwareVersionModel(firmwareVersionModel); downloadModel.SetFirmwareVersionModel(firmwareVersionModel); patchModel.SetFirmwareVersionModel(firmwareVersionModel); dfuModel.SetFirmwareVersionModel(firmwareVersionModel); tetherModel.SetFirmwareVersionModel(firmwareVersionModel); tetherPresenter = new TetherPresenter(tetherModel, tetherView); tetherPresenter.ProcessFinished += tetherPresenter_ProcessFinished; patchPresetner = new PatchPresenter(patchControl, patchModel); patchPresetner.Finished += patchPresetner_Finished; dfuPresenter = new DFUPresenter(dfuModel, dfuControl); dfuPresenter.ProcessFinished += dfuPresenter_ProcessFinished; downloadPresenter = new DownloadPresenter(downloadModel, downloadView); downloadPresenter.ProcessFinished += downloadPresenter_ProcessFinished; }
public ViewFileViewModel(IMainModel mainModel, IGoogleDriveService googleDriveService, IMessageBoxService messageBoxService, ISystemTrayService systemTrayService, IMediaLibraryService mediaLibraryService) { _mainModel = mainModel; _googleDriveService = googleDriveService; _messageBoxService = messageBoxService; _systemTrayService = systemTrayService; _mediaLibraryService = mediaLibraryService; DownloadFileCommand = new RelayCommand(DownloadFile, () => !IsBusy && CanDownload); BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e => { AbortCurrentCall(false); }); }
public MainPresenter(IMainView view, IMainModel model, SynchronizationContext context) { _model = model; _view = view; _context = context; }
public MainPresenter(IMainView _view, IMainModel _model) { view = _view; model = _model; }
public ExplorerViewModel(IMainModel mainModel, IGoogleDriveService googleDriveService, INavigationService navigationService, IMessageBoxService messageBoxService, ISystemTrayService systemTrayService, IPhotoChooserService photoChooserService) { _mainModel = mainModel; _googleDriveService = googleDriveService; _navigationService = navigationService; _messageBoxService = messageBoxService; _systemTrayService = systemTrayService; _photoChooserService = photoChooserService; Files = new ObservableCollection<GoogleFileViewModel>(); PictureFiles = new ObservableCollection<GoogleFileViewModel>(); OpenFileCommand = new RelayCommand<GoogleFileViewModel>(file => { if (IsSelectionEnabled) { return; } OpenFile(file); }); ChangeStaredStatusCommand = new RelayCommand<GoogleFileViewModel>(file => { if (IsSelectionEnabled) { return; } ChangeStaredStatus(file); }); AddFileCommand = new RelayCommand(UploadFile); EnableSelectionCommand = new RelayCommand(() => { if (IsBusy) { return; } IsSelectionEnabled = true; }); RefreshFilesCommand = new RelayCommand(RefreshFiles); DeleteFilesCommand = new RelayCommand<IList>(files => { _messageBoxService.Show("You are about to delete the selected files. Do you wish to proceed?", "Delete files?", new[] { "delete", "cancel" }, button => { if (button != 0) return; var filesArray = files .Cast<GoogleFileViewModel>() .ToArray(); IsSelectionEnabled = false; DeleteFiles(filesArray); }); }); CreateNewFolderCommand = new RelayCommand(CreateNewFolder); RenameFileCommand = new RelayCommand<GoogleFileViewModel>(RenameFile); DeleteFileCommand = new RelayCommand<GoogleFileViewModel>(file => { _messageBoxService.Show(string.Format("You are about to delete '{0}'. Do you wish to proceed?", file.Title), "Delete file?", new[] { "delete", "cancel" }, button => { if (button != 0) return; DeleteFile(file); }); }); ShowAboutCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AboutPage.xaml"); }); PageLoadedCommand = new RelayCommand(ExecuteInitialLoad); BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e => { GoogleDriveFile item; if (PivotSelectedIndex == 1) { PivotSelectedIndex = 0; e.Cancel = true; } else if (IsSelectionEnabled) { IsSelectionEnabled = false; e.Cancel = true; } else if (_mainModel.TryPop(out item)) { AbortCurrentCall(); RaisePropertyChanged(() => CurrentPath); RefreshFiles(); e.Cancel = true; } else { AbortCurrentCall(true); Files.Clear(); PictureFiles.Clear(); } }); MessengerInstance.Register<RefreshFilesMessage>(this, message => { DispatcherHelper.RunAsync(RefreshFiles); }); }
public MainViewModel(IMainModel mainModel, INavigationService navigationService, IMessageBoxService messageBoxService, IApplicationSettingsService applicationSettingsService, IShellTileService shellTileService) { _mainModel = mainModel; _navigationService = navigationService; _messageBoxService = messageBoxService; _applicationSettingsService = applicationSettingsService; _shellTileService = shellTileService; NewAccountCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AuthorizationPage.xaml"); }); RemoveAccountCommand = new RelayCommand<AccountViewModel>(account => { _mainModel.AvailableAccounts.Remove(account.Model); _mainModel.Save(); RefreshAccountsList(); }); OpenAccountCommand = new RelayCommand<AccountViewModel>(account => { _mainModel.CurrentAccount = account.Model; _mainModel.ExecuteInitialLoad = true; _navigationService.NavigateTo("/View/ExplorerPage.xaml"); }); ShowAboutCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AboutPage.xaml"); }); PageLoadedCommand = new RelayCommand(() => { _mainModel.CurrentAccount = null; if (!_applicationSettingsService.Get<bool>("AcceptedDisclaimer", false)) { _applicationSettingsService.Set("AcceptedDisclaimer", true); _applicationSettingsService.Save(); _messageBoxService.Show("You are advised to read the GDrive disclaimer before you continue.\n\nWould you like to read it now?\n\nYou can always find it later in the About page.", "Welcome to GDrive", new[] { "now", "later" }, buttonIndex => { if (buttonIndex == 0) { _navigationService.NavigateTo("/View/AboutPage.xaml?disclaimer=true"); } }); } }); MessengerInstance.Register<AvailableAccountsChangedMessage>(this, message => { RefreshAccountsList(); }); #if !WP8 DispatcherHelper.RunAsync(UpdateTiles); #endif }
public GnuPlotGeneratorService ( IMainModel model ) { _model = model; }
/// <summary> /// Initialize the <c>Model</c> /// </summary> /// <remarks> /// <para>Called by the <c>initializeFacade</c> method. Override this method in your subclass of <c>Facade</c> if one or both of the following are true:</para> /// <list type="bullet"> /// <item>You wish to initialize a different <c>IModel</c></item> /// <item>You have <c>Model</c>s to register with the Model that do not retrieve a reference to the Facade at construction time</item> /// </list> /// <para>If you don't want to initialize a different <c>IModel</c>, call <c>base.initializeModel()</c> at the beginning of your method, then register <c>Model</c>s</para> /// <para>Note: This method is <i>rarely</i> overridden; in practice you are more likely to use a <c>Controller</c> to create and register <c>Model</c>s with the <c>Model</c>, since <c>Model</c>s with mutable data will likely need to send <c>INotification</c>s and thus will likely want to fetch a reference to the <c>Facade</c> during their construction</para> /// </remarks> protected virtual void InitializeMainModel() { if (this.mMainModel != null) return; this.mMainModel = MainModel.Instance; }
public MainPresenter(IMainModel model, IMainView view) : base(model, view) { }
public LogService(IMainModel model) { _model = model; }
public MainPresenter(IMainView mainView) { this.mainView = mainView; this.mainModel = new MainModel(); }