From 303e6180d4f3d88e0feafc9515cae3be8117d2e7 Mon Sep 17 00:00:00 2001
From: chr <chrry550@163.com>
Date: 星期四, 07 三月 2024 16:30:18 +0800
Subject: [PATCH] 添加不同平台的行尾文件;
---
Controls/InnerWindow.xaml.cs | 135 +++++++++++++++++++++++++-------------------
1 files changed, 76 insertions(+), 59 deletions(-)
diff --git a/Controls/InnerWindow.xaml.cs b/Controls/InnerWindow.xaml.cs
index db9ee1c..6c89b76 100644
--- a/Controls/InnerWindow.xaml.cs
+++ b/Controls/InnerWindow.xaml.cs
@@ -1,13 +1,18 @@
-锘縰sing CommonModel;
+锘縰sing HandyControl.Controls;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Documents;
+using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Shapes;
using WPFProject.Models;
using WPFProject.UI.Test;
using WPFProject.Utils;
+using static WPFProject.Utils.Resize.Resizeable;
namespace WPFProject.Controls
{
@@ -15,7 +20,8 @@
/// InnerWindow.xaml 鐨勪氦浜掗�昏緫
/// </summary>
public partial class InnerWindow : UserControl, INotifyPropertyChanged
- {
+ {
+ #region INotifyPropertyChanged
public virtual event PropertyChangedEventHandler PropertyChanged;
protected virtual void RaisePropertyChanged(string name)
@@ -30,36 +36,46 @@
{
RaisePropertyChanged(propertyName);
}
- }
-
- public CanvasPosition canvasPosition;
-
+ }
+ #endregion
+
+ #region 灞炴��
+
+ #region Common
public DragType DragType { get; set; } = DragType.Canvas;
-
- private int _Zindex;
-
- public int Zindex
- {
- get { return _Zindex; }
- set => RaiseAndSetIfChanged(ref _Zindex, value);
- }
-
-
- public event EventHandler MinEvent;
- public event EventHandler MaxEvent;
- public event EventHandler CloseEvent;
- public event EventHandler ZIndexEvent;
-
+ public CanvasPosition canvasPosition;
+ private Canvas canvas;
public WindowState WindowState { get; set; } = WindowState.Normal;
-
+ public AdornerDecorator ResizeAdornerDecorator { get => VisualTreeHelper.GetChild(this, 0) as AdornerDecorator; }
+
private string _Title;
-
public string Title
{
get { return _Title; }
set => RaiseAndSetIfChanged(ref _Title, value);
- }
-
+ }
+
+ public int Zindex
+ {
+ get
+ {
+ return Canvas.GetZIndex(this);
+ }
+ set
+ {
+ Canvas.SetZIndex(this, value);
+ }
+ }
+ #endregion
+
+ #region 浜嬩欢
+ public event EventHandler MinEvent;
+ public event EventHandler MaxEvent;
+ public event EventHandler CloseEvent;
+ public event EventHandler ZIndexEvent;
+ #endregion
+
+ #region DependencyProperty
public Brush HeaderBackground
{
get { return (Brush)GetValue(HeaderBackgroundProperty); }
@@ -78,8 +94,11 @@
public static readonly DependencyProperty HeaderFontColorProperty =
DependencyProperty.Register("HeaderFontColor", typeof(Brush), typeof(ProgramList),
- new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 255, 225))));
-
+ new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 255, 225))));
+ #endregion
+
+ #endregion
+
public InnerWindow() : this(null)
{
@@ -96,13 +115,7 @@
DataContext = this;
InitializeComponent();
- SizeChanged += InnerWindow_SizeChanged;
Loaded += InnerWindow_Loaded;
- }
-
- private void InnerWindow_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- //throw new NotImplementedException();
}
private void InnerWindow_Loaded(object sender, RoutedEventArgs e)
@@ -118,15 +131,9 @@
};
}
Loaded -= InnerWindow_Loaded;
- }
-
- private Canvas canvas;
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- Visibility = Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
- }
-
+ }
+
+ #region 鎷栨嫿绉诲姩鐩稿叧
private void DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
switch (DragType)
@@ -172,12 +179,8 @@
{
canvasPosition.Top = Canvas.GetTop(this);
canvasPosition.Left = Canvas.GetLeft(this);
- }
-
- private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
- {
-
- }
+ }
+ #endregion
/// <summary>
/// 娣诲姞鍒扮敾甯冧笂
@@ -187,7 +190,7 @@
{
if (true)
{
- Resize.SetIsResizeable(this, true);
+ Resize.SetIsResizeable(this, true);
}
canvas.Children.Add(this);
this.canvas = canvas;
@@ -201,8 +204,23 @@
}
Canvas.SetLeft(this, canvasPosition == null ? 0 : canvasPosition.Left);
Canvas.SetTop(this, canvasPosition == null ? 0 : canvasPosition.Top);
- }
-
+ canvas.SizeChanged += Canvas_SizeChanged;
+ }
+
+ private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ Size newSize = e.NewSize;
+ Size previousSize = e.PreviousSize;
+
+ double xRate = newSize.Width / previousSize.Width;
+ double yRate = newSize.Height / previousSize.Height;
+
+ Canvas.SetLeft(this, Canvas.GetLeft(this) * xRate);
+ Canvas.SetTop(this, Canvas.GetTop(this) * yRate);
+ this.Width = this.Width * xRate;
+ this.Height = this.Height * yRate;
+ }
+
private void Min_Click(object sender, RoutedEventArgs e)
{
MinEvent?.Invoke(this, null);
@@ -225,14 +243,13 @@
private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
-
- }
- }
-
- public class InnerWindowProp : NotifyBase
- {
-
-
+ this.Focus();
+ }
+
+ private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+
+ }
}
public enum DragType
--
Gitblit v1.9.1