public WaUpdaterViewModel(BuildType buildType)
        {
            if (buildType == BuildType.Stable)
            {
                manager = new StableWaUpdateManager();
            }
            else if (buildType == BuildType.Beta)
            {
                manager = new BetaWaUpdateManager();
            }
            else
            {
                throw new LauncherException("Unknown build type");
            }

            Settings = App.PersistentFactory.Create<UpdaterSettings>("UpdaterSettings" + buildType);
            Settings.Data.PropertyChanged += (sender, args) =>
                Settings.RequireSave();
            Application.Current.Exit += (sender, args) =>
                Settings.Save();

            UpdateCommand = new AwaitableDelegateCommand(async () =>
            {
                try
                {
                    await manager.UpdateAsync();
                    NewVersionAvailable = false;
                    nextUpdateCheck = DateTime.Now;
                }
                catch (Exception exception)
                {
                    App.Logger.LogError("update error", this, exception);
                    ErrorManager.ShowWarning("update error: " + exception.Message, exception);
                }
                manager.StatusReset();
            }, () => !UpdateInProgress);

            ReinstallCommand = new AwaitableDelegateCommand(async () =>
            {
                try
                {
                    manager.StatusReset();
                    AvailabilityStatus = string.Empty;
                    await manager.UninstallAsync();
                    await UpdateCommand.ExecuteAsync(null);
                }
                catch (Exception exception)
                {
                    App.Logger.LogError("reinstall error", this, exception);
                    ErrorManager.ShowWarning("reinstall error: " + exception.Message, exception);
                }
            });

            manager.UpdateStatusChanged += (sender, args) =>
            {
                UpdateStatus = args.Status;
                UpdateInProgress = args.IsRunning;
                UpdateProgressIndeterminate = args.ProgressIndeterminate;
                UpdateProgress = args.Progress;
            };

            AvailabilityStatus = "Checking for updates...";

            timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };

            timer.Tick += async (s, a) =>
            {
                timer.Interval = TimeSpan.FromSeconds(10);

                if (!initialNewsLoad)
                {
                    initialNewsLoad = true;
                    RefreshWaNews();
                }

                Settings.Update();
                if (!UpdateInProgress && DateTime.Now > nextUpdateCheck)
                {
                    nextUpdateCheck = DateTime.Now + TimeSpan.FromHours(6);

                    try
                    {
                        CheckingVersion = true;
                        AvailabilityStatus = "Checking for updates...";
                        await CheckForNewVersion();
                        CheckingVersion = false;

                        if (newVersionAvailable)
                        {
                            RefreshWaNews();
                            manager.StatusReset();
                            AvailabilityStatus = string.Empty;
                            // run auto update if applicable
                            if (Settings.Data.NotifyOnNewVersion)
                            {
                                // todo show baloon, max once each 16 hours
                                if (DateTime.Now > nextUpdateReminder)
                                {
                                    var message = string.Format("New {0} Wurm Assistant version is available!", buildType);
                                    App.LauncherTaskbarIcon.ShowBalloonTip("Rejoice!", message, BalloonIcon.Info);
                                    nextUpdateReminder = DateTime.Now + TimeSpan.FromHours(16);
                                }
                            }
                            if (Settings.Data.AutoUpdate)
                            {
                                try
                                {
                                    await manager.UpdateAsync();
                                    NewVersionAvailable = false;
                                    nextUpdateCheck = DateTime.Now;
                                    var message =
                                        string.Format("{0} Wurm Assistant has just been updated to new version!",
                                            buildType);
                                    // show tray pop
                                    App.LauncherTaskbarIcon.ShowBalloonTip("Rejoice!", message, BalloonIcon.Info);
                                }
                                catch (Exception exception)
                                {
                                    // handle exceptions silently
                                    App.Logger.LogError("auto update failed, " + buildType, this, exception);
                                }
                                manager.StatusReset();
                            }
                        }
                        else
                        {
                            manager.StatusReset();
                            AvailabilityStatus = "WA-" + buildType + " is up to date";
                        }
                    }
                    catch (Exception exception)
                    {
                        App.Logger.LogError("Update error", this, exception);
                        AvailabilityStatus = "Error: " + exception.Message +
                            ". Try checking internet connection, firewall settings or restarting the launcher."
                            + " Version check will retry in 5 minutes.";
                        nextUpdateCheck = DateTime.Now + TimeSpan.FromMinutes(5);
                    }
                }
            };
        }
        public NodeWindowViewModel(LocationModel locationModel,
                                   INodeNavigationService nodeNavigationService,
                                   ILocationService locationService,
                                   LocationViewmodel.Factory locationViewmodelFactory,
                                   DispatcherAccessor dispatcherAccessor,
                                   NodeHistoryState nodeHistoryState,
                                   BreadCrumbViewmodel.Factory breadCrumbViewmodelFactory)
        {
            _locationViewModel        = locationViewmodelFactory(locationModel, this);
            _nodeNavigationService    = nodeNavigationService;
            _locationService          = locationService;
            _locationViewmodelFactory = locationViewmodelFactory;
            _dispatcherAccessor       = dispatcherAccessor;

            _title = locationModel.Name;

            _nodeHistoryState           = nodeHistoryState;
            _breadCrumbViewmodelFactory = breadCrumbViewmodelFactory;

            BackCommand    = new AwaitableDelegateCommand(GoBack, () => BackAvailable);
            ForwardCommand = new AwaitableDelegateCommand(GoForward, () => ForwardAvailable);
            var breadCrumbs = ConvertToBreadCrumbs(_nodeHistoryState);

            BreadCrumbs = new ObservableCollection <BreadCrumbViewmodel>(breadCrumbs);
        }
