private void btnAddFeature_Click(object sender, RoutedEventArgs e) { if (_featuresService == null) _featuresService = ObjectLocator.GetInstance<IFeaturesService>(); if (string.IsNullOrEmpty(txtFeatureName.Text)) { MessageBox.Show("You must supply a feature name."); return; } Feature f = new Feature(); f.Name = txtFeatureName.Text; f.Description = txtFeatureDescription.Text; f.ProductId = _product.ProductId; if (_featuresService.IsFeatureNameInUse(_product.ProductId, f.Name)) { MessageBox.Show("Feature name is in use for this product, please try again"); return; } else { _featuresService.SaveFeature(f); txtFeatureName.Text = ""; txtFeatureDescription.Text = ""; _product.Features = new NotifyList<Feature>(_featuresService.GetFeaturesForProduct(_product.ProductId)); gridFeatures.ItemsSource = SelectedProduct.Features; } }
private void btnRemoveSelected_Click(object sender, RoutedEventArgs e) { if (_featuresService == null) _featuresService = ObjectLocator.GetInstance<IFeaturesService>(); if (gridFeatures.SelectedItem != null) { Feature feat = gridFeatures.SelectedItem as Feature; if (_featuresService.IsFeatureInUse(feat.FeatureId)) { MessageBox.Show("Cannot delete feature, as it's in use in a license/edition set"); return; } else { if (MessageBox.Show("Are you sure you want to delete this feature?", "Delete Feature", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { _featuresService.DeleteFeatureById(feat.FeatureId); _product.Features = new NotifyList<Feature>(_featuresService.GetFeaturesForProduct(feat.ProductId)); gridFeatures.ItemsSource = SelectedProduct.Features; } } } }
public SourceTreeViewModel(IApplicationService applicationService, IFeaturesService featuresService) { _applicationService = applicationService; _featuresService = featuresService; GoToItemCommand = ReactiveUI.ReactiveCommand.Create(); GoToItemCommand.OfType<ContentModel>().Subscribe(x => { if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase)) { ShowViewModel<SourceTreeViewModel>(new NavObject { Username = Username, Branch = Branch, Repository = Repository, Path = x.Path, TrueBranch = TrueBranch }); } if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase)) { if (x.DownloadUrl == null) { var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", StringComparison.Ordinal) + 7); var indexOfGit = nameAndSlug.LastIndexOf("/git", StringComparison.Ordinal); indexOfGit = indexOfGit < 0 ? 0 : indexOfGit; var repoId = RepositoryIdentifier.FromFullName(nameAndSlug.Substring(0, indexOfGit)); if (repoId == null) return; var sha = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); ShowViewModel<SourceTreeViewModel>(new NavObject {Username = repoId?.Owner, Repository = repoId?.Name, Branch = sha}); } else { ShowViewModel<SourceViewModel>(new SourceViewModel.NavObject { Name = x.Name, Username = Username, Repository = Repository, Branch = Branch, Path = x.Path, HtmlUrl = x.HtmlUrl, GitUrl = x.GitUrl, TrueBranch = TrueBranch }); } } }); }
public UpgradesViewModel(IFeaturesService featuresService) { LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => { Keys = (await featuresService.GetAvailableFeatureIds()).ToArray(); }); }
public SettingsViewModel(ISessionService applicationService, IFeaturesService featuresService, IAccountsRepository accountsService, IEnvironmentalService environmentalService, IPushNotificationRegistrationService pushNotificationsService) { Title = "Account Settings"; _sessionService = applicationService; _featuresService = featuresService; _accountsService = accountsService; _environmentService = environmentalService; _pushNotificationsService = pushNotificationsService; AccountImageUrl = applicationService.Account.AvatarUrl; GoToDefaultStartupViewCommand = ReactiveCommand.Create(); GoToDefaultStartupViewCommand.Subscribe(_ => { var vm = this.CreateViewModel<DefaultStartupViewModel>(); vm.WhenAnyValue(x => x.SelectedStartupView) .Subscribe(x => DefaultStartupViewName = x); NavigateTo(vm); }); GoToSyntaxHighlighterCommand = ReactiveCommand.Create().WithSubscription(_ => { var vm = this.CreateViewModel<SyntaxHighlighterSettingsViewModel>(); vm.SaveCommand.Subscribe(__ => SyntaxHighlighter = vm.SelectedTheme); NavigateTo(vm); }); DeleteAllCacheCommand = ReactiveCommand.Create(); GoToSourceCodeCommand = ReactiveCommand.Create().WithSubscription(_ => { var vm = this.CreateViewModel<RepositoryViewModel>(); vm.Init("thedillonb", "codehub"); NavigateTo(vm); }); ShowOrganizationsInEvents = applicationService.Account.ShowOrganizationsInEvents; this.WhenAnyValue(x => x.ShowOrganizationsInEvents).Skip(1).Subscribe(x => { applicationService.Account.ShowOrganizationsInEvents = x; accountsService.Update(applicationService.Account); }); ExpandOrganizations = applicationService.Account.ExpandOrganizations; this.WhenAnyValue(x => x.ExpandOrganizations).Skip(1).Subscribe(x => { applicationService.Account.ExpandOrganizations = x; accountsService.Update(applicationService.Account); }); ShowRepositoryDescriptionInList = applicationService.Account.ShowRepositoryDescriptionInList; this.WhenAnyValue(x => x.ShowRepositoryDescriptionInList).Skip(1).Subscribe(x => { applicationService.Account.ShowRepositoryDescriptionInList = x; accountsService.Update(applicationService.Account); }); }
public UpgradesView() { Title = "Upgrades"; EnableSearch = false; Style = MonoTouch.UIKit.UITableViewStyle.Plain; _features = Cirrious.CrossCore.Mvx.Resolve<IFeaturesService>(); NavigationItem.RightBarButtonItem = new MonoTouch.UIKit.UIBarButtonItem("Restore", MonoTouch.UIKit.UIBarButtonItemStyle.Plain, (s, e) => Restore()); }
public ApplicationService(IAccountsService accounts, IMvxViewDispatcher viewDispatcher, IFeaturesService features, IPushNotificationsService pushNotifications, IAlertDialogService alertDialogService) { _viewDispatcher = viewDispatcher; _pushNotifications = pushNotifications; Accounts = accounts; _features = features; _alertDialogService = alertDialogService; }
public PurchaseProViewModel(IFeaturesService featuresService) { var purchaseCommand = ReactiveCommand.CreateAsyncTask(x => featuresService.EnableProEdition()); purchaseCommand.Subscribe(_ => DismissCommand.ExecuteIfCan()); PurchaseCommand = purchaseCommand; var restoreCommand = ReactiveCommand.CreateAsyncTask(x => featuresService.RestorePurchase()); restoreCommand.Subscribe(_ => DismissCommand.ExecuteIfCan()); RestoreCommand = restoreCommand; GetPrice(featuresService); }
public SettingsViewModel(IApplicationService applicationService, IFeaturesService featuresService, IDefaultValueService defaultValueService, IAccountsService accountsService, IAnalyticsService analyticsService) { _applicationService = applicationService; _featuresService = featuresService; _defaultValueService = defaultValueService; _accountsService = accountsService; _analyticsService = analyticsService; GoToDefaultStartupViewCommand = new ReactiveCommand(); GoToDefaultStartupViewCommand.Subscribe(_ => ShowViewModel(CreateViewModel<DefaultStartupViewModel>())); DeleteAllCacheCommand = new ReactiveCommand(); }
public UpgradeView(INetworkActivityService networkActivityService) { _featuresService = Locator.Current.GetService<IFeaturesService>(); _inAppPurchaseService = Locator.Current.GetService<IInAppPurchaseService>(); _web = new UIWebView { ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.All }; _web.LoadFinished += (sender, e) => networkActivityService.PopNetworkActive(); _web.LoadStarted += (sender, e) => networkActivityService.PushNetworkActive(); _web.LoadError += (sender, e) => networkActivityService.PopNetworkActive(); _web.ShouldStartLoad = (w, r, n) => ShouldStartLoad(r, n); _activityView = new UIActivityIndicatorView { Color = Theme.PrimaryNavigationBarColor, AutoresizingMask = UIViewAutoresizing.FlexibleWidth, }; }
public InterestsViewModel(IApplicationService applicationService, IFeaturesService featuresService) { ApplicationService = applicationService; var interests = new ReactiveList<Interest>(); Interests = interests; DeleteInterestCommand = ReactiveCommand.Create(); DeleteInterestCommand.OfType<Interest>().Subscribe(ApplicationService.Account.Interests.Remove); GoToStumbleInterestCommand = ReactiveCommand.Create(); GoToStumbleInterestCommand.OfType<Interest>().Subscribe(x => { var vm = CreateViewModel<StumbleViewModel>(); vm.Interest = x; ShowViewModel(vm); }); GoToAddInterestCommand = ReactiveCommand.Create(); GoToAddInterestCommand.Subscribe(_ => { if (ApplicationService.Account.Interests.Count() >= 3 && !featuresService.ProEditionEnabled) { var vm = CreateViewModel<PurchaseProViewModel>(); ShowViewModel(vm); } else { var vm = CreateViewModel<AddInterestViewModel>(); ShowViewModel(vm); } }); this.WhenActivated(d => { interests.Reset(ApplicationService.Account.Interests.Query.OrderBy(x => x.Keyword)); }); }
public StumbleViewModel(IApplicationService applicationService, INetworkActivityService networkActivity, IFeaturesService featuresService, IDefaultValueService defaultValues) : base(applicationService, networkActivity) { this._applicationService = applicationService; var localStumbleCount = 0; GoToPurchaseCommand = ReactiveCommand.Create(); GoToPurchaseCommand.Subscribe(_ => CreateAndShowViewModel<PurchaseProViewModel>()); StumbleCommand = ReactiveCommand.CreateAsyncTask(LoadCommand.IsExecuting.Select(x => !x), x => StumbleRepository()); StumbleCommand.Subscribe(x => { if (!featuresService.ProEditionEnabled) { var stumbleTimes = defaultValues.Get<nint>(StumbleKey) + 1; defaultValues.Set(StumbleKey, stumbleTimes); if (localStumbleCount > 0 && stumbleTimes % 50 == 0) { GoToPurchaseCommand.ExecuteIfCan(); } } localStumbleCount++; Reset(); RepositoryIdentifier = new RepositoryIdentifierModel(x.Repository.Owner, x.Repository.Name); LoadCommand.ExecuteIfCan(); }); StumbleCommand.TriggerNetworkActivity(networkActivity); DislikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); LikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); }
public ProfileViewModel(IApplicationService applicationService, INetworkActivityService networkActivity, IFeaturesService featuresService) { StumbleHistory = new ReactiveList<StumbledRepository>(); GoToInterestsCommand = ReactiveCommand.Create(); Username = applicationService.Account.Username; Action updateStumbled = () => { var stumbledRepositories = applicationService.Account.StumbledRepositories.Count(); Interests = applicationService.Account.Interests.Count(); Likes = applicationService.Account.StumbledRepositories.LikedRepositories(); Dislikes = applicationService.Account.StumbledRepositories.DislikedRepositories(); HasMoreHistory = stumbledRepositories > 30; if (stumbledRepositories != StumbledRepositories) { StumbledRepositories = stumbledRepositories; StumbleHistory.Reset(applicationService.Account.StumbledRepositories.Query.OrderByDescending(x => x.CreatedAt).Take(30)); } }; this.WhenActivated(d => { if (applicationService.Account != null) { updateStumbled(); d(applicationService.RepositoryAdded .Buffer(TimeSpan.FromSeconds(5)) .Where(x => x.Count > 0) .ObserveOn(SynchronizationContext.Current) .Subscribe(x => updateStumbled())); } CanPurchase = !featuresService.ProEditionEnabled; }); GoToRepositoryCommand = ReactiveCommand.Create(); GoToRepositoryCommand.OfType<StumbledRepository>().Subscribe(x => { var vm = CreateViewModel<RepositoryViewModel>(); vm.RepositoryIdentifier = new BaseRepositoryViewModel.RepositoryIdentifierModel(x.Owner, x.Name); ShowViewModel(vm); }); GoToPurchaseCommand = ReactiveCommand.Create(); GoToPurchaseCommand.Subscribe(_ => CreateAndShowViewModel<PurchaseProViewModel>()); GoToHistoryCommand = ReactiveCommand.Create(); GoToHistoryCommand.Subscribe(_ => CreateAndShowViewModel<HistoryViewModel>()); GoToLikesCommand = ReactiveCommand.Create(); GoToLikesCommand.Subscribe(_ => CreateAndShowViewModel<LikedRepositoriesViewModel>()); GoToDislikesCommand = ReactiveCommand.Create(); GoToDislikesCommand.Subscribe(_ => CreateAndShowViewModel<DislikedRepositoriesViewModel>()); GoToSettingsCommand = ReactiveCommand.Create(); GoToSettingsCommand.Subscribe(_ => CreateAndShowViewModel<SettingsViewModel>()); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { User = await applicationService.Client.User.Current(); }); LoadCommand.TriggerNetworkActivity(networkActivity); }
public SourceTreeViewModel(IFeaturesService featuresService) { _featuresService = featuresService; Content = new CollectionViewModel <ContentModel>(); }
public NewAccountView(IFeaturesService featuresService) : base("NewAccountView", null) { _featuresService = featuresService; }
public LoginViewModel(ILoginFactory loginFactory, IFeaturesService featuresService) { _loginFactory = loginFactory; _featuresService = featuresService; }
public FeaturesController(IFeaturesService objService) { this.ObjService = objService; }
public SettingsViewModel(IFeaturesService featuresService) { _featuresService = featuresService; }
private async Task GetPrice(IFeaturesService featuresService) { Price = await featuresService.GetProEditionPrice(); }
public EnablePushNotificationsViewController(IStatusIndicatorService statusIndicatorService, IFeaturesService featuresService) : base("EnablePushNotificationsViewController", null) { _statusIndicatorService = statusIndicatorService; _featuresService = featuresService; }
public PullRequestViewModel(IFeaturesService featuresService) { _featuresService = featuresService; this.Bind(x => x.PullRequest, true).IsNotNull().Select(x => string.Equals(x.State, "closed")).Subscribe(x => IsClosed = x); GoToOwner = ReactiveUI.ReactiveCommand.Create(this.Bind(x => x.Issue, true).Select(x => x != null)); GoToOwner.Subscribe(_ => ShowViewModel<UserViewModel>(new UserViewModel.NavObject { Username = Issue?.User?.Login })); }
public NewAccountViewController(IFeaturesService featuresService = null) { _featuresService = featuresService ?? Locator.Current.GetService <IFeaturesService>(); Title = "New Account"; }
public ChangesetsViewModel(IApplicationService applicationService,IFeaturesService featuresService) : base(applicationService, featuresService) { }
public LoginViewModel(ILoginFactory loginFactory, IFeaturesService featuresService) { _loginFactory = loginFactory; _featuresService = featuresService; }
public UpgradesViewModel(IFeaturesService featuresService) { _featuresService = featuresService; }
public PullRequestCommitsViewModel(IApplicationService applicationService, IFeaturesService featuresService) : base(applicationService, featuresService) { }
public MenuViewModel(IApplicationService application, IFeaturesService featuresService) { _application = application; _featuresService = featuresService; _notificationCountToken = Messenger.SubscribeOnMainThread <NotificationCountMessage>(OnNotificationCountMessage); }
public SettingsViewModel(IFeaturesService featuresService, IDefaultValueService defaultValueService) { _featuresService = featuresService; _defaultValueService = defaultValueService; }
public EnablePushNotificationsViewController(IStatusIndicatorService statusIndicatorService, IFeaturesService featuresService) : base("EnablePushNotificationsViewController", null) { _statusIndicatorService = statusIndicatorService; _featuresService = featuresService; }
public UpgradeViewController() { _featuresService = Locator.Current.GetService<IFeaturesService>(); _networkActivityService = Locator.Current.GetService<INetworkActivityService>(); _inAppPurchaseService = Locator.Current.GetService<IInAppPurchaseService>(); }
public EnablePushNotificationsViewController(IAlertDialogFactory alertDialogFactory, IFeaturesService featuresService) : base("EnablePushNotificationsViewController", null) { _alertDialogFactory = alertDialogFactory; _featuresService = featuresService; }
public IssueViewModel(IApplicationService applicationService, IFeaturesService featuresService) { _applicationService = applicationService; _featuresService = featuresService; this.Bind(x => x.Issue, true).Where(x => x != null).Select(x => string.Equals(x.State, "closed")).Subscribe(x => IsClosed = x); GoToOwner = ReactiveUI.ReactiveCommand.Create(this.Bind(x => x.Issue, true).Select(x => x != null)); GoToOwner.Subscribe(_ => ShowViewModel<UserViewModel>(new UserViewModel.NavObject { Username = Issue?.User?.Login })); }
public EnableEnterpriseViewController(IStatusIndicatorService statusIndicatorService, IFeaturesService featuresService) : base("EnableEnterpriseViewController", null) { _statusIndicatorService = statusIndicatorService; _featuresService = featuresService; }
public SettingsViewModel(IFeaturesService featuresService) { _featuresService = featuresService; }