WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit b1842ed

Browse files
authored
Merge pull request #168 from reactivemarbles/CP_RemoveSystemWindowsForms
Remove System Windows Forms
2 parents 1868cc7 + 940a455 commit b1842ed

File tree

7 files changed

+35
-53
lines changed

7 files changed

+35
-53
lines changed

src/CrissCross.WPF.UI/Controls/AutoSuggestBox/AutoSuggestBox.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
Icon="{TemplateBinding Icon}"
124124
IconPlacement="Right"
125125
PlaceholderText="{TemplateBinding PlaceholderText}"
126-
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}" />
126+
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
127127

128128
<Popup
129129
x:Name="PART_SuggestionsPopup"

src/CrissCross.WPF.UI/Controls/IconElement/FontIcon.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ public string? Glyph
126126
/// <returns>A UIElement.</returns>
127127
protected override UIElement InitializeChildren()
128128
{
129-
if (VisualParent is not null)
130-
{
131-
FontSize = TextElement.GetFontSize(VisualParent);
132-
}
133-
134129
if (FontSize.Equals(SystemFonts.MessageFontSize))
135130
{
136131
SetResourceReference(FontSizeProperty, "DefaultIconFontSize");
132+
133+
// If the FontSize is the default, set it to the parent's FontSize.
134+
if (VisualParent is not null && TextElement.GetFontSize(VisualParent) != SystemFonts.MessageFontSize)
135+
{
136+
SetCurrentValue(FontSizeProperty, TextElement.GetFontSize(VisualParent));
137+
}
137138
}
138139

139140
TextBlock = new TextBlock

src/CrissCross.WPF.UI/Controls/ListBox/ListBoxItem.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
<ContentPresenter />
2828
</Border>
2929
<ControlTemplate.Triggers>
30+
<Trigger Property="IsMouseOver" Value="True">
31+
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MenuBarItemBackgroundSelected}" />
32+
</Trigger>
3033
<Trigger Property="IsSelected" Value="True">
3134
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListBoxItemSelectedBackgroundThemeBrush}" />
3235
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemSelectedForegroundThemeBrush}" />

src/CrissCross.WPF.UI/Controls/ListView/ListView.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class ListView : System.Windows.Controls.ListView
2828
/// <summary>Identifies the <see cref="ViewState"/> dependency property.</summary>
2929
public static readonly DependencyProperty ViewStateProperty = DependencyProperty.Register(nameof(ViewState), typeof(ListViewViewState), typeof(ListView), new FrameworkPropertyMetadata(ListViewViewState.Default, OnViewStateChanged));
3030

31+
private DependencyPropertyDescriptor? _descriptor;
32+
3133
static ListView() => DefaultStyleKeyProperty.OverrideMetadata(typeof(ListView), new FrameworkPropertyMetadata(typeof(ListView)));
3234