Exemple #3
0
 public StartViewModel(Page startPage)
 {
     _currentPage         = startPage;
     GoHomePageCommand    = new AwaitableDelegateCommand(async() => CurrentPage = await NavigatorService.GoPage(CurrentPage, "HomePage"));
     GoCpuPageCommand     = new AwaitableDelegateCommand(async() => CurrentPage = await NavigatorService.GoPage(CurrentPage, "CpuPage"));
     GoProcessPageCommand = new AwaitableDelegateCommand(async() => CurrentPage = await NavigatorService.GoPage(CurrentPage, "ProcessPage"));
 }
        public ShellViewModel(
            IDialogService dialogService,
            IEventAggregator eventAggregator,
            MdiViewModel mdi,
            SettingsViewModel settingsViewModel,
            UpdaterViewModel updaterViewModel,
            Func <DocumentViewModel> documentViewModelFactory,
            IDocumentFactory documentFactory,
            IFileSystem fileSystem,
            SearchSettings searchSettings, IOpenDocumentFromWeb openDocumentFromWeb)
        {
            this.eventAggregator = eventAggregator;
            this.dialogService   = dialogService;
            MDI     = mdi;
            Updater = updaterViewModel;
            this.documentViewModelFactory = documentViewModelFactory;
            this.documentFactory          = documentFactory;
            this.fileSystem          = fileSystem;
            SearchSettings           = searchSettings;
            this.openDocumentFromWeb = openDocumentFromWeb;

            Settings = settingsViewModel;
            Settings.Initialize();
            NewDocumentCommand       = new DelegateCommand(() => NewDocument());
            NewJekyllDocumentCommand = new DelegateCommand(() => NewDocument(CreateJekyllHeader()));
            SaveDocumentCommand      = new AwaitableDelegateCommand(SaveDocument, () => !IsWorking);
            SaveDocumentAsCommand    = new AwaitableDelegateCommand(SaveDocumentAs, () => !IsWorking);
            SaveAllDocumentsCommand  = new AwaitableDelegateCommand(SaveAllDocuments, () => !IsWorking);
            PublishDocumentCommand   = new AwaitableDelegateCommand(PublishDocument, () => !IsWorking);
            OpenDocumentCommand      = new DelegateCommand(OpenDocument, () => !IsWorking);
            OpenFromWebCommand       = new AwaitableDelegateCommand(OpenFromWeb, () => !IsWorking);
            CloseDocumentCommand     = new DelegateCommand(CloseDocument, () => ActiveDocumentViewModel != null);

            ActivateItem(mdi);
        }
        public ProjectAdministrationModel(IAdministrationRemoteService adminService, ApplicationGlobalModel globalModel, [Named("WpfClientMapper")] IMapper mapper,
                                          IEventAggregator eventAggregator)
        {
            this.adminService     = adminService;
            this.globalModel      = globalModel;
            this.mapper           = mapper;
            this._eventAggregator = eventAggregator;

            TabModel = new TabModel()
            {
                Title      = Properties.Resources.AdministrationTab_Title_Project,
                CanClose   = false,
                IsModified = false
            };


            IsProjectSelected = false;

            AllCompanyUsers = new ObservableCollection <User>();
            ProjectUsers    = new ObservableCollection <ProjectUser>();

            AddUserToProjectCommand      = new AwaitableDelegateCommand(AddUserToProject, CanExecuteAddUserToProject);
            RemoveUserFromProjectCommand = new AwaitableDelegateCommand(RemoveUserFromProject, CanExecuteRemoveUserFromProject);
            InviteUserCommand            = new AwaitableDelegateCommand(InviteUser, CanExecuteInviteUser);
            CompanyAdminCheckCommand     = new AwaitableDelegateCommand(CompanyAdminCheck);
            ProjectSetAsAdminCommand     = new AwaitableDelegateCommand(SetAsAdmin, CanSetAsAdmin);
            InitializeCommand            = new AwaitableDelegateCommand(LoadProjects);

            ChangeNotification = new InteractionRequest <INotification>();
        }
        public UserSelfAdministrationModel(IAdministrationRemoteService adminService, ApplicationGlobalModel globalModel,
                                           UserNameClientCredentials userCredentials, [Named("WpfClientMapper")]  IMapper mapper, IEventAggregator eventAggregator)
        {
            this._adminService    = adminService;
            this._mapper          = mapper;
            this._userCredentials = userCredentials;
            this._eventAggregator = eventAggregator;

            TabModel = new TabModel()
            {
                Title      = Properties.Resources.AdministrationTab_Title_User,
                CanClose   = false,
                IsModified = false
            };

            CurrentUser = globalModel.CurrentUser;
            BackupUser  = new User();

            IsUserInEditMode     = false;
            IsPasswordInEditMode = false;
            PasswordChangeModel  = new PasswordChangeViewModel();

            StartUserChangesCommand  = new DelegateCommand(StartUserChanges);
            SaveUserChangesCommand   = new AwaitableDelegateCommand(SaveUserChanges);
            CancelUserChangesCommand = new DelegateCommand(CancelUserChanges);

            StartPasswordChangeCommand  = new DelegateCommand(StartPasswordChange);
            ChangeUserPasswordCommand   = new AwaitableDelegateCommand(ChangeUserPassword);
            CancelPasswordChangeCommand = new DelegateCommand(CancelPasswordChange);

            ChangeNotification = new InteractionRequest <INotification>();
        }
