Beispiel #1
0
        private void handleLinkerUri(string fullArgs, string parentProcessName)
        {
            if (parentProcessName != "osu!")
            {
                _linkerBrowser(fullArgs);
                return;
            }

            Match osuMatch = osuReg.Match(fullArgs);

            if (osuMatch.Success && !(WinTools.IsKeyHeldDown(0x10) && WinTools.IsKeyHeldDown(0x11))) // 0x10=VK_SHIFT, 0x11=VK_CONTROL
            {
                if (WinTools.IsKeyHeldDown(0x09))                                                    // 0x09=VK_TAB
                {
                    _linkerClipboard(fullArgs);
                    return;
                }

                bool isSetId = osuMatch.Groups[1].ToString() == "s";
                directDownload(isSetId, osuMatch.Groups[2].ToString());
            }
            else
            {
                _linkerBrowser(fullArgs);
            }
        }
Beispiel #2
0
        private async void dataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!SettingManager.Get("audioPreviews"))
            {
                return;
            }

            var set = WinTools.GetGridViewSelectedRowItem <BeatmapSet>(sender, e);

            if (set == null)
            {
                return;
            }

            if (set == lastSetPreviewed)
            {
                forceStopPreview();
                lastSetPreviewed = null;
                return;
            }

            // hacky
            forceStopPreview(); // if already playing something just stop it
            await Task.Delay(250);

            // kind of a hack, pt 2
            if (DownloadManager.Downloads.Any(d => d.Set.Id == set.Id))
            {
                return; // check for if already d/l'ing overlaps
            }
            previewPlayer = await Osu.PlayPreviewAudio(set, (float)SettingManager.Get("previewVolume"));

            lastSetPreviewed = set;
        }
Beispiel #3
0
        private static void setProgId()
        {
            using (RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes\NexDirect.Url"))
            {
                key.SetValue("", "NexDirect http passthrough");

                string appLocation = WinTools.GetExecLocation();
                using (RegistryKey shellOpenKey = key.CreateSubKey(@"shell\open\command"))
                    shellOpenKey.SetValue("", $"\"{appLocation}\" \"/link:%1\"");
            }
        }
Beispiel #4
0
        private void _linkerBrowser(string url)
        {
            if (String.IsNullOrEmpty(SettingManager.Get("linkerDefaultBrowser")))
            {
                MessageBox.Show("NexDirect as a System Browser has not been configured properly. Please visit the Settings page to (re)register NexDirect as a browser.");
                return;
            }

            Process newProcess = Process.Start(new ProcessStartInfo(SettingManager.Get("linkerDefaultBrowser"), url));

            WinTools.SetHandleForeground(newProcess.Handle);
        }
Beispiel #5
0
        private void dataGrid_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var beatmap = WinTools.GetGridViewSelectedRowItem <BeatmapSet>(sender, e);

            if (beatmap == null)
            {
                return;
            }

            forceStopPreview();
            DownloadManagement.DownloadBeatmapSet(beatmap);
        }
