コード例 #1
0
        private void OpenFile_Impl()
        {
            if (ConfirmSaveChanges() == ConfirmSaveResult.Cancel)
            {
                return;
            }

            string filename = services.OpenFileDialog("Open File", "Showlight XML files|*.xml");

            if (filename is not null)
            {
                try
                {
                    var showlightFile = ShowLights.Load(filename);

                    Showlights.Clear();

                    foreach (var sl in showlightFile)
                    {
                        // Old versions of Toolkit have generated undefined notes
                        if (sl.GetShowLightType() != ShowLightType.Undefined)
                        {
                            Showlights.AddOrUpdate(new ShowLightViewModel(sl));
                        }
                    }

                    ResetEditor(filename, clearShowlights: false);
                }
                catch (Exception ex)
                {
                    services.ShowError("Opening the file failed:" + Environment.NewLine + ex.Message);
                }
            }
        }
コード例 #2
0
        private async Task Generate_Impl()
        {
            var fogOptions = new FogGenerationOptions
            {
                ShouldGenerate            = ShouldGenerateFog,
                ChangeFogColorEveryNthBar = Preferences.FogChangeBars,
                RandomizeColors           = Preferences.FogRandomize,
                MinTimeBetweenNotes       = (float)Preferences.FogMinTime,
                GenerationMethod          = Preferences.FogMethod,
                SelectedSingleFogColor    = (byte)SelectedSingleFogColor,
            };

            var beamOptions = new BeamGenerationOptions
            {
                ShouldGenerate      = ShouldGenerateBeams,
                GenerationMethod    = Preferences.BeamMethod,
                MinTimeBetweenNotes = (float)Preferences.BeamMinTime,
                RandomizeColors     = Preferences.BeamRandomize,
                UseCompatibleColors = Preferences.BeamCompatibleColors
            };

            var laserOptions = new LaserGenerationOptions
            {
                ShouldGenerate     = ShouldGenerateLasers,
                DisableLaserLights = Preferences.DisableLasers
            };

            var generator = new Generator(ArrangementForFogFilename, ArrangementForBeamsFilename, fogOptions, beamOptions, laserOptions);

            try
            {
                ShowlightsList = await Task.Run(() => generator.Generate(CurrentShowlights.Select(x => x.Model))).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                services.ShowError(
                    "Generation failed: " + Environment.NewLine +
                    ex.Message + Environment.NewLine +
                    Environment.NewLine +
                    ex.StackTrace
                    );
            }

            Hide(result: true);
        }