Exemple #7
0
        public Session(Fiddler.Session session, Core core)
        {
            fSession = session;
            fSession.OnStateChanged += (x, stateChangeEventArgs) =>
            {
                State = (int)stateChangeEventArgs.newState;
            };
            score           = core;
            CmdAbortSession = new SimpleCommand <Session>()
            {
                ExecuteDelegate = (oS) =>
                {
                    oS.fSession.Abort();
                },
                CanExecuteDelegate = (oS) =>
                {
                    if (oS == null)
                    {
                        return(false);
                    }
                    return(oS.fSession.state != SessionStates.Aborted);
                }
            };
            CmdDownloadSession = new AwaitableDelegateCommand(

                executeMethod: () =>
            {
                return(Task.Run(() =>
                {
                    //DownloadQueueProcessor dq = new DownloadQueueProcessor();
                    DownloadQueueProcessor.Initialize(this);
                    DownloadQueueProcessor.Start(this, Config.MaxParallel);
                    //score.SegmentedDownload(oS);
                }));
            },
                canExecuteMethod: () =>
            {
                return(true);
            }
                );
            CmdRefreshSession = new SimpleCommand <Session>()
            {
                ExecuteDelegate = (oS) =>
                {
                    oS.NotifyPropertyChanged("Size");
                },
                CanExecuteDelegate = (oS) =>
                {
                    return(true);
                }
            };
            CmdXSession = new SimpleCommand <Session>()
            {
                ExecuteDelegate    = (oS) => { },
                CanExecuteDelegate = (oS) =>
                {
                    return(true);
                }
            };
        }
