Skip to content

Commit

Permalink
Fixed: Can't update ColorPicker (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Aug 6, 2021
1 parent 5a2a0ef commit 5b178ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions ColorPicker/Pages/PickerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ private void HandleSelectKeyboard()
if (isRunning)
{
dispatcherTimer.Stop();
miniPicker.timer.Stop(); // Stop
miniPicker.Hide();
isRunning = false;
SelectColorBtn.Content = Properties.Resources.SelectColor; // Set text
}
else
{
dispatcherTimer.Start();
miniPicker.timer.Start(); // Start
miniPicker.Show();
isRunning = true;
SelectColorBtn.Content = Properties.Resources.Stop; // Set text
Expand Down Expand Up @@ -172,22 +174,24 @@ private void BlueSlider_ValueChanged(object sender, RoutedPropertyChangedEventAr
HEXTxt.Text = $"{Properties.Resources.HEXP} #{(u ? h.Value.ToUpper() : h.Value)}";
}

MiniPicker miniPicker = new(); // MiniPicker window
internal MiniPicker miniPicker = new(); // MiniPicker window
private void SelectColorBtn_Click(object sender, RoutedEventArgs e)
{
if (!isRunning)
{
dispatcherTimer.Start(); // Start
miniPicker.timer.Start(); // Start
SelectColorBtn.Content = Properties.Resources.Stop; // Set text
isRunning = true;

miniPicker.Left = Env.GetMouseCursorPositionWPF().X; // Define position
miniPicker.Top = Env.GetMouseCursorPositionWPF().Y; // Define position
miniPicker.Show(); // Show
}
else
{
dispatcherTimer.Stop(); // Stop
miniPicker.timer.Stop(); // Stop
SelectColorBtn.Content = Properties.Resources.SelectColor; // Set text
isRunning = false;
miniPicker.Hide(); // Hide
Expand Down
2 changes: 2 additions & 0 deletions ColorPicker/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ MIT License
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -59,6 +60,7 @@ public SettingsPage()
string lastVersion = await Update.GetLastVersionAsync(Global.LastVersionLink); // Get last version
if (MessageBox.Show(Properties.Resources.InstallConfirmMsg, $"{Properties.Resources.InstallVersion} {lastVersion}", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
Global.PickerPage.miniPicker.Close();
Env.ExecuteAsAdmin(Directory.GetCurrentDirectory() + @"\Xalyus Updater.exe"); // Start the updater
Environment.Exit(0); // Close
}
Expand Down
4 changes: 1 addition & 3 deletions ColorPicker/Windows/MiniPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ColorPicker.Windows
/// </summary>
public partial class MiniPicker : Window
{
DispatcherTimer timer = new() { Interval = new(0, 0, 0, 0, 1) };
internal DispatcherTimer timer = new() { Interval = new(0, 0, 0, 0, 1) };
bool u = Global.Settings.HEXUseUpperCase.Value;
public MiniPicker()
{
Expand All @@ -69,8 +69,6 @@ public MiniPicker()
BlueTxt.Text = $"{Properties.Resources.BlueP} {pixel.B}"; // Set text
HEXTxt.Text = $"{Properties.Resources.HEXP} #{(u ? hexColor.Value.ToUpper() : hexColor.Value)}"; // Set text
};

timer.Start();
}
}
}

0 comments on commit 5b178ad

Please sign in to comment.