3335
/// <summary>
@@ -66,12 +68,23 @@ private static void OnViewStateChanged(DependencyObject d, DependencyPropertyCha
6668

6769
private void OnLoaded(object sender, RoutedEventArgs e)
6870
{
69-
Loaded -= OnLoaded; // prevent memory leaks
71+
// prevent memory leaks
72+
Loaded -= OnLoaded;
73+
Unloaded += OnUnloaded;
7074

7175
// Setup initial ViewState and hook into View property changes
72-
var descriptor = DependencyPropertyDescriptor.FromProperty(System.Windows.Controls.ListView.ViewProperty, typeof(System.Windows.Controls.ListView));
73-
descriptor?.AddValueChanged(this, OnViewPropertyChanged);
74-
UpdateViewState(); // set the initial state
76+
_descriptor = DependencyPropertyDescriptor.FromProperty(System.Windows.Controls.ListView.ViewProperty, typeof(System.Windows.Controls.ListView));
77+
_descriptor?.AddValueChanged(this, OnViewPropertyChanged);
78+
79+
// set the initial state
80+
UpdateViewState();
81+
}
82+
83+
private void OnUnloaded(object sender, RoutedEventArgs e)
84+
{
85+
Unloaded -= OnUnloaded;
86+
87+
_descriptor?.RemoveValueChanged(this, OnViewPropertyChanged);
7588
}
7689

7790
private void OnViewPropertyChanged(object? sender, EventArgs e) => UpdateViewState();

src/CrissCross.WPF.UI/Controls/NumberPad/NumberPad.xaml.cs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public NumberPad(INumberPadButton newOwner)
9999
if (Value.Value.HasValue && Value.Value!.Value <= _owner.Maximum && Value.Value.Value >= _owner.Minimum)
100100
{
101101
_limitsTimer?.Stop();
102-
////Value.Background = Brushes.White;
103102
}
104103
},
105104
Dispatcher);
@@ -319,41 +318,14 @@ private void Showkeypad()
319318
{
320319
// Get the current screen
321320
WindowInteropHelper wih = new(window);
322-
323-
// TODO: Replace WinForms with Native calls
324-
////var monitor = MonitorFromWindow(wih.Handle, MONITOR_DEFAULTTONEAREST);
325-
326-
////var monitorInfo = new NativeMonitorInfo();
327-
////if (monitor != IntPtr.Zero)
328-
////{
329-
//// GetMonitorInfo(monitor, monitorInfo);
330-
331-
//// var left = monitorInfo.Monitor.Left;
332-
//// var top = monitorInfo.Monitor.Top;
333-
//// var width = monitorInfo.Monitor.Right - monitorInfo.Monitor.Left;
334-
//// var height = monitorInfo.Monitor.Bottom - monitorInfo.Monitor.Top;
335-
////}
336-
337-
var screen = System.Windows.Forms.Screen.FromHandle(wih.Handle);
338-
339-
// Get all the screens and identify the primary
340-
List<System.Drawing.Rectangle> screens = [];
341-
var primaryScreen = -1;
342-
var scr = 0;
343-
foreach (var s in System.Windows.Forms.Screen.AllScreens)
321+
if (User32.MonitorFromWindow(wih.Handle, User32.MONITOR_DEFAULTTONEAREST) is IntPtr monitor && monitor != IntPtr.Zero)
344322
{
345-
screens.Add(s.Bounds);
346-
if (s.Primary)
347-
{
348-
primaryScreen = scr;
349-
}
323+
var monitorInfo = new User32.NativeMonitorInfo();
324+
User32.GetMonitorInfo(monitor, monitorInfo);
350325

351-
scr++;
326+
Left = monitorInfo.Monitor.Left;
327+
Top = monitorInfo.Monitor.Top;
352328
}
353-
354-
Top = screen.Bounds.Location.Y;
355-
var curScreen = screens.FindIndex(x => x == screen.Bounds);
356-
Left = curScreen <= primaryScreen ? screen.Bounds.Location.X : screen.Bounds.Width;
357329
}
358330
else
359331
{
@@ -369,12 +341,10 @@ private void Showkeypad()
369341
if (window != null && button != null && presentationSource != null)
370342
{
371343
var ownerPosition = button.TransformToAncestor(presentationSource.RootVisual).Transform(new Point(0, 0));
372-
var windowPosition = window.PointToScreen(default);
373344

374345
// Set the top position of the Keypad
375346
_margin[1] = ownerPosition.Y - 100;
376347

377-
// WGrid.Height = 366
378348
if ((_margin[1] + WGrid.Height) > window.ActualHeight)
379349
{
380350
_margin[1] = window.ActualHeight - WGrid.Height - 10;
@@ -392,7 +362,6 @@ private void Showkeypad()
392362
_margin[2] = ownerPosition.X + button.ActualWidth + 10;
393363
}
394364

395-
// WGrid.Width = 206
396365
if ((_margin[2] + WGrid.Width) > (window.ActualWidth - 10))
397366
{
398367
// Set location to left of button if the location + with of keypad will be off

src/CrissCross.WPF.UI/Controls/NumericPushButton/NumericPushButton.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class NumericPushButton : System.Windows.Controls.Button, INumberPadButto
1717
/// <summary>
1818
/// Defaults decimal points.
1919
/// </summary>
20-
public static readonly DependencyProperty DecimalPlaceProperty =
20+
public static readonly DependencyProperty DecimalPlacesProperty =
2121
DependencyProperty.Register(
2222
nameof(DecimalPlaces),
2323
typeof(int),
@@ -202,9 +202,9 @@ public NumericPushButton()
202202
[Category("Common")]
203203
public int DecimalPlaces
204204
{
205-
get => (int)GetValue(DecimalPlaceProperty);
205+
get => (int)GetValue(DecimalPlacesProperty);
206206

207-
set => SetValue(DecimalPlaceProperty, value);
207+
set => SetValue(DecimalPlacesProperty, value);
208208
}
209209

210210
/// <summary>

src/CrissCross.WPF.UI/CrissCross.WPF.UI.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
<DefineConstants>$(DefineConstants);LACKS_STREAM_MEMORY_OVERLOADS</DefineConstants>
1616
</PropertyGroup>
1717

18-
<ItemGroup Condition="$(TargetFramework.StartsWith('net46'))">
19-
<Reference Include="System.Windows.Forms" />
20-
</ItemGroup>
21-
2218
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
2319
<PackageReference Include="System.Net.Http" Version="4.3.4" />
2420
</ItemGroup>

0 commit comments

Comments
 (0)