Exemple #8
0
        public MainWindowViewModel()
        {
            Log.ResetSettings(true, true);
            Log.Info($@"---
Version:{Assembly.GetExecutingAssembly().GetName().Version}
MachineName:{Environment.MachineName}
OSVersion:{Environment.OSVersion}
Is64BitOperatingSystem:{Environment.Is64BitOperatingSystem}");

#if !DEBUG
            System.Windows.Application.Current.DispatcherUnhandledException += (s, e) => Log.Error($"DispatcherUnhandledException: {e.Exception}");
#endif

            if (Settings.Default.UpdateRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.UpdateRequired = false;
                Settings.Default.Save();
            }

            App.SecondInstanceStarted += App_SecondInstanceStarted;

            updateCheckTimer.Interval = TimeSpan.FromHours(2);
            updateCheckTimer.Tick    += UpdateCheckTimer_Tick;
            updateCheckTimer.Start();

            RefreshCommand           = new AwaitableDelegateCommand(ExecuteRefreshCommandAsync);
            UpgradeAllCommand        = new AwaitableDelegateCommand(ExecuteUpgradeAllCommandAsync);
            InstallCommand           = new AwaitableDelegateCommand(ExecuteInstallCommandAsync);
            UpdateCommand            = new AwaitableDelegateCommand(ExecuteUpdateCommandAsync);
            UninstallCommand         = new AwaitableDelegateCommand(ExecuteUninstallCommandAsync);
            ImportCommand            = new DelegateCommand(ExecuteImportCommand);
            ExportCommand            = new DelegateCommand(ExecuteExportCommand);
            OpenCommandPromptCommand = new DelegateCommand(ExecuteOpenCommandPromptCommand);
            SearchStartedCommand     = new AwaitableDelegateCommand(ExecuteSearchStartedCommandAsync);

            PropertyChanged += async(s, e) =>
            {
                if (e.PropertyName == nameof(IncludePreReleases))
                {
                    chocoExecutor.IncludePreReleases = IncludePreReleases;
                }

                if (e.PropertyName == nameof(Filter) || e.PropertyName == nameof(IncludePreReleases))
                {
                    await ApplyFilterAsync();
                }

                if (e.PropertyName == nameof(SelectedPackage))
                {
                    HasSelectedPackage = SelectedPackage != Package.Empty && SelectedPackage != null;

                    if (HasSelectedPackage)
                    {
                        SelectedVersion = SelectedPackage.Versions.First();
                    }
                }
            };
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="fileService">File service to use.</param>
 /// <param name="ipodFix">iPod fix to use.</param>
 public MainWindowViewModel(IFileService fileService, IIpodFix ipodFix)
 {
     _fileService             = fileService;
     _ipodFix                 = ipodFix;
     ChooseSourceCommand      = new DelegateCommand <string>(ChooseSourcePath);
     ChooseDestinationCommand = new DelegateCommand(ChooseDestinationPath);
     StartCommand             = new AwaitableDelegateCommand <object>(StartAsync);
 }
 public CategoryListModel(ITaskRemoteService taskService, IAdministrationRemoteService adminService, IEventAggregator eventAggregator)
 {
     this._taskService     = taskService;
     this._adminService    = adminService;
     this._eventAggregator = eventAggregator;
     CreateCategory        = new AwaitableDelegateCommand(OnCreateCategory);
     Categories            = new ObservableCollection <Category>();
 }
 public NewLocationViewmodel(IEnumerable <NewRelatedLocationViewmodel> relatedLocations,
                             Action closeCallback,
                             IGameScreenContext gameScreenContext)
 {
     _closeCallback     = closeCallback;
     _gameScreenContext = gameScreenContext;
     SaveCommand        = new AwaitableDelegateCommand(OnSaveClicked);
     Locations          = new ObservableCollection <NewRelatedLocationViewmodel>(relatedLocations);
 }
 public async Task TestCommand() {
     testCount = 0;
     var testIncrement = new Func<Task>(async () => { await Task.Run(() => { testCount++; }); });
     var command = new AwaitableDelegateCommand(testIncrement);
     for (int i = 0; i < 10; i++) {
         await command.ExecuteAsync();
     }
     Assert.AreEqual(10, testCount, "testCount hat nicht den erwarteten Wert!");
 }
        public TestAttachmentCleanup()
        {
            SearchCommand = new AwaitableDelegateCommand(Search, CanWork);
            DeleteCommand = new AwaitableDelegateCommand(Delete, CanWork);
            StopCommand = new DelegateCommand(Stop, () => Working);

            TestRunAttachmentsInfo = new ObservableCollection<TestRunAttachmentInfo>();
            BuildSearchFilters();
        }
Exemple #14
0
 public MainWindowViewModel()
 {
     _pokeService                = new PokeInformationService();
     _printingService            = new PrintingService();
     SearchPokemon               = new AwaitableDelegateCommand(SearchPokemonAsync);
     SortByTypeCommand           = new AwaitableDelegateCommand(SortByType);
     PrintSelectedPokemonCommand = new AwaitableDelegateCommand(PrintSelectedPokemon);
     _ = PrintAllPokemonAsync();
 }
        public TestAttachmentCleanup()
        {
            SearchCommand = new AwaitableDelegateCommand(Search, CanWork);
            DeleteCommand = new AwaitableDelegateCommand(Delete, CanWork);
            StopCommand   = new DelegateCommand(Stop, () => Working);

            TestRunAttachmentsInfo = new ObservableCollection <TestRunAttachmentInfo>();
            BuildSearchFilters();
        }
        public async Task TaskCalculateParallelWhenAllShouldReturnSquares(int anzahl)
        {
            _testee.Anzahl = anzahl;

            AwaitableDelegateCommand command = _testee.CalculateParallelWhenAllCommand;
            await command.ExecuteAsync(null);

            _testee.ResultOutput.Should().Be(GetSquares(0, anzahl - 1));
        }
        public async Task CalculateMultiAsyncResultShouldBeVisible()
        {
            _testee.Anzahl = 3;

            AwaitableDelegateCommand command = _testee.CalculateMultiAsyncCommand;
            await command.ExecuteAsync(null);

            _testee.IsResultVisible.Should().Be(true);
        }
        public async Task CalculateMultiAsyncShouldReturnSquares()
        {
            _testee.Anzahl = 10;

            AwaitableDelegateCommand command = _testee.CalculateMultiAsyncCommand;
            await command.ExecuteAsync(null);

            _testee.ResultOutput.Should().Be(GetSquares(0, 9));
        }
Exemple #19
0
        public async Task TestCommand()
        {
            testCount = 0;
            var testIncrement = new Func <Task>(async() => { await Task.Run(() => { testCount++; }); });
            var command       = new AwaitableDelegateCommand(testIncrement);

            for (int i = 0; i < 10; i++)
            {
                await command.ExecuteAsync();
            }
            Assert.AreEqual(10, testCount, "testCount hat nicht den erwarteten Wert!");
        }
Exemple #20
0
 public GraphViewModel(NavigationViewModel navigationViewModel, Pings pings)
 {
     _navigationViewModel     = navigationViewModel;
     BackCommand              = new MyICommand(OnBackCommand);
     CloseGraphCommand        = new MyICommand(OnCloseGraphCommand);
     CompressionValueBoxEnter = new MyICommand(OnCompressionValueBoxEnter);
     ToggleDisplayTypeCommand = new AwaitableDelegateCommand(OnToggleDisplayTypeCommand);
     OpenDataFolderCommand    = new MyICommand(OnOpenDataFolderCommand);
     _pings = pings;
     InitGraph();
     graphHelper = new GraphHelper();
 }
Exemple #21
0
        public SerialPortViewModel()
        {
            _             = RefreshPortNameList();
            BaudRatesList = Settings.Instance.GetBaudRates();
            ParitiesList  = Settings.Instance.GetParities();
            DataBitsList  = Settings.Instance.GetDataBits();
            StopBitsList  = Settings.Instance.GetStopBits();
            HandshakeList = Settings.Instance.GetHandshakes();

            OpenCommand    = new AwaitableDelegateCommand(OpenAsync);
            CloseCommand   = new AwaitableDelegateCommand(CloseAsync);
            RefreshCommand = new AwaitableDelegateCommand(RefreshPortNameList);
        }
Exemple #22
0
        public MissionViewModel(SQLiteDataContext dataContext)
        {
            this.dataContext = dataContext;
            FlashQuene       = new BlockingCollection <Memory <Byte> >();
            StreamQuene      = new BlockingCollection <Memory <Byte> >();

            TakeDataCommand    = new AwaitableDelegateCommand(TakeDataAsync);
            DeleteCommand      = new AwaitableDelegateCommand(DeleteAsync);
            DisplayCommand     = new AwaitableDelegateCommand(DisplayAsync);
            StartStreamCommand = new AwaitableDelegateCommand(StartStreamAsync);
            StopStreamCommand  = new AwaitableDelegateCommand(StopStreamAsync);

            _ = QueryAsync();
        }
Exemple #23
0
        public LoginModel(ApplicationGlobalModel applicationGlobalModel, UserNameClientCredentials userCredentials,
                          IAuthorisationRemoteService authorisationService, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            this.applicationGlobalModel = applicationGlobalModel;
            this.regionManager          = regionManager;
            this.userCredentials        = userCredentials;
            this.authorisationService   = authorisationService;
            this._eventAggregator       = eventAggregator;

            LoginCommand  = new AwaitableDelegateCommand(Login);
            LoadedCommand = new AwaitableDelegateCommand(Loaded);

            scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            LoadPreviousSettings();
        }
        public TaskListModel(ITaskRemoteService service, TaskFilter filter, ApplicationGlobalModel applicationGlobalModel,
                             IEventAggregator eventAggregator, [Named("WpfClientMapper")] IMapper mapper)
        {
            this._service                     = service;
            this._taskFilter                  = filter;
            this._eventAggregator             = eventAggregator;
            this.Tasks                        = new ObservableCollection <Task>();
            CreateTask                        = new AwaitableDelegateCommand(OnCreateTask);
            this._taskFilter.PropertyChanged += Filter_PropertyChanged;
            _currentUser                      = applicationGlobalModel.CurrentUser;
            _mapper = mapper;

            TaskDeletedEvent taskDeletedEvent = eventAggregator.GetEvent <TaskDeletedEvent>();

            taskDeletedEvent.Subscribe(OnDeleteTask, ThreadOption.UIThread, false, t => Category != null && t.CategoryId == Category.CategoryId);
        }
Exemple #25
0
 public FileConverterViewModel(NavigationViewModel navigationViewModel)
 {
     _navigationViewModel                   = navigationViewModel;
     ConvertFilesCommand                    = new AwaitableDelegateCommand(onConvertFilesCommand, canConvertFilesCommand);
     StartDirectorySerachCommand            = new MyICommand(onStartDirectorySerachCommand);
     CloseInfoBannerCommand                 = new MyICommand(onCloseInfoBannerCommand);
     CancelSearchCommand                    = new MyICommand(onCancelSearchCommand);
     RemoveListedFileCommand                = new MyICommand(onRemoveListedFileCommand);
     RemoveAllNonSelectedListedFilesCommand = new MyICommand(onRemoveAllNonSelectedListedFilesCommand);
     UpdateFilesNotSelectedCommand          = new MyICommand(onUpdateFilesNotSelectedCommand);
     RemovalAnimationTimer.Interval         = TimeSpan.FromMilliseconds(200);
     RemovalAnimationTimer.Tick            += RemovalAnimationTimer_Tick;
     InfoBannerTimer.Interval               = TimeSpan.FromMilliseconds(50);
     InfoBannerTimer.Tick                  += InfoBannerTimer_Tick;
     initFileCoverter();
 }
        public MainWindowViewModel()
        {
            DownloadNewLauncherCommand = new AwaitableDelegateCommand(async () =>
            {
                try
                {
                    var requestUrl = string.Format("ProjectApi/LatestLauncherDownloadUrl/{0}", AppContext.ProjectName);
                    var newVersionUri = await TransientHelper.CompensateAsync(
                        () => WebApiEx.GetObjectFromWebApiAsync<string>(
                            AppContext.WebApiBasePath,
                            requestUrl,
                            TimeSpan.FromSeconds(15)),
                        "error while contacting web service",
                        5);
                    if (!string.IsNullOrWhiteSpace(newVersionUri))
                    {
                        Process.Start(newVersionUri);
                    }
                    else
                    {
                        throw new LauncherException("returned string was empty, requested at: " + requestUrl);
                    }
                }
                catch (Exception exception)
                {
                    App.Logger.LogError("problem: ", this, exception);
                    ErrorManager.ShowWarning("Failed to get download link for latest version", exception);
                }
            });

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);

            timer.Tick += async (sender, args) =>
            {
                timer.Interval = TimeSpan.FromHours(2);
                try
                {
                    NewVersionAvailable = await IsLauncherUpdateAvailableAsync();
                }
                catch (Exception exception)
                {
                    App.Logger.LogError("Failed to obtain latest launcher version", this, exception);
                }
            };
            timer.Start();
        }
Exemple #27
0
        public Game()
        {
#if AutomatedPlay
            Players.Add(new ComputerPlayer(new Player("Peter")));
#else
            var user = new User(new Player("Peter"));

            user.CardRequested += (s, e) => {
                while (true)
                {
                    _autoWaitHandle.WaitOne();
                    if (SelectedCard == null || SelectedPlayer == null)
                    {
                        FireNotifyEvent("Please select both a card to ask for, and the person to ask.");
                    }
                    else
                    {
                        e.Card         = SelectedCard.Value;
                        e.Player       = SelectedPlayer.Player;
                        SelectedCard   = null;
                        SelectedPlayer = null;
                        break;
                    }
                }
            };

            Players.Add(user);
#endif
            Players.Add(new ComputerPlayer(new Player("Melvin")));
            Players.Add(new ComputerPlayer(new Player("John")));
            Players.Add(new ComputerPlayer(new Player("Raymond")));

#if AutomatedPlay
#else
            User = new UserViewModel(user);
#endif
            ComputerPlayers.AddRange(Players.Where(p => typeof(IAutomatedPlayer).IsAssignableFrom(p.GetType())).Select(p => new ComputerPlayerViewModel(p)));

            StartGame   = new DelegateCommand(StartGameCallback);
            PlayRound   = new AwaitableDelegateCommand(() => Task.Factory.StartNew(PlayRoundCallback));
            RequestCard = new DelegateCommand(RequestCardCallback);
            Reset       = new DelegateCommand(ResetCallback);

            _context = SynchronizationContext.Current;
        }
        public ImplementedIdolViewModel(AppConfig config, OwnedIdolViewModel ovm)
        {
            m_config = config;
            m_ovm = ovm;

            Idols = new ListCollectionView(m_config.ImplementedIdols);
            Filter = new IdolFilter(config, Idols, true);
            Filter.SetConfig(config.ImplementedIdolFilterConfig);

            foreach(var option in m_config.ImplementedIdolSortOptions)
            {
                Idols.SortDescriptions.Add(option.ToSortDescription());
            }

            ReloadDataCommand = new AwaitableDelegateCommand(ReloadData);
            AddToOwnedCommand = new DelegateCommand(AddToOwned, () => SelectedIdols!=null && SelectedIdols.Count > 0);
            CopyIidCommand = new DelegateCommand(CopyIid, () => SelectedIdols != null && SelectedIdols.Count ==1);
        }
        public DirectorySelectionViewModel()
        {
            _musicConverter = new MusicLibraryConverter();

            //TODO: MUST include directory validation in all these "CanExecute" commands.
            //For now, we enable/disable buttons based on whether the conversion command is executing or not.

            StartConversionCommand  = new AwaitableDelegateCommand(StartConversion_Async);
            CancelConversionCommand = new DelegateCommand(CancelConversion, () => !StartConversionCommand.CanExecute(null));

            ChooseSourceCommand = new DelegateCommand(ChooseSource, () => StartConversionCommand.CanExecute(null));
            ChooseTargetCommand = new DelegateCommand(ChooseTarget, () => StartConversionCommand.CanExecute(null));

            CloseApplicationCommand = new DelegateCommand(() => Application.Current.MainWindow.Close());
            StartOverCommand        = new DelegateCommand(StartApplicationOver);

            CurrentApplicationState = ApplicationState.Starting;
        }
Exemple #30
0
        public ImplementedIdolViewModel(AppConfig config, MainViewModel mvm)
        {
            m_config = config;
            m_mvm    = mvm;

            Idols  = new ListCollectionView(m_config.ImplementedIdols);
            Filter = new IdolFilter(config, Idols, true);
            Filter.SetConfig(config.ImplementedIdolFilterConfig);

            foreach (var option in m_config.ImplementedIdolSortOptions)
            {
                Idols.SortDescriptions.Add(option.ToSortDescription());
            }

            ReloadDataCommand     = new AwaitableDelegateCommand(ReloadData);
            AddToOwnedCommand     = new DelegateCommand(AddToOwned, () => SelectedIdols != null && SelectedIdols.Count > 0);
            CopyIidCommand        = new DelegateCommand(CopyIid, () => SelectedIdols != null && SelectedIdols.Count == 1);
            SetGuestCenterCommand = new DelegateCommand(SetGuestCenter, () => SelectedIdols != null && SelectedIdols.Count == 1);
        }
        public ConcurrencyViewModel()
        {
            GetHtmlCommand                  = new DelegateCommand(GetHtml);
            GetHtmlAsyncCommand             = new DelegateCommand(GetHtmlAsync);
            GetHtmlAsync2Command            = new DelegateCommand(GetHtmlAsync2);
            CalculateCommand                = new DelegateCommand(Calculate);
            CalculateAsyncCommand           = new AwaitableDelegateCommand(CalculateAsync);
            CalculateMultiCommand           = new DelegateCommand(CalculateMulti);
            CalculateMultiAsyncCommand      = new AwaitableDelegateCommand(CalculateMultiAsync);
            CancelTaskCommand               = new DelegateCommand(CancelTasks);
            CalculateParallelForEachCommand = new AwaitableDelegateCommand(CalculateParallelForEachAsync);
            CancelParallelForEachCommand    = new DelegateCommand(CancelParallel);
            CalculateParallelWhenAllCommand = new AwaitableDelegateCommand(CalculateParallelWhenAllAsync);

            IsProgressBarVisible = false;
            IsResultVisible      = false;

            Anzahl = 10;
        }
        public MainViewModel(PresenceService presenceService, INotificationService notificationService)
        {
            if (presenceService == null)
            {
                throw new ArgumentNullException(nameof(presenceService));
            }

            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }

            _presenceService     = presenceService;
            _notificationService = notificationService;

            _getPresenceCommand = new AwaitableDelegateCommand(GetPresence, CanCheckPresence);

            SipUri = "sip:[email protected]";
        }
        public MainViewModel(PresenceService presenceService, INotificationService notificationService)
        {
            if (presenceService == null)
            {
                throw new ArgumentNullException(nameof(presenceService));
            }

            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }

            _presenceService = presenceService;
            _notificationService = notificationService;

            _getPresenceCommand = new AwaitableDelegateCommand(GetPresence, CanCheckPresence);

            SipUri = "sip:[email protected]";
        }
