Inheritance: AcTools.Render.Wrapper.BaseKn5FormWrapper
Beispiel #1
0
        public static async Task Run(TrackObjectBase track)
        {
            var modelsFilename = track.ModelsFilename;

            Logging.Debug(modelsFilename);

            string kn5Filename = null;

            if (!File.Exists(modelsFilename))
            {
                modelsFilename = null;
                kn5Filename    = Path.Combine(track.Location, track.Id + ".kn5");
                if (!File.Exists(kn5Filename))
                {
                    ModernDialog.ShowMessage("Model not found");
                    return;
                }
            }

            TrackMapPreparationRenderer renderer = null;

            try {
                using (WaitingDialog.Create("Loading model…")) {
                    renderer = modelsFilename == null ?
                               new TrackMapPreparationRenderer(await Task.Run(() => Kn5.FromFile(kn5Filename))) :
                               new TrackMapPreparationRenderer(await Task.Run(() => TrackComplexModelDescription.CreateLoaded(modelsFilename)));
                }

                var wrapper = new TrackMapRendererWrapper(track, renderer);
                wrapper.Form.Icon = AppIconService.GetAppIcon();
                wrapper.Run();
            } finally {
                renderer?.Dispose();
            }
        }
        public static async Task Run(TrackObjectBase track) {
            var modelsFilename = track.ModelsFilename;
            string kn5Filename = null;
            if (!File.Exists(modelsFilename)) {
                modelsFilename = null;
                kn5Filename = Path.Combine(track.Location, track.Id + ".kn5");
                if (!File.Exists(kn5Filename)) {
                    ModernDialog.ShowMessage("Model not found");
                    return;
                }
            }

            Kn5 kn5;
            using (var waiting = new WaitingDialog()) {
                waiting.Report("Loading model…");
                kn5 = await Task.Run(() => modelsFilename != null ? Kn5.FromModelsIniFile(modelsFilename) : Kn5.FromFile(kn5Filename));
            }

            using (var renderer = new TrackMapPreparationRenderer(kn5)) {
                var wrapper = new TrackMapRendererWrapper(track, renderer);
                wrapper.Form.Icon = AppIconService.GetAppIcon();
                wrapper.Run();
            }
        }