Exemplo n.º 1
0
 public void UpdateEditing(Boolean edit)
 {
     if (ProfileTypes != null)
     {
         ProfileTypes.ForEach(p => p.AllowEdit = edit);
     }
 }
Exemplo n.º 2
0
    public static string GetExtension(ProfileTypes type)
    {
        string val;

        profileExtensions.TryGetValue(type, out val);
        return(val);
    }
Exemplo n.º 3
0
 private void FillingToolBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Frame == null)
     {
         return;
     }
     ClearEventHandlers();
     FillingToolBtn.IsChecked = true;
     Frame.AddInputEventListener(FillingCreationEventHandler);
     FillingCreationEventHandler.FillingType = FillingTypeComboBox.SelectedItem as FillingType;
     if (IProfileTypeComboBox.SelectedItem == null || (IProfileTypeComboBox.SelectedItem as ProfileType).Shape != ProfileShape.I)
     {
         var pType = ProfileTypes.FirstOrDefault(x => x.Shape == ProfileShape.I);
         if (pType != null)
         {
             IProfileTypeComboBox.SelectedItem = pType;
         }
     }
     if (IncludeIProfileCheckBox.IsChecked.Value)
     {
         FillingCreationEventHandler.ProfileType = IProfileTypeComboBox.SelectedItem as ProfileType;
     }
     else
     {
         FillingCreationEventHandler.ProfileType = null;
     }
     FillingToolActive = true;
 }
Exemplo n.º 4
0
        public async Task <ResponseModel <ProfileTypes> > UpdateProfileType(int id, ProfileTypes profileTypes)
        {
            ResponseModel <ProfileTypes> response = InitializeProfileType();

            _context.Entry(profileTypes).State = EntityState.Modified;

            return(await UpdateRecord(id, profileTypes, response));
        }
 public void UpdateItemsDisplayname(Dictionary <Int32, String> translations)
 {
     foreach (dtoCallPersonTypeAssignment pType in ProfileTypes)
     {
         pType.UpdateDisplayname(translations);
     }
     ProfileTypes = ProfileTypes.OrderBy(p => p.DisplayName).ToList();
 }
