Clean up warnings

This commit is contained in:
amwx
2026-05-16 21:45:45 -04:00
parent de1d85deff
commit 818497c381
16 changed files with 57 additions and 309 deletions
@@ -47,8 +47,9 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Watermark="{TemplateBinding Watermark}"
UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
PlaceholderText="{TemplateBinding PlaceholderText}"
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
@@ -213,7 +213,7 @@
SelectedItem="{Binding SelectedFilter}"
Margin="2 0 0 0"/>
<TextBox Text="{Binding FileName}"
Watermark="File name"
PlaceholderText="File name"
IsVisible="{Binding !SelectingFolder}"
Margin="0 0 2 0"/>
</DockPanel>
@@ -116,7 +116,7 @@
BorderBrush="Transparent"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Watermark="{TemplateBinding PlaceholderText}"
PlaceholderText="{TemplateBinding PlaceholderText}"
Foreground="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay}"
IsVisible="False"
@@ -429,7 +429,7 @@
Grid.Row="1"
Grid.ColumnSpan="3"
Foreground="{TemplateBinding Foreground}"
Watermark="{TemplateBinding PlaceholderText}"
PlaceholderText="{TemplateBinding PlaceholderText}"
DataValidationErrors.Errors="{TemplateBinding DataValidationErrors.Errors}"
SelectionBrush="{TemplateBinding SelectionHighlightColor}"
FontSize="{TemplateBinding FontSize}"
@@ -289,11 +289,15 @@ public partial class FAComboBox : HeaderedSelectingItemsControl
{
if (_popup?.IsInsidePopup(src) == true)
{
if (UpdateSelectionFromEventSource(e.Source))
var container = GetContainerFromEventSource(e.Source);
if (container != null)
{
_popup.Close();
e.Handled = true;
}
if (UpdateSelectionFromEvent(container, e))
{
_popup.Close();
e.Handled = true;
}
}
}
else
{
@@ -85,7 +85,7 @@ public partial class FABitmapIcon : FAIconElement
skDC.Clear(new SKColor(0, 0, 0, 0));
var finalBmp = _bitmap.Resize(new SKImageInfo(wid, hei), SKFilterQuality.High);
var finalBmp = _bitmap.Resize(new SKImageInfo(wid, hei), new SKSamplingOptions(SKCubicResampler.Mitchell));
if (ShowAsMonochrome)
{
@@ -742,7 +742,7 @@ public partial class FAItemsRepeater : Panel
// Bug in framework's reference tracking causes crash during
// UIAffinityQueue cleanup. To avoid that bug, take a strong ref
private IFAElementFactory _itemTemplate;
//private IFAElementFactory _itemTemplate;
// Bug where DataTemplate with no content causes a crash.
// See: https://github.com/microsoft/microsoft-ui-xaml/issues/776
@@ -339,7 +339,7 @@ internal class ViewportManager
}
// Register to rendering event to go back to how things were before where any child can be the anchor.
_isBringIntoViewInProgress = true;
//_isBringIntoViewInProgress = true;
if (!_renderingToken)
{
_renderingToken = true;
@@ -383,7 +383,7 @@ internal class ViewportManager
_renderingToken = false;
//CompositionTarget.Rendering -= OnCompositionTargetRendering;
_isBringIntoViewInProgress = false;
//_isBringIntoViewInProgress = false;
_makeAnchorElement = null;
// Now that the item has been brought into view, we can let the anchor provider pick a new anchor.
@@ -581,7 +581,7 @@ internal class ViewportManager
private double _horizontalCacheBufferPerSide;
private double _verticalCacheBufferPerSide;
private bool _isBringIntoViewInProgress = false;
//private bool _isBringIntoViewInProgress = false;
// For non-virtualizing layouts, we do not need to keep
// updating viewports and invalidating measure often. So when
// a non virtualizing layout is used, we stop doing all that work.
@@ -67,7 +67,7 @@ public partial class FATabView : TemplatedControl
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
UnhookEventsAndClearFields();
_isItemBeingDragged = false;
//_isItemBeingDragged = false;
_isItemDraggedOver = false;
_expandedWidthForDragOver = null;
@@ -770,7 +770,7 @@ public partial class FATabView : TemplatedControl
private void OnListViewDragItemsStarting(object sender, DragItemsStartingEventArgs args)
{
_isItemBeingDragged = true;
//_isItemBeingDragged = true;
var item = args.Items[0];
var tab = FindTabViewItemFromDragItem(item);
@@ -815,7 +815,7 @@ public partial class FATabView : TemplatedControl
private void OnListViewDragItemsCompleted(object sender, DragItemsCompletedEventArgs args)
{
_isItemBeingDragged = false;
//_isItemBeingDragged = false;
// Selection may have changed during drag if dragged outside, so we update SelectedIndex again.
if (_listView != null)
@@ -1001,10 +1001,10 @@ public partial class FATabView : TemplatedControl
{
// Don't update any tab widths when we're in the middle of a tab tear-out loop -
// we'll update tab widths when it's done.
if (_isInTabTearOutLoop)
{
return;
}
//if (_isInTabTearOutLoop)
//{
// return;
//}
var maxTabWidth = this.TryFindResource(c_tabViewItemMaxWidthName, out var mtw) ? (double)mtw : c_tabMaximumWidth;
double tabWidth = double.NaN;
@@ -1665,14 +1665,14 @@ public partial class FATabView : TemplatedControl
private Button _addButton;
private ItemsPresenter _itemsPresenter;
private Border _verticalPaneResizeHandle;
private SplitView _splitView;
//private SplitView _splitView;
private bool _isDraggingPane;
private Point? _initDragPanePoint;
private double _startingPaneSize;
private bool _isSwitchingTabLocation;
private int _selectedIndexBeforeTabSwitch = -1;
//private int _selectedIndexBeforeTabSwitch = -1;
// A bunch of event revokers
private IDisposable _listViewCanReorderItemsPropertyChangedRevoker;
@@ -1681,12 +1681,10 @@ public partial class FATabView : TemplatedControl
private Size _previousAvailableSize;
private bool _isDragging = false;
private bool _isItemBeingDragged;
//private bool _isItemBeingDragged;
private bool _isItemDraggedOver;
private double? _expandedWidthForDragOver;
private bool _isInTabTearOutLoop;
private Size _lastItemsPresenterSize;
//private bool _isInTabTearOutLoop;
private static double c_tabMinimumWidth = 48d;
private static double c_tabMaximumWidth = 200d;
@@ -388,12 +388,12 @@ public partial class FATabViewItem : FASelectorItem
private void OnTabDragStarting(FATabView sender, FATabViewTabDragStartingEventArgs args)
{
_isBeingDragged = true;
//_isBeingDragged = true;
}
private void OnTabDragCompleted(FATabView sender, FATabViewTabDragCompletedEventArgs args)
{
_isBeingDragged = false;
//_isBeingDragged = false;
StopCheckingForDrag(_dragPointerId);
UpdateDragDropVisualState(false);
@@ -614,18 +614,16 @@ public partial class FATabViewItem : FASelectorItem
}
private Button _closeButton;
private object _toolTip;
private ContentPresenter _headerContentPresenter;
private FATabViewWidthMode _tabViewWidthMode = FATabViewWidthMode.Equal;
private FATabViewCloseButtonOverlayMode _closeButtonOverlayMode = FATabViewCloseButtonOverlayMode.Auto;
private bool _firstTimeSettingToolTip = true;
private FACompositeDisposable _tabDragRevoker;
private Path _selectedBackgroundPath;
private FATabViewTabStripLocation _location;
private bool _hasPointerCapture = false;
private bool _isMiddlePointerButtonPressed = false;
private bool _isBeingDragged = false;
//private bool _isBeingDragged = false;
private bool _isPointerOver = false;
private Point _lastPointerPressedPosition;
private int _dragPointerId;
@@ -844,7 +844,6 @@ public sealed class FATabViewListView : ListBox
private bool _isInDrag = false;
private bool _isInReorder = false;
private IDisposable _dragItemOpacitySub;
private bool _processReorder;
private Point? _initialPoint;
private double _cxDrag = double.NaN;
private double _cyDrag = double.NaN;
@@ -853,11 +852,7 @@ public sealed class FATabViewListView : ListBox
// True if there is a drag drop operation started by this listview
private bool _isDraggingOverSelf;
private LiveReorderHelper _liveReorderHelper;
//private LiveReorderIndices _liveReorderIndices = new LiveReorderIndices(-1,-1,-1);
private DispatcherTimer _liveReorderTimer;
//private readonly MovedItems _movedItems = new MovedItems();
//private List<Rect> _cachedContainerBounds;
private LiveReorderHelper _liveReorderHelper;
private Point? _lastDragOverPoint;
// For 12.0/v3 - Avalonia has decided to make the decision that the lowest common denominator
+19 -19
View File
@@ -1115,10 +1115,10 @@ public struct Color2 : IEquatable<Color2>
{
Color2 newColor = new Color2();
newColor._cType = ColorType.RGB;
newColor._c1 = FAMathHelpers.Clamp(r, 0, 1);
newColor._c2 = FAMathHelpers.Clamp(g, 0, 1);
newColor._c3 = FAMathHelpers.Clamp(b, 0, 1);
newColor._alpha = FAMathHelpers.Clamp(a, 0, 1);
newColor._c1 = float.Clamp(r, 0, 1);
newColor._c2 = float.Clamp(g, 0, 1);
newColor._c3 = float.Clamp(b, 0, 1);
newColor._alpha = float.Clamp(a, 0, 1);
return newColor;
}
@@ -1162,10 +1162,10 @@ public struct Color2 : IEquatable<Color2>
{
Color2 newColor = new Color2();
newColor._cType = ColorType.HSV;
newColor._c1 = hue == -1 ? 0 : FAMathHelpers.Clamp(hue % 360, 0, 360);
newColor._c2 = FAMathHelpers.Clamp(sat, 0, 1);
newColor._c3 = FAMathHelpers.Clamp(val, 0, 1);
newColor._alpha = FAMathHelpers.Clamp(alpha, 0, 1);
newColor._c1 = hue == -1 ? 0 : float.Clamp(hue % 360, 0, 360);
newColor._c2 = float.Clamp(sat, 0, 1);
newColor._c3 = float.Clamp(val, 0, 1);
newColor._alpha = float.Clamp(alpha, 0, 1);
return newColor;
}
@@ -1194,10 +1194,10 @@ public struct Color2 : IEquatable<Color2>
{
Color2 newColor = new Color2();
newColor._cType = ColorType.HSL;
newColor._c1 = hue == -1 ? 0 : FAMathHelpers.Clamp(hue % 360, 0, 360);
newColor._c2 = FAMathHelpers.Clamp(sat, 0, 1);
newColor._c3 = FAMathHelpers.Clamp(light, 0, 1);
newColor._alpha = FAMathHelpers.Clamp(alpha, 0, 1);
newColor._c1 = hue == -1 ? 0 : float.Clamp(hue % 360, 0, 360);
newColor._c2 = float.Clamp(sat, 0, 1);
newColor._c3 = float.Clamp(light, 0, 1);
newColor._alpha = float.Clamp(alpha, 0, 1);
return newColor;
}
@@ -1228,11 +1228,11 @@ public struct Color2 : IEquatable<Color2>
{
Color2 newColor = new Color2();
newColor._cType = ColorType.CMYK;
newColor._c1 = FAMathHelpers.Clamp(c, 0, 1);
newColor._c2 = FAMathHelpers.Clamp(m, 0, 1);
newColor._c3 = FAMathHelpers.Clamp(y, 0, 1);
newColor._c4 = FAMathHelpers.Clamp(k, 0, 1);
newColor._alpha = FAMathHelpers.Clamp(alpha, 0, 1);
newColor._c1 = float.Clamp(c, 0, 1);
newColor._c2 = float.Clamp(m, 0, 1);
newColor._c3 = float.Clamp(y, 0, 1);
newColor._c4 = float.Clamp(k, 0, 1);
newColor._alpha = float.Clamp(alpha, 0, 1);
return newColor;
}
@@ -1358,7 +1358,7 @@ public struct Color2 : IEquatable<Color2>
return ToHSL().Lighten(amount);
var l = _c3 + amount;
FAMathHelpers.Clamp(l, 0, 1);
float.Clamp(l, 0, 1);
return FromHSLf(_c1, _c2, l, _alpha);
}
@@ -1374,7 +1374,7 @@ public struct Color2 : IEquatable<Color2>
return ToHSL().LightenPercent(percent);
var l = _c3 < EPSILON ? percent : _c3 + (_c3 * percent);
FAMathHelpers.Clamp(l, 0, 1);
float.Clamp(l, 0, 1);
return FromHSLf(_c1, _c2, l, _alpha);
}
@@ -289,6 +289,4 @@ public partial class FAAppWindow : Window
PseudoClasses.Set(":splashOpen", false);
_splashContext.HasShownSplashScreen = true;
}
private bool _hasShown;
}
@@ -105,22 +105,18 @@ public partial class FAAppWindow : Window
protected override Type StyleKeyOverride => typeof(FAAppWindow);
internal FAMinMaxCloseControl SystemCaptionControl => _captionButtons;
private SplashScreenContext _splashContext;
private Border _templateRoot;
private FAMinMaxCloseControl _captionButtons;
private Panel _defaultTitleBar;
private FAAppWindowTitleBar _titleBar;
private List<WeakReference<Control>> _excludeHitTestList;
private bool _hideSizeButtons;
// Resource names used in SetTitleBarColors
private static readonly string s_SystemAccentColor = "SystemAccentColor";
private static readonly string s_SystemAccentColorLight1 = "SystemAccentColorLight1";
private static readonly string s_SystemAccentColorDark1 = "SystemAccentColorDark1";
private static readonly string s_TextFillColorPrimary = "TextFillColorPrimary";
//private static readonly string s_SystemAccentColor = "SystemAccentColor";
//private static readonly string s_SystemAccentColorLight1 = "SystemAccentColorLight1";
//private static readonly string s_SystemAccentColorDark1 = "SystemAccentColorDark1";
//private static readonly string s_TextFillColorPrimary = "TextFillColorPrimary";
private static readonly string s_TitleBarBackground = "TitleBarBackground";
private static readonly string s_TitleBarForeground = "TitleBarForeground";
@@ -1,236 +0,0 @@
using Avalonia.Controls;
using Avalonia;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Input;
using FluentAvalonia.Core;
namespace FluentAvalonia.UI.Windowing;
/// <summary>
/// Represents the caption buttons for a <see cref="FAAppWindow"/>
/// </summary>
public class FAMinMaxCloseControl : TemplatedControl
{
public FAMinMaxCloseControl()
{
KeyboardNavigation.SetIsTabStop(this, false);
}
internal Button MinimizeButton => _minimizeButton;
internal Button MaximizeButton => _maximizeButton;
internal Button CloseButton => _closeButton;
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
_minimizeButton?.Click -= OnButtonClick;
_maximizeButton?.Click -= OnButtonClick;
_closeButton?.Click -= OnButtonClick;
base.OnApplyTemplate(e);
// Changed to.Get<>(), template shouldn't be messed with to extent these items aren't found
// anymore, so throw if we have an invalid template
_minimizeButton = e.NameScope.Get<Button>("MinimizeButton");
_minimizeButton.Click += OnButtonClick;
_maximizeButton = e.NameScope.Get<Button>("MaxRestoreButton");
_maximizeButton.Click += OnButtonClick;
_closeButton = e.NameScope.Get<Button>("CloseButton");
_closeButton.Click += OnButtonClick;
// MinMaxCloseControl should only be used in Template of AppWindow - so TemplatedParent
// here should A) never be null, and B) Always be AppWindow
_owner = TemplatedParent as FAAppWindow;
_owner.Opened += OwnerWindowOpened;
if (_owner.ShowAsDialog)
{
_minimizeButton.IsVisible = false;
_maximizeButton.IsVisible = false;
}
}
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnDetachedFromVisualTree(e);
_windowStateObservable?.Dispose();
_windowStateObservable = null;
}
private void OwnerWindowOpened(object sender, EventArgs args)
{
_windowStateObservable = new FACompositeDisposable(
_owner.GetObservable(Window.WindowStateProperty).Subscribe(OnWindowStateChanged),
_owner.GetObservable(WindowBase.IsActiveProperty).Subscribe(OnWindowActiveChanged));
}
private void OnButtonClick(object sender, RoutedEventArgs e)
{
if (_owner == null)
return;
if (sender == _minimizeButton)
{
_owner.WindowState = WindowState.Minimized;
}
else if (sender == _maximizeButton)
{
if (_owner.WindowState == WindowState.Maximized)
{
_owner.WindowState = WindowState.Normal;
}
else if (_owner.WindowState == WindowState.Normal)
{
_owner.WindowState = WindowState.Maximized;
}
}
else if (sender == _closeButton)
{
_owner.Close();
}
}
private void OnWindowStateChanged(WindowState state)
{
PseudoClasses.Set(":maximized", state == WindowState.Maximized);
PseudoClasses.Set(":fullscreen", state == WindowState.FullScreen);
}
private void OnWindowActiveChanged(bool active)
{
((IPseudoClasses)MinimizeButton.Classes).Set(":inactive", !active);
((IPseudoClasses)MaximizeButton.Classes).Set(":inactive", !active);
((IPseudoClasses)CloseButton.Classes).Set(":inactive", !active);
}
internal CaptionButton HitTest(Point p)
{
if (_maximizeButton == null)
return CaptionButton.None;
var mat = this.TransformToVisual(_owner).Value;
var bnds = new Rect(Bounds.Size).TransformToAABB(mat);
if (bnds.Contains(p))
{
if (HitTestMaxButton(p))
{
return CaptionButton.Maximize;
}
else if (HitTestMinButton(p))
{
return CaptionButton.Minimize;
}
else if (HitTestCloseButton(p))
{
return CaptionButton.Close;
}
}
return CaptionButton.None;
}
internal bool HitTestMaxButton(Point pos)
{
if (_maximizeButton == null)
return false;
var mat = _maximizeButton.TransformToVisual(_owner).Value;
var bnds = new Rect(_maximizeButton.Bounds.Size).TransformToAABB(mat);
return bnds.Contains(pos);
}
internal bool HitTestMinButton(Point pos)
{
if (_minimizeButton == null)
return false;
var mat = _minimizeButton.TransformToVisual(_owner).Value;
var bnds = new Rect(_minimizeButton.Bounds.Size).TransformToAABB(mat);
return bnds.Contains(pos);
}
internal bool HitTestCloseButton(Point pos)
{
if (_closeButton == null)
return false;
var mat = _closeButton.TransformToVisual(_owner).Value;
var bnds = new Rect(_closeButton.Bounds.Size).TransformToAABB(mat);
return bnds.Contains(pos);
}
internal void ClearButtonState()
{
ClearButtonState(CaptionButton.Maximize);
ClearButtonState(CaptionButton.Minimize);
ClearButtonState(CaptionButton.Close);
}
internal void ClearButtonState(CaptionButton button)
{
FakeButtonHover(button, false);
FakeButtonPressed(button, false);
}
internal void FakeButtonHover(CaptionButton b, bool hover)
{
var button = GetButton(b);
if (button != null)
{
((IPseudoClasses)button.Classes).Set(":pointerover", hover);
}
}
internal void FakeButtonPressed(CaptionButton b, bool pressed)
{
var button = GetButton(b);
if (button != null)
{
((IPseudoClasses)button.Classes).Set(":pressed", pressed);
}
}
internal void FakeButtonClick(CaptionButton b)
{
var button = GetButton(b);
if (button != null)
OnButtonClick(button, null);
}
private Button GetButton(CaptionButton b)
{
return b switch
{
CaptionButton.Maximize => _maximizeButton,
CaptionButton.Minimize => _minimizeButton,
CaptionButton.Close => _closeButton,
_ => null
};
}
private IDisposable _windowStateObservable;
private FAAppWindow _owner;
private Button _minimizeButton;
private Button _maximizeButton;
private Button _closeButton;
}
internal enum CaptionButton
{
None,
Minimize,
Maximize,
Close
}
@@ -2,10 +2,8 @@
using Avalonia.Controls;
using FluentAvalonia.Interop.Win32;
using Avalonia;
using Avalonia.Logging;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Avalonia.Threading;
using Avalonia.Platform;
using FluentAvalonia.Interop;
@@ -136,11 +134,7 @@ internal unsafe class Win32WindowManager
private readonly FAAppWindow _window;
private bool _isMaximized;
private CaptionButton _fakingButton;
private CaptionButton _currentDownButton;
private readonly nint _oldWndProc;
private readonly nint _wndProc;
private RECT _restoreRect;
}