Пример #1
0
        private static ArgumentHandleResult ProcessSharedRaceGridPreset(SharedEntry shared, byte[] data)
        {
            var result = ShowDialog(shared);

            switch (result)
            {
            case Choise.Save:
            case Choise.ApplyAndSave:
                var filename = FileUtils.EnsureUnique(Path.Combine(
                                                          PresetsManager.Instance.GetDirectory(RaceGridViewModel.PresetableKeyValue), @"Loaded", shared.GetFileName()));
                Directory.CreateDirectory(Path.GetDirectoryName(filename) ?? "");
                File.WriteAllBytes(filename, data);
                if (result == Choise.ApplyAndSave)
                {
                    RaceGridViewModel.LoadPreset(filename);
                    QuickDrive.NavigateToPage();
                }
                return(ArgumentHandleResult.SuccessfulShow);

            case Choise.Apply:
                RaceGridViewModel.LoadSerializedPreset(data.ToUtf8String());
                QuickDrive.NavigateToPage();
                return(ArgumentHandleResult.SuccessfulShow);

            default:
                return(ArgumentHandleResult.Failed);
            }
        }