コード例 #1
0
 public DistribInteractionService(IEventAggregator eventAggregator, IAppStateService appState)
 {
     _eventAggregator = eventAggregator;
     _appState = appState;
     _distribIOC = new Distrib.IOC.Ninject.NinjectBootstrapper();
     _distribIOC.Start();
 }
コード例 #2
0
 public AppStateManager_Controller()
 {
     _viewFactory          = Substitute.For <IAppViewFactory>();
     _serviceProvider      = Substitute.For <IServiceProvider>();
     _stateManager         = AppStates.CreateStateManager(_viewFactory, _serviceProvider);
     _stateManagerThreadId = Thread.CurrentThread.ManagedThreadId;
 }
コード例 #3
0
        public AppStateManager()
        {
            var viewFactory     = Substitute.For <IAppViewFactory>();
            var serviceProvider = Substitute.For <IServiceProvider>();

            _stateManager = AppStates.CreateStateManager(viewFactory, serviceProvider);
        }
コード例 #4
0
        public OpenPackageViewModel(IProjectPackageMapper mapper, ITagService tags, IAppStateService state)
        {
            _mapper = mapper;
            _tags   = tags;
            _state  = state;

            _state.ProjectChanged += async(s, e) =>
            {
                await GetPackagesAsync();
            };

            this.SelectPackage = new RelayCommand <ISmartInkPackage>(async(package) => {
                if (package == null)
                {
                    return;
                }

                if (_state.CurrentPackage?.Name == package.Name)
                {
                    return;
                }

                var tagList    = await _tags.GetTagsAsync();
                var updateTags = new Dictionary <Guid, string>();
                foreach (var tag in tagList)
                {
                    updateTags.Add(tag.Id, tag.Name);
                }

                await package.UpdateTagsAsync(updateTags);

                _state.SetCurrentPackage(package);
            });
        }
コード例 #5
0
 public ProcessHostInteractionViewModel(
     IAppStateService appState,
     IDistribInteractionService distrib,
     IEventAggregator eventAggregator,
     DistribProcessHost processHost)
 {
     _processHost = processHost;
 }
コード例 #6
0
        /// <summary>
        /// Application entry point
        /// Initializes Xamarin.Forms application
        /// </summary>
        /// <param name="args">Command line arguments</param>
        static void Main(string[] args)
        {
            var app = new Program();

            global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
            global::Tizen.Wearable.CircularUI.Forms.Renderer.FormsCircularUI.Init();
            _appStateService = DependencyService.Get <IAppStateService>();
            app.Run(args);
        }
コード例 #7
0
 public ScorecardsViewModel(
     IApiClient <Scorecard, ScorecardInfo> apiClient,
     IAppStateService stateService,
     NavigationManager navigation)
 {
     _apiClient       = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
     _appStateService = stateService ?? throw new ArgumentNullException(nameof(stateService));
     _navigation      = navigation ?? throw new ArgumentNullException(nameof(navigation));
 }
コード例 #8
0
        public ProjectsViewModel(IProjectService projects, IAppStateService state, IDialogService dialog)
        {
            _projects = projects;
            _state    = state;
            _dialog   = dialog;


            _state.KeysChanged += async(s, e) =>
            {
                await LoadAsync();
            };

            this.ShowCreate = new RelayCommand(() => { IsCreating = true; });

            this.SelectProject = new RelayCommand <Project>((project) => {
                if (project == null)
                {
                    return;
                }

                _state.CurrentProject = project;
                _state.SetCurrentPackage(null);
                ApplicationData.Current.LocalSettings.Values["LastProject"] = _state.CurrentProject.Name;
            });

            this.CreateProject = new RelayCommand <string>(async(project) => {
                if (string.IsNullOrWhiteSpace(project))
                {
                    return;
                }

                var newProject = await _projects.CreateProjectAsync(project);
                ProjectsList.Add(newProject);
                CurrentProject = newProject;
                IsCreating     = false;
            });
            this.ManageProjects = new RelayCommand(async() => {
                await _dialog.OpenAsync(DialogKeys.ManageProjects, this);
            });
            this.DeleteProject = new RelayCommand <Project>(async(project) => {
                Debug.WriteLine($"Delete {project.Name}");
                var confirm = await _dialog.ConfirmAsync("Confirm", $"Are you sure you want to delete {project.Name}?", "Yes", "No");

                if (!confirm)
                {
                    return;
                }

                await _projects.DeleteProjectAsync(project.Id);
                if (CurrentProject.Id == project.Id)
                {
                    CurrentProject = null;
                }
                ProjectsList.Remove(project);
            });
        }