Exemplo n.º 6
0
 public ProfileData(string assetPath, ProfileTypes type)
 {
     AssetPath = assetPath;
     Type      = type;
     if (Importer != null)
     {
         Apply();
     }
 }
        private ProfileType(string name, string exe, string modFolder, string defaultLaunchArgs, Func <Version, bool> isSupportingGameJolt)
        {
            Name                     = name;
            Exe                      = exe;
            ModFolder                = modFolder;
            DefaultLaunchArgs        = defaultLaunchArgs;
            IsSupportingGameJoltFunc = isSupportingGameJolt;

            ProfileTypes.Add(this);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Create new charging preferences for an EV driver.
 /// </summary>
 /// <param name="ProfileType">Type of Smart Charging Profile selected by the driver.</param>
 /// <param name="Departure">Expected departure. The driver has given this timestamp as expected departure moment. It is only an estimation and not necessarily the timestamp of the actual departure.</param>
 /// <param name="EnergyNeed">Requested amount of energy in kWh. The EV driver wants to have this amount of energy charged.</param>
 /// <param name="DischargeAllowed">The driver allows their EV to be discharged when needed, as long as the other preferences are met.</param>
 public ChargingPreference(ProfileTypes ProfileType,
                           DateTime?Departure,
                           Double?EnergyNeed,
                           Boolean DischargeAllowed)
 {
     this.ProfileType      = ProfileType;
     this.Departure        = Departure;
     this.EnergyNeed       = EnergyNeed;
     this.DischargeAllowed = DischargeAllowed;
 }
        public async Task <IActionResult> PutProfileTypes(int id, ProfileTypes profileTypes)
        {
            if (id != profileTypes.ProfileTypeId)
            {
                return(BadRequest());
            }

            var response = await _db.UpdateProfileType(id, profileTypes);

            return(_responsesService.PutResponse(response));
        }
        void Close(bool okPressed)
        {
            if (okPressed)
            {
                if (ProfileTypes.Count(p => p.IsSelected) != 1)
                {
                    _uiService.ShowErrorDialog("Please select exactly one option.", ComponentContainer.MessageBoxTitle);
                    return;
                }

                SelectedProfile = ProfileTypes.Single(p => p.IsSelected).ProfileType;
            }

            CloseRequested?.Invoke(this, new CloseEventArgs(okPressed));
        }
        public SelectProfileViewModel(IReadOnlyCollection <IProfileType> profileTypes, IUiService uiService)
        {
            if (profileTypes == null)
            {
                throw new ArgumentNullException(nameof(profileTypes));
            }
            if (uiService == null)
            {
                throw new ArgumentNullException(nameof(uiService));
            }

            _uiService   = uiService;
            ProfileTypes = profileTypes.Select(p => new ProfileViewModel(p)).ToList();
            ProfileTypes.First().IsSelected = true;

            OkCommand     = new DelegateCommand(_ => Close(true));
            CancelCommand = new DelegateCommand(_ => Close(false));
        }
Exemplo n.º 12
0
        void Close(bool okPressed)
        {
            if (okPressed)
            {
                if (ProfileTypes.Count(p => p.IsSelected) != 1)
                {
                    _uiService.ShowErrorDialog(Strings.Get($"Please select exactly one option."), ComponentContainer.MessageBoxTitle);
                    return;
                }

                if (StringComparer.InvariantCultureIgnoreCase.Equals(ProfileTypes.Single(p => p.IsSelected).ProfileType.Name, "Open-Xchange"))
                {
                    _uiService.ShowOXInfoDialog();
                    return;
                }

                SelectedProfile = ProfileTypes.Single(p => p.IsSelected).ProfileType;
            }

            CloseRequested?.Invoke(this, new CloseEventArgs(okPressed));
        }
Exemplo n.º 13
0
    public static ProfileData CreateProfile(ProfileTypes type, string name)
    {
        string path = string.Format("Assets/ImportProfiles/Editor/Profiles/{0}/{1}{2}", type.ToString() + 's',
                                    name, profileExtensions[type]);

        if (!AssetDatabase.IsValidFolder(Path.GetDirectoryName(path)?.Replace('\\', '/')))
        {
            AssetDatabase.CreateFolder("Assets/ImportProfiles/Editor/Profiles", type.ToString() + 's');
        }

        if (AssetDatabase.LoadAssetAtPath <Object>(path) != null)
        {
            path = AssetDatabase.GenerateUniqueAssetPath(path);
        }

        Func <string, Object> value;

        if (!assetCreationfunctions.TryGetValue(type, out value))
        {
            return(null);
        }

        value.Invoke(path);
        AssetDatabase.ImportAsset(path);
        AssetDatabase.SaveAssets();

        var importer = AssetImporter.GetAtPath(path);

        if (importer != null)
        {
            var profile = new ProfileData(path, type);
            AddProfile(importer);
            return(profile);
        }

        return(null);
    }
Exemplo n.º 14
0
 public async Task <ResponseModel <ProfileTypes> > UpdateProfileType(int id, ProfileTypes profileType)
 {
     return(await CallUpdate <ProfileTypes>(id, profileType));
 }
Exemplo n.º 15
0
 public async Task <ResponseModel <ProfileTypes> > CreateProfileType(ProfileTypes profileType)
 {
     return(await CallCreate <ProfileTypes>(profileType));
 }
Exemplo n.º 16
0
        public async Task <ResponseModel <ProfileTypes> > CreateProfileType(ProfileTypes profileTypes)
        {
            ResponseModel <ProfileTypes> response = InitializeProfileType();

            return(await CreateRecord(profileTypes, response));
        }
Exemplo n.º 17
0
        public MainWindowViewModel()
        {
            SelectFolder = ReactiveCommand.CreateFromTask(async ct =>
            {
                var dialog = new OpenFolderDialog
                {
                    Title = "Select folder with datafiles"
                };
                var path = await dialog.ShowAsync();
                return(path);
            });
            SelectFolder.Subscribe(path => FolderPath = path);

            LoadFolder = ReactiveCommand.Create(LoadFolderImpl);
            LoadFolder.ThrownExceptions
            .Subscribe(exception =>
            {
                if (exception is DirectoryNotFoundException dirNotFound)
                {
                    FolderPathError = dirNotFound.Message;
                }
                Log.Warning(exception, "Error when loading folder");
            });
            LoadFolder.Subscribe(results =>
            {
                Datafiles.Clear();
                Datafiles.AddRange(results);
                FolderPathError = null;
            });

            this.WhenAnyValue(x => x.FolderPathError)
            .DistinctUntilChanged()
            .Subscribe(x => ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(FolderPath))));

            this.WhenAnyValue(x => x.FolderPath)
            .Throttle(TimeSpan.FromSeconds(0.5), RxApp.MainThreadScheduler)
            .Select(x => Unit.Default)
            .InvokeCommand(this, x => x.LoadFolder);

            DatafilesToLoad = new Subject <DatafileInfo>();

            Datafiles.ActOnEveryObject(item => DatafilesToLoad.OnNext(item), item => { });

            this.WhenAnyObservable(x => x.DatafilesToLoad)
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Select(info => (info, LoadFileRoot(info)))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(tuple =>
            {
                var(info, node) = tuple;
                info.Name       = $"{node.Name} (v{node.Revision.ToString()})";
                info.Root       = node;
            });

            RefreshRuleSelections = ReactiveCommand.Create(RefreshRuleSelectionsImpl);
            RefreshRuleSelections
            .Subscribe(results =>
            {
                Rules.Clear();
                Rules.AddRange(results);
            });

            MarkAllRules = ReactiveCommand.Create(MarkAllRulesImpl, Rules.IsEmptyChanged.Select(x => !x));

            Rules.ItemChanged
            .WithLatestFrom(MarkAllRules.IsExecuting, (changed, isExecuting) => isExecuting ? null : changed)
            .Where(x => x != null)
            .Subscribe(e =>
            {
                if (!e.Sender.IsSelected)
                {
                    AllRulesSelected = false;
                }
            });

            SelectedDatafiles.Changed
            .Select(x => Unit.Default)
            .InvokeCommand(RefreshRuleSelections);

            RefreshProfileTypes = ReactiveCommand.Create(RefreshProfileTypesImpl);
            RefreshProfileTypes
            .Subscribe(results =>
            {
                ProfileTypes.Clear();
                ProfileTypes.AddRange(results);
                SelectedProfileType = ProfileTypes.FirstOrDefault();
            });

            SelectedDatafiles.Changed
            .Select(x => Unit.Default)
            .InvokeCommand(RefreshProfileTypes);

            RefreshCharacteristicTypeInfos = ReactiveCommand.Create(RefreshCharacteristicTypeInfosImpl);
            RefreshCharacteristicTypeInfos
            .Subscribe(results =>
            {
                CharacteristicInfos.Clear();
                CharacteristicInfos.AddRange(results);
                SelectedCharacteristicType = CharacteristicInfos.FirstOrDefault();
            });

            this.WhenAnyValue(x => x.SelectedProfileType)
            .Select(x => Unit.Default)
            .InvokeCommand(RefreshCharacteristicTypeInfos);

            DatafileConversionStatuses = SelectedDatafiles
                                         .CreateDerivedCollection(
                x => new DatafileConversionStatus(x),
                filter: null,
                orderer: (left, right) => left.Info.Name.CompareTo(right.Info.Name));

            var canConvert =
                this.WhenAnyValue(
                    x => x.FolderPath,
                    x => x.FolderPathError,
                    x => x.SelectedDatafiles.IsEmpty,
                    x => x.SelectedProfileType,
                    x => x.SelectedCharacteristicType,
                    x => x.Rules.IsEmpty,
                    (path, error, emptyFiles, profileType, chType, emptyRules)
                    => !string.IsNullOrWhiteSpace(path) && error == null && !emptyFiles && profileType != null && chType != null && !emptyRules);

            Convert = ReactiveCommand.Create(ConvertImpl, canConvert);
            Convert.InvokeCommand(LoadFolder);
        }
Exemplo n.º 18
0
 public static IEnumerable <ProfileData> GetProfiles(ProfileTypes type)
 {
     RemoveNulls();
     return(profiles.Where(x => x.Type == type));
 }
Exemplo n.º 19
0
        public async Task <IActionResult> PostProfileTypes(ProfileTypes profileTypes)
        {
            var response = await _db.CreateProfileType(profileTypes);

            return(_responsesService.PostResponse(response));
        }