private async void CheckForUpdates(bool silent)
        {
            miUpdateVersion.Enabled = false;
            VersionResponse oldVersion = Configs.Instance.UpdateHelper.UpdateAvailable;
            await Task.Run(() => Configs.Instance.UpdateHelper.CheckForUpdates());

            VersionResponse version = Configs.Instance.UpdateHelper.UpdateAvailable;

            miUpdateVersion.Enabled = true;

            if (version == null || version == oldVersion)
            {
                miUpdateVersion.Text = "Check for Updates";
                if (!silent)
                {
                    MessageBox.Show(this, $"You are using an actual version of the {APP_TITLE}.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }

            miUpdateVersion.Text = $"Update to {version.Version}...";
            if (TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Update is Available",
                    "The Obfuscar Mapping Parser update is available. Update now?",
                    version.Description,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Update now", "Don't update" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) == TaskDialogResult.Yes)
            {
                DoUpdateVersion();
            }
        }
示例#2
0
        public async void OpenInVisualStudio(string filename, int line)
        {
            if (!File.Exists(filename))
            {
                if (TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "File Not Exists",
                        "File not found. Would you like to locate file by sourself?",
                        "Filename: " + filename,
                        TaskDialogStandardIcon.Error,
                        new string[] { "Browse", "Cancel" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No, }
                        ) != TaskDialogResult.Yes)
                {
                    return;
                }

                string file = PathUtils.GetFilename(filename);
                odSourceFile.Filter   = file + "|" + file;
                odSourceFile.FileName = file;
                if (odSourceFile.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                filename = odSourceFile.FileName;
            }
            string vs = Configs.Instance.GetRecentProperty(mapping.Mapping.Filename, Configs.PROPERTY_EDITOR);

            if (vs == null)
            {
                vs = Configs.Instance.Editor;
            }
            IVisualStudioInfo visualStudio = VisualStudioDetector.GetVisualStudioInfo(vs);

            BeginLoading("Starting the Visual Studio...");
            try
            {
                await Task.Run(() => visualStudio.OpenFile(filename, line));
            }
            catch (Exception ex)
            {
                this.SetTaskbarProgressValue(100, 100);
                this.SetTaskbarProgressState(Taskbar.ThumbnailProgressState.Error);
                TaskDialogHelper.ShowMessageBox(
                    Handle,
                    "Failed to Open in Visual Studio",
                    "Failed to open in Visual Studio. Try to use another version of Visual Studio.",
                    filename + ":" + line + "\n" + ex.Message,
                    TaskDialogStandardIcon.Error
                    );
            }
            EndLoading("");
        }
示例#3
0
        private void UpdateFound(UpdateHelper updateHelper)
        {
            TaskDialogResult result = TaskDialogHelper.ShowTaskDialog(
                Handle,
                "Update is Available",
                $"The Obfuscar Mapping Parser update to {updateHelper.UpdateAvailable.Version} is available. Update now?",
                updateHelper.UpdateAvailable.Description,
                TaskDialogStandardIcon.Information,
                new string[] { "Update Now", "Schedule Update", "Ignore Update", "Cancel" },
                new string[] { "Perform update and restart app", "Perform update when app is closed", "Don't update to this version", null },
                new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.Ok, TaskDialogResult.No, TaskDialogResult.Cancel, }
                );

            switch (result)
            {
            // update now
            case TaskDialogResult.Yes:
                updateHelper.ScheduleUpdate(
                    UpdateHelper.BuildCommandLine(
                        null,
                        new Dictionary <string, string>
                {
                    { "doRestart", null },
                    { "restartCmd", mappingFilename }
                }
                        )
                    );
                Close();
                break;

            // schedule
            case TaskDialogResult.Ok:
                // run updater silently
                updateHelper.ScheduleUpdate(updateHelper.SilentCommandline);
                break;

            // ignore
            case TaskDialogResult.No:
                updateHelper.IgnoreUpdate();
                break;
            }
        }
示例#4
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            if (mapping == null)
            {
                return;
            }

            foreach (PdbFile pdbFile in mapping.PdbFiles)
            {
                if (pdbFile.CheckFileModification() &&
                    TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "PDB File Change Detected",
                        "External PDB file change detected. Reload?",
                        pdbFile.Filename,
                        TaskDialogStandardIcon.Information,
                        new string[] { "Reload", "Don't reload" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        ) == TaskDialogResult.Yes)
                {
                    pdbFile.ReloadFile();
                }
            }

            if (mapping.CheckModifications() &&
                TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Mapping File Change Detected",
                    "External mapping file change detected. Reload?",
                    mapping.Mapping.Filename,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Reload", "Don't reload" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) == TaskDialogResult.Yes)
            {
                ReloadFile();
            }
        }
        private void btnDetach_Click(object sender, EventArgs e)
        {
            if (TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Detach PDBs",
                    "Detach selected PDB files?",
                    null,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Detach", "Don't detach" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) != TaskDialogResult.Yes)
            {
                return;
            }

            foreach (ListViewItem item in lvList.SelectedItems)
            {
                PdbFile file = (PdbFile)item.Tag;
                files.Remove(file);
                Configs.Instance.RemoveRecentPdb(mainForm.Mapping.Filename, file.Filename);
                item.Remove();
            }
        }
示例#6
0
        private void AttachPDB(IList <string> files, bool addToRecent)
        {
            if (files == null || mapping == null)
            {
                return;
            }

            // single file - different dialog
            if (files.Count == 1)
            {
                if (TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        ) ==
                    TaskDialogResult.Yes)
                {
                    AttachPDB(files[0], this, addToRecent);
                }

                return;
            }

            bool isYesToAll = false;

            for (int i = 0; i < files.Count; i++)
            {
                string file = files[i];
                if (!File.Exists(file))
                {
                    continue;
                }

                if (mapping.IsPdbAttached(file))
                {
                    continue;
                }

                TaskDialogResult result;

                if (isYesToAll)
                {
                    result = TaskDialogResult.Yes;
                }
                else if (i == files.Count - 1)
                {
                    result = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        );
                }
                else
                {
                    result = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Attach All", "Don't attach", "Cancel" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.Ok, TaskDialogResult.No, TaskDialogResult.Cancel, }
                        );
                }

                switch (result)
                {
                case TaskDialogResult.Yes: // "yes"
                    AttachPDB(file, this, addToRecent);
                    break;

                case TaskDialogResult.Ok: // "yes to all"
                    isYesToAll = true;
                    goto case TaskDialogResult.Yes;

                case TaskDialogResult.Cancel: // "cancel"
                    return;
                }
            }
        }
        private void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            List <string> files = new List <string>((string[])e.Data.GetData(DataFormats.FileDrop));

            string fileToOpen = null;
            int    i          = 0;

            do
            {
                // search for xml files to open
                if (string.Compare(Path.GetExtension(files[i]).ToLower(), ".xml", StringComparison.Ordinal) == 0)
                {
                    fileToOpen = files[i];
                    files.RemoveAt(i);
                    continue;
                }

                // search for pdb files to attach after open
                if (string.Compare(Path.GetExtension(files[i]).ToLower(), ".pdb", StringComparison.Ordinal) == 0)
                {
                    if (pdbToAttach == null)
                    {
                        pdbToAttach = new List <string>();
                    }
                    pdbToAttach.Add(files[i]);
                }

                i++;
            }while (i < files.Count);

            // open file if found. found pdbs will be attached after open (pdbToAttach)
            if (fileToOpen != null)
            {
                if (MessageBox.Show(this, "Open file\n" + fileToOpen + "\n?", "Open file", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }

                OpenFile(fileToOpen);
                return;
            }

            if (mapping == null)
            {
                return;
            }

            // attach pdb files
            foreach (string file in files)
            {
                if (string.Compare(Path.GetExtension(file).ToLower(), ".pdb", StringComparison.Ordinal) == 0)
                {
                    TaskDialogResult d = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach related PDB file?",
                        file,
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach", "Cancel operation" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No, TaskDialogResult.Cancel, }
                        );
                    switch (d)
                    {
                    case TaskDialogResult.Yes:
                        AttachPDB(file, this);
                        break;

                    case TaskDialogResult.No:
                        break;

                    default:
                        return;
                    }
                }
            }
        }