终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

89 lines
2.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace BPASmartClient.CustomResource.UserControls
  16. {
  17. /// <summary>
  18. /// BPABorder.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class BPABorder : UserControl
  21. {
  22. public BPABorder()
  23. {
  24. InitializeComponent();
  25. this.Loaded += (s, o) =>
  26. {
  27. this.canvas.Width = this.ActualWidth;
  28. this.canvas.Height = this.ActualHeight;
  29. if (this.ActualWidth - 3 >= 0)
  30. this.border.Width = this.ActualWidth - 3;
  31. if (this.ActualHeight - 3 >= 0)
  32. this.border.Height = this.ActualHeight - 3;
  33. if (this.ActualWidth - 38 >= 0)
  34. {
  35. this.TitleBorder.Width = this.ActualWidth - 38;
  36. this.bor.Width = this.TitleBorder.Width;
  37. }
  38. this.bor.Margin = new Thickness(19, 17 + TitleHeight, 0, 0);
  39. if (this.ActualHeight - TitleHeight - 21 >= 0)
  40. this.bor.Height = this.ActualHeight - TitleHeight - 21;
  41. };
  42. }
  43. private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs s)
  44. {
  45. (d as BPABorder)?.Refresh();
  46. }
  47. private void Refresh()
  48. {
  49. this.bor.Children.Clear();
  50. this.bor.Children.Add(BackGrid);
  51. }
  52. public float TitleHeight
  53. {
  54. get { return (float)GetValue(TitleHeightProperty); }
  55. set { SetValue(TitleHeightProperty, value); }
  56. }
  57. public static readonly DependencyProperty TitleHeightProperty = DependencyProperty.Register("TitleHeight", typeof(float), typeof(BPABorder), new(30.0f));
  58. public string TitleName
  59. {
  60. get { return (string)GetValue(TitleNameProperty); }
  61. set { SetValue(TitleNameProperty, value); }
  62. }
  63. public static readonly DependencyProperty TitleNameProperty = DependencyProperty.Register("TitleName", typeof(string), typeof(BPABorder), new("标题"));
  64. public Panel BackGrid
  65. {
  66. get { return (Panel)GetValue(BackGridProperty); }
  67. set { SetValue(BackGridProperty, value); }
  68. }
  69. public static readonly DependencyProperty BackGridProperty =
  70. DependencyProperty.Register("BackGrid", typeof(Panel), typeof(BPABorder),
  71. new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));
  72. }
  73. }