Beispiel #6
0
        private async void CheckForUpdates()
        {
            UpdateChecker.Update update = await UpdateChecker.Check(WinTools.GetGitStyleVersion(), UpdateChecker.Platform.Windows);

            if (update == null)
            {
                return;
            }

            MessageBoxResult downloadNew = MessageBox.Show($"There is a new update available for NexDirect (version {update.Version}).\nIt was published on GitHub at {update.PublishedAt.ToString("g")}.\n\nOpen your browser now to download the latest update?", "NexDirect - Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (downloadNew == MessageBoxResult.No)
            {
                return;
            }
            Process.Start(update.Url);
        }
Beispiel #7
0
        private async void CheckForUpdates()
        {
            UpdateChecker.Update update = await UpdateChecker.Check(WinTools.GetGitStyleVersion(), UpdateChecker.Platform.Windows);

            if (update == null)
            {
                return;
            }

            bool             daylight    = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time").IsDaylightSavingTime(update.PublishedAt);
            MessageBoxResult downloadNew = MessageBox.Show($"There is a new update available for NexDirect (version {update.Version}).\nIt was published on GitHub at {WinTools.ToAustralianEasternTime(update.PublishedAt).ToString("g")} AE{(daylight ? "D" : "S")}T (Australian Eastern {(daylight ? "Daylight" : "Standard")} Time).\n\nOpen your browser now to download the latest update?", "NexDirect - Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (downloadNew == MessageBoxResult.No)
            {
                return;
            }
            Process.Start(update.Url);
        }
Beispiel #8
0
        private void progressGrid_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var download = WinTools.GetGridViewSelectedRowItem <BeatmapDownload>(sender, e);

            if (download == null)
            {
                return;
            }

            MessageBoxResult cancelPrompt = MessageBox.Show("Are you sure you wish to cancel the current download for: " + download.FriendlyName + "?", "NexDirect - Cancel Download", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (cancelPrompt == MessageBoxResult.No)
            {
                return;
            }

            DownloadManager.CancelDownload(download);
        }
Beispiel #9
0
        private static void registerCapabilities()
        {
            string appLocation = WinTools.GetExecLocation();

            using (RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Clients\StartMenuInternet\NexDirect"))
            {
                key.SetValue("", "NexDirect");

                using (RegistryKey capibilitySubkey = key.CreateSubKey(@"Capabilities"))
                {
                    capibilitySubkey.SetValue("ApplicationDescription", "Intercepts browser requests so that relevant ones can be sent to NexDirect.");
                    capibilitySubkey.SetValue("ApplicationName", "NexDirect");

                    using (RegistryKey urlAssocKey = capibilitySubkey.CreateSubKey(@"URLAssociations"))
                    {
                        urlAssocKey.SetValue("http", "NexDirect.Url");
                        urlAssocKey.SetValue("https", "NexDirect.Url");
                    }
                }

                using (RegistryKey iconSubkey = key.CreateSubKey(@"DefaultIcon"))
                    iconSubkey.SetValue("", $"{appLocation},0");
            }
        }
Beispiel #10
0
        private void dataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!SettingManager.Get("audioPreviews"))
            {
                return;
            }

            var set = WinTools.GetGridViewSelectedRowItem <BeatmapSet>(sender, e);

            if (set == null)
            {
                return;
            }

            if (set == lastSetPreviewed)
            {
                AudioManager.ForceStopPreview();
                lastSetPreviewed = null;
                return;
            }

            Osu.PlayPreviewAudio(set);
            lastSetPreviewed = set;
        }
        public static void Main(string[] args)
        {
            // If we need to upgrade the config file, need to do it now.
            if (NexDirect.Properties.Settings.Default.configUpgradeRequired)
            {
                NexDirect.Properties.Settings.Default.Upgrade();
                NexDirect.Properties.Settings.Default.configUpgradeRequired = false;

                // we need to smash the cookies as we have updates :(
                NexDirect.Properties.Settings.Default.officialOsuCookies = null;

                NexDirect.Properties.Settings.Default.Save();

                // The osu! folder check is to check if it is a new installation, because if it is then configupgrade will be true, and we dont need to pop this.
                if (!string.IsNullOrEmpty(NexDirect.Properties.Settings.Default.osuFolder))
                {
                    MessageBox.Show($"Your NexDirect installation has been successfully updated to version {WinTools.GetGitStyleVersion()}. Your previous settings have all been upgraded. Welcome back!", "NexDirect - Successful Update", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            if (SingleInstance <App> .InitializeAsFirstInstance(AppUnique))
            {
                var app = new App();

                app.InitializeComponent();
                //app.HandleURIArgs(args.ToList());
                app.Run(new MainWindow(args));

                SingleInstance <App> .Cleanup();
            }
        }