Exemple #34
0
        public BuildsView()
        {
            Builds            = new ObservableCollection <BuildDetail>();
            BuildDefinitions  = new ObservableCollection <IBuildDefinition>();
            DeleteOptionsList = new ObservableCollection <NodeItem>
            {
                new NodeItem()
                {
                    IsSelected = true, Title = DeleteOptions.All.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.Details.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.DropLocation.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.Label.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.None.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.Symbols.ToString()
                },
                new NodeItem()
                {
                    IsSelected = false, Title = DeleteOptions.TestResults.ToString()
                }
            };

            SearchCommand        = new AwaitableDelegateCommand(Search, () => !Working);
            DestroyCommand       = new AwaitableDelegateCommand(Destroy, () => SelectedIBuildDefinition != null && !Working);
            DeleteBuildsCommand  = new AwaitableDelegateCommand <object>(DeleteBuilds);
            DestroyBuildsCommand = new AwaitableDelegateCommand <object>(DestroyBuilds);
            GetDefinitions();
        }
Exemple #35
0
 protected override void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _back          = null;
             _forward       = null;
             _cancel        = null;
             _confirm       = null;
             _new           = null;
             _modify        = null;
             _find          = null;
             _duplicate     = null;
             _reloadCurrent = null;
         }
         _disposed = true;
     }
     base.Dispose(disposing);
 }