コード例 #9
0
        public ProcessesInvestigatorViewModel(IAppStateService appState, IDistribInteractionService distrib, IEventAggregator eventAgg)
        {
            _appState = appState;
            _distrib = distrib;
            _eventAggregator = eventAgg;

            _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>()
                .Subscribe(OnAssemblyStateChanged, ThreadOption.UIThread);
            ProcessHosts = new ObservableCollection<DistribProcessHost>();
        }
コード例 #10
0
        public ProcessRunnerMainViewModel(Services.IDistribInteractionService distribService,
            IEventAggregator eventAggregator, Services.IAppStateService appState)
        {
            _appState = appState;
            _distribService = distribService;
            _eventAgg = eventAggregator;

            _eventAgg.GetEvent<Events.PluginAssemblyStateChangeEvent>()
                .Subscribe(OnPluginAssemblyStateChange);
        }
コード例 #11
0
        public AssemblyPickerStateViewModel(IAppStateService appState, 
            IDistribInteractionService distribInteraction,
            IEventAggregator eventAggregator)
        {
            _appState = appState;
            _distribInteraction = distribInteraction;
            _eventAggregator = eventAggregator;

            _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>()
                .Subscribe(OnAssemblyStateChanged);
        }
コード例 #12
0
        public ResourceKeysViewModel(IClassifierService classifier, ISecureKeyService keys, SmartInkLaboratory.Services.UX.IDialogService dialog, IAppStateService state, INavigationService nav)
        {
            _classifier = classifier;
            _keyService = keys;
            _dialog     = dialog;
            _state      = state;
            _nav        = nav;

            this.ShowKeys = new RelayCommand(() => { IsOpen = true; });

            this.SelectKey = new RelayCommand <string>((resource) => {
                if (string.IsNullOrWhiteSpace(resource))
                {
                    return;
                }

                if (!_keys.ContainsKey(resource))
                {
                    throw new InvalidOperationException("Resource not found");
                }

                var key            = SetKeys(resource);
                _state.CurrentKeys = key;
            });

            this.SaveKeys = new RelayCommand(() => {
                _keyService.SaveKeys(Resource, TrainingKey, PredictionKey);
                ApplicationData.Current.LocalSettings.Values["LastResource"] = Resource;
                _state.CurrentKeys = (new ResourceKeys {
                    Resource = Resource, TrainingKey = TrainingKey, PredicationKey = PredictionKey
                });
                IsOpen             = false;
            },
                                             () => {
                return(!string.IsNullOrWhiteSpace(Resource) &&
                       !string.IsNullOrWhiteSpace(TrainingKey) &&
                       !string.IsNullOrWhiteSpace(PredictionKey) &&
                       _isDirty);
            });

            this.More = new RelayCommand(async() => {
                await _dialog.OpenAsync <ResourceKeysViewModel>(DialogKeys.ResourceList, this);
            });

            this.DeleteKey = new RelayCommand <string>((key) => {
                _keyService.DeleteKey(key);
                KeyList.Remove(key);
            });

            Load();
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstalledModsControlViewModel" /> class.
 /// </summary>
 /// <param name="gameService">The game service.</param>
 /// <param name="localizationManager">The localization manager.</param>
 /// <param name="modService">The mod service.</param>
 /// <param name="appStateService">The application state service.</param>
 /// <param name="modSelectedSortOrder">The mod selected sort order.</param>
 /// <param name="modNameSortOrder">The mod name sort order.</param>
 /// <param name="modVersionSortOrder">The mod version sort order.</param>
 /// <param name="filterMods">The filter mods.</param>
 /// <param name="appAction">The application action.</param>
 /// <param name="notificationAction">The notification action.</param>
 public InstalledModsControlViewModel(IGameService gameService, ILocalizationManager localizationManager,
                                      IModService modService, IAppStateService appStateService, SortOrderControlViewModel modSelectedSortOrder,
                                      SortOrderControlViewModel modNameSortOrder, SortOrderControlViewModel modVersionSortOrder,
                                      SearchModsControlViewModel filterMods, IAppAction appAction, INotificationAction notificationAction)
 {
     this.modService          = modService;
     this.gameService         = gameService;
     this.appStateService     = appStateService;
     this.appAction           = appAction;
     this.notificationAction  = notificationAction;
     this.localizationManager = localizationManager;
     ModNameSortOrder         = modNameSortOrder;
     ModVersionSortOrder      = modVersionSortOrder;
     ModSelectedSortOrder     = modSelectedSortOrder;
     FilterMods = filterMods;
 }
コード例 #14
0
        public MainViewModel(IconMapViewModel iconMap,
                             TrainViewModel train,
                             TestViewModel test,
                             IAppStateService state,
                             IDialogService dialog)
        {
            IconMap = iconMap;
            Train   = train;
            Test    = test;
            _state  = state;
            _dialog = dialog;

            _state.PackageChanged += (s, e) =>
            {
                HasPackage = _state.CurrentPackage != null;
            };
        }
コード例 #15
0
        public NewPackageViewModel(IProjectPackageMapper mapper, ITagService tags, IAppStateService state, INavigationService nav)
        {
            _mapper         = mapper;
            _tags           = tags;
            _state          = state;
            _nav            = nav;
            _packageManager = new PackageManager();

            this.Save = new RelayCommand(async() =>
            {
                ISmartInkPackage package;
                try
                {
                    if (IsMediaPackage)
                    {
                        package = await _packageManager.CreateLocalPackageAsync <SmartInkMediaPackage>(Name);
                    }
                    else
                    {
                        package = await _packageManager.CreateLocalPackageAsync <SmartInkPackage>(Name);
                    }

                    var taglist = await _tags.GetTagsAsync();
                    var newTags = new Dictionary <Guid, string>();
                    foreach (var tag in taglist)
                    {
                        newTags.Add(tag.Id, tag.Name);
                    }

                    await package.AddTagsAsync(newTags);

                    await _mapper.AddAsync(package.Name, _state.CurrentProject.Id.ToString());

                    _state.SetCurrentPackage(package);

                    Reset();
                }
                catch (Exception)
                {
                }
            },
                                         () => {
                return(!string.IsNullOrWhiteSpace(Name) && !string.IsNullOrWhiteSpace(Version));
            });
        }
コード例 #16
0
 public OnModuleLoad(INWScript script,
                     INWNXChat nwnxChat,
                     INWNXEvents nwnxEvents,
                     IDeathService death,
                     IStructureService structure,
                     IObjectProcessingService objectProcessing,
                     IFarmingService farming,
                     IAppStateService appStateService,
                     INWNXDamage nwnxDamage)
 {
     _                 = script;
     _nwnxChat         = nwnxChat;
     _nwnxEvents       = nwnxEvents;
     _death            = death;
     _structure        = structure;
     _objectProcessing = objectProcessing;
     _farming          = farming;
     _appStateService  = appStateService;
     _nwnxDamage       = nwnxDamage;
 }
コード例 #17
0
        public ImageTagsViewModel(ITagService tagService, IAppStateService state)
        {
            _tagService = tagService;
            _state      = state;
            Tags.Sort(t => t.Name, SortDirection.Ascending);

            _state.ProjectChanged += async(s, e) => {
                await LoadTagsAsync();
            };



            this.AddTag = new RelayCommand(async() => {
                if (string.IsNullOrWhiteSpace(NewCategoryName))
                {
                    return;
                }
                try
                {
                    var newTag = await _tagService.CreateTagAsync(NewCategoryName);
                    Tags.Add(newTag);
                    CurrentTag      = newTag;
                    NewCategoryName = string.Empty;
                }
                catch (ImageTagsServiceException ex)
                {
                }
                catch (Exception ex)
                { }
            });
            this.DeleteTag = new RelayCommand <Tag>(async(tag) => {
                await _tagService.DeleteTagAsync(tag.Id);
                _state.DeleteTag(tag);
                Tags.Remove(tag);
            });
            this.Refresh = new RelayCommand(async() => {
                await LoadTagsAsync();
            });
        }
コード例 #18
0
        public IconMapViewModel(IAppStateService state)
        {
            _state = state;

            _state.PackageChanged += async(s, e) => {
                if (_state.CurrentPackage == null)
                {
                    //_storageFolder = null;
                    VisualStateChanged.Invoke(this, new VisualStateEventArgs {
                        NewState = "NotMedia"
                    });
                    return;
                }
                //_storageFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(_state.CurrentPackage.Name, CreationCollisionOption.OpenIfExists);
                IsMediaPackage = _state.CurrentPackage.IsMediaPackage;
                //VisualStateChanged.Invoke(this, new VisualStateEventArgs { NewState = "HasPackage" });
                var mediaState = (IsMediaPackage) ? "IsMedia" : "NotMedia";
                VisualStateChanged.Invoke(this, new VisualStateEventArgs {
                    NewState = mediaState
                });
            };

            _state.TagChanged += async(s, e) => {
                if (_state.CurrentPackage == null)
                {
                    return;
                }

                if (_state.CurrentTag != null)
                {
                    if (!_state.CurrentPackage.Tags.Contains(_state.CurrentTag.Name.ToLower()))
                    {
                        await _state.CurrentPackage.AddTagAsync(_state.CurrentTag.Id, _state.CurrentTag.Name);
                    }
                    if (IsMediaPackage)
                    {
                        await SetIconLocation(_state.CurrentTag.Id);
                    }
                }
                OpenFile.RaiseCanExecuteChanged();
            };

            this.OpenFile = new RelayCommand(async() => {
                var picker      = new FileOpenPicker();
                picker.ViewMode = PickerViewMode.Thumbnail;
                picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                picker.FileTypeFilter.Add(".jpg");
                picker.FileTypeFilter.Add(".jpeg");
                picker.FileTypeFilter.Add(".png");


                var file = await picker.PickSingleFileAsync();
                if (file != null)
                {
                    await UpdateIconAsync(file);
                    await _state.CurrentPackage.SaveAsync();
                    _state.IconUpdated();
                }
            },
                                             () => {
                return(_state.CurrentProject != null && CurrentTag != null);
            });
        }
コード例 #19
0
        public TrainViewModel(IImageService images, ITrainingService train, IAppStateService state)
        {
            _images = images;
            _train  = train;
            _state  = state;

            _state.TagChanged += async(s, e) => {
                if (_state.CurrentTag == null)
                {
                    return;
                }

                var iconfile = await GetIconFileAsync(_state.CurrentTag.Id);

                if (iconfile != null)
                {
                    await LoadIconAsync(iconfile);
                }
            };

            _state.IconChanged += async(s, e) => {
                var iconfile = await GetIconFileAsync(_state.CurrentTag.Id);

                if (iconfile != null)
                {
                    await LoadIconAsync(iconfile);
                }
            };

            _state.PackageChanged += async(s, e) => {
                if (_state.CurrentPackage == null)
                {
                    TotalImageCount = 0;
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "NoPackage"
                    });
                    return;
                }
                var files = await CreateFileListAsync();

                TotalImageCount = files.Count;
                VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                    NewState = "HasPackage"
                });
            };

            this.Upload = new RelayCommand(
                async() => {
                VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                    NewState = "Uploading"
                });
                await UploadImagesAsync();
                VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                    NewState = "Waiting"
                });
            },
                () => { return(TotalImageCount > 0); });
            this.Train = new RelayCommand(
                async() => {
                TrainingStatus = "Training...";
                VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                    NewState = "Training"
                });
                try
                {
                    var iteration = await _train.TrainCurrentIterationAsync();
                    if (iteration != null)
                    {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "TrainingFinished"
                        });
                        _state.CurrentIteration = iteration;
                    }
                }
                catch (TrainingServiceException ex)
                {
                    TrainingStatus = $"ERROR! {ex.Response.Message}";
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "TrainingError"
                    });
                }
            },
                () => { return(_uploadComplete || TotalImageCount == 0); });

            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
        }
