Exemplo n.º 1
0
 private void toolStripButtonOpenDir_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(InstallDirectoryHelper.GetPluginPath());
     }
     catch (SystemException ex)
     {
         MessageBox.Show(ex.Message, "Failed to start application", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        private static DefaultAssemblyResolver GetResolver(FileInfo location)
        {
            var resolver = new DefaultAssemblyResolver();

            if (location.Directory != null)
            {
                var coreDir = Path.Combine(InstallDirectoryHelper.GetPluginPath(), "core");
                if (Directory.Exists(coreDir))
                {
                    resolver.AddSearchDirectory(coreDir);
                }
            }

            return(resolver);
        }
Exemplo n.º 3
0
        private void PopulateStartMenu()
        {
            var toAdd        = new List <ToolStripItem>();
            var pluginPath   = InstallDirectoryHelper.GetPluginPath();
            var allExes      = InstallDirectoryHelper.KoikatuDirectory.GetFiles("*.exe", SearchOption.AllDirectories);
            var filteredExes = allExes.Where(x => !x.Name.Equals("bepinex.patcher.exe", StringComparison.OrdinalIgnoreCase) && !x.FullName.StartsWith(pluginPath, StringComparison.OrdinalIgnoreCase));

            foreach (var file in filteredExes.OrderBy(x => x.Name))
            {
                var item = new ToolStripMenuItem(file.Name);
                item.AutoToolTip = false;
                item.ToolTipText = file.FullName;
                item.Click      += (o, args) => { ProcessTools.SafeStartProcess(file.FullName); };
                toAdd.Add(item);
            }
            this.SafeInvoke(() => startTheGameToolStripMenuItem.DropDownItems.AddRange(toAdd.ToArray()));
        }
Exemplo n.º 4
0
        private void PopulateStartMenu()
        {
            var toAdd        = new List <ToolStripItem>();
            var pluginPath   = InstallDirectoryHelper.GetPluginPath();
            var allExes      = InstallDirectoryHelper.KoikatuDirectory.GetFiles("*.exe", SearchOption.AllDirectories);
            var filteredExes = allExes.Where(x => !x.Name.Equals("bepinex.patcher.exe", StringComparison.OrdinalIgnoreCase) && !x.FullName.StartsWith(pluginPath, StringComparison.OrdinalIgnoreCase));

            var first = true;

            foreach (var folder in filteredExes.GroupBy(x => x.DirectoryName, StringComparer.OrdinalIgnoreCase).OrderBy(x => x.Key, StringComparer.OrdinalIgnoreCase))
            {
                if (!first)
                {
                    toAdd.Add(new ToolStripSeparator());
                }
                first = false;

                foreach (var file in folder.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase))
                {
                    // Trim .exe but leave other extensions
                    var trimmedName = file.Name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ? file.Name.Substring(0, file.Name.Length - 4) : file.Name;
                    var item        = new ToolStripMenuItem(trimmedName);

                    item.AutoToolTip = false;
                    item.ToolTipText = file.FullName;

                    item.Click += (o, args) => { ProcessTools.SafeStartProcess(file.FullName); };

                    try { item.Image = Icon.ExtractAssociatedIcon(file.FullName)?.ToBitmap(); }
                    catch { item.Image = null; }

                    toAdd.Add(item);
                }
            }

            this.SafeInvoke(() =>
            {
                foreach (var item in toAdd)
                {
                    startTheGameToolStripMenuItem.DropDownItems.Add(item);
                }
            });
        }
Exemplo n.º 5
0
        public void ReloadList()
        {
            CancelListReload();
            objectListView1.ClearObjects();

            _cancellationTokenSource = new CancellationTokenSource();
            var token = _cancellationTokenSource.Token;
            var observable = PluginLoader.TryLoadPlugins(InstallDirectoryHelper.GetPluginPath(), token);

            observable
                .Buffer(TimeSpan.FromSeconds(0.5))
                .ObserveOn(this)
                .Subscribe(list => objectListView1.AddObjects((ICollection)list),
                    () =>
                    {
                        objectListView1.FastAutoResizeColumns();
                        MainWindow.SetStatusText("Done loading plugins");
                    }, token);
        }