Exemple #36
0
        public CategoryShowEditModel(ITaskRemoteService service, IEventAggregator eventAggregator)
        {
            this._eventAggregator = eventAggregator;
            this._service         = service;
            IsEditorEnabled       = false;

            StartEditCategory  = new DelegateCommand(OnStartEditCategory);
            CancelEditCategory = new DelegateCommand(OnCancelEditCategory);
            UpdateCategory     = new AwaitableDelegateCommand(OnUpdateCategory);
            DeleteCategory     = new AwaitableDelegateCommand(OnDeleteCategory);

            var categoryEditStartedEvent = eventAggregator.GetEvent <CategoryEditStartedEvent>();

            categoryEditStartedEvent.Subscribe(CategoryEditStartedEventHandler, ThreadOption.UIThread, false, c => c != Category);

            var taskEditStartedEvent = eventAggregator.GetEvent <TaskEditStartedEvent>();

            taskEditStartedEvent.Subscribe(CategoryEditStartedEventHandler);
            this.DeleteConfirmation = new InteractionRequest <IConfirmation>();
        }
Exemple #37
0
        public SimulationViewModel(AppConfig config)
        {
            m_config = config;

            if(config.Songs==null)
            {
                config.Songs = new List<Song>();
            }

            Songs = config.Songs;
            LoadSongsCommand = new AwaitableDelegateCommand(LoadSongs);

            Simulator = new Simulator(config);

            GrooveBursts = new List<Tuple<AppealType?, string>>
            {
               Tuple.Create(new AppealType?(),"なし" ),
               Tuple.Create((AppealType?)AppealType.Vocal,"Vo 150%"),
               Tuple.Create((AppealType?)AppealType.Dance,"Da 150%"),
               Tuple.Create((AppealType?)AppealType.Visual,"Vi 150%")
            };

            GrooveTypes = new List<Tuple<IdolCategory, string>>
            {
               Tuple.Create(IdolCategory.Cute, "Cu 30%"),
               Tuple.Create(IdolCategory.Cool, "Co 30%"),
               Tuple.Create(IdolCategory.Passion, "Pa 30%")
            };

            SkillControls = new List<Tuple<SkillTriggerControl, string>>
            {
                Tuple.Create(SkillTriggerControl.Auto, "制御しない"),
                Tuple.Create(SkillTriggerControl.AlwaysTrigger, "100%発動する"),
                Tuple.Create(SkillTriggerControl.NeverTrigger, "発動しない"),
            };

            StartSimulationCommand = new AwaitableDelegateCommand(StartSimulation);

            Simulator.Song = Songs.FirstOrDefault();
            Simulator.Unit = Units.FirstOrDefault();
        }
Exemple #38
0
        public BuildsView()
        {
            Builds = new ObservableCollection<BuildDetail>();
            BuildDefinitions = new ObservableCollection<IBuildDefinition>();
            DeleteOptionsList = new ObservableCollection<NodeItem>
            {
                new NodeItem() {IsSelected = true,  Title = DeleteOptions.All.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.Details.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.DropLocation.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.Label.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.None.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.Symbols.ToString()},
                new NodeItem() {IsSelected = false, Title = DeleteOptions.TestResults.ToString()}
            };

            SearchCommand = new AwaitableDelegateCommand(Search, () => !Working);
            DestroyCommand = new AwaitableDelegateCommand(Destroy, () => SelectedIBuildDefinition != null && !Working);
            DeleteBuildsCommand = new AwaitableDelegateCommand<object>(DeleteBuilds);
            DestroyBuildsCommand = new AwaitableDelegateCommand<object>(DestroyBuilds);
            GetDefinitions();
        }
Exemple #39
0
        public TestPageViewModel(ITestService testService, IStorageService storageService)
        {
            _testService = testService;
            _storageService = storageService;

            GetSmallStreamCommand = new AwaitableDelegateCommand(ExecutePostSmallStreamCommand);
            GetLargeStreamCommand = new AwaitableDelegateCommand(ExecutePostLargeStreamCommand);
            
            GetSmallHttpCommand = new AwaitableDelegateCommand(ExecutePostSmallHttpCommand);
            GetLargeHttpCommand = new AwaitableDelegateCommand(ExecutePostLargeHttpCommand);

            SaveCommand = new AwaitableDelegateCommand(ExecuteSaveAndClearAllLists);

            SmallStreamModelsList = new List<SmallObjectTestModel>();
            SmallHttpModelsList = new List<SmallObjectTestModel>();
            LargeStreamModelsList = new List<LargeObjectTestModel>();
            LargeHttpModelsList = new List<LargeObjectTestModel>();

            SmallStreamModelsQueue = new ConcurrentQueue<SmallObjectTestModel>();
            SmallHttpModelsQueue = new ConcurrentQueue<SmallObjectTestModel>();
            LargeStreamModelsQueue = new ConcurrentQueue<LargeObjectTestModel>();
            LargeHttpModelsQueue = new ConcurrentQueue<LargeObjectTestModel>();

            Task.Run(async () =>
            {
                while (true)
                {
                    SmallObjectTestModel objectInQueue;
                    if (SmallStreamModelsQueue.TryDequeue(out objectInQueue))
                    {
                        lock (SmallStreamModelsList)
                        {
                            SmallStreamModelsList.Add(objectInQueue);
                        }
                    }
                    else
                    {
                        await Task.Delay(200);
                    }
                }
            });

            Task.Run(async () =>
            {
                while (true)
                {
                    SmallObjectTestModel objectInQueue;
                    if (SmallHttpModelsQueue.TryDequeue(out objectInQueue))
                    {
                        lock (SmallHttpModelsList)
                        {
                            SmallHttpModelsList.Add(objectInQueue);
                        }
                    }
                    else
                    {
                        await Task.Delay(200);
                    }
                }
            });

            Task.Run(async () =>
            {
                while (true)
                {
                    LargeObjectTestModel objectInQueue;
                    if (LargeStreamModelsQueue.TryDequeue(out objectInQueue))
                    {
                        lock (LargeStreamModelsList)
                        {
                            LargeStreamModelsList.Add(objectInQueue);
                        }
                    }
                    else
                    {
                        await Task.Delay(200);
                    }
                }
            });

            Task.Run(async () =>
            {
                while (true)
                {
                    LargeObjectTestModel objectInQueue;
                    if (LargeHttpModelsQueue.TryDequeue(out objectInQueue))
                    {
                        lock (LargeHttpModelsList)
                        {
                            LargeHttpModelsList.Add(objectInQueue);
                        }
                    }
                    else
                    {
                        await Task.Delay(200);
                    }
                }
            });
        }
 public void TestInitialize() {
     _command = new AwaitableDelegateCommand(new Func<Task>(async () => { 
         await Task.Run(() => Thread.Sleep(SLEEPTIME)); 
     }));
 }
        public WaBackupsViewModel(BuildType buildType)
        {
            if (buildType == BuildType.Stable)
            {
                manager = new StableBackupsManager(this);
            }
            else if (buildType == BuildType.Beta)
            {
                manager = new BetaBackupsManager(this);
            }
            else
            {
                throw new LauncherException("Unknown build type");
            }

            CreateBackupStatus = "Create backup";

            CreateBackupCommand = new AwaitableDelegateCommand(async () =>
            {
                try
                {
                    CreateBackupStatus = "Creating...";
                    makingBackup = true;
                    var t = new Task<WaBackup>(() => manager.CreateBackup());
                    t.Start();
                    var backup = await t;
                    WaBackups.Add(backup);
                }
                catch (Exception exception)
                {
                    App.Logger.LogError("", this, exception);
                    ErrorManager.ShowWarning(exception.Message, exception);
                }
                finally
                {
                    makingBackup = false;
                    CreateBackupStatus = "Create backup";
                    UpdateLastBackupTime();
                }
            }, () => !makingBackup);

            ManageBackupsCommand = new DelegateCommand(() =>
            {
                var ui = new ManageWaBackups(this);
                ui.ShowDialog();
            });

            ImportSettingsCommand = new DelegateCommand(() =>
            {
                // nothing yet
            });

            Title = string.Format("Backups manager ({0})", buildType.ToString());
            RefreshBackups();

            UpdateLastBackupTime();

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(30);
            timer.Tick += (sender, args) => UpdateLastBackupForDisplay();

            WaBackups.CollectionChanged += (sender, args) => UpdateLastBackupTime();
        }
Exemple #42
0
        public SimulationViewModel(AppConfig config)
        {
            m_config = config;

            if (config.Songs == null)
            {
                config.Songs = new List<Song>();
            }

            Songs = config.Songs;
            LoadSongsCommand = new AwaitableDelegateCommand(LoadSongs);

            Simulator = new Simulator(config);

            GrooveBursts = new List<Tuple<AppealType?, string>>
            {
               Tuple.Create(new AppealType?(),"なし" ),
               Tuple.Create((AppealType?)AppealType.Vocal,"Vo 150%"),
               Tuple.Create((AppealType?)AppealType.Dance,"Da 150%"),
               Tuple.Create((AppealType?)AppealType.Visual,"Vi 150%")
            };

            GrooveTypes = new List<Tuple<IdolCategory, string>>
            {
               Tuple.Create(IdolCategory.Cute, "Cu 30%"),
               Tuple.Create(IdolCategory.Cool, "Co 30%"),
               Tuple.Create(IdolCategory.Passion, "Pa 30%")
            };

            SkillControls = new List<Tuple<SkillTriggerControl, string>>
            {
                Tuple.Create(SkillTriggerControl.Auto, "制御しない"),
                Tuple.Create(SkillTriggerControl.AlwaysTrigger, "100%発動する"),
                Tuple.Create(SkillTriggerControl.NeverTrigger, "発動しない"),
            };

            StartSimulationCommand = new AwaitableDelegateCommand(StartSimulation);

            Runs = config.SimulatorConfig.Runs;
            EnableGuest = config.SimulatorConfig.EnableGuest;
            Simulator.EnableRoomEffect = config.SimulatorConfig.EnableRoomEffect;
            Simulator.EnableSupportMembers = config.SimulatorConfig.EnableSupportMembers;
            Simulator.SkillControl = config.SimulatorConfig.SkillControl;

            var song = Songs.FirstOrDefault(x => x.Title == config.SimulatorConfig.SongTitle);
            if (song != null)
            {
                Simulator.Song = song;
                var data = Simulator.SongDataList.FirstOrDefault(x => x.Difficulty == config.SimulatorConfig.SongDifficulty);
                if (data != null)
                {
                    Simulator.SongData = data;
                }
            }
            else
            {
                Simulator.Song = Songs.FirstOrDefault();
            }

            var unit = Units.FirstOrDefault(x => x.Name == config.SimulatorConfig.UnitName);
            if (unit != null)
            {
                Simulator.Unit = unit;
            }
            else
            {
                Simulator.Unit = Units.FirstOrDefault();
            }

            Simulator.GrooveBurst = config.SimulatorConfig.GrooveBurst;
            if(Simulator.GrooveBurst!=null)
            {
                Simulator.GrooveType = config.SimulatorConfig.GrooveType;
            }

            GuestIid = config.SimulatorConfig.GuestIid;
            Simulator.GuestPotential = config.SimulatorConfig.GuestPotential;

            UtilizeActualPattern = config.SimulatorConfig.UtilizeActualPattern.GetValueOrDefault(true);

            CopyIidCommand = new DelegateCommand<int?>(CopyIid);
            SetGuestCenterCommand = new DelegateCommand<int?>(SetGuestCenter);
        }
 public MainWindowViewModel()
 {
     BrowseCommand = new DelegateCommand(Browse);
     BrowseTestsCommand = new DelegateCommand(BrowseTests);
     AssignTestCaseCommand = new AwaitableDelegateCommand(AssignTestCase, CanAssignTestCase);
 }