コード例 #20
0
ファイル: AppController.cs プロジェクト: iiitpux/furykanban
 public AppController(IAppStateService appService, AuthUser authUser)
 {
     _appService = appService;
     _authUser   = authUser;
 }
コード例 #21
0
        public PackageManagerViewModel(ITagService tags, IProjectPackageMapper mapper, IAppStateService state, IDialogService dialog)
        {
            _tags   = tags;
            _mapper = mapper;
            _state  = state;
            _dialog = dialog;

            _state.KeysChanged += (s, e) => {
                NewPackage.RaiseCanExecuteChanged();
            };

            _state.TagDeleted += async(s, e) => {
                if (_state.CurrentPackage != null)
                {
                    await _state.CurrentPackage.RemoveTagAsync(e.DeletedTag.Id);
                }
            };

            _state.PackageChanged += (s, e) => {
                RaisePropertyChanged(nameof(CurrentPackage));
                PublishPackage.RaiseCanExecuteChanged();
            };

            _state.ProjectChanged += async(s, e) => {
                _packageCount = (await _mapper.GetPackagesByProjectAsync(_state.CurrentProject.Id.ToString())).Count;
                OpenPackage.RaiseCanExecuteChanged();
            };

            this.NewPackage = new RelayCommand(async() => {
                await _dialog.OpenAsync(DialogKeys.NewPackage);
            },
                                               () => { return(_state.CurrentKeys != null); });

            this.OpenPackage = new RelayCommand(async() => {
                await _dialog.OpenAsync(DialogKeys.OpenPackage);
            },
                                                () => {
                return(_state.CurrentProject != null && _packageCount > 0);
            });

            this.PublishPackage = new RelayCommand(async() => {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                // Dropdown of file types the user can save the file as
                savePicker.FileTypeChoices.Add("Nuget Package", new List <string>()
                {
                    ".nupkg"
                });
                var nugetFileName = $"SmartInk.{_state.CurrentPackage.Name}.{_state.CurrentPackage.Version}.nupkg";
                // Default file name if the user does not type one in or select a file to replace
                savePicker.SuggestedFileName = nugetFileName;
                var file = await savePicker.PickSaveFileAsync();
                if (file != null)
                {
                    await _packageManager.PublishPackageAsync(_state.CurrentPackage.BasePackage, file);
                }
            },
                                                   () => {
                return(_state.CurrentPackage != null);
            });
        }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PermissionCheckService" /> class.
 /// </summary>
 /// <param name="gameService">The game service.</param>
 /// <param name="appStateService">The application state service.</param>
 /// <param name="storageProvider">The storage provider.</param>
 /// <param name="mapper">The mapper.</param>
 public PermissionCheckService(IGameService gameService, IAppStateService appStateService, IStorageProvider storageProvider, IMapper mapper) : base(storageProvider, mapper)
 {
     this.appStateService = appStateService;
     this.gameService     = gameService;
 }
