Exemplo n.º 1
0
        private static string GetDefaultApp()
        {
            var alreadySetPath = GetExternalScriptEditor();

            if (!string.IsNullOrEmpty(alreadySetPath) && RiderPathExist(alreadySetPath))
            {
                return(alreadySetPath);
            }

            switch (SystemInfoRiderPlugin.operatingSystemFamily)
            {
            case OperatingSystemFamily.Windows:
                //"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains\*Rider*.lnk"
                //%appdata%\Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox\*Rider*.lnk
                string[] folders = { @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                                         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                         @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox") };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists).SelectMany(c => c.GetFiles("*Rider*.lnk"));
                if (newPathLnks.Any())
                {
                    var newPath = newPathLnks.Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName))).OrderBy(a => FileVersionInfo.GetVersionInfo(a.FullName).ProductVersion).LastOrDefault();
                    if (!string.IsNullOrEmpty(newPath.FullName))
                    {
                        /*if (EnableLogging) Debug.Log("[Rider] " + string.Format("Update {0} to {1} product version: {2}", alreadySetPath, newPath, FileVersionInfo.GetVersionInfo(newPath.FullName).ProductVersion));
                         * SetExternalScriptEditor(newPath.FullName);*/
                        return(newPath.FullName);
                    }
                }
                break;

            case OperatingSystemFamily.MacOSX:
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] foldersMac = { "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications") };
                var      newPathMac = foldersMac.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                      .SelectMany(c => c.GetDirectories("*Rider*.app")).OrderBy(a => FileVersionInfo.GetVersionInfo(a.FullName).ProductVersion).LastOrDefault();
                if (newPathMac != null)
                {
                    if (!string.IsNullOrEmpty(newPathMac.FullName))
                    {
                        /*if (EnableLogging) Debug.Log("[Rider] " + string.Format("Update {0} to {1}", alreadySetPath, newPathMac));
                         * SetExternalScriptEditor(newPathMac.FullName);*/
                        return(newPathMac.FullName);
                    }
                }
                break;
            }

            var riderPath = GetExternalScriptEditor();

            if (!RiderPathExist(riderPath))
            {
                Debug.Log("[Rider] Rider plugin for Unity is present, but Rider executable was not found. Please update 'External Script Editor'.");
                return(null);
            }

            return(riderPath);
        }
Exemplo n.º 2
0
        private static string[] GetAllRiderPaths(OperatingSystemFamilyRider operatingSystemFamily)
        {
            switch (operatingSystemFamily)
            {
            case OperatingSystemFamilyRider.Windows:
            {
                string[] folders =
                {
                    @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox")
                };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetFiles("*Rider*.lnk")).ToArray();
                if (newPathLnks.Any())
                {
                    var results = newPathLnks
                                  .Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName)))
                                  .Where(fi => File.Exists(fi.FullName))
                                  .ToArray()
                                  .OrderByDescending(fi => FileVersionInfo.GetVersionInfo(fi.FullName).ProductVersion)
                                  .Select(a => a.FullName).ToArray();

                    return(results);
                }
            }
            break;

            case OperatingSystemFamilyRider.MacOSX:
            {
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] folders =
                {
                    "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications/JetBrains Toolbox")
                };
                var results = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                              .SelectMany(c => c.GetDirectories("*Rider*.app"))
                              .Select(a => a.FullName).ToArray();
                return(results);
            }

            case OperatingSystemFamilyRider.Linux:
            {
                var home = Environment.GetEnvironmentVariable("HOME");
                if (string.IsNullOrEmpty(home))
                {
                    return(new string[0]);
                }
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/bin/rider.sh
                var riderPath = Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider");
                var results   = Directory.GetDirectories(riderPath).SelectMany(Directory.GetDirectories).Select(b => Path.Combine(b, "bin/rider.sh")).Where(File.Exists).ToArray();
                return(results);
            }
            }

            return(new string[0]);
        }
Exemplo n.º 3
0
        private static string[] GetAllRiderPaths()
        {
            switch (SystemInfoRiderPlugin.operatingSystemFamily)
            {
            case OperatingSystemFamily.Windows:
                string[] folders =
                {
                    @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox")
                };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetFiles("*Rider*.lnk")).ToArray();
                if (newPathLnks.Any())
                {
                    var newPaths = newPathLnks
                                   .Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName)))
                                   .Where(fi => File.Exists(fi.FullName))
                                   .ToArray()
                                   .OrderByDescending(fi => FileVersionInfo.GetVersionInfo(fi.FullName).ProductVersion)
                                   .Select(a => a.FullName).ToArray();

                    return(newPaths);
                }
                break;

            case OperatingSystemFamily.MacOSX:
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] foldersMac =
                {
                    "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications/JetBrains Toolbox")
                };
                var newPathsMac = foldersMac.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetDirectories("*Rider*.app"))
                                  .Select(a => a.FullName).ToArray();
                return(newPathsMac);
            }
            return(new string[0]);
        }
Exemplo n.º 4
0
        private void lvSettings_OnDropFilesNative(string[] files)
        {
            if (files.Length == 1)
            {
                var fileInfo = new FileInfo(files[0]);
                if (fileInfo.Extension.ToLower().Equals(".nip"))
                {
                    ImportProfiles(fileInfo.FullName);
                    return;
                }


                var profileName = "";
                var exeFile     = ShortcutResolver.ResolveExecuteable(files[0], out profileName);
                if (exeFile != "")
                {
                    var profiles = _scanner.FindProfilesUsingApplication(exeFile);
                    if (profiles != "")
                    {
                        var profile = profiles.Split(';')[0];
                        var idx     = cbProfiles.Items.IndexOf(profile);
                        if (idx > -1)
                        {
                            cbProfiles.SelectedIndex = idx;
                        }
                    }
                    else
                    {
                        var dr = MessageBox.Show("Would you like to create a new profile for this application?", "Profile not found!", MessageBoxButtons.YesNo);
                        if (dr == DialogResult.Yes)
                        {
                            ShowCreateProfileDialog(profileName, exeFile);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private static string[] GetAllRiderPaths(OperatingSystemFamilyRider operatingSystemFamily)
        {
            switch (operatingSystemFamily)
            {
            case OperatingSystemFamilyRider.Windows:
            {
                string[] folders =
                {
                    @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox")
                };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetFiles("*Rider*.lnk")).ToArray();
                if (newPathLnks.Any())
                {
                    var results = newPathLnks
                                  .Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName)))
                                  .Where(fi => File.Exists(fi.FullName))
                                  .ToArray()
                                  .OrderByDescending(fi => FileVersionInfo.GetVersionInfo(fi.FullName).ProductVersion)
                                  .Select(a => a.FullName).ToArray();

                    return(results);
                }
            }
            break;

            case OperatingSystemFamilyRider.MacOSX:
            {
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] folders =
                {
                    "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications/JetBrains Toolbox")
                };
                var results = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                              .SelectMany(c => c.GetDirectories("*Rider*.app"))
                              .Select(a => a.FullName).ToArray();
                return(results);
            }

            case OperatingSystemFamilyRider.Linux:
            {
                var home = Environment.GetEnvironmentVariable("HOME");
                if (string.IsNullOrEmpty(home))
                {
                    return(new string[0]);
                }
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/bin/rider.sh
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/.channel.settings.json
                var riderPath    = Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider");
                var channelFiles = Directory.GetDirectories(riderPath)
                                   .Select(b => Path.Combine(b, ".channel.settings.json")).Where(File.Exists).ToArray();

                var paths = channelFiles.Select(a =>
                    {
                        try
                        {
                            var channelDir = Path.GetDirectoryName(a);
                            var json       = File.ReadAllText(a);
                            var data       = (JObject)JsonConvert.DeserializeObject(json);
                            var builds     = data["active-application"]["builds"];
                            if (builds.HasValues)
                            {
                                var build = builds.First;
                                return(Path.Combine(Path.Combine(channelDir, build.Value <string>()), @"bin/rider.sh"));
                            }
                        }
                        catch (Exception e)
                        {
                            ourLogger.Warn(e, "Failed to get RiderPath via .channel.settings.json");
                        }
                        return(null);
                    })
                            .Where(c => !string.IsNullOrEmpty(c))
                            .ToArray();
                if (!paths.Any())
                {
                    return(Directory.GetDirectories(riderPath).SelectMany(Directory.GetDirectories).Select(b => Path.Combine(b, "bin/rider.sh")).Where(File.Exists).ToArray());
                }
                return(paths);
            }
            }

            return(new string[0]);
        }
Exemplo n.º 6
0
 private void MainWindow_KeyDown(object sender, KeyEventArgs e)
 {
     ShortcutResolver.ResolveShortcut(sender, e);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Get the shortcut when pressed on the textbox
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void getShortcut(object sender, KeyEventArgs e)
 {
     textBoxShortcut.Clear();
     textBoxShortcut.Text = ShortcutResolver.GetShortcutString(sender, e);
     textBoxShortcut.Text = textBoxShortcut.Text == "Back" ? "" : textBoxShortcut.Text;
 }