Skip to content

Commit

Permalink
Migrate Search box to WPF control (#2917)
Browse files Browse the repository at this point in the history
* Replaced UWP searchbox with WPF

* Updated foreground color scheme for textbox

* Add focus on visibility changed

* Updated initial hiding of window

* Fixed list box border

* vis issue on start, fixing border

* Revert "Merge branch 'somil55/MigrateSearchBoxToWPF' into fewTweaks"

This reverts commit 3525171, reversing
changes made to b5daffc.

* Remove change in startup visibility

Co-authored-by: Clint Rutkas <clint@rutkas.com>
  • Loading branch information
dsrivastavv and crutkas committed May 12, 2020
1 parent 245b52d commit a1e1d66
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 345 deletions.
2 changes: 0 additions & 2 deletions src/modules/launcher/PowerLauncher.UI/LauncherControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
ActualThemeChanged="UserControl_ActualThemeChanged"
Loaded="UserControl_Loaded"
d:DesignHeight="300"
d:DesignWidth="720">
<UserControl.Resources>
Expand Down
40 changes: 1 addition & 39 deletions src/modules/launcher/PowerLauncher.UI/LauncherControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,12 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace PowerLauncher.UI
{
public sealed partial class LauncherControl : UserControl, INotifyPropertyChanged
public sealed partial class LauncherControl : UserControl
{
private Brush _borderBrush;

public LauncherControl()
{
InitializeComponent();
}

public Brush SolidBorderBrush
{
get { return _borderBrush; }
set { Set(ref _borderBrush, value); }
}

private void Set<T>(ref T storage, T value, [CallerMemberName]string propertyName = null)
{
if (Equals(storage, value))
{
return;
}

storage = value;
OnPropertyChanged(propertyName);
}

private void UserControl_ActualThemeChanged(FrameworkElement sender, object args)
{
SolidBorderBrush = Application.Current.Resources["SystemChromeLow"] as SolidColorBrush;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
SolidBorderBrush = Application.Current.Resources["SystemChromeLow"] as SolidColorBrush;
}

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
3 changes: 2 additions & 1 deletion src/modules/launcher/PowerLauncher.UI/ResultList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:ToolkitBehaviors="using:Microsoft.Toolkit.Uwp.UI.Animations.Behaviors"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
Loaded="UserControl_Loaded"
ActualThemeChanged="UserControl_ActualThemeChanged"
d:DesignHeight="300"
d:DesignWidth="720">
<UserControl.Resources>
Expand Down
50 changes: 49 additions & 1 deletion src/modules/launcher/PowerLauncher.UI/ResultList.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
using Microsoft.PowerLauncher.Telemetry;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Media;

namespace PowerLauncher.UI
{
public sealed partial class ResultList : UserControl
{
private Brush _borderBrush;

private Brush _primaryTextColor;

private LauncherResultActionEvent.TriggerType triggerType = LauncherResultActionEvent.TriggerType.Click;

public ResultList()
{
InitializeComponent();
Expand Down Expand Up @@ -41,5 +50,44 @@ private void ContextButton_OnClick(object sender, Windows.UI.Xaml.RoutedEventArg
//Restore the trigger type back to click
triggerType = LauncherResultActionEvent.TriggerType.Click;
}

public Brush SolidBorderBrush
{
get { return _borderBrush; }
set { Set(ref _borderBrush, value); }
}

public Brush PrimaryTextColor
{
get { return _primaryTextColor; }
set { Set(ref _primaryTextColor, value); }
}

private void Set<T>(ref T storage, T value, [CallerMemberName]string propertyName = null)
{
if (Equals(storage, value))
{
return;
}

storage = value;
OnPropertyChanged(propertyName);
}

private void UserControl_ActualThemeChanged(FrameworkElement sender, object args)
{
SolidBorderBrush = Application.Current.Resources["SystemChromeLow"] as SolidColorBrush;
PrimaryTextColor = Application.Current.Resources["PrimaryTextColor"] as SolidColorBrush;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
SolidBorderBrush = Application.Current.Resources["SystemChromeLow"] as SolidColorBrush;
PrimaryTextColor = Application.Current.Resources["PrimaryTextColor"] as SolidColorBrush;
}

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

0 comments on commit a1e1d66

Please sign in to comment.