コード例 #23
0
 public AppStateFilter(IAppStateService appStateService, AuthUser authUser)
 {
     _appStateService = appStateService;
     _authUser        = authUser;
 }
コード例 #24
0
        public TestViewModel(ITrainingService training, IPredictionService prediction, IAppStateService state)
        {
            _training   = training;
            _prediction = prediction;
            _state      = state;

            Iterations.Sort(i => i.TrainedAt.Value, SortDirection.Descending);
            _state.KeysChanged += (s, e) =>
            {
                prediction.Initialize(_state.CurrentKeys.PredicationKey);
            };

            _state.PackageChanged += async(s, e) =>
            {
                await GetIterationsAsync();

                IsLocalModelAvailable = (_state.CurrentPackage == null) ? false : _state.CurrentPackage.IsLocalModelAvailable;

                RaisePropertyChanged(nameof(IsReadyToTest));

                if (_state.CurrentPackage == null || !IsReadyToTest)
                {
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "NoPackage"
                    });
                }
                else
                {
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "HasPackage"
                    });
                }
            };



            this.UploadCorrection = new RelayCommand(() =>
            {
            },
                                                     () =>
            {
                if (EvaluationResult == null || _state.CurrentTag == null)
                {
                    return(false);
                }

                return(_state.CurrentTag.Name != EvaluationResult);
            });

            this.DownloadModel = new RelayCommand(async() => {
                var downloadUri = await _training.GetModuleDownloadUriAsync(SelectedIteration.Id);
                if (downloadUri != null)
                {
                    var manager = new PackageManager();
                    manager.ModelDownloadStarted += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadStarted"
                        });
                    };
                    manager.ModelDownloadCompleted += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadCompleted"
                        });
                    };
                    manager.ModelDownloadError += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadError"
                        });
                    };
                    manager.ModelDownloadProgress += (s, e) => {
                        DownloadProgress = e.Percentage;
                    };
                    var model = await manager.DownloadModelAsync(downloadUri);
                    await _state.CurrentPackage.SaveModelAsync(model);
                    IsLocalModelAvailable = _state.CurrentPackage.IsLocalModelAvailable;
                }
            }, () => { return(SelectedIteration != null); });

            this.RefreshIterations = new RelayCommand(async() => {
                await GetIterationsAsync();
            });
        }