Exemplo n.º 1
0
        public void Assembly(params Assembly[] assemblies)
        {
            var classMapType = typeof(IEntityProfile);

            var rslt = assemblies.SelectMany(assembly => assembly.DefinedTypes
                                             .Where(x => x.IsClass && !x.IsAbstract && classMapType.IsAssignableFrom(x))
                                             .Select(x => x.Instantiate <IEntityProfile>()));

            Profiles = Profiles.AddRange(rslt);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds profiles and its dependencies
        /// </summary>
        public void AddProfilesAndDependencies(IEnumerable <SsoProfile> profiles)
        {
            var groupedProfiles = profiles
                                  .Where(p => p.ApplicationId == Id)
                                  .GroupBy(p => new { p.ApplicationId, p.Id })
                                  .Select(gp => gp.FirstOrDefault());

            if (groupedProfiles.Any())
            {
                Profiles.AddRange(groupedProfiles);

                Profiles = Profiles
                           .Where(p => p.ApplicationId == Id)
                           .GroupBy(p => new { p.ApplicationId, p.Id })
                           .Select(gp => gp.FirstOrDefault())
                           .ToList();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Loads all profiles for the current game and keyboard
        /// </summary>
        private void LoadProfiles()
        {
            Profiles.Clear();
            if (_gameModel == null || _mainManager.DeviceManager.ActiveKeyboard == null)
            {
                return;
            }

            Profiles.AddRange(ProfileProvider.GetAll(_gameModel, _mainManager.DeviceManager.ActiveKeyboard));

            // If a profile name was provided, try to load it
            ProfileModel lastProfileModel = null;

            if (!string.IsNullOrEmpty(LastProfile))
            {
                lastProfileModel = Profiles.FirstOrDefault(p => p.Name == LastProfile);
            }

            SelectedProfile = lastProfileModel ?? Profiles.FirstOrDefault();
        }
Exemplo n.º 4
0
        public MainViewModel()
        {
            SelectedProfile = new ProfileModel();
            //pulls models from external source but no logic which collections are for
            try
            {
                profileCommand = new ProfileCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Profiles.AddRange(profileCommand.GetList());

                EmployeeCommand employeeCommand = new EmployeeCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Employees.AddRange(employeeCommand.GetList());

                CompanyCommand companyCommand = new CompanyCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Companies.AddRange(companyCommand.GetList());
            }
            catch (Exception ex)
            {
                AppStatus = ex.Message;
                NotifyOfPropertyChange(() => AppStatus);
            }
        }
Exemplo n.º 5
0
        public RunViewModel()
        {
            eventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>();

            profiles = new ObservableCollection <ProfileObject>(NoteService.CurrentNotesAppSettings.Profiles);
            stages   = new ObservableCollection <StageObject>();

            var canRun = this.WhenAny(x => x.RunMode, x => x.SelectedNoteObject, x => x.SelectedProfile,
                                      (x1, x2, x3) => (x1.Value == RunMode.AllNotes) ||
                                      (x1.Value == RunMode.ByNote && x2.Value != null && x2.Value is NoteObject) ||
                                      (x1.Value == RunMode.ByProfile && x3.Value != null));

            RunCommand = ReactiveCommand.Create(Run, canRun);

            ReloadStages();

            RunMode = RunMode.AllNotes;

            refreshProfilesSubscriptionToken = eventAggregator.GetEvent <RefreshSettingsEvent>().Subscribe(x =>
            {
                Profiles.Clear();
                Profiles.AddRange(NoteService.CurrentNotesAppSettings.Profiles);
            });
        }
Exemplo n.º 6
0
 public void AddProfiles(List <Profile> profiles)
 {
     Profiles.AddRange(profiles);
     CalcLevel();
 }
 private void LoadProfiles()
 {
     Profiles.Clear();
     Profiles.AddRange(WorkingProfile.LoadProfiles());
     RaisePropertyChanged(() => HasProfiles);
 }
Exemplo n.º 8
0
    public void Merge(MavenSettings copy)
    {
        if (copy == null)
        {
            return;
        }

        Phase.AddRange(copy.Phase);
        Goal.AddRange(copy.Goal);
        Profiles.AddRange(copy.Profiles);
        foreach (var property in copy.Properties)
        {
            Properties[property.Key] = property.Value;
        }
        if (copy.SettingsFile != null)
        {
            SettingsFile = copy.SettingsFile;
        }
        if (copy.BatchMode != null)
        {
            BatchMode = copy.BatchMode;
        }
        if (copy.NonRecursive != null)
        {
            NonRecursive = copy.NonRecursive;
        }
        if (copy.Offline != null)
        {
            Offline = copy.Offline;
        }
        if (copy.ForceUpdate != null)
        {
            ForceUpdate = copy.ForceUpdate;
        }

        if (copy.ToolPath != null)
        {
            ToolPath = copy.ToolPath;
        }
        if (copy.ToolTimeout != null)
        {
            ToolTimeout = copy.ToolTimeout;
        }
        if (copy.WorkingDirectory != null)
        {
            WorkingDirectory = copy.WorkingDirectory;
        }
        if (copy.ArgumentCustomization != null)
        {
            ArgumentCustomization = copy.ArgumentCustomization;
        }
        if (copy.EnvironmentVariables != null)
        {
            if (EnvironmentVariables == null)
            {
                EnvironmentVariables = new Dictionary <string, string>(copy.EnvironmentVariables);
            }
            else
            {
                foreach (var pair in copy.EnvironmentVariables)
                {
                    EnvironmentVariables[pair.Key] = pair.Value;
                }
            }
        }
    }
        /// <summary>
        /// A helper method to initilize the viewmodel commands
        /// </summary>
        private void InitCommands()
        {
            // Init the refresh command
            RefreshCommand = new DelegateCommand(async() => await DialogHost.Show(new Resources.ProgressDialog(), "RootDialog", async(s, e) =>
            {
                // fetch profiles from server
                var profiles = (await _hotspotClient.LoadAllProfilesAsync()).ToList().Select(u => new HotspotUserProfileViewModel(u)
                {
                    SelectionChangedCommand = SharedItemSelectionChangedCommand, DeleteProfileCommand = SharedDeleteProfileCommand
                });

                // Update user list
                Profiles.Clear();
                Profiles.AddRange(profiles);

                e.Session.Close();

                RaisePropertyChanged(nameof(ProfilesCount));
                RaisePropertyChanged(nameof(SelectedCount));
                RaisePropertyChanged(nameof(HasSelectedProfiles));

                GC.Collect();
            }, null));

            // Init the deleting command
            RemoveSelectedProfilesCommand = new DelegateCommand(async() =>
            {
                var selected = Profiles.Where(p => p.IsSelected && p.Name != "default").ToList();
                if (selected.Count <= 0)
                {
                    return;
                }

                var confirm = _dialogService.ShowMessageAsync("Confirm", $"Are sure that you want to delete the selected {selected.Count} selected profiles?", MessageDialogStyle.AffirmativeAndNegative);
                if (await confirm == MessageDialogResult.Negative)
                {
                    return;
                }

                var dlg = await _dialogService.ShowProgressAsync("Deleting...", $"Deleting profile 1 of {selected.Count}...");
                dlg.SetCancelable(true);

                int done = 0;
                for (int i = 0; i < selected.Count; i++)
                {
                    if (dlg.IsCanceled)
                    {
                        break;
                    }

                    dlg.SetMessage($"Deleting profile {i + 1} of {selected.Count}...");
                    dlg.SetProgress((double)i / selected.Count);

                    if (await _hotspotClient.RemoveProfileAsync(selected[i].UserProfileModel))
                    {
                        Profiles.Remove(selected[i]);
                        ++done;
                    }
                }

                var msg = $"Deleted {done} profiles successfully!";
                _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs(msg, null, new SideNotificationViewModel("Hotspot User Profiles", msg)));

                await dlg.CloseAsync();
                RefreshSelectionState();
                GC.Collect();
            });

            //Init the global delete command
            SharedDeleteProfileCommand = new DelegateCommand <HotspotUserProfileViewModel>(async vm =>
            {
                if (vm?.Name == "default")
                {
                    _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs("Can't delete the default hotspot user profile!"));
                    return;
                }

                var confirm = _dialogService.ShowMessageAsync("Confirm", $"Are you sure that you want to delete profile `{vm.Name}` ?", MessageDialogStyle.AffirmativeAndNegative);
                if (await confirm == MessageDialogResult.Negative)
                {
                    return;
                }

                var done = _hotspotClient.RemoveProfileAsync(vm.UserProfileModel);
                var msg  = await done ? $"Profile `{vm.Name}` Deleted Successfully!" : $"Can't Delete the profile";

                _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs(msg, null, new SideNotificationViewModel("Hotspot User Profiles", msg)));
                if (await done)
                {
                    Profiles.Remove(vm);
                }

                RefreshSelectionState();
                GC.Collect();
            });

            // Init the global selection changed command
            SharedItemSelectionChangedCommand = new DelegateCommand(RefreshSelectionState);

            // Init the selection commands
            SelectAllCommand = new DelegateCommand(() =>
            {
                Profiles.ForEach(p => { if (p.Name == "default")
                                        {
                                            return;
                                        }
                                        p.IsSelected = true; });
                RefreshSelectionState();
            });

            // Init the invert selection command
            InverseSelectionCommand = new DelegateCommand(() => { Profiles.ForEach(p => p.IsSelected ^= true); RefreshSelectionState(); });

            // Init the command which will show the adding profile dialog
            AddProfileCommand = new DelegateCommand(() => DialogHost.Show(new AddHotspotUserProfileView {
                DataContext = new AddHotspotUserProfileViewModel(_eventAggregator, null)
            }));
        }