From 5e08a5bb44721b6d2468f15fa246c924816e24f8 Mon Sep 17 00:00:00 2001 From: mika Date: Fri, 26 Apr 2019 22:40:41 +0300 Subject: [PATCH] add enter and esc keys to upgrade dialog #fixes 80, fix release note urls fixes #73, if no matching upgrade version set first row selected, fix HaveExactVersionInstalled (returned true for null version), download missing version button now shows version number in target url, fix missing statuslabel, add button to launch adb logcat fixes #62, release 28 --- UnityLauncher/Form1.Designer.cs | 48 ++++++++++++++++++++------------ UnityLauncher/Form1.cs | 49 ++++++++++++++++++++------------- UnityLauncher/Form2.Designer.cs | 1 + UnityLauncher/Form2.cs | 43 ++++++++++++++++++++++------- 4 files changed, 95 insertions(+), 46 deletions(-) diff --git a/UnityLauncher/Form1.Designer.cs b/UnityLauncher/Form1.Designer.cs index 81c3ce7..af7b7ab 100644 --- a/UnityLauncher/Form1.Designer.cs +++ b/UnityLauncher/Form1.Designer.cs @@ -71,6 +71,7 @@ private void InitializeComponent() this._Date = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._UnityUpdateVersion = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tabSettings = new System.Windows.Forms.TabPage(); + this.btnOpenLogcatCmd = new System.Windows.Forms.Button(); this.chkDarkSkin = new System.Windows.Forms.CheckBox(); this.btnCheckUpdates = new System.Windows.Forms.Button(); this.linkProjectGithub = new System.Windows.Forms.LinkLabel(); @@ -108,7 +109,6 @@ private void InitializeComponent() this.tabUpdates.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridUnityUpdates)).BeginInit(); this.tabSettings.SuspendLayout(); - this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // tabControl1 @@ -606,6 +606,7 @@ private void InitializeComponent() // // tabSettings // + this.tabSettings.Controls.Add(this.btnOpenLogcatCmd); this.tabSettings.Controls.Add(this.chkDarkSkin); this.tabSettings.Controls.Add(this.btnCheckUpdates); this.tabSettings.Controls.Add(this.linkProjectGithub); @@ -634,11 +635,23 @@ private void InitializeComponent() this.tabSettings.Text = "Settings"; this.tabSettings.UseVisualStyleBackColor = true; // + // btnOpenLogcatCmd + // + this.btnOpenLogcatCmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnOpenLogcatCmd.Location = new System.Drawing.Point(453, 311); + this.btnOpenLogcatCmd.Name = "btnOpenLogcatCmd"; + this.btnOpenLogcatCmd.Size = new System.Drawing.Size(119, 23); + this.btnOpenLogcatCmd.TabIndex = 42; + this.btnOpenLogcatCmd.Text = "ADB logcat (cmd)"; + this.toolTip1.SetToolTip(this.btnOpenLogcatCmd, "adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG -v color"); + this.btnOpenLogcatCmd.UseVisualStyleBackColor = true; + this.btnOpenLogcatCmd.Click += new System.EventHandler(this.btnOpenLogcatCmd_Click); + // // chkDarkSkin // this.chkDarkSkin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkDarkSkin.AutoSize = true; - this.chkDarkSkin.Location = new System.Drawing.Point(20, 416); + this.chkDarkSkin.Location = new System.Drawing.Point(20, 443); this.chkDarkSkin.Name = "chkDarkSkin"; this.chkDarkSkin.Size = new System.Drawing.Size(85, 17); this.chkDarkSkin.TabIndex = 41; @@ -678,7 +691,7 @@ private void InitializeComponent() this.linkArgumentsDocs.AutoSize = true; this.linkArgumentsDocs.LinkArea = new System.Windows.Forms.LinkArea(1, 4); this.linkArgumentsDocs.LinkBehavior = System.Windows.Forms.LinkBehavior.AlwaysUnderline; - this.linkArgumentsDocs.Location = new System.Drawing.Point(385, 348); + this.linkArgumentsDocs.Location = new System.Drawing.Point(385, 375); this.linkArgumentsDocs.Name = "linkArgumentsDocs"; this.linkArgumentsDocs.Size = new System.Drawing.Size(36, 17); this.linkArgumentsDocs.TabIndex = 38; @@ -691,7 +704,7 @@ private void InitializeComponent() // this.chkShowGitBranchColumn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkShowGitBranchColumn.AutoSize = true; - this.chkShowGitBranchColumn.Location = new System.Drawing.Point(266, 370); + this.chkShowGitBranchColumn.Location = new System.Drawing.Point(266, 397); this.chkShowGitBranchColumn.Name = "chkShowGitBranchColumn"; this.chkShowGitBranchColumn.Size = new System.Drawing.Size(76, 17); this.chkShowGitBranchColumn.TabIndex = 36; @@ -705,7 +718,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Enabled = false; this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(263, 322); + this.label5.Location = new System.Drawing.Point(263, 349); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(105, 13); this.label5.TabIndex = 35; @@ -715,7 +728,7 @@ private void InitializeComponent() // this.chkShowLauncherArgumentsColumn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkShowLauncherArgumentsColumn.AutoSize = true; - this.chkShowLauncherArgumentsColumn.Location = new System.Drawing.Point(266, 347); + this.chkShowLauncherArgumentsColumn.Location = new System.Drawing.Point(266, 374); this.chkShowLauncherArgumentsColumn.Name = "chkShowLauncherArgumentsColumn"; this.chkShowLauncherArgumentsColumn.Size = new System.Drawing.Size(124, 17); this.chkShowLauncherArgumentsColumn.TabIndex = 34; @@ -727,7 +740,7 @@ private void InitializeComponent() // this.ChkQuitAfterOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.ChkQuitAfterOpen.AutoSize = true; - this.ChkQuitAfterOpen.Location = new System.Drawing.Point(20, 370); + this.ChkQuitAfterOpen.Location = new System.Drawing.Point(20, 397); this.ChkQuitAfterOpen.Name = "ChkQuitAfterOpen"; this.ChkQuitAfterOpen.Size = new System.Drawing.Size(172, 17); this.ChkQuitAfterOpen.TabIndex = 33; @@ -738,7 +751,7 @@ private void InitializeComponent() // btnOpenLogFolder // this.btnOpenLogFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnOpenLogFolder.Location = new System.Drawing.Point(453, 285); + this.btnOpenLogFolder.Location = new System.Drawing.Point(453, 273); this.btnOpenLogFolder.Name = "btnOpenLogFolder"; this.btnOpenLogFolder.Size = new System.Drawing.Size(119, 23); this.btnOpenLogFolder.TabIndex = 32; @@ -750,7 +763,7 @@ private void InitializeComponent() // this.chkQuitAfterCommandline.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkQuitAfterCommandline.AutoSize = true; - this.chkQuitAfterCommandline.Location = new System.Drawing.Point(20, 393); + this.chkQuitAfterCommandline.Location = new System.Drawing.Point(20, 420); this.chkQuitAfterCommandline.Name = "chkQuitAfterCommandline"; this.chkQuitAfterCommandline.Size = new System.Drawing.Size(189, 17); this.chkQuitAfterCommandline.TabIndex = 31; @@ -761,7 +774,7 @@ private void InitializeComponent() // btnAddRegister // this.btnAddRegister.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnAddRegister.Location = new System.Drawing.Point(139, 481); + this.btnAddRegister.Location = new System.Drawing.Point(139, 493); this.btnAddRegister.Name = "btnAddRegister"; this.btnAddRegister.Size = new System.Drawing.Size(64, 23); this.btnAddRegister.TabIndex = 30; @@ -772,7 +785,7 @@ private void InitializeComponent() // btnRemoveRegister // this.btnRemoveRegister.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnRemoveRegister.Location = new System.Drawing.Point(209, 481); + this.btnRemoveRegister.Location = new System.Drawing.Point(209, 493); this.btnRemoveRegister.Name = "btnRemoveRegister"; this.btnRemoveRegister.Size = new System.Drawing.Size(64, 23); this.btnRemoveRegister.TabIndex = 29; @@ -784,7 +797,7 @@ private void InitializeComponent() // this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(19, 486); + this.label4.Location = new System.Drawing.Point(19, 498); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(117, 13); this.label4.TabIndex = 28; @@ -796,7 +809,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Enabled = false; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(17, 322); + this.label2.Location = new System.Drawing.Point(17, 349); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(88, 13); this.label2.TabIndex = 26; @@ -806,7 +819,7 @@ private void InitializeComponent() // this.chkMinimizeToTaskbar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkMinimizeToTaskbar.AutoSize = true; - this.chkMinimizeToTaskbar.Location = new System.Drawing.Point(20, 347); + this.chkMinimizeToTaskbar.Location = new System.Drawing.Point(20, 374); this.chkMinimizeToTaskbar.Name = "chkMinimizeToTaskbar"; this.chkMinimizeToTaskbar.Size = new System.Drawing.Size(116, 17); this.chkMinimizeToTaskbar.TabIndex = 25; @@ -900,6 +913,8 @@ private void InitializeComponent() // // statusStrip1 // + // this next line keeps disappearing : this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.toolStripStatusLabel1}); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.toolStripStatusLabel1}); this.statusStrip1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.statusStrip1.AutoSize = false; @@ -932,7 +947,7 @@ private void InitializeComponent() this.MinimumSize = new System.Drawing.Size(600, 650); this.Name = "Form1"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "UnityLauncher - Getting Darker Edition 26"; + this.Text = "UnityLauncher - SummerEdition 28"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.ResizeEnd += new System.EventHandler(this.Form1_ResizeEnd); @@ -951,8 +966,6 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.gridUnityUpdates)).EndInit(); this.tabSettings.ResumeLayout(false); this.tabSettings.PerformLayout(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); this.ResumeLayout(false); } @@ -1027,6 +1040,7 @@ private void InitializeComponent() private System.Windows.Forms.TextBox tbSearchUpdates; private System.ComponentModel.BackgroundWorker backgroundWorker1; private System.Windows.Forms.CheckBox chkDarkSkin; + private System.Windows.Forms.Button btnOpenLogcatCmd; } } diff --git a/UnityLauncher/Form1.cs b/UnityLauncher/Form1.cs index 40bf7c9..5aab7a6 100644 --- a/UnityLauncher/Form1.cs +++ b/UnityLauncher/Form1.cs @@ -184,10 +184,7 @@ void LoadSettings() /// bool HaveExactVersionInstalled(string version) { - //Console.WriteLine("checking: '" + version + "'"); - var installedExact = unityList.ContainsKey(version); - //Console.WriteLine("have exact:" + installedExact); - return installedExact; + return string.IsNullOrEmpty(version) == false && unityList.ContainsKey(version); } @@ -545,7 +542,6 @@ string GetDownloadUrlForUnityVersion(string releaseUrl) if (match.Success == true) { url = match.Groups[0].Captures[0].Value; - // Console.WriteLine(url); } else { @@ -559,7 +555,7 @@ string GetDownloadUrlForUnityVersion(string releaseUrl) /// launches browser to download installer /// /// full url to installer - void DownloadInBrowser(string url) + void DownloadInBrowser(string url, string version) { string exeURL = GetDownloadUrlForUnityVersion(url); if (string.IsNullOrEmpty(exeURL) == false) @@ -571,7 +567,7 @@ void DownloadInBrowser(string url) { SetStatus("Error> Cannot find installer executable ... opening website instead"); url = "https://unity3d.com/get-unity/download/archive"; - Process.Start(url + "#installer-exe-not-found"); + Process.Start(url + "#installer-not-found---version-" + version); } } @@ -584,7 +580,7 @@ string[] GetUnityInstallationsRootFolder() string[] rootFolders = null; try { - // if settings exists, use that + // if settings exists, use that value rootFolders = new string[Properties.Settings.Default.rootFolders.Count]; Properties.Settings.Default.rootFolders.CopyTo(rootFolders, 0); } @@ -622,6 +618,7 @@ void LaunchSelectedProject(bool openProject = true) { var projectPath = gridRecent.Rows[(int)selected].Cells["_path"].Value.ToString(); var version = Tools.GetProjectVersion(projectPath); + Console.WriteLine("version: '" + version + "'"); LaunchProject(projectPath, version, openProject); SetStatus("Ready"); } @@ -631,7 +628,7 @@ void LaunchSelectedProject(bool openProject = true) void LaunchSelectedUnity() { - + var selected = gridUnityList?.CurrentCell?.RowIndex; if (selected.HasValue && selected > -1) { @@ -719,7 +716,7 @@ private void btnLaunchUnity_Click(object sender, EventArgs e) private void btnExploreUnity_Click(object sender, EventArgs e) { - + var selected = gridUnityList?.CurrentCell?.RowIndex; if (selected.HasValue && selected > -1) { @@ -1141,7 +1138,7 @@ void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launch string url = Tools.GetUnityReleaseURL(currentVersion); if (string.IsNullOrEmpty(url) == false) { - DownloadInBrowser(url); + DownloadInBrowser(url, currentVersion); } else { @@ -1218,31 +1215,27 @@ void BrowseForExistingProjectFolder() folderBrowserDialog1.Description = "Select existing project folder"; var d = folderBrowserDialog1.ShowDialog(); var projectPath = folderBrowserDialog1.SelectedPath; + + // NOTE: if user didnt click enter or deselect-select newly created folder, this fails as it returns "new folder" instead of actual name + // https://social.msdn.microsoft.com/Forums/vstudio/en-US/cc7f1d54-c1a0-45de-9611-7f69873f32df/folderbrowserdialog-bug-when-click-ok-while-modify-new-folders-name?forum=netfxbcl + if (String.IsNullOrWhiteSpace(projectPath) == false && Directory.Exists(projectPath) == true) { - // TODO: remove duplicate code (from UpdateRecentList()) - string projectName = ""; - Console.WriteLine(Path.DirectorySeparatorChar); - Console.WriteLine(Path.AltDirectorySeparatorChar); - // get project name from full path if (projectPath.IndexOf(Path.DirectorySeparatorChar) > -1) { projectName = projectPath.Substring(projectPath.LastIndexOf(Path.DirectorySeparatorChar) + 1); - Console.WriteLine("1"); } else if (projectPath.IndexOf(Path.AltDirectorySeparatorChar) > -1) { projectName = projectPath.Substring(projectPath.LastIndexOf(Path.AltDirectorySeparatorChar) + 1); - Console.WriteLine("2"); } else // no path separator found { projectName = projectPath; - Console.WriteLine("3"); } string csprojFile = Path.Combine(projectPath, projectName + ".csproj"); @@ -1332,5 +1325,23 @@ void FixSelectedRow() } } + private void btnOpenLogcatCmd_Click(object sender, EventArgs e) + { + try + { + Process myProcess = new Process(); + var cmd = "cmd.exe"; + myProcess.StartInfo.FileName = cmd; + // NOTE windows 10 cmd line supports ansi colors, otherwise remove -v color + var pars = " /c adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG -v color"; + myProcess.StartInfo.Arguments = pars; + myProcess.Start(); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } + } // class Form } // namespace \ No newline at end of file diff --git a/UnityLauncher/Form2.Designer.cs b/UnityLauncher/Form2.Designer.cs index 344580b..6293ff1 100644 --- a/UnityLauncher/Form2.Designer.cs +++ b/UnityLauncher/Form2.Designer.cs @@ -54,6 +54,7 @@ private void InitializeComponent() this.lstUnityVersions.Name = "lstUnityVersions"; this.lstUnityVersions.Size = new System.Drawing.Size(235, 303); this.lstUnityVersions.TabIndex = 1; + this.lstUnityVersions.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstUnityVersions_KeyDown); // // btnCancelUpgrade // diff --git a/UnityLauncher/Form2.cs b/UnityLauncher/Form2.cs index 00ef5e4..d8df7aa 100644 --- a/UnityLauncher/Form2.cs +++ b/UnityLauncher/Form2.cs @@ -34,7 +34,6 @@ void Start() if (string.IsNullOrEmpty(currentVersion) == false) { string nearestVersion = Tools.FindNearestVersion(currentVersion, Form1.unityList.Keys.ToList()); - //Console.WriteLine("nearest:" + nearestVersion); // preselect most likely version int likelyIndex = lstUnityVersions.FindString(nearestVersion); @@ -42,6 +41,11 @@ void Start() { lstUnityVersions.SetSelected(likelyIndex, true); } + else + { + // just select first item then + lstUnityVersions.SetSelected(0, true); + } // enable release and dl buttons btn_GoInstallMissingVersion.Enabled = true; @@ -54,6 +58,8 @@ void Start() btn_OpenMissingVersionReleasePage.Enabled = false; currentVersion = "None"; + // just select first item then + if (lstUnityVersions != null && lstUnityVersions.Items.Count > 0) lstUnityVersions.SetSelected(0, true); } // fill textbox @@ -64,15 +70,7 @@ void Start() private void btnConfirmUpgrade_Click(object sender, EventArgs e) { - if (lstUnityVersions.SelectedIndex > -1) - { - currentVersion = lstUnityVersions.Items[lstUnityVersions.SelectedIndex].ToString(); - DialogResult = DialogResult.Yes; - } - else - { - // no version selected - } + UpgradeToSelected(); } private void btnCancelUpgrade_Click(object sender, EventArgs e) @@ -91,5 +89,30 @@ private void btn_GoInstallMissingVersion_Click(object sender, EventArgs e) } #endregion + + private void lstUnityVersions_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Return) + { + UpgradeToSelected(); + } + else if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + void UpgradeToSelected() + { + if (lstUnityVersions.SelectedIndex > -1) + { + currentVersion = lstUnityVersions.Items[lstUnityVersions.SelectedIndex].ToString(); + DialogResult = DialogResult.Yes; + } + else + { + // no version selected + } + } } }