From e51fde511e365193b69607d5842c4d04fedffead Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 23 Oct 2018 07:16:49 -0400 Subject: [PATCH] Hide LocationDialog after OK clicked and handle no theme correctly in ThemeDialog --- src/InputDialog.Designer.cs | 12 ------------ src/InputDialog.cs | 13 ++++++------- src/Properties/AssemblyInfo.cs | 2 +- src/ThemeDialog.cs | 18 +++++++++++++++++- src/WinDynamicDesktop.csproj | 14 ++++++-------- src/packages.config | 4 ++-- uwp/Package.appxmanifest | 2 +- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/InputDialog.Designer.cs b/src/InputDialog.Designer.cs index 44a84ee..22b24b3 100644 --- a/src/InputDialog.Designer.cs +++ b/src/InputDialog.Designer.cs @@ -33,7 +33,6 @@ private void InitializeComponent() this.okButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button(); this.locationCheckBox = new System.Windows.Forms.CheckBox(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.SuspendLayout(); // // label1 @@ -88,15 +87,6 @@ private void InitializeComponent() this.locationCheckBox.Text = "Use Windows location service"; this.locationCheckBox.UseVisualStyleBackColor = true; // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(15, 36); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(300, 23); - this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; - this.progressBar1.TabIndex = 4; - this.progressBar1.Visible = false; - // // InputDialog // this.AcceptButton = this.okButton; @@ -104,7 +94,6 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(330, 134); - this.Controls.Add(this.progressBar1); this.Controls.Add(this.locationCheckBox); this.Controls.Add(this.cancelButton); this.Controls.Add(this.label1); @@ -132,7 +121,6 @@ private void InitializeComponent() private System.Windows.Forms.Button okButton; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.CheckBox locationCheckBox; - private System.Windows.Forms.ProgressBar progressBar1; } } diff --git a/src/InputDialog.cs b/src/InputDialog.cs index 7cea37d..c875074 100644 --- a/src/InputDialog.cs +++ b/src/InputDialog.cs @@ -18,6 +18,7 @@ public InputDialog() private void UpdateGuiState() { + inputBox.Enabled = !locationCheckBox.Checked; okButton.Enabled = inputBox.TextLength > 0 || locationCheckBox.Checked; } @@ -56,8 +57,6 @@ private async void locationCheckBox_CheckedChanged(object sender, EventArgs e) { JsonConfig.settings.useWindowsLocation = true; locationCheckBox.Checked = true; - inputBox.Enabled = false; - okButton.Enabled = true; } locationCheckBox.CheckedChanged += locationCheckBox_CheckedChanged; @@ -65,7 +64,6 @@ private async void locationCheckBox_CheckedChanged(object sender, EventArgs e) else { JsonConfig.settings.useWindowsLocation = false; - inputBox.Enabled = true; } locationCheckBox.Enabled = true; @@ -86,6 +84,8 @@ private async void okButton_Click(object sender, EventArgs e) JsonConfig.settings.latitude = data.lat; JsonConfig.settings.longitude = data.lon; + this.Hide(); + if (ThemeManager.isReady) { AppContext.wcsService.RunScheduler(); @@ -106,8 +106,7 @@ private async void okButton_Click(object sender, EventArgs e) } else { - progressBar1.Visible = true; - + this.Hide(); bool locationUpdated = await UwpLocation.UpdateGeoposition(); if (locationUpdated) @@ -121,10 +120,10 @@ private async void okButton_Click(object sender, EventArgs e) } else { - progressBar1.Visible = false; - MessageBox.Show("Failed to get location from Windows location service.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); + + this.Show(); } } diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 66edcc5..ed5f8e5 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.2")] +[assembly: AssemblyVersion("2.1.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ThemeDialog.cs b/src/ThemeDialog.cs index 2d88d39..c29f401 100644 --- a/src/ThemeDialog.cs +++ b/src/ThemeDialog.cs @@ -124,7 +124,7 @@ private void LoadPreviewImage(int imageNumber) private void ThemeDialog_Load(object sender, EventArgs e) { darkModeCheckbox.Checked = JsonConfig.settings.darkMode; - string currentTheme = JsonConfig.settings.themeName ?? "Mojave_Desert"; + string currentTheme = JsonConfig.settings.themeName; ImageList imageList = new ImageList(); imageList.ColorDepth = ColorDepth.Depth32Bit; @@ -134,6 +134,18 @@ private void ThemeDialog_Load(object sender, EventArgs e) imageList.Images.Add(ShrinkImage(windowsWallpaper, 192, 108)); listView1.Items.Add("None", 0); + if (currentTheme == null) + { + if (JsonConfig.firstRun) + { + currentTheme = "Mojave_Desert"; + } + else + { + listView1.Items[0].Selected = true; + } + } + for (int i = 0; i < ThemeManager.themeSettings.Count; i++) { ThemeConfig theme = ThemeManager.themeSettings[i]; @@ -191,6 +203,8 @@ private void darkModeCheckbox_CheckedChanged(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e) { + okButton.Enabled = false; + string themeName = listView1.SelectedItems[0].Text.Replace(' ', '_'); JsonConfig.settings.themeName = themeName; JsonConfig.settings.darkMode = darkModeCheckbox.Checked; @@ -221,6 +235,7 @@ private void okButton_Click(object sender, EventArgs e) UwpDesktop.GetHelper().SetWallpaper(windowsWallpaper); } + okButton.Enabled = true; this.Close(); } @@ -241,6 +256,7 @@ private void OnFormClosing(object sender, FormClosingEventArgs e) if (result != DialogResult.Yes) { e.Cancel = true; + this.Show(); } } } diff --git a/src/WinDynamicDesktop.csproj b/src/WinDynamicDesktop.csproj index d2f87f6..190c14e 100644 --- a/src/WinDynamicDesktop.csproj +++ b/src/WinDynamicDesktop.csproj @@ -1,6 +1,6 @@  - + Debug @@ -38,8 +38,8 @@ WinDynamicDesktop.ico - - packages\Costura.Fody.3.1.5\lib\net46\Costura.dll + + packages\Costura.Fody.3.1.6\lib\net46\Costura.dll packages\DesktopBridge.Helpers.1.1\lib\net45\DesktopBridge.Helpers.dll @@ -167,10 +167,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + - - + \ No newline at end of file diff --git a/src/packages.config b/src/packages.config index 5214f59..4a7067f 100644 --- a/src/packages.config +++ b/src/packages.config @@ -1,9 +1,9 @@  - + - + diff --git a/uwp/Package.appxmanifest b/uwp/Package.appxmanifest index 2682d95..13f2090 100644 --- a/uwp/Package.appxmanifest +++ b/uwp/Package.appxmanifest @@ -1,6 +1,6 @@  - + WinDynamicDesktop Timothy Johnson