Пример #1
0
        public void Trigger(bool lit)
        {
            if (ChainKind? !Preferences.ChainSignalIndicators : !Preferences.DeviceSignalIndicators)
            {
                return;
            }

            lock (locker) {
                if (Disposed)
                {
                    return;
                }

                Timer?.Dispose();

                Timer = new Courier()
                {
                    Interval = 200
                };

                Timer.Elapsed += (_, __) => SetIndicator(0);
                Timer.Start();

                SetIndicator(lit? 1 : 0.5);
            }
        }
Пример #2
0
        static void Init()
        {
            if (Initialized)
            {
                return;
            }

            Presence = new DiscordRpcClient("579791801527959592");
            Presence.Initialize();
            Time        = new Timestamps(DateTime.UtcNow);
            Initialized = true;

            Refresh();
            courier.Start();
        }
Пример #3
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime))
            {
                throw new ApplicationException("Invalid ApplicationLifetime");
            }

            if (Args.Length > 0 && Args[0] == "--update")
            {
                lifetime.MainWindow = new UpdateWindow();
            }
            else
            {
                if (!DriverChecker.Run(out MessageWindow driverError))
                {
                    lifetime.MainWindow = driverError;

                    base.OnFrameworkInitializationCompleted();
                    return;
                }

                if (!AbletonConnector.Connected)
                {
                    lifetime.MainWindow = new MessageWindow(
                        $"Another instance of Apollo Studio is currently running.\n\n" +
                        "Please close other instances of Apollo Studio before launching Apollo Studio."
                        );
                    base.OnFrameworkInitializationCompleted();
                    return;
                }

                Program.HadCrashed  = Preferences.Crashed;
                Preferences.Crashed = true;

                if (Preferences.DiscordPresence)
                {
                    Discord.Set(true);
                }

                MIDI.Start();

                foreach (int i in Preferences.VirtualLaunchpads)
                {
                    LaunchpadWindow.Create(MIDI.ConnectVirtual(i), null);
                    MIDI.Update();
                }

                Courier autosave = new Courier()
                {
                    Interval = 180000
                };
                autosave.Elapsed += async(_, __) => {
                    if (Preferences.Autosave && Program.Project != null && File.Exists(Program.Project.FilePath) && !Program.Project.Undo.Saved)
                    {
                        try {
                            string dir = Path.Combine(Path.GetDirectoryName(Program.Project.FilePath), $"{Program.Project.FileName} Backups");
                            if (!Directory.Exists(dir))
                            {
                                Directory.CreateDirectory(dir);
                            }

                            await Program.Project.WriteFile(
                                null,
                                Path.Join(dir, $"{Program.Project.FileName} Autosave {DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}.approj"),
                                false
                                );
                        } catch {}
                    }

                    Preferences.Save();
                };
                autosave.Start();

                lifetime.Exit += (_, __) => {
                    autosave.Dispose();
                    MIDI.Stop();
                    Discord.Set(false);
                    AbletonConnector.Dispose();
                    Preferences.Crashed = Program.HadCrashed;

                    Preferences.Save();
                };

                lifetime.MainWindow = new SplashWindow();
                base.OnFrameworkInitializationCompleted();
            }
        }