Browse Source

controls

main
hulei 3 weeks ago
parent
commit
2649df20dc
100 changed files with 8841 additions and 0 deletions
  1. 93
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PlaceholderAdorner.cs
  2. 62
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptAdorner.ts
  3. 31
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptChrome.cs
  4. 0
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptChrome.vue
  5. 84
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/TextLengthAdorner.cs
  6. 71
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Arrow/Arrow.ts
  7. 86
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Button/ImageButton.cs
  8. 907
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Button/ImageButtonChrome.cs
  9. 75
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/ClipBorder.ts
  10. 124
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/GeometryHelper.ts
  11. 838
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/ToggleSwitch.cs
  12. 141
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapDevice.ts
  13. 74
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapGrabber.ts
  14. 47
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapHelper.ts
  15. 159
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapInterfaces.ts
  16. 85
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapPlayer.ts
  17. 90
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapStructures.ts
  18. 45
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CaptureImageCommands.ts
  19. 122
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/FilterInfo.ts
  20. 28
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/ThreeFourthConverter.ts
  21. 434
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBox.xaml
  22. 1484
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBox.xaml.cs
  23. 20
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxItem.xaml
  24. 67
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxItem.xaml.cs
  25. 50
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxShowData.xaml
  26. 35
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxShowData.xaml.cs
  27. 91
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataPager/DataPager.xaml
  28. 344
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataPager/DataPager.xaml.cs
  29. 37
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorDialog.xaml
  30. 72
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorDialog.xaml.cs
  31. 339
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorPicker.xaml
  32. 216
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorPicker.xaml.cs
  33. 47
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/FontHeight.ts
  34. 35
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/FontList.ts
  35. 349
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/RtfEditorBox.xaml
  36. 341
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/RtfEditorBox.xaml.cs
  37. 38
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/BufferTimer.ts
  38. 59
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ButtonHelper.ts
  39. 325
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ComboBoxHelper.ts
  40. 134
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ControlHelper.ts
  41. 16
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/CurrencyEditorHelper.ts
  42. 23
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/CurrencyRateEditorHelper.ts
  43. 52
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/DataGridHelper.ts
  44. 31
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/DataViewFilter.ts
  45. 94
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/GridHelper.ts
  46. 113
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ItemsControlHelper.ts
  47. 145
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/PasswordBoxHelper.ts
  48. 148
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/TextBoxHelper.ts
  49. 33
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ToggleSwitchHelper.ts
  50. 269
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyBase.ts
  51. 93
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyEditor.ts
  52. 70
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyRateEditor.ts
  53. 75
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/ProportionalEditor.ts
  54. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/3.ico
  55. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/9.ico
  56. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignCenter.png
  57. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignFullJustify.png
  58. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignLeft.png
  59. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignRight.png
  60. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Backcolor.png
  61. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchCircle.png
  62. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchSquare.png
  63. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchSquare2.png
  64. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Expanded.ico
  65. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/FilePrint.png
  66. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Indent.png
  67. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/IndentRemove.png
  68. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/MainICO.png
  69. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/MenuTree_TradeSelected.png
  70. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/NotExpanded.ico
  71. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_error.png
  72. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_information.png
  73. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_question.png
  74. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_warning.png
  75. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Subscript.png
  76. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Superscript.png
  77. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Textcolor.png
  78. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/charactergrowfont.png
  79. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/charactershrinkfont.png
  80. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/copy.png
  81. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/cut.png
  82. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/fileopen.png
  83. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/filesave.png
  84. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/listbullets.png
  85. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/listnumbering.png
  86. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_first.gif
  87. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_first_gray.gif
  88. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_last.gif
  89. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_last_gray.gif
  90. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_load.png
  91. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_loading.gif
  92. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_next.gif
  93. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_next_gray.gif
  94. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_prev.gif
  95. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_prev_gray.gif
  96. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/paste.png
  97. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/redo.png
  98. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/sign.gif
  99. BIN
      ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/undo.png
  100. 0
    0
      ant-design-pro-vue3/src/views/front/platfrom/controls/TableContainer/ComboBoxDataGrid/ComboBoxDataGrid.ts

+ 93
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PlaceholderAdorner.cs View File

@@ -0,0 +1,93 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows.Documents;
6
+using System.Windows.Media;
7
+using System.Windows.Controls;
8
+using System.Windows;
9
+using System.Windows.Data;
10
+using System.ComponentModel;
11
+using System.Globalization;
12
+using Platform.Common.BasicFunctions;
13
+using Platform.Controls.ControlsHelper;
14
+
15
+namespace Platform.Controls.AdornerContainer
16
+{
17
+   [DesignTimeVisible(false)]
18
+   public class PlaceholderAdorner:Adorner
19
+   {
20
+       private VisualCollection _visCollec;
21
+       private TextBlock _tb;
22
+       private TextBox _txt;
23
+
24
+       public PlaceholderAdorner(UIElement ele, string placeholder)
25
+           : base(ele)
26
+       {
27
+           _txt = ele as TextBox;
28
+           if (_txt == null) return;
29
+
30
+           Binding bd = new Binding("IsVisible");
31
+           bd.Source = _txt;
32
+           bd.Mode = BindingMode.OneWay;
33
+           bd.Converter = new BoolToVisibilityConverter();
34
+           this.SetBinding(TextBox.VisibilityProperty, bd);
35
+           _visCollec = new VisualCollection(this);
36
+           _tb = new TextBlock();
37
+           _tb.Style = null;
38
+           _tb.FontSize = _txt.FontSize;
39
+           _tb.FontFamily = _txt.FontFamily;
40
+           _tb.FontWeight = _txt.FontWeight;
41
+           _tb.FontStretch = _txt.FontStretch;
42
+           _tb.FontStyle = FontStyles.Italic;
43
+           _tb.Foreground = Brushes.Gray;
44
+           _tb.Text = placeholder;
45
+           _tb.IsHitTestVisible = false;
46
+           _visCollec.Add(_tb);
47
+       }
48
+
49
+       protected override int VisualChildrenCount
50
+       {
51
+           get
52
+           {
53
+               return _visCollec.Count;
54
+           }
55
+       }
56
+
57
+       protected override Size ArrangeOverride(Size finalSize)
58
+       {
59
+           Point point = TextBoxHelper.GetPlaceholderOffset(this.AdornedElement);
60
+           _tb.Arrange(new Rect(point, finalSize));
61
+           return finalSize;
62
+       }
63
+
64
+       protected override Visual GetVisualChild(int index)
65
+       {
66
+           return _visCollec[index];
67
+       }
68
+
69
+       /// <summary>
70
+       /// 重写方法以添加进一步图形元素到呈现的元素,如效果或装饰器。
71
+       /// </summary>
72
+       /// <param name="drawingContext">DrawingContext 对象作为参数传递,可以为绘制形状、文本、图像或视频提供方法</param>
73
+       //protected override void OnRender(DrawingContext drawingContext)
74
+       //{
75
+       //    TextBox txt = this.AdornedElement as TextBox;
76
+       //    if (txt == null || !txt.IsVisible) return;
77
+
78
+       //    this.IsHitTestVisible = false;
79
+
80
+       //    drawingContext.DrawText(
81
+       //        new FormattedText
82
+       //        (
83
+       //            _placeholder, 
84
+       //            CultureInfo.CurrentCulture,
85
+       //            txt.FlowDirection,
86
+       //            new Typeface(txt.FontFamily, FontStyles.Italic, txt.FontWeight, txt.FontStretch), 
87
+       //            txt.FontSize,
88
+       //            Brushes.Gray
89
+       //        ),
90
+       //        new Point(4, 2));
91
+       //}
92
+   }
93
+}

+ 62
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptAdorner.ts View File

@@ -0,0 +1,62 @@
1
+import { Directive, DirectiveBinding, ObjectDirective } from 'vue';
2
+
3
+// 模拟 PromptChrome
4
+class PromptChrome {
5
+    // 这里可以添加具体的渲染逻辑
6
+    render() {
7
+        // ...
8
+    }
9
+}
10
+
11
+// 定义附加属性的存储对象
12
+const promptCountMap = new WeakMap<HTMLElement, number>();
13
+const isPromptEnabledMap = new WeakMap<HTMLElement, boolean>();
14
+
15
+// 获取和设置 PromptCount
16
+function getPromptCount(el: HTMLElement): number {
17
+    return promptCountMap.get(el) || 0;
18
+}
19
+
20
+function setPromptCount(el: HTMLElement, value: number): void {
21
+    value = Math.max(0, value);
22
+    promptCountMap.set(el, value);
23
+    // 这里可以添加 PromptCountChangedCallBack 的逻辑
24
+}
25
+
26
+// 获取和设置 IsPromptEnabled
27
+function getIsPromptEnabled(el: HTMLElement): boolean {
28
+    return isPromptEnabledMap.get(el) || false;
29
+}
30
+
31
+function setIsPromptEnabled(el: HTMLElement, value: boolean): void {
32
+    isPromptEnabledMap.set(el, value);
33
+    isPromptEnabledChangedCallBack(el, value);
34
+}
35
+
36
+// IsPromptEnabled 属性值改变回调方法
37
+function isPromptEnabledChangedCallBack(el: HTMLElement, isEnabled: boolean) {
38
+    const chrome = new PromptChrome();
39
+    if (isEnabled) {
40
+        // 模拟添加装饰件
41
+        chrome.render();
42
+    } else {
43
+        // 模拟移除装饰件
44
+        // ...
45
+    }
46
+}
47
+
48
+// 自定义指令
49
+const PromptAdornerDirective: ObjectDirective = {
50
+    mounted(el: HTMLElement, binding: DirectiveBinding) {
51
+        const { promptCount, isPromptEnabled } = binding.value;
52
+        setPromptCount(el, promptCount);
53
+        setIsPromptEnabled(el, isPromptEnabled);
54
+    },
55
+    updated(el: HTMLElement, binding: DirectiveBinding) {
56
+        const { promptCount, isPromptEnabled } = binding.value;
57
+        setPromptCount(el, promptCount);
58
+        setIsPromptEnabled(el, isPromptEnabled);
59
+    }
60
+};
61
+
62
+export default PromptAdornerDirective;

+ 31
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptChrome.cs View File

@@ -0,0 +1,31 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Data;
7
+using System.Windows.Controls;
8
+using System.Windows.Media;
9
+
10
+namespace Platform.Controls.AdornerContainer
11
+{
12
+  public  class PromptChrome:Control
13
+    {
14
+        static PromptChrome()
15
+        {
16
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(PromptChrome), new FrameworkPropertyMetadata(typeof(PromptChrome)));
17
+        }
18
+        protected override Size ArrangeOverride(Size arrangeBounds)
19
+        {
20
+            this.Width = 20;
21
+            this.Height = 20;
22
+            this.HorizontalAlignment = HorizontalAlignment.Right;
23
+            this.VerticalAlignment = VerticalAlignment.Top;
24
+            TranslateTransform tt = new TranslateTransform();
25
+            tt.X = 2;
26
+            tt.Y = -5;
27
+            this.RenderTransform = tt;
28
+            return base.ArrangeOverride(arrangeBounds);
29
+        }
30
+    }
31
+}

+ 0
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/PromptAdornerCount/PromptChrome.vue View File


+ 84
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/AdornerContainer/TextLengthAdorner.cs View File

@@ -0,0 +1,84 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows.Documents;
6
+using System.Windows.Media;
7
+using System.Windows.Controls;
8
+using System.Windows;
9
+using System.Windows.Data;
10
+using System.ComponentModel;
11
+using Platform.Common.BasicFunctions;
12
+
13
+namespace Platform.Controls.AdornerContainer
14
+{
15
+   [DesignTimeVisible(false)]
16
+   public class TextLengthAdorner:Adorner
17
+   {
18
+       private VisualCollection _visCollec;
19
+       private TextBlock _rec;
20
+       private TextBox _tb;
21
+       protected override int VisualChildrenCount
22
+       {
23
+           get
24
+           {
25
+               return _visCollec.Count;
26
+           }
27
+       }
28
+
29
+       public string LengthText
30
+       {
31
+           set { _rec.Text = value; }
32
+       }
33
+       public TextLengthAdorner(UIElement ele)
34
+           : base(ele)
35
+       {
36
+           if (ele is TextBox)
37
+           {
38
+               _tb =(TextBox) ele;
39
+               Binding bd = new Binding("IsVisible");
40
+               bd.Source = _tb;
41
+               bd.Mode = BindingMode.OneWay;
42
+               bd.Converter = new BoolToVisibilityConverter();
43
+               this.SetBinding(TextBox.VisibilityProperty, bd);
44
+               _visCollec = new VisualCollection(this);
45
+               _rec = new TextBlock();
46
+               _rec.SizeChanged += new SizeChangedEventHandler(rec_SizeChanged);
47
+               _rec.FontSize = 12;
48
+               _rec.VerticalAlignment = VerticalAlignment.Top;
49
+               _rec.SetBinding(TextBlock.TextProperty, new Binding("Text") 
50
+               { 
51
+                   Source = _tb,
52
+                   Converter = new TextToEncodingLengthConverter()
53
+               });
54
+               _visCollec.Add(_rec);
55
+
56
+           }
57
+       }
58
+
59
+       /// <summary>
60
+       /// 重新定位子元素
61
+       /// </summary>
62
+       private void Arrange()
63
+       {
64
+           Rect r = new Rect(this._tb.ActualWidth + 2, 6, this._rec.ActualWidth, this.AdornedElement.DesiredSize.Height);
65
+           _rec.Arrange(r);
66
+       }
67
+
68
+       protected override Size ArrangeOverride(Size finalSize)
69
+       {
70
+           this.Arrange();
71
+           return finalSize;
72
+       }
73
+
74
+       private void rec_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
75
+       {
76
+           // textblock大小发生变化意味着里面字符长度发生变化,所以需要重新计算装饰器大小
77
+           this.Arrange();
78
+       }
79
+       protected override Visual GetVisualChild(int index)
80
+       {
81
+           return _visCollec[index];
82
+       }
83
+   }
84
+}

+ 71
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Arrow/Arrow.ts View File

@@ -0,0 +1,71 @@
1
+import { defineComponent, ref, computed } from 'vue';
2
+
3
+export default defineComponent({
4
+    props: {
5
+        X1: {
6
+            type: Number,
7
+            default: 10
8
+        },
9
+        Y1: {
10
+            type: Number,
11
+            default: 10
12
+        },
13
+        X2: {
14
+            type: Number,
15
+            default: 25
16
+        },
17
+        Y2: {
18
+            type: Number,
19
+            default: 10
20
+        },
21
+        HeadHeight: {
22
+            type: Number,
23
+            default: 15
24
+        },
25
+        HeadWidth: {
26
+            type: Number,
27
+            default: 20
28
+        },
29
+        LineHeight: {
30
+            type: Number,
31
+            default: 3
32
+        }
33
+    },
34
+    setup(props) {
35
+        const stroke = ref('gray');
36
+        const strokeThickness = ref(1);
37
+        const fill = ref('black');
38
+
39
+        const pathData = computed(() => {
40
+            const y = (props.Y1 + props.Y2) / 2;
41
+            const yAdd = y + props.LineHeight;
42
+            const yDel = y - props.LineHeight;
43
+            const yHA = y + props.HeadHeight / 2;
44
+            const yHD = y - props.HeadHeight / 2;
45
+            const xH = props.X2 + props.HeadWidth;
46
+
47
+            const p1 = `M${props.X1},${yAdd}`;
48
+            const p2 = `L${props.X2},${yAdd}`;
49
+            const p3 = `L${props.X2},${yHA}`;
50
+            const p4 = `L${xH},${y}`;
51
+            const p5 = `L${props.X2},${yHD}`;
52
+            const p6 = `L${props.X2},${yDel}`;
53
+            const p7 = `L${props.X1},${yDel}`;
54
+            const close = 'Z';
55
+
56
+            return `${p1} ${p2} ${p3} ${p4} ${p5} ${p6} ${p7} ${close}`;
57
+        });
58
+
59
+        return {
60
+            stroke,
61
+            strokeThickness,
62
+            fill,
63
+            pathData
64
+        };
65
+    },
66
+    template: `
67
+        <svg>
68
+            <path :d="pathData" :stroke="stroke" :stroke-width="strokeThickness" :fill="fill" />
69
+        </svg>
70
+    `
71
+});

+ 86
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Button/ImageButton.cs View File

@@ -0,0 +1,86 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Navigation;
13
+using System.Windows.Shapes;
14
+
15
+namespace Platform.Controls.BaseContainer
16
+{
17
+    public class ImageButton : Button
18
+    {
19
+        Image innerImage;
20
+
21
+        static ImageButton()
22
+        {
23
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton), new FrameworkPropertyMetadata(typeof(ImageButton)));
24
+        }
25
+
26
+        public ImageButton()
27
+        {
28
+            this.IsEnabledChanged += new DependencyPropertyChangedEventHandler(ImageButton_IsEnabledChanged);
29
+        }
30
+
31
+        public override void OnApplyTemplate()
32
+        {
33
+            base.OnApplyTemplate();
34
+
35
+            innerImage = this.Template.FindName("innerImage", this) as Image;
36
+
37
+            if (innerImage == null) return;
38
+
39
+            if (this.IsEnabled && ImageSource != null)
40
+            {
41
+                innerImage.Source = ImageSource;
42
+            }
43
+            else if (!this.IsEnabled && GrayImageSource != null)
44
+            {
45
+                innerImage.Source = GrayImageSource;
46
+            }
47
+        }
48
+
49
+        void ImageButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
50
+        {
51
+            if (innerImage == null) return;
52
+
53
+            if (this.IsEnabled && ImageSource != null)
54
+            {
55
+                innerImage.Source = ImageSource;
56
+            }
57
+            else if (!this.IsEnabled && GrayImageSource != null)
58
+            {
59
+                innerImage.Source = GrayImageSource;
60
+            }
61
+        }
62
+
63
+        public ImageSource ImageSource
64
+        {
65
+            get { return (ImageSource)GetValue(ImageSourceProperty); }
66
+            set { SetValue(ImageSourceProperty, value); }
67
+        }
68
+
69
+        // Using a DependencyProperty as the backing store for ImageSource.  This enables animation, styling, binding, etc...
70
+        public static readonly DependencyProperty ImageSourceProperty =
71
+            DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(ImageButton), new UIPropertyMetadata(null));
72
+
73
+
74
+
75
+        public ImageSource GrayImageSource
76
+        {
77
+            get { return (ImageSource)GetValue(GrayImageSourceProperty); }
78
+            set { SetValue(GrayImageSourceProperty, value); }
79
+        }
80
+
81
+        // Using a DependencyProperty as the backing store for GrayImageSource.  This enables animation, styling, binding, etc...
82
+        public static readonly DependencyProperty GrayImageSourceProperty =
83
+            DependencyProperty.Register("GrayImageSource", typeof(ImageSource), typeof(ImageButton), new UIPropertyMetadata(null));
84
+
85
+    }
86
+}

+ 907
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/Button/ImageButtonChrome.cs View File

@@ -0,0 +1,907 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows.Controls;
6
+using System.Windows.Media;
7
+using System.Windows;
8
+using System.Runtime;
9
+using System.Windows.Media.Animation;
10
+
11
+namespace Platform.Controls.BaseContainer
12
+{
13
+    public sealed class ImageButtonChrome : Decorator
14
+    {
15
+        private class LocalResources
16
+        {
17
+            public Pen BorderOverlayPen;
18
+            public Pen InnerBorderPen;
19
+            public LinearGradientBrush BackgroundOverlay;
20
+            public LinearGradientBrush LeftDropShadowBrush;
21
+            public LinearGradientBrush TopDropShadowBrush;
22
+        }
23
+        public static readonly DependencyProperty BackgroundProperty;
24
+        public static readonly DependencyProperty BorderBrushProperty;
25
+        public static readonly DependencyProperty RenderDefaultedProperty;
26
+        public static readonly DependencyProperty RenderMouseOverProperty;
27
+        public static readonly DependencyProperty RenderPressedProperty;
28
+        public static readonly DependencyProperty RoundCornersProperty;
29
+        private static Pen _commonBorderPen;
30
+        private static Pen _commonInnerBorderPen;
31
+        private static Pen _commonDisabledBorderOverlay;
32
+        private static SolidColorBrush _commonDisabledBackgroundOverlay;
33
+        private static Pen _commonDefaultedInnerBorderPen;
34
+        private static LinearGradientBrush _commonHoverBackgroundOverlay;
35
+        private static Pen _commonHoverBorderOverlay;
36
+        private static LinearGradientBrush _commonPressedBackgroundOverlay;
37
+        private static Pen _commonPressedBorderOverlay;
38
+        private static LinearGradientBrush _commonPressedLeftDropShadowBrush;
39
+        private static LinearGradientBrush _commonPressedTopDropShadowBrush;
40
+        private static object _resourceAccess;
41
+        private ImageButtonChrome.LocalResources _localResources;
42
+        public Brush Background
43
+        {
44
+            get
45
+            {
46
+                return (Brush)base.GetValue(ImageButtonChrome.BackgroundProperty);
47
+            }
48
+            set
49
+            {
50
+                base.SetValue(ImageButtonChrome.BackgroundProperty, value);
51
+            }
52
+        }
53
+        public Brush BorderBrush
54
+        {
55
+            get
56
+            {
57
+                return (Brush)base.GetValue(ImageButtonChrome.BorderBrushProperty);
58
+            }
59
+            set
60
+            {
61
+                base.SetValue(ImageButtonChrome.BorderBrushProperty, value);
62
+            }
63
+        }
64
+        public bool RenderDefaulted
65
+        {
66
+            get
67
+            {
68
+                return (bool)base.GetValue(ImageButtonChrome.RenderDefaultedProperty);
69
+            }
70
+            set
71
+            {
72
+                base.SetValue(ImageButtonChrome.RenderDefaultedProperty, value);
73
+            }
74
+        }
75
+        public bool RenderMouseOver
76
+        {
77
+            get
78
+            {
79
+                return (bool)base.GetValue(ImageButtonChrome.RenderMouseOverProperty);
80
+            }
81
+            set
82
+            {
83
+                base.SetValue(ImageButtonChrome.RenderMouseOverProperty, value);
84
+            }
85
+        }
86
+        public bool RenderPressed
87
+        {
88
+            get
89
+            {
90
+                return (bool)base.GetValue(ImageButtonChrome.RenderPressedProperty);
91
+            }
92
+            set
93
+            {
94
+                base.SetValue(ImageButtonChrome.RenderPressedProperty, value);
95
+            }
96
+        }
97
+        public bool RoundCorners
98
+        {
99
+            get
100
+            {
101
+                return (bool)base.GetValue(ImageButtonChrome.RoundCornersProperty);
102
+            }
103
+            set
104
+            {
105
+                base.SetValue(ImageButtonChrome.RoundCornersProperty, value);
106
+            }
107
+        }
108
+        internal int EffectiveValuesInitialSize
109
+        {
110
+            get
111
+            {
112
+                return 9;
113
+            }
114
+        }
115
+        private bool Animates
116
+        {
117
+            get
118
+            {
119
+                return SystemParameters.PowerLineStatus == PowerLineStatus.Online && SystemParameters.ClientAreaAnimation && RenderCapability.Tier > 0 && base.IsEnabled;
120
+            }
121
+        }
122
+        private static LinearGradientBrush CommonHoverBackgroundOverlay
123
+        {
124
+            get
125
+            {
126
+                if (ImageButtonChrome._commonHoverBackgroundOverlay == null)
127
+                {
128
+                    lock (ImageButtonChrome._resourceAccess)
129
+                    {
130
+                        if (ImageButtonChrome._commonHoverBackgroundOverlay == null)
131
+                        {
132
+                            LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
133
+                            linearGradientBrush.StartPoint = new Point(0.0, 0.0);
134
+                            linearGradientBrush.EndPoint = new Point(0.0, 1.0);
135
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 234, 246, 253), 0.0));
136
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 217, 240, 252), 0.5));
137
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 190, 230, 253), 0.5));
138
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 167, 217, 245), 1.0));
139
+                            linearGradientBrush.Freeze();
140
+                            ImageButtonChrome._commonHoverBackgroundOverlay = linearGradientBrush;
141
+                        }
142
+                    }
143
+                }
144
+                return ImageButtonChrome._commonHoverBackgroundOverlay;
145
+            }
146
+        }
147
+        private static LinearGradientBrush CommonPressedBackgroundOverlay
148
+        {
149
+            get
150
+            {
151
+                if (ImageButtonChrome._commonPressedBackgroundOverlay == null)
152
+                {
153
+                    lock (ImageButtonChrome._resourceAccess)
154
+                    {
155
+                        if (ImageButtonChrome._commonPressedBackgroundOverlay == null)
156
+                        {
157
+                            LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
158
+                            linearGradientBrush.StartPoint = new Point(0.0, 0.0);
159
+                            linearGradientBrush.EndPoint = new Point(0.0, 1.0);
160
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 194, 228, 246), 0.5));
161
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 171, 218, 243), 0.5));
162
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 144, 203, 235), 1.0));
163
+                            linearGradientBrush.Freeze();
164
+                            ImageButtonChrome._commonPressedBackgroundOverlay = linearGradientBrush;
165
+                        }
166
+                    }
167
+                }
168
+                return ImageButtonChrome._commonPressedBackgroundOverlay;
169
+            }
170
+        }
171
+        private static SolidColorBrush CommonDisabledBackgroundOverlay
172
+        {
173
+            get
174
+            {
175
+                if (ImageButtonChrome._commonDisabledBackgroundOverlay == null)
176
+                {
177
+                    lock (ImageButtonChrome._resourceAccess)
178
+                    {
179
+                        if (ImageButtonChrome._commonDisabledBackgroundOverlay == null)
180
+                        {
181
+                            SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromRgb(244, 244, 244));
182
+                            solidColorBrush.Freeze();
183
+                            ImageButtonChrome._commonDisabledBackgroundOverlay = solidColorBrush;
184
+                        }
185
+                    }
186
+                }
187
+                return ImageButtonChrome._commonDisabledBackgroundOverlay;
188
+            }
189
+        }
190
+        private Brush BackgroundOverlay
191
+        {
192
+            get
193
+            {
194
+                if (!base.IsEnabled)
195
+                {
196
+                    return Brushes.Transparent;
197
+                    //return ImageButtonChrome.CommonDisabledBackgroundOverlay;
198
+                }
199
+                if (!this.Animates)
200
+                {
201
+                    if (this.RenderPressed)
202
+                    {
203
+                        return ImageButtonChrome.CommonPressedBackgroundOverlay;
204
+                    }
205
+                    if (this.RenderMouseOver)
206
+                    {
207
+                        return ImageButtonChrome.CommonHoverBackgroundOverlay;
208
+                    }
209
+                    return null;
210
+                }
211
+                else
212
+                {
213
+                    if (this._localResources != null)
214
+                    {
215
+                        if (this._localResources.BackgroundOverlay == null)
216
+                        {
217
+                            this._localResources.BackgroundOverlay = ImageButtonChrome.CommonHoverBackgroundOverlay.Clone();
218
+                            this._localResources.BackgroundOverlay.Opacity = 0.0;
219
+                        }
220
+                        return this._localResources.BackgroundOverlay;
221
+                    }
222
+                    return null;
223
+                }
224
+            }
225
+        }
226
+        private static Pen CommonHoverBorderOverlay
227
+        {
228
+            get
229
+            {
230
+                if (ImageButtonChrome._commonHoverBorderOverlay == null)
231
+                {
232
+                    lock (ImageButtonChrome._resourceAccess)
233
+                    {
234
+                        if (ImageButtonChrome._commonHoverBorderOverlay == null)
235
+                        {
236
+                            Pen pen = new Pen();
237
+                            pen.Thickness = 1.0;
238
+                            pen.Brush = new SolidColorBrush(Color.FromRgb(60, 127, 177));
239
+                            pen.Freeze();
240
+                            ImageButtonChrome._commonHoverBorderOverlay = pen;
241
+                        }
242
+                    }
243
+                }
244
+                return ImageButtonChrome._commonHoverBorderOverlay;
245
+            }
246
+        }
247
+        private static Pen CommonPressedBorderOverlay
248
+        {
249
+            get
250
+            {
251
+                if (ImageButtonChrome._commonPressedBorderOverlay == null)
252
+                {
253
+                    lock (ImageButtonChrome._resourceAccess)
254
+                    {
255
+                        if (ImageButtonChrome._commonPressedBorderOverlay == null)
256
+                        {
257
+                            Pen pen = new Pen();
258
+                            pen.Thickness = 1.0;
259
+                            pen.Brush = new SolidColorBrush(Color.FromRgb(44, 98, 139));
260
+                            pen.Freeze();
261
+                            ImageButtonChrome._commonPressedBorderOverlay = pen;
262
+                        }
263
+                    }
264
+                }
265
+                return ImageButtonChrome._commonPressedBorderOverlay;
266
+            }
267
+        }
268
+        private static Pen CommonDisabledBorderOverlay
269
+        {
270
+            get
271
+            {
272
+                if (ImageButtonChrome._commonDisabledBorderOverlay == null)
273
+                {
274
+                    lock (ImageButtonChrome._resourceAccess)
275
+                    {
276
+                        if (ImageButtonChrome._commonDisabledBorderOverlay == null)
277
+                        {
278
+                            Pen pen = new Pen();
279
+                            pen.Thickness = 1.0;
280
+                            pen.Brush = new SolidColorBrush(Color.FromRgb(173, 178, 181));
281
+                            pen.Freeze();
282
+                            ImageButtonChrome._commonDisabledBorderOverlay = pen;
283
+                        }
284
+                    }
285
+                }
286
+                return ImageButtonChrome._commonDisabledBorderOverlay;
287
+            }
288
+        }
289
+        private Pen BorderOverlayPen
290
+        {
291
+            get
292
+            {
293
+                if (!base.IsEnabled)
294
+                {
295
+                    if (this.RoundCorners)
296
+                    {
297
+                        return ImageButtonChrome.CommonDisabledBorderOverlay;
298
+                    }
299
+                    return null;
300
+                }
301
+                else
302
+                {
303
+                    if (!this.Animates)
304
+                    {
305
+                        if (this.RenderPressed)
306
+                        {
307
+                            return ImageButtonChrome.CommonPressedBorderOverlay;
308
+                        }
309
+                        if (this.RenderMouseOver)
310
+                        {
311
+                            return ImageButtonChrome.CommonHoverBorderOverlay;
312
+                        }
313
+                        return null;
314
+                    }
315
+                    else
316
+                    {
317
+                        if (this._localResources != null)
318
+                        {
319
+                            if (this._localResources.BorderOverlayPen == null)
320
+                            {
321
+                                this._localResources.BorderOverlayPen = ImageButtonChrome.CommonHoverBorderOverlay.Clone();
322
+                                this._localResources.BorderOverlayPen.Brush.Opacity = 0.0;
323
+                            }
324
+                            return this._localResources.BorderOverlayPen;
325
+                        }
326
+                        return null;
327
+                    }
328
+                }
329
+            }
330
+        }
331
+        private static Pen CommonInnerBorderPen
332
+        {
333
+            get
334
+            {
335
+                if (ImageButtonChrome._commonInnerBorderPen == null)
336
+                {
337
+                    lock (ImageButtonChrome._resourceAccess)
338
+                    {
339
+                        if (ImageButtonChrome._commonInnerBorderPen == null)
340
+                        {
341
+                            Pen pen = new Pen();
342
+                            pen.Thickness = 1.0;
343
+                            pen.Brush = new LinearGradientBrush
344
+                            {
345
+                                StartPoint = new Point(0.0, 0.0),
346
+                                EndPoint = new Point(0.0, 1.0),
347
+                                GradientStops = 
348
+								{
349
+									new GradientStop(Color.FromArgb(250, 255, 255, 255), 0.0),
350
+									new GradientStop(Color.FromArgb(133, 255, 255, 255), 1.0)
351
+								}
352
+                            };
353
+                            pen.Freeze();
354
+                            ImageButtonChrome._commonInnerBorderPen = pen;
355
+                        }
356
+                    }
357
+                }
358
+                return ImageButtonChrome._commonInnerBorderPen;
359
+            }
360
+        }
361
+        private static Pen CommonDefaultedInnerBorderPen
362
+        {
363
+            get
364
+            {
365
+                if (ImageButtonChrome._commonDefaultedInnerBorderPen == null)
366
+                {
367
+                    lock (ImageButtonChrome._resourceAccess)
368
+                    {
369
+                        if (ImageButtonChrome._commonDefaultedInnerBorderPen == null)
370
+                        {
371
+                            Pen pen = new Pen();
372
+                            pen.Thickness = 1.0;
373
+                            pen.Brush = new SolidColorBrush(Color.FromArgb(249, 0, 204, 255));
374
+                            pen.Freeze();
375
+                            ImageButtonChrome._commonDefaultedInnerBorderPen = pen;
376
+                        }
377
+                    }
378
+                }
379
+                return ImageButtonChrome._commonDefaultedInnerBorderPen;
380
+            }
381
+        }
382
+        private Pen InnerBorderPen
383
+        {
384
+            get
385
+            {
386
+                if (!base.IsEnabled)
387
+                {
388
+                    return ImageButtonChrome.CommonInnerBorderPen;
389
+                }
390
+                if (!this.Animates)
391
+                {
392
+                    if (this.RenderPressed)
393
+                    {
394
+                        return null;
395
+                    }
396
+                    if (this.RenderDefaulted)
397
+                    {
398
+                        return ImageButtonChrome.CommonDefaultedInnerBorderPen;
399
+                    }
400
+                    return ImageButtonChrome.CommonInnerBorderPen;
401
+                }
402
+                else
403
+                {
404
+                    if (this._localResources != null)
405
+                    {
406
+                        if (this._localResources.InnerBorderPen == null)
407
+                        {
408
+                            this._localResources.InnerBorderPen = ImageButtonChrome.CommonInnerBorderPen.Clone();
409
+                        }
410
+                        return this._localResources.InnerBorderPen;
411
+                    }
412
+                    return ImageButtonChrome.CommonInnerBorderPen;
413
+                }
414
+            }
415
+        }
416
+        private static LinearGradientBrush CommonPressedLeftDropShadowBrush
417
+        {
418
+            get
419
+            {
420
+                if (ImageButtonChrome._commonPressedLeftDropShadowBrush == null)
421
+                {
422
+                    lock (ImageButtonChrome._resourceAccess)
423
+                    {
424
+                        if (ImageButtonChrome._commonPressedLeftDropShadowBrush == null)
425
+                        {
426
+                            LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
427
+                            linearGradientBrush.StartPoint = new Point(0.0, 0.0);
428
+                            linearGradientBrush.EndPoint = new Point(1.0, 0.0);
429
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(128, 51, 51, 51), 0.0));
430
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0, 51, 51, 51), 1.0));
431
+                            linearGradientBrush.Freeze();
432
+                            ImageButtonChrome._commonPressedLeftDropShadowBrush = linearGradientBrush;
433
+                        }
434
+                    }
435
+                }
436
+                return ImageButtonChrome._commonPressedLeftDropShadowBrush;
437
+            }
438
+        }
439
+        private LinearGradientBrush LeftDropShadowBrush
440
+        {
441
+            get
442
+            {
443
+                if (!base.IsEnabled)
444
+                {
445
+                    return null;
446
+                }
447
+                if (!this.Animates)
448
+                {
449
+                    if (this.RenderPressed)
450
+                    {
451
+                        return ImageButtonChrome.CommonPressedLeftDropShadowBrush;
452
+                    }
453
+                    return null;
454
+                }
455
+                else
456
+                {
457
+                    if (this._localResources != null)
458
+                    {
459
+                        if (this._localResources.LeftDropShadowBrush == null)
460
+                        {
461
+                            this._localResources.LeftDropShadowBrush = ImageButtonChrome.CommonPressedLeftDropShadowBrush.Clone();
462
+                            this._localResources.LeftDropShadowBrush.Opacity = 0.0;
463
+                        }
464
+                        return this._localResources.LeftDropShadowBrush;
465
+                    }
466
+                    return null;
467
+                }
468
+            }
469
+        }
470
+        private static LinearGradientBrush CommonPressedTopDropShadowBrush
471
+        {
472
+            get
473
+            {
474
+                if (ImageButtonChrome._commonPressedTopDropShadowBrush == null)
475
+                {
476
+                    lock (ImageButtonChrome._resourceAccess)
477
+                    {
478
+                        if (ImageButtonChrome._commonPressedTopDropShadowBrush == null)
479
+                        {
480
+                            LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
481
+                            linearGradientBrush.StartPoint = new Point(0.0, 0.0);
482
+                            linearGradientBrush.EndPoint = new Point(0.0, 1.0);
483
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(128, 51, 51, 51), 0.0));
484
+                            linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0, 51, 51, 51), 1.0));
485
+                            linearGradientBrush.Freeze();
486
+                            ImageButtonChrome._commonPressedTopDropShadowBrush = linearGradientBrush;
487
+                        }
488
+                    }
489
+                }
490
+                return ImageButtonChrome._commonPressedTopDropShadowBrush;
491
+            }
492
+        }
493
+        private LinearGradientBrush TopDropShadowBrush
494
+        {
495
+            get
496
+            {
497
+                if (!base.IsEnabled)
498
+                {
499
+                    return null;
500
+                }
501
+                if (!this.Animates)
502
+                {
503
+                    if (this.RenderPressed)
504
+                    {
505
+                        return ImageButtonChrome.CommonPressedTopDropShadowBrush;
506
+                    }
507
+                    return null;
508
+                }
509
+                else
510
+                {
511
+                    if (this._localResources != null)
512
+                    {
513
+                        if (this._localResources.TopDropShadowBrush == null)
514
+                        {
515
+                            this._localResources.TopDropShadowBrush = ImageButtonChrome.CommonPressedTopDropShadowBrush.Clone();
516
+                            this._localResources.TopDropShadowBrush.Opacity = 0.0;
517
+                        }
518
+                        return this._localResources.TopDropShadowBrush;
519
+                    }
520
+                    return null;
521
+                }
522
+            }
523
+        }
524
+        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
525
+        public ImageButtonChrome()
526
+        {
527
+        }
528
+        protected override Size MeasureOverride(Size availableSize)
529
+        {
530
+            UIElement child = this.Child;
531
+            Size desiredSize;
532
+            if (child != null)
533
+            {
534
+                Size availableSize2 = default(Size);
535
+                bool flag = availableSize.Width < 4.0;
536
+                bool flag2 = availableSize.Height < 4.0;
537
+                if (!flag)
538
+                {
539
+                    availableSize2.Width = availableSize.Width - 4.0;
540
+                }
541
+                if (!flag2)
542
+                {
543
+                    availableSize2.Height = availableSize.Height - 4.0;
544
+                }
545
+                child.Measure(availableSize2);
546
+                desiredSize = child.DesiredSize;
547
+                if (!flag)
548
+                {
549
+                    desiredSize.Width += 4.0;
550
+                }
551
+                if (!flag2)
552
+                {
553
+                    desiredSize.Height += 4.0;
554
+                }
555
+            }
556
+            else
557
+            {
558
+                desiredSize = new Size(Math.Min(4.0, availableSize.Width), Math.Min(4.0, availableSize.Height));
559
+            }
560
+            return desiredSize;
561
+        }
562
+        protected override Size ArrangeOverride(Size finalSize)
563
+        {
564
+            Rect finalRect = default(Rect);
565
+            finalRect.Width = Math.Max(0.0, finalSize.Width - 4.0);
566
+            finalRect.Height = Math.Max(0.0, finalSize.Height - 4.0);
567
+            finalRect.X = (finalSize.Width - finalRect.Width) * 0.5;
568
+            finalRect.Y = (finalSize.Height - finalRect.Height) * 0.5;
569
+            UIElement child = this.Child;
570
+            if (child != null)
571
+            {
572
+                child.Arrange(finalRect);
573
+            }
574
+            return finalSize;
575
+        }
576
+        protected override void OnRender(DrawingContext drawingContext)
577
+        {
578
+            Rect rect = new Rect(0.0, 0.0, base.ActualWidth, base.ActualHeight);
579
+            this.DrawBackground(drawingContext, ref rect);
580
+            this.DrawDropShadows(drawingContext, ref rect);
581
+            if (IsEnabled)
582
+            {
583
+                this.DrawBorder(drawingContext, ref rect);
584
+            }
585
+            this.DrawInnerBorder(drawingContext, ref rect);
586
+        }
587
+        static ImageButtonChrome()
588
+        {
589
+            ImageButtonChrome.BackgroundProperty = Control.BackgroundProperty.AddOwner(typeof(ImageButtonChrome), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
590
+            ImageButtonChrome.BorderBrushProperty = Border.BorderBrushProperty.AddOwner(typeof(ImageButtonChrome), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
591
+            ImageButtonChrome.RenderDefaultedProperty = DependencyProperty.Register("RenderDefaulted", typeof(bool), typeof(ImageButtonChrome), new FrameworkPropertyMetadata(false, new PropertyChangedCallback(ImageButtonChrome.OnRenderDefaultedChanged)));
592
+            ImageButtonChrome.RenderMouseOverProperty = DependencyProperty.Register("RenderMouseOver", typeof(bool), typeof(ImageButtonChrome), new FrameworkPropertyMetadata(false, new PropertyChangedCallback(ImageButtonChrome.OnRenderMouseOverChanged)));
593
+            ImageButtonChrome.RenderPressedProperty = DependencyProperty.Register("RenderPressed", typeof(bool), typeof(ImageButtonChrome), new FrameworkPropertyMetadata(false, new PropertyChangedCallback(ImageButtonChrome.OnRenderPressedChanged)));
594
+            ImageButtonChrome.RoundCornersProperty = DependencyProperty.Register("RoundCorners", typeof(bool), typeof(ImageButtonChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
595
+            ImageButtonChrome._resourceAccess = new object();
596
+            UIElement.IsEnabledProperty.OverrideMetadata(typeof(ImageButtonChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
597
+        }
598
+        private static void OnRenderDefaultedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
599
+        {
600
+            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;
601
+            if (buttonChrome.Animates)
602
+            {
603
+                if (!buttonChrome.RenderPressed)
604
+                {
605
+                    if ((bool)e.NewValue)
606
+                    {
607
+                        if (buttonChrome._localResources == null)
608
+                        {
609
+                            buttonChrome._localResources = new ImageButtonChrome.LocalResources();
610
+                            buttonChrome.InvalidateVisual();
611
+                        }
612
+                        Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
613
+                        ColorAnimation animation = new ColorAnimation(Color.FromArgb(249, 0, 204, 255), duration);
614
+                        GradientStopCollection gradientStops = ((LinearGradientBrush)buttonChrome.InnerBorderPen.Brush).GradientStops;
615
+                        gradientStops[0].BeginAnimation(GradientStop.ColorProperty, animation);
616
+                        gradientStops[1].BeginAnimation(GradientStop.ColorProperty, animation);
617
+                        DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
618
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.5)));
619
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.75)));
620
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(2.0)));
621
+                        doubleAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
622
+                        Timeline.SetDesiredFrameRate(doubleAnimationUsingKeyFrames, new int?(10));
623
+                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
624
+                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
625
+                        return;
626
+                    }
627
+                    if (buttonChrome._localResources == null)
628
+                    {
629
+                        buttonChrome.InvalidateVisual();
630
+                        return;
631
+                    }
632
+                    Duration duration2 = new Duration(TimeSpan.FromSeconds(0.2));
633
+                    DoubleAnimation doubleAnimation = new DoubleAnimation();
634
+                    doubleAnimation.Duration = duration2;
635
+                    buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
636
+                    buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
637
+                    ColorAnimation colorAnimation = new ColorAnimation();
638
+                    colorAnimation.Duration = duration2;
639
+                    GradientStopCollection gradientStops2 = ((LinearGradientBrush)buttonChrome.InnerBorderPen.Brush).GradientStops;
640
+                    gradientStops2[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
641
+                    gradientStops2[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
642
+                    return;
643
+                }
644
+            }
645
+            else
646
+            {
647
+                buttonChrome._localResources = null;
648
+                buttonChrome.InvalidateVisual();
649
+            }
650
+        }
651
+        private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
652
+        {
653
+            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;
654
+            if (buttonChrome.Animates)
655
+            {
656
+                if (!buttonChrome.RenderPressed)
657
+                {
658
+                    if ((bool)e.NewValue)
659
+                    {
660
+                        if (buttonChrome._localResources == null)
661
+                        {
662
+                            buttonChrome._localResources = new ImageButtonChrome.LocalResources();
663
+                            buttonChrome.InvalidateVisual();
664
+                        }
665
+                        Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
666
+                        DoubleAnimation animation = new DoubleAnimation(1.0, duration);
667
+                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
668
+                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, animation);
669
+                        return;
670
+                    }
671
+                    if (buttonChrome._localResources == null)
672
+                    {
673
+                        buttonChrome.InvalidateVisual();
674
+                        return;
675
+                    }
676
+                    if (buttonChrome.RenderDefaulted)
677
+                    {
678
+                        double opacity = buttonChrome.BackgroundOverlay.Opacity;
679
+                        double num = (1.0 - opacity) * 0.5;
680
+                        DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
681
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(num)));
682
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(num + 0.25)));
683
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(num + 1.5)));
684
+                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(opacity, TimeSpan.FromSeconds(2.0)));
685
+                        doubleAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
686
+                        Timeline.SetDesiredFrameRate(doubleAnimationUsingKeyFrames, new int?(10));
687
+                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
688
+                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
689
+                        return;
690
+                    }
691
+                    Duration duration2 = new Duration(TimeSpan.FromSeconds(0.2));
692
+                    DoubleAnimation doubleAnimation = new DoubleAnimation();
693
+                    doubleAnimation.Duration = duration2;
694
+                    buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
695
+                    buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
696
+                    return;
697
+                }
698
+            }
699
+            else
700
+            {
701
+                buttonChrome._localResources = null;
702
+                buttonChrome.InvalidateVisual();
703
+            }
704
+        }
705
+        private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
706
+        {
707
+            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;
708
+            if (!buttonChrome.Animates)
709
+            {
710
+                buttonChrome._localResources = null;
711
+                buttonChrome.InvalidateVisual();
712
+                return;
713
+            }
714
+            if ((bool)e.NewValue)
715
+            {
716
+                if (buttonChrome._localResources == null)
717
+                {
718
+                    buttonChrome._localResources = new ImageButtonChrome.LocalResources();
719
+                    buttonChrome.InvalidateVisual();
720
+                }
721
+                Duration duration = new Duration(TimeSpan.FromSeconds(0.1));
722
+                DoubleAnimation animation = new DoubleAnimation(1.0, duration);
723
+                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, animation);
724
+                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
725
+                buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
726
+                buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
727
+                animation = new DoubleAnimation(0.0, duration);
728
+                buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
729
+                ColorAnimation animation2 = new ColorAnimation(Color.FromRgb(194, 228, 246), duration);
730
+                GradientStopCollection gradientStops = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;
731
+                gradientStops[0].BeginAnimation(GradientStop.ColorProperty, animation2);
732
+                gradientStops[1].BeginAnimation(GradientStop.ColorProperty, animation2);
733
+                animation2 = new ColorAnimation(Color.FromRgb(171, 218, 243), duration);
734
+                gradientStops[2].BeginAnimation(GradientStop.ColorProperty, animation2);
735
+                animation2 = new ColorAnimation(Color.FromRgb(144, 203, 235), duration);
736
+                gradientStops[3].BeginAnimation(GradientStop.ColorProperty, animation2);
737
+                animation2 = new ColorAnimation(Color.FromRgb(44, 98, 139), duration);
738
+                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, animation2);
739
+                return;
740
+            }
741
+            if (buttonChrome._localResources == null)
742
+            {
743
+                buttonChrome.InvalidateVisual();
744
+                return;
745
+            }
746
+            bool renderMouseOver = buttonChrome.RenderMouseOver;
747
+            Duration duration2 = new Duration(TimeSpan.FromSeconds(0.1));
748
+            DoubleAnimation doubleAnimation = new DoubleAnimation();
749
+            doubleAnimation.Duration = duration2;
750
+            buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
751
+            buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
752
+            buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
753
+            if (!renderMouseOver)
754
+            {
755
+                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
756
+                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
757
+            }
758
+            ColorAnimation colorAnimation = new ColorAnimation();
759
+            colorAnimation.Duration = duration2;
760
+            buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
761
+            GradientStopCollection gradientStops2 = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;
762
+            gradientStops2[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
763
+            gradientStops2[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
764
+            gradientStops2[2].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
765
+            gradientStops2[3].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
766
+        }
767
+        private void DrawBackground(DrawingContext dc, ref Rect bounds)
768
+        {
769
+            if (!base.IsEnabled && !this.RoundCorners)
770
+            {
771
+                return;
772
+            }
773
+            Brush brush = this.Background;
774
+            if (bounds.Width > 4.0 && bounds.Height > 4.0)
775
+            {
776
+                Rect rectangle = new Rect(bounds.Left + 1.0, bounds.Top + 1.0, bounds.Width - 2.0, bounds.Height - 2.0);
777
+                if (brush != null)
778
+                {
779
+                    dc.DrawRectangle(brush, null, rectangle);
780
+                }
781
+                brush = this.BackgroundOverlay;
782
+                if (brush != null)
783
+                {
784
+                    dc.DrawRectangle(brush, null, rectangle);
785
+                }
786
+            }
787
+        }
788
+        private void DrawDropShadows(DrawingContext dc, ref Rect bounds)
789
+        {
790
+            if (bounds.Width > 4.0 && bounds.Height > 4.0)
791
+            {
792
+                Brush leftDropShadowBrush = this.LeftDropShadowBrush;
793
+                if (leftDropShadowBrush != null)
794
+                {
795
+                    dc.DrawRectangle(leftDropShadowBrush, null, new Rect(1.0, 1.0, 2.0, bounds.Bottom - 2.0));
796
+                }
797
+                Brush topDropShadowBrush = this.TopDropShadowBrush;
798
+                if (topDropShadowBrush != null)
799
+                {
800
+                    dc.DrawRectangle(topDropShadowBrush, null, new Rect(1.0, 1.0, bounds.Right - 2.0, 2.0));
801
+                }
802
+            }
803
+        }
804
+        private void DrawBorder(DrawingContext dc, ref Rect bounds)
805
+        {
806
+            if (bounds.Width >= 5.0 && bounds.Height >= 5.0)
807
+            {
808
+                Brush brush = this.BorderBrush;
809
+                Pen pen = null;
810
+                if (brush != null)
811
+                {
812
+                    if (ImageButtonChrome._commonBorderPen == null)
813
+                    {
814
+                        lock (ImageButtonChrome._resourceAccess)
815
+                        {
816
+                            if (ImageButtonChrome._commonBorderPen == null)
817
+                            {
818
+                                if (!brush.IsFrozen && brush.CanFreeze)
819
+                                {
820
+                                    brush = brush.Clone();
821
+                                    brush.Freeze();
822
+                                }
823
+                                Pen pen2 = new Pen(brush, 1.0);
824
+                                if (pen2.CanFreeze)
825
+                                {
826
+                                    pen2.Freeze();
827
+                                    ImageButtonChrome._commonBorderPen = pen2;
828
+                                }
829
+                            }
830
+                        }
831
+                    }
832
+                    if (ImageButtonChrome._commonBorderPen != null && brush == ImageButtonChrome._commonBorderPen.Brush)
833
+                    {
834
+                        pen = ImageButtonChrome._commonBorderPen;
835
+                    }
836
+                    else
837
+                    {
838
+                        if (!brush.IsFrozen && brush.CanFreeze)
839
+                        {
840
+                            brush = brush.Clone();
841
+                            brush.Freeze();
842
+                        }
843
+                        pen = new Pen(brush, 1.0);
844
+                        if (pen.CanFreeze)
845
+                        {
846
+                            pen.Freeze();
847
+                        }
848
+                    }
849
+                }
850
+                Pen borderOverlayPen = this.BorderOverlayPen;
851
+                if (pen != null || borderOverlayPen != null)
852
+                {
853
+                    if (this.RoundCorners)
854
+                    {
855
+                        Rect rectangle = new Rect(bounds.Left + 0.5, bounds.Top + 0.5, bounds.Width - 1.0, bounds.Height - 1.0);
856
+                        if (base.IsEnabled && pen != null)
857
+                        {
858
+                            dc.DrawRoundedRectangle(null, pen, rectangle, 2.75, 2.75);
859
+                        }
860
+                        if (borderOverlayPen != null)
861
+                        {
862
+                            dc.DrawRoundedRectangle(null, borderOverlayPen, rectangle, 2.75, 2.75);
863
+                            return;
864
+                        }
865
+                    }
866
+                    else
867
+                    {
868
+                        PathFigure pathFigure = new PathFigure();
869
+                        pathFigure.StartPoint = new Point(0.5, 0.5);
870
+                        pathFigure.Segments.Add(new LineSegment(new Point(0.5, bounds.Bottom - 0.5), true));
871
+                        pathFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 2.5, bounds.Bottom - 0.5), true));
872
+                        pathFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 0.5, bounds.Bottom - 2.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true));
873
+                        pathFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 0.5, bounds.Top + 2.5), true));
874
+                        pathFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 2.5, bounds.Top + 0.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true));
875
+                        pathFigure.IsClosed = true;
876
+                        PathGeometry pathGeometry = new PathGeometry();
877
+                        pathGeometry.Figures.Add(pathFigure);
878
+                        if (base.IsEnabled && pen != null)
879
+                        {
880
+                            dc.DrawGeometry(null, pen, pathGeometry);
881
+                        }
882
+                        if (borderOverlayPen != null)
883
+                        {
884
+                            dc.DrawGeometry(null, borderOverlayPen, pathGeometry);
885
+                        }
886
+                    }
887
+                }
888
+            }
889
+        }
890
+        private void DrawInnerBorder(DrawingContext dc, ref Rect bounds)
891
+        {
892
+            if (!base.IsEnabled && !this.RoundCorners)
893
+            {
894
+                return;
895
+            }
896
+            if (bounds.Width >= 4.0 && bounds.Height >= 4.0)
897
+            {
898
+                Pen innerBorderPen = this.InnerBorderPen;
899
+                if (innerBorderPen != null)
900
+                {
901
+                    dc.DrawRoundedRectangle(null, innerBorderPen, new Rect(bounds.Left + 1.5, bounds.Top + 1.5, bounds.Width - 3.0, bounds.Height - 3.0), 1.75, 1.75);
902
+                }
903
+            }
904
+        }
905
+    }
906
+
907
+}

+ 75
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/ClipBorder.ts View File

@@ -0,0 +1,75 @@
1
+// 假设 GeometryHelper 类的实现
2
+class GeometryHelper {
3
+    static GetRoundRectangle(rect: { width: number; height: number }, borderThickness: number, cornerRadius: number): string {
4
+        // 这里只是简单返回一个 CSS 的 border-radius 值,实际应用中可能需要更复杂的计算
5
+        return `${cornerRadius}px`;
6
+    }
7
+}
8
+
9
+class ClipBorder {
10
+    private clipRect: string | null = null;
11
+    private oldClip: string | null = null;
12
+    private element: HTMLElement;
13
+    private child: HTMLElement | null = null;
14
+
15
+    constructor(element: HTMLElement) {
16
+        this.element = element;
17
+    }
18
+
19
+    set Child(value: HTMLElement | null) {
20
+        if (this.child !== value) {
21
+            if (this.child) {
22
+                // Restore original clipping of the old child
23
+                this.child.style.clipPath = this.oldClip || '';
24
+            }
25
+
26
+            if (value) {
27
+                // Store the current clipping of the new child
28
+                this.oldClip = value.style.clipPath;
29
+            } else {
30
+                // If we dont set it to null we could leak a Geometry object
31
+                this.oldClip = null;
32
+            }
33
+
34
+            this.child = value;
35
+            if (this.child) {
36
+                this.element.appendChild(this.child);
37
+                this.onApplyChildClip();
38
+            }
39
+        }
40
+    }
41
+
42
+    get Child(): HTMLElement | null {
43
+        return this.child;
44
+    }
45
+
46
+    private onApplyChildClip() {
47
+        const child = this.child;
48
+        if (child) {
49
+            // Get the geometry of a rounded rectangle border based on the BorderThickness and CornerRadius
50
+            const borderThickness = parseFloat(getComputedStyle(this.element).borderWidth);
51
+            const cornerRadius = parseFloat(getComputedStyle(this.element).borderTopLeftRadius);
52
+            const rect = { width: child.offsetWidth, height: child.offsetHeight };
53
+            this.clipRect = GeometryHelper.GetRoundRectangle(rect, borderThickness, cornerRadius);
54
+            child.style.clipPath = `round rect(0, 0, ${rect.width}px, ${rect.height}px, ${this.clipRect})`;
55
+        }
56
+    }
57
+
58
+    render() {
59
+        this.onApplyChildClip();
60
+    }
61
+}
62
+
63
+// 使用示例
64
+const container = document.createElement('div');
65
+container.style.border = '1px solid black';
66
+container.style.borderRadius = '10px';
67
+document.body.appendChild(container);
68
+
69
+const clipBorder = new ClipBorder(container);
70
+const childElement = document.createElement('div');
71
+childElement.style.width = '200px';
72
+childElement.style.height = '200px';
73
+childElement.style.backgroundColor = 'red';
74
+clipBorder.Child = childElement;
75
+clipBorder.render();

+ 124
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/GeometryHelper.ts View File

@@ -0,0 +1,124 @@
1
+// 定义 Rect 类型
2
+interface Rect {
3
+    x: number;
4
+    y: number;
5
+    width: number;
6
+    height: number;
7
+}
8
+
9
+// 定义 Thickness 类型
10
+interface Thickness {
11
+    left: number;
12
+    top: number;
13
+    right: number;
14
+    bottom: number;
15
+}
16
+
17
+// 定义 CornerRadius 类型
18
+interface CornerRadius {
19
+    topLeft: number;
20
+    topRight: number;
21
+    bottomLeft: number;
22
+    bottomRight: number;
23
+}
24
+
25
+// 定义 GeometryHelper 类
26
+class GeometryHelper {
27
+    /**
28
+     * 获取带有圆角的矩形 SVG 路径
29
+     * @param baseRect 基础矩形
30
+     * @param thickness 边框厚度
31
+     * @param cornerRadius 圆角半径
32
+     * @returns SVG 路径字符串
33
+     */
34
+    static getRoundRectangle(baseRect: Rect, thickness: Thickness, cornerRadius: CornerRadius): string {
35
+        // 归一化圆角半径
36
+        if (cornerRadius.topLeft < Number.EPSILON)
37
+            cornerRadius.topLeft = 0.0;
38
+        if (cornerRadius.topRight < Number.EPSILON)
39
+            cornerRadius.topRight = 0.0;
40
+        if (cornerRadius.bottomLeft < Number.EPSILON)
41
+            cornerRadius.bottomLeft = 0.0;
42
+        if (cornerRadius.bottomRight < Number.EPSILON)
43
+            cornerRadius.bottomRight = 0.0;
44
+
45
+        // 考虑边框厚度
46
+        const leftHalf = thickness.left * 0.5;
47
+        const topHalf = thickness.top * 0.5;
48
+        const rightHalf = thickness.right * 0.5;
49
+        const bottomHalf = thickness.bottom * 0.5;
50
+
51
+        // 计算公差
52
+        const tolerance = baseRect.height < baseRect.width ? baseRect.height / baseRect.width : baseRect.width / baseRect.height;
53
+
54
+        // 创建四个角的矩形
55
+        const topLeftRect: Rect = {
56
+            x: baseRect.x - tolerance,
57
+            y: baseRect.y - tolerance,
58
+            width: Math.max(0.0, cornerRadius.topLeft - leftHalf),
59
+            height: Math.max(0.0, cornerRadius.topLeft - topHalf)
60
+        };
61
+        const topRightRect: Rect = {
62
+            x: baseRect.x + baseRect.width - cornerRadius.topRight + rightHalf + tolerance,
63
+            y: baseRect.y - tolerance,
64
+            width: Math.max(0.0, cornerRadius.topRight - rightHalf),
65
+            height: Math.max(0.0, cornerRadius.topRight - topHalf)
66
+        };
67
+        const bottomRightRect: Rect = {
68
+            x: baseRect.x + baseRect.width - cornerRadius.bottomRight + rightHalf + tolerance,
69
+            y: baseRect.y + baseRect.height - cornerRadius.bottomRight + bottomHalf + tolerance,
70
+            width: Math.max(0.0, cornerRadius.bottomRight - rightHalf),
71
+            height: Math.max(0.0, cornerRadius.bottomRight - bottomHalf)
72
+        };
73
+        const bottomLeftRect: Rect = {
74
+            x: baseRect.x - tolerance,
75
+            y: baseRect.y + baseRect.height - cornerRadius.bottomLeft + bottomHalf + tolerance,
76
+            width: Math.max(0.0, cornerRadius.bottomLeft - leftHalf),
77
+            height: Math.max(0.0, cornerRadius.bottomLeft - bottomHalf)
78
+        };
79
+
80
+        // 调整角矩形的宽高比例
81
+        if (topLeftRect.x + topLeftRect.width > topRightRect.x) {
82
+            const newWidth = (topLeftRect.width / (topLeftRect.width + topRightRect.width)) * baseRect.width;
83
+            topLeftRect.width = newWidth;
84
+            topRightRect.x = baseRect.x + newWidth;
85
+            topRightRect.width = Math.max(0.0, baseRect.width - newWidth);
86
+        }
87
+
88
+        if (topRightRect.y + topRightRect.height > bottomRightRect.y) {
89
+            const newHeight = (topRightRect.height / (topRightRect.height + bottomRightRect.height)) * baseRect.height;
90
+            topRightRect.height = newHeight;
91
+            bottomRightRect.y = baseRect.y + newHeight;
92
+            bottomRightRect.height = Math.max(0.0, baseRect.height - newHeight);
93
+        }
94
+
95
+        if (bottomRightRect.x < bottomLeftRect.x + bottomLeftRect.width) {
96
+            const newWidth = (bottomLeftRect.width / (bottomLeftRect.width + bottomRightRect.width)) * baseRect.width;
97
+            bottomLeftRect.width = newWidth;
98
+            bottomRightRect.x = baseRect.x + newWidth;
99
+            bottomRightRect.width = Math.max(0.0, baseRect.width - newWidth);
100
+        }
101
+
102
+        if (bottomLeftRect.y < topLeftRect.y + topLeftRect.height) {
103
+            const newHeight = (topLeftRect.height / (topLeftRect.height + bottomLeftRect.height)) * baseRect.height;
104
+            topLeftRect.height = newHeight;
105
+            bottomLeftRect.y = baseRect.y + newHeight;
106
+            bottomLeftRect.height = Math.max(0.0, baseRect.height - newHeight);
107
+        }
108
+
109
+        // 创建 SVG 路径
110
+        let path = `M ${topLeftRect.x + topLeftRect.width},${topLeftRect.y + topLeftRect.height}`;
111
+        path += ` A ${topLeftRect.width},${topLeftRect.height} 0 0 1 ${topLeftRect.x},${topLeftRect.y + topLeftRect.height}`;
112
+        path += ` L ${topRightRect.x},${topRightRect.y}`;
113
+        path += ` A ${topRightRect.width},${topRightRect.height} 0 0 1 ${topRightRect.x + topRightRect.width},${topRightRect.y}`;
114
+        path += ` L ${bottomRightRect.x + bottomRightRect.width},${bottomRightRect.y}`;
115
+        path += ` A ${bottomRightRect.width},${bottomRightRect.height} 0 0 1 ${bottomRightRect.x + bottomRightRect.width},${bottomRightRect.y + bottomRightRect.height}`;
116
+        path += ` L ${bottomLeftRect.x + bottomLeftRect.width},${bottomLeftRect.y + bottomLeftRect.height}`;
117
+        path += ` A ${bottomLeftRect.width},${bottomLeftRect.height} 0 0 1 ${bottomLeftRect.x},${bottomLeftRect.y + bottomLeftRect.height}`;
118
+        path += ' Z';
119
+
120
+        return path;
121
+    }
122
+}
123
+
124
+export default GeometryHelper;

+ 838
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/BaseContainer/ToggleSwitch/ToggleSwitch.cs View File

@@ -0,0 +1,838 @@
1
+#region File Header
2
+
3
+// -------------------------------------------------------------------------------
4
+// 
5
+// This file is part of the WPFSpark project: http://wpfspark.codeplex.com/
6
+//
7
+// Author: Ratish Philip
8
+// 
9
+// WPFSpark v1.1
10
+//
11
+// -------------------------------------------------------------------------------
12
+
13
+#endregion
14
+
15
+using System.Windows;
16
+using System.Windows.Controls;
17
+using System.Windows.Controls.Primitives;
18
+using System.Windows.Media;
19
+using System;
20
+
21
+namespace Platform.Controls.BaseContainer
22
+{
23
+    [TemplatePart(Name = "PART_ContentBorder", Type = typeof(Border))]
24
+    [TemplatePart(Name = "PART_RootGrid", Type = typeof(Grid))]
25
+    [TemplatePart(Name = "PART_ContentGrid", Type = typeof(Grid))]
26
+    public class ToggleSwitch : ToggleButton
27
+    {
28
+        #region Fields
29
+
30
+        Grid rootGrid = null;
31
+        Border contentBorder = null;
32
+        Grid contentGrid = null;
33
+        Border checkedBorder = null;
34
+        Border unCheckedBorder = null;
35
+        TextBlock checkedContent = null;
36
+        TextBlock unCheckedContent = null;
37
+        double contentBorderMargin;
38
+
39
+        #endregion
40
+
41
+        #region Constants
42
+
43
+        private const double DEFAULT_THUMB_WIDTH = 40.0;
44
+        private const double MIN_THUMB_WIDTH = 10.0;
45
+        private const double MAX_THUMB_WIDTH = 90.0;
46
+
47
+        #endregion
48
+
49
+        #region Dependency Properties
50
+        /// <summary>
51
+        /// IsReadOnly Dependency Property
52
+        /// </summary>
53
+        public bool IsReadOnly
54
+        {
55
+            get { return (bool)GetValue(IsReadOnlyProperty); }
56
+            set { SetValue(IsReadOnlyProperty, value); }
57
+        }
58
+
59
+        // Using a DependencyProperty as the backing store for IsReadOnly.  This enables animation, styling, binding, etc...
60
+        public static readonly DependencyProperty IsReadOnlyProperty =
61
+            DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(ToggleSwitch), new UIPropertyMetadata(false));
62
+
63
+        
64
+
65
+        #region CheckedText
66
+
67
+        /// <summary>
68
+        /// CheckedText Dependency Property
69
+        /// </summary>
70
+        public static readonly DependencyProperty CheckedTextProperty =
71
+            DependencyProperty.Register("CheckedText", typeof(string), typeof(ToggleSwitch),
72
+                new PropertyMetadata(string.Empty));
73
+
74
+        /// <summary>
75
+        /// Gets or sets the CheckedText property. This dependency property 
76
+        /// indicates the on text.
77
+        /// </summary>
78
+        public string CheckedText
79
+        {
80
+            get { return (string)GetValue(CheckedTextProperty); }
81
+            set { SetValue(CheckedTextProperty, value); }
82
+        }
83
+
84
+        #endregion
85
+
86
+        #region CheckedBackground
87
+
88
+        /// <summary>
89
+        /// CheckedBackground Dependency Property
90
+        /// </summary>
91
+        public static readonly DependencyProperty CheckedBackgroundProperty =
92
+            DependencyProperty.Register("CheckedBackground", typeof(Brush), typeof(ToggleSwitch),
93
+                new PropertyMetadata(Brushes.White));
94
+
95
+        /// <summary>
96
+        /// Gets or sets the CheckedBackground property. This dependency property 
97
+        /// indicates Background of the Checked Text.
98
+        /// </summary>
99
+        public Brush CheckedBackground
100
+        {
101
+            get { return (Brush)GetValue(CheckedBackgroundProperty); }
102
+            set { SetValue(CheckedBackgroundProperty, value); }
103
+        }
104
+
105
+        #endregion
106
+
107
+        #region CheckedForeground
108
+
109
+        /// <summary>
110
+        /// CheckedForeground Dependency Property
111
+        /// </summary>
112
+        public static readonly DependencyProperty CheckedForegroundProperty =
113
+            DependencyProperty.Register("CheckedForeground", typeof(Brush), typeof(ToggleSwitch),
114
+                new PropertyMetadata(Brushes.Black));
115
+
116
+        /// <summary>
117
+        /// Gets or sets the CheckedForeground property. This dependency property 
118
+        /// indicates Foreground of the Checked Text.
119
+        /// </summary>
120
+        public Brush CheckedForeground
121
+        {
122
+            get { return (Brush)GetValue(CheckedForegroundProperty); }
123
+            set { SetValue(CheckedForegroundProperty, value); }
124
+        }
125
+
126
+        #endregion
127
+
128
+        #region CheckedToolTip
129
+
130
+        /// <summary>
131
+        /// CheckedToolTip Dependency Property
132
+        /// </summary>
133
+        public static readonly DependencyProperty CheckedToolTipProperty =
134
+            DependencyProperty.Register("CheckedToolTip", typeof(string), typeof(ToggleSwitch),
135
+                new FrameworkPropertyMetadata(string.Empty,
136
+                    new PropertyChangedCallback(OnCheckedToolTipChanged)));
137
+
138
+        /// <summary>
139
+        /// Gets or sets the CheckedToolTip property. This dependency property 
140
+        /// indicates the tooltip of the ToggleSwitch when the control is in Checked state.
141
+        /// </summary>
142
+        public string CheckedToolTip
143
+        {
144
+            get { return (string)GetValue(CheckedToolTipProperty); }
145
+            set { SetValue(CheckedToolTipProperty, value); }
146
+        }
147
+
148
+        /// <summary>
149
+        /// Handles changes to the CheckedToolTip property.
150
+        /// </summary>
151
+        /// <param name="d">ToggleSwitch</param>
152
+        /// <param name="e">DependencyProperty changed event arguments</param>
153
+        private static void OnCheckedToolTipChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
154
+        {
155
+            ToggleSwitch tSwitch = (ToggleSwitch)d;
156
+            string oldCheckedToolTip = (string)e.OldValue;
157
+            string newCheckedToolTip = tSwitch.CheckedToolTip;
158
+            tSwitch.OnCheckedToolTipChanged(oldCheckedToolTip, newCheckedToolTip);
159
+        }
160
+
161
+        /// <summary>
162
+        /// Provides derived classes an opportunity to handle changes to the CheckedToolTip property.
163
+        /// </summary>
164
+        /// <param name="oldCheckedToolTip">Old Value</param>
165
+        /// <param name="newCheckedToolTip">New Value</param>
166
+        protected void OnCheckedToolTipChanged(string oldCheckedToolTip, string newCheckedToolTip)
167
+        {
168
+            Dispatcher.BeginInvoke(new Action(() =>
169
+            {
170
+                if ((this.IsChecked == true) && (!String.IsNullOrWhiteSpace(newCheckedToolTip)))
171
+                {
172
+                    this.ToolTip = new ToolTip() { Content = newCheckedToolTip };
173
+                }
174
+            }));
175
+        }
176
+
177
+        #endregion
178
+
179
+        #region CornerRadius
180
+
181
+        /// <summary>
182
+        /// CornerRadius Dependency Property
183
+        /// </summary>
184
+        public static readonly DependencyProperty CornerRadiusProperty =
185
+            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ToggleSwitch),
186
+                new PropertyMetadata(new CornerRadius()));
187
+
188
+        /// <summary>
189
+        /// Gets or sets the CornerRadius property. This dependency property 
190
+        /// indicates the corner radius of the outer most border of the ToggleSwitch.
191
+        /// </summary>
192
+        public CornerRadius CornerRadius
193
+        {
194
+            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
195
+            set { SetValue(CornerRadiusProperty, value); }
196
+        }
197
+
198
+        #endregion
199
+
200
+        #region IsCheckedLeft
201
+
202
+        /// <summary>
203
+        /// IsCheckedLeft Dependency Property
204
+        /// </summary>
205
+        public static readonly DependencyProperty IsCheckedLeftProperty =
206
+            DependencyProperty.Register("IsCheckedLeft", typeof(bool), typeof(ToggleSwitch),
207
+                new FrameworkPropertyMetadata(true,
208
+                    new PropertyChangedCallback(OnIsCheckedLeftChanged)));
209
+
210
+        /// <summary>
211
+        /// Gets or sets the IsCheckedLeft property. This dependency property 
212
+        /// indicates whether the content for the Checked state should appear in the left side.
213
+        /// </summary>
214
+        public bool IsCheckedLeft
215
+        {
216
+            get { return (bool)GetValue(IsCheckedLeftProperty); }
217
+            set { SetValue(IsCheckedLeftProperty, value); }
218
+        }
219
+
220
+        /// <summary>
221
+        /// Handles changes to the IsCheckedLeft property.
222
+        /// </summary>
223
+        /// <param name="d">ToggleSwitch</param>
224
+        /// <param name="e">DependencyProperty changed event arguments</param>
225
+        private static void OnIsCheckedLeftChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
226
+        {
227
+            ToggleSwitch tSwitch = (ToggleSwitch)d;
228
+            bool oldIsCheckedLeft = (bool)e.OldValue;
229
+            bool newIsCheckedLeft = tSwitch.IsCheckedLeft;
230
+            tSwitch.OnIsCheckedLeftChanged(oldIsCheckedLeft, newIsCheckedLeft);
231
+        }
232
+
233
+        /// <summary>
234
+        /// Provides derived classes an opportunity to handle changes to the IsCheckedLeft property.
235
+        /// </summary>
236
+        /// <param name="oldIsCheckedLeft">Old Value</param>
237
+        /// <param name="newIsCheckedLeft">New Value</param>
238
+        protected void OnIsCheckedLeftChanged(bool oldIsCheckedLeft, bool newIsCheckedLeft)
239
+        {
240
+            UpdateToggleSwitchContents(newIsCheckedLeft);
241
+        }
242
+
243
+        #endregion
244
+
245
+        #region TargetColumnInternal
246
+
247
+        /// <summary>
248
+        /// TargetColumnInternal Dependency Property
249
+        /// </summary>
250
+        public static readonly DependencyProperty TargetColumnInternalProperty =
251
+            DependencyProperty.Register("TargetColumnInternal", typeof(int), typeof(ToggleSwitch),
252
+                new FrameworkPropertyMetadata((new PropertyChangedCallback(OnTargetColumnInternalChanged))));
253
+
254
+        /// <summary>
255
+        /// Gets or sets the TargetColumnInternal property. This dependency property 
256
+        /// indicates the win column to which the contentborder moves when the control is in unchecked state.
257
+        /// This property is used internally.
258
+        /// </summary>
259
+        public int TargetColumnInternal
260
+        {
261
+            get { return (int)GetValue(TargetColumnInternalProperty); }
262
+            set { SetValue(TargetColumnInternalProperty, value); }
263
+        }
264
+
265
+        /// <summary>
266
+        /// Handles changes to the TargetColumnInternal property.
267
+        /// </summary>
268
+        /// <param name="d">ToggleSwitch</param>
269
+        /// <param name="e">DependencyProperty changed event arguments</param>
270
+        private static void OnTargetColumnInternalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
271
+        {
272
+            ToggleSwitch ts = (ToggleSwitch)d;
273
+            int oldTargetColumnInternal = (int)e.OldValue;
274
+            int newTargetColumnInternal = ts.TargetColumnInternal;
275
+            ts.OnTargetColumnInternalChanged(oldTargetColumnInternal, newTargetColumnInternal);
276
+        }
277
+
278
+        /// <summary>
279
+        /// Provides derived classes an opportunity to handle changes to the TargetColumnInternal property.
280
+        /// </summary>
281
+        /// <param name="oldTargetColumnInternal">Old Value</param>
282
+        /// <param name="newTargetColumnInternal">New Value</param>
283
+        protected void OnTargetColumnInternalChanged(int oldTargetColumnInternal, int newTargetColumnInternal)
284
+        {
285
+
286
+        }
287
+
288
+        #endregion
289
+
290
+        #region ThumbBackground
291
+
292
+        /// <summary>
293
+        /// ThumbBackground Dependency Property
294
+        /// </summary>
295
+        public static readonly DependencyProperty ThumbBackgroundProperty =
296
+            DependencyProperty.Register("ThumbBackground", typeof(Brush), typeof(ToggleSwitch),
297
+                new PropertyMetadata((Brushes.Black)));
298
+
299
+        /// <summary>
300
+        /// Gets or sets the ThumbBackground property. This dependency property 
301
+        /// indicates the Background of the Thumb.
302
+        /// </summary>
303
+        public Brush ThumbBackground
304
+        {
305
+            get { return (Brush)GetValue(ThumbBackgroundProperty); }
306
+            set { SetValue(ThumbBackgroundProperty, value); }
307
+        }
308
+
309
+        #endregion
310
+
311
+        #region ThumbBorderBrush
312
+
313
+        /// <summary>
314
+        /// ThumbBorderBrush Dependency Property
315
+        /// </summary>
316
+        public static readonly DependencyProperty ThumbBorderBrushProperty =
317
+            DependencyProperty.Register("ThumbBorderBrush", typeof(Brush), typeof(ToggleSwitch),
318
+                new PropertyMetadata(Brushes.Gray));
319
+
320
+        /// <summary>
321
+        /// Gets or sets the ThumbBorderBrush property. This dependency property 
322
+        /// indicates the BorderBrush of the Thumb.
323
+        /// </summary>
324
+        public Brush ThumbBorderBrush
325
+        {
326
+            get { return (Brush)GetValue(ThumbBorderBrushProperty); }
327
+            set { SetValue(ThumbBorderBrushProperty, value); }
328
+        }
329
+
330
+        #endregion
331
+
332
+        #region ThumbBorderThickness
333
+
334
+        /// <summary>
335
+        /// ThumbBorderThickness Dependency Property
336
+        /// </summary>
337
+        public static readonly DependencyProperty ThumbBorderThicknessProperty =
338
+            DependencyProperty.Register("ThumbBorderThickness", typeof(Thickness), typeof(ToggleSwitch),
339
+                new PropertyMetadata(new Thickness()));
340
+
341
+        /// <summary>
342
+        /// Gets or sets the ThumbBorderThickness property. This dependency property 
343
+        /// indicates the BorderThickness of the Thumb.
344
+        /// </summary>
345
+        public Thickness ThumbBorderThickness
346
+        {
347
+            get { return (Thickness)GetValue(ThumbBorderThicknessProperty); }
348
+            set { SetValue(ThumbBorderThicknessProperty, value); }
349
+        }
350
+
351
+        #endregion
352
+
353
+        #region ThumbCornerRadius
354
+
355
+        /// <summary>
356
+        /// ThumbCornerRadius Dependency Property
357
+        /// </summary>
358
+        public static readonly DependencyProperty ThumbCornerRadiusProperty =
359
+            DependencyProperty.Register("ThumbCornerRadius", typeof(CornerRadius), typeof(ToggleSwitch),
360
+                new PropertyMetadata(new CornerRadius()));
361
+
362
+        /// <summary>
363
+        /// Gets or sets the ThumbCornerRadius property. This dependency property 
364
+        /// indicates the corner radius of the Thumb.
365
+        /// </summary>
366
+        public CornerRadius ThumbCornerRadius
367
+        {
368
+            get { return (CornerRadius)GetValue(ThumbCornerRadiusProperty); }
369
+            set { SetValue(ThumbCornerRadiusProperty, value); }
370
+        }
371
+
372
+        #endregion
373
+
374
+        #region ThumbGlowColor
375
+
376
+        /// <summary>
377
+        /// ThumbGlowColor Dependency Property
378
+        /// </summary>
379
+        public static readonly DependencyProperty ThumbGlowColorProperty =
380
+            DependencyProperty.Register("ThumbGlowColor", typeof(Color), typeof(ToggleSwitch),
381
+                new PropertyMetadata(Colors.LawnGreen));
382
+
383
+        /// <summary>
384
+        /// Gets or sets the ThumbGlowColor property. This dependency property 
385
+        /// indicates the GlowColor of the Thumb.
386
+        /// </summary>
387
+        public Color ThumbGlowColor
388
+        {
389
+            get { return (Color)GetValue(ThumbGlowColorProperty); }
390
+            set { SetValue(ThumbGlowColorProperty, value); }
391
+        }
392
+
393
+        #endregion
394
+
395
+        #region ThumbShineCornerRadius
396
+
397
+        /// <summary>
398
+        /// ThumbShineCornerRadius Dependency Property
399
+        /// </summary>
400
+        public static readonly DependencyProperty ThumbShineCornerRadiusProperty =
401
+            DependencyProperty.Register("ThumbShineCornerRadius", typeof(CornerRadius), typeof(ToggleSwitch),
402
+                new FrameworkPropertyMetadata(new CornerRadius()));
403
+
404
+        /// <summary>
405
+        /// Gets or sets the ThumbShineCornerRadius property. This dependency property 
406
+        /// indicates the corner radius of the shine over the thumb.
407
+        /// </summary>
408
+        public CornerRadius ThumbShineCornerRadius
409
+        {
410
+            get { return (CornerRadius)GetValue(ThumbShineCornerRadiusProperty); }
411
+            set { SetValue(ThumbShineCornerRadiusProperty, value); }
412
+        }
413
+
414
+        #endregion
415
+
416
+        #region ThumbWidth
417
+
418
+        /// <summary>
419
+        /// ThumbWidth Dependency Property
420
+        /// </summary>
421
+        public static readonly DependencyProperty ThumbWidthProperty =
422
+            DependencyProperty.Register("ThumbWidth", typeof(double), typeof(ToggleSwitch),
423
+                new FrameworkPropertyMetadata(DEFAULT_THUMB_WIDTH,
424
+                    FrameworkPropertyMetadataOptions.AffectsMeasure,
425
+                    new PropertyChangedCallback(OnThumbWidthChanged),
426
+                    new CoerceValueCallback(CoerceThumbWidth)));
427
+
428
+        /// <summary>
429
+        /// Gets or sets the ThumbWidth property. This dependency property 
430
+        /// indicates the width  of the Thumb as a percentage of the total width of the ToggleSwitch.
431
+        /// </summary>
432
+        public double ThumbWidth
433
+        {
434
+            get { return (double)GetValue(ThumbWidthProperty); }
435
+            set { SetValue(ThumbWidthProperty, value); }
436
+        }
437
+
438
+        /// <summary>
439
+        /// Coerces the Thumb Width to an acceptable value
440
+        /// </summary>
441
+        /// <param name="d">Dependency Object</param>
442
+        /// <param name="value">Value</param>
443
+        /// <returns>Coerced Value</returns>
444
+        private static object CoerceThumbWidth(DependencyObject d, object value)
445
+        {
446
+            double percentage = (double)value;
447
+
448
+            if (percentage < MIN_THUMB_WIDTH)
449
+            {
450
+                return MIN_THUMB_WIDTH;
451
+            }
452
+
453
+            if (percentage > MAX_THUMB_WIDTH)
454
+            {
455
+                return MAX_THUMB_WIDTH;
456
+            }
457
+
458
+            return percentage;
459
+        }
460
+
461
+        /// <summary>
462
+        /// Handles changes to the ThumbWidth property.
463
+        /// </summary>
464
+        /// <param name="d">ToggleSwitch</param>
465
+        /// <param name="e">DependencyProperty changed event arguments</param>
466
+        private static void OnThumbWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
467
+        {
468
+            ToggleSwitch ts = (ToggleSwitch)d;
469
+            double oldThumbWidth = (double)e.OldValue;
470
+            double newThumbWidth = ts.ThumbWidth;
471
+            ts.OnThumbWidthChanged(oldThumbWidth, newThumbWidth);
472
+        }
473
+
474
+        /// <summary>
475
+        /// Provides derived classes an opportunity to handle changes to the ThumbWidth property.
476
+        /// </summary>
477
+        /// <param name="oldThumbWidth">Old Value</param>
478
+        /// <param name="newThumbWidth">New Value</param>
479
+        protected void OnThumbWidthChanged(double oldThumbWidth, double newThumbWidth)
480
+        {
481
+            CalculateLayout();
482
+        }
483
+
484
+        #endregion
485
+
486
+        #region UncheckedBackground
487
+
488
+        /// <summary>
489
+        /// UncheckedBackground Dependency Property
490
+        /// </summary>
491
+        public static readonly DependencyProperty UncheckedBackgroundProperty =
492
+            DependencyProperty.Register("UncheckedBackground", typeof(Brush), typeof(ToggleSwitch),
493
+                new PropertyMetadata(Brushes.White));
494
+
495
+        /// <summary>
496
+        /// Gets or sets the UncheckedBackground property. This dependency property 
497
+        /// indicates the Background of the Unchecked Text.
498
+        /// </summary>
499
+        public Brush UncheckedBackground
500
+        {
501
+            get { return (Brush)GetValue(UncheckedBackgroundProperty); }
502
+            set { SetValue(UncheckedBackgroundProperty, value); }
503
+        }
504
+
505
+        #endregion
506
+
507
+        #region UncheckedForeground
508
+
509
+        /// <summary>
510
+        /// UncheckedForeground Dependency Property
511
+        /// </summary>
512
+        public static readonly DependencyProperty UncheckedForegroundProperty =
513
+            DependencyProperty.Register("UncheckedForeground", typeof(Brush), typeof(ToggleSwitch),
514
+                new PropertyMetadata(Brushes.Black));
515
+
516
+        /// <summary>
517
+        /// Gets or sets the UncheckedForeground property. This dependency property 
518
+        /// indicates the Foreground of the Unchecked Text.
519
+        /// </summary>
520
+        public Brush UncheckedForeground
521
+        {
522
+            get { return (Brush)GetValue(UncheckedForegroundProperty); }
523
+            set { SetValue(UncheckedForegroundProperty, value); }
524
+        }
525
+
526
+        #endregion
527
+
528
+        #region UncheckedText
529
+
530
+        /// <summary>
531
+        /// UncheckedText Dependency Property
532
+        /// </summary>
533
+        public static readonly DependencyProperty UncheckedTextProperty =
534
+            DependencyProperty.Register("UncheckedText", typeof(string), typeof(ToggleSwitch),
535
+                new PropertyMetadata(string.Empty));
536
+
537
+        /// <summary>
538
+        /// Gets or sets the UncheckedText property. This dependency property 
539
+        /// indicates the off text.
540
+        /// </summary>
541
+        public string UncheckedText
542
+        {
543
+            get { return (string)GetValue(UncheckedTextProperty); }
544
+            set { SetValue(UncheckedTextProperty, value); }
545
+        }
546
+
547
+        #endregion
548
+
549
+        #region UncheckedToolTip
550
+
551
+        /// <summary>
552
+        /// UncheckedToolTip Dependency Property
553
+        /// </summary>
554
+        public static readonly DependencyProperty UncheckedToolTipProperty =
555
+            DependencyProperty.Register("UncheckedToolTip", typeof(string), typeof(ToggleSwitch),
556
+                new FrameworkPropertyMetadata(string.Empty,
557
+                    new PropertyChangedCallback(OnUncheckedToolTipChanged)));
558
+
559
+        /// <summary>
560
+        /// Gets or sets the UncheckedToolTip property. This dependency property 
561
+        /// indicates the tooltip for the control when it is in Unchecked state.
562
+        /// </summary>
563
+        public string UncheckedToolTip
564
+        {
565
+            get { return (string)GetValue(UncheckedToolTipProperty); }
566
+            set { SetValue(UncheckedToolTipProperty, value); }
567
+        }
568
+
569
+        /// <summary>
570
+        /// Handles changes to the UncheckedToolTip property.
571
+        /// </summary>
572
+        /// <param name="d">ToggleSwitch</param>
573
+        /// <param name="e">DependencyProperty changed event arguments</param>
574
+        private static void OnUncheckedToolTipChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
575
+        {
576
+            ToggleSwitch tSwitch = (ToggleSwitch)d;
577
+            string oldUncheckedToolTip = (string)e.OldValue;
578
+            string newUncheckedToolTip = tSwitch.UncheckedToolTip;
579
+            tSwitch.OnUncheckedToolTipChanged(oldUncheckedToolTip, newUncheckedToolTip);
580
+        }
581
+
582
+        /// <summary>
583
+        /// Provides derived classes an opportunity to handle changes to the UncheckedToolTip property.
584
+        /// </summary>
585
+        /// <param name="oldUncheckedToolTip">Old Value</param>
586
+        /// <param name="newUncheckedToolTip">New Value</param>
587
+        protected void OnUncheckedToolTipChanged(string oldUncheckedToolTip, string newUncheckedToolTip)
588
+        {
589
+            Dispatcher.BeginInvoke(new Action(() =>
590
+            {
591
+                if ((this.IsChecked == false) && (!String.IsNullOrWhiteSpace(newUncheckedToolTip)))
592
+                {
593
+                    this.ToolTip = new ToolTip() { Content = newUncheckedToolTip };
594
+                }
595
+            }));
596
+        }
597
+
598
+        #endregion
599
+
600
+        #endregion
601
+
602
+        #region Construction
603
+
604
+        static ToggleSwitch()
605
+        {
606
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(ToggleSwitch), new FrameworkPropertyMetadata(typeof(ToggleSwitch)));
607
+        }
608
+
609
+        #endregion
610
+
611
+        #region Overrides
612
+
613
+        /// <summary>
614
+        /// Override which is called when the template is applied
615
+        /// </summary>
616
+        public override void OnApplyTemplate()
617
+        {
618
+            base.OnApplyTemplate();
619
+
620
+            // Get all the controls in the template
621
+            GetTemplateParts();
622
+
623
+            // Calculate the layout of the ToggleSwitch contents
624
+            CalculateLayout();
625
+        }
626
+
627
+        protected override void OnClick()
628
+        {
629
+            if (IsReadOnly)
630
+            {
631
+                return;
632
+            }
633
+            base.OnClick();
634
+        }
635
+        /// <summary>
636
+        /// Handler for the event raised when the size of the ToggleSwitch changes
637
+        /// </summary>
638
+        /// <param name="sizeInfo">Size Changed Info</param>
639
+        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
640
+        {
641
+            base.OnRenderSizeChanged(sizeInfo);
642
+
643
+            // Calculate the margin of the content border
644
+            CalculateContentBorderMargin();
645
+        }
646
+
647
+        /// <summary>
648
+        /// Overridden handler for the event when the ToggleSwitch becomes Checked
649
+        /// </summary>
650
+        /// <param name="e">RoutedEventArgs</param>
651
+        protected override void OnChecked(RoutedEventArgs e)
652
+        {
653
+            // Hide the tooltip if it is displayed
654
+            ToolTip tt = ((ToolTip)ToolTipService.GetToolTip((DependencyObject)this));
655
+            if (tt != null)
656
+                tt.IsOpen = false;
657
+
658
+            base.OnChecked(e);
659
+
660
+            // Set the ToggleSwitch's ToolTip to CheckedToolTip property if it 
661
+            // is not null or empty, else set the ToolTip to null.
662
+            if (!String.IsNullOrWhiteSpace(CheckedToolTip))
663
+                this.ToolTip = new ToolTip() { Content = CheckedToolTip };
664
+            else
665
+                this.ToolTip = null;
666
+        }
667
+
668
+        /// <summary>
669
+        /// Overridden handler for the event when the ToggleSwitch becomes Unchecked
670
+        /// </summary>
671
+        /// <param name="e">RoutedEventArgs</param>
672
+        protected override void OnUnchecked(RoutedEventArgs e)
673
+        {
674
+            // Hide the tooltip if it is displayed
675
+            ToolTip tt = ((ToolTip)ToolTipService.GetToolTip((DependencyObject)this));
676
+            if (tt != null)
677
+                tt.IsOpen = false;
678
+
679
+            base.OnUnchecked(e);
680
+
681
+            // Set the ToggleSwitch's ToolTip to UncheckedToolTip property if it 
682
+            // is not null or empty, else set the ToolTip to null.
683
+            if (!String.IsNullOrWhiteSpace(UncheckedToolTip))
684
+                this.ToolTip = new ToolTip() { Content = UncheckedToolTip };
685
+            else
686
+                this.ToolTip = null;
687
+        }
688
+
689
+        #endregion
690
+
691
+        #region Helpers
692
+
693
+        /// <summary>
694
+        /// Gets the required controls in the template
695
+        /// </summary>
696
+        protected void GetTemplateParts()
697
+        {
698
+            // PART_RootGrid
699
+            rootGrid = GetChildControl<Grid>("PART_RootGrid");
700
+            // PART_ContentBorder
701
+            contentBorder = GetChildControl<Border>("PART_ContentBorder");
702
+            // PART_ContentGrid
703
+            contentGrid = GetChildControl<Grid>("PART_ContentGrid");
704
+            // PART_CheckedBorder
705
+            checkedBorder = GetChildControl<Border>("PART_CheckedBorder");
706
+            // PART_CheckedContent
707
+            checkedContent = GetChildControl<TextBlock>("PART_CheckedContent");
708
+            // PART_UncheckedBorder
709
+            unCheckedBorder = GetChildControl<Border>("PART_UncheckedBorder");
710
+            // PART_UncheckedContent
711
+            unCheckedContent = GetChildControl<TextBlock>("PART_UncheckedContent");
712
+
713
+            UpdateToggleSwitchContents(IsCheckedLeft);
714
+        }
715
+
716
+        /// <summary>
717
+        /// Updates the contents of the ToggleSwitch based on IsCheckedLeft flag.
718
+        /// If it is true, then the Checked content would be in the left side, 
719
+        /// the Unchecked content in the right side and vice-versa if it is false.
720
+        /// </summary>
721
+        /// <param name="isCheckedLeft"></param>
722
+        private void UpdateToggleSwitchContents(bool isCheckedLeft)
723
+        {
724
+            if (isCheckedLeft)
725
+            {
726
+                if (checkedBorder != null)
727
+                    Grid.SetColumn(checkedBorder, 0);
728
+                if (checkedContent != null)
729
+                    Grid.SetColumn(checkedContent, 0);
730
+                if (unCheckedBorder != null)
731
+                    Grid.SetColumn(unCheckedBorder, 3);
732
+                if (unCheckedContent != null)
733
+                    Grid.SetColumn(unCheckedContent, 4);
734
+            }
735
+            else
736
+            {
737
+                if (checkedBorder != null)
738
+                    Grid.SetColumn(checkedBorder, 3);
739
+                if (checkedContent != null)
740
+                    Grid.SetColumn(checkedContent, 4);
741
+                if (unCheckedBorder != null)
742
+                    Grid.SetColumn(unCheckedBorder, 0);
743
+                if (unCheckedContent != null)
744
+                    Grid.SetColumn(unCheckedContent, 0);
745
+            }
746
+        }
747
+
748
+        /// <summary>
749
+        /// Generic method to get a control from the template
750
+        /// </summary>
751
+        /// <typeparam name="T">Type of the control</typeparam>
752
+        /// <param name="ctrlName">Name of the control in the template</param>
753
+        /// <returns>Control</returns>
754
+        protected T GetChildControl<T>(string ctrlName) where T : DependencyObject
755
+        {
756
+            T ctrl = GetTemplateChild(ctrlName) as T;
757
+            return ctrl;
758
+        }
759
+
760
+        /// <summary>
761
+        /// Calculates the width and margin of the contents of the ContentBorder
762
+        /// The following calculation is used: (Here p is the value of ThumbWidth)
763
+        /// p = [10, 90]
764
+        /// Margin = 1 - p
765
+        /// Left = (1 - p)/(2 - p)
766
+        /// Right = (1 - p)/(2 - p)
767
+        /// Center = 0.03
768
+        /// CenterLeft = 0.485 - Left
769
+        /// CenterRight = 0.485 - Left
770
+        /// </summary>
771
+        private void CalculateLayout()
772
+        {
773
+            if ((rootGrid == null) || (contentGrid == null))
774
+                return;
775
+
776
+            // Convert the ThumbWidth value to a percentage
777
+            double thumbPercentage = ThumbWidth / 100.0;
778
+            // Calculate the percentage of Total width available for the content
779
+            double contentPercentage = 1 - thumbPercentage;
780
+
781
+            if (thumbPercentage <= 0.5)
782
+            {
783
+                // Calculate the width of the RootGrid Columns
784
+                rootGrid.ColumnDefinitions[0].Width = new GridLength(thumbPercentage, GridUnitType.Star);
785
+                rootGrid.ColumnDefinitions[1].Width = new GridLength(1.0 - (2 * thumbPercentage), GridUnitType.Star);
786
+                rootGrid.ColumnDefinitions[2].Width = new GridLength(thumbPercentage, GridUnitType.Star);
787
+
788
+                // Adjust the thumb
789
+                TargetColumnInternal = 2;
790
+                Grid.SetColumnSpan(contentBorder, 1);
791
+            }
792
+            else
793
+            {
794
+                // Calculate the width of the RootGrid Columns
795
+                rootGrid.ColumnDefinitions[0].Width = new GridLength(contentPercentage, GridUnitType.Star);
796
+                rootGrid.ColumnDefinitions[1].Width = new GridLength(1.0 - (2 * contentPercentage), GridUnitType.Star);
797
+                rootGrid.ColumnDefinitions[2].Width = new GridLength(contentPercentage, GridUnitType.Star);
798
+
799
+                // Adjust the thumb
800
+                TargetColumnInternal = 1;
801
+                Grid.SetColumnSpan(contentBorder, 2);
802
+            }
803
+
804
+            // Calculate the width of the ContentGrid Columns
805
+            double leftRight = (1 - thumbPercentage) / (2 - thumbPercentage);
806
+            double centerLeftRight = 0.485 - leftRight;
807
+            double center = 0.03;
808
+            contentGrid.ColumnDefinitions[0].Width = new GridLength(leftRight, GridUnitType.Star);
809
+            contentGrid.ColumnDefinitions[1].Width = new GridLength(centerLeftRight, GridUnitType.Star);
810
+            contentGrid.ColumnDefinitions[2].Width = new GridLength(center, GridUnitType.Star);
811
+            contentGrid.ColumnDefinitions[3].Width = new GridLength(centerLeftRight, GridUnitType.Star);
812
+            contentGrid.ColumnDefinitions[4].Width = new GridLength(leftRight, GridUnitType.Star);
813
+
814
+            contentBorderMargin = contentPercentage;
815
+
816
+            CalculateContentBorderMargin();
817
+
818
+            InvalidateVisual();
819
+        }
820
+
821
+        /// <summary>
822
+        /// Calculates the margin of the contentBorder
823
+        /// </summary>
824
+        private void CalculateContentBorderMargin()
825
+        {
826
+            if (contentBorder != null)
827
+            {
828
+                // Change the margin of the content border so that its size is (1 + contentBorderMargin) times the width of
829
+                // the Toggle switch
830
+                contentBorder.Margin = new Thickness(-(this.Width * contentBorderMargin) + 1, 0, -(this.Width * contentBorderMargin) + 1, 0);
831
+            }
832
+
833
+
834
+        }
835
+
836
+        #endregion
837
+    }
838
+}

+ 141
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapDevice.ts View File

@@ -0,0 +1,141 @@
1
+// 假设在前端项目中,可创建一个文件 CapDevice.ts
2
+// 定义 FilterInfo 类
3
+class FilterInfo {
4
+    constructor(public MonikerString: string, public Name: string) {}
5
+}
6
+
7
+// 定义 CapDevice 类
8
+class CapDevice {
9
+    private _stopSignal: boolean = false;
10
+    private _worker: Promise<void> | null = null;
11
+    private _stream: MediaStream | null = null;
12
+    private _videoElement: HTMLVideoElement | null = null;
13
+    private _timer: number = 0;
14
+    private _frames: number = 0;
15
+    private _monikerString: string = "";
16
+    private _name: string = "";
17
+    private _framerate: number = 0;
18
+    private _bitmapSource: HTMLCanvasElement | null = null;
19
+
20
+    public NewBitmapReady: (() => void) | null = null;
21
+
22
+    constructor(moniker: string = "") {
23
+        this._monikerString = moniker;
24
+    }
25
+
26
+    public static async getDeviceMonikers(): Promise<FilterInfo[]> {
27
+        const devices = await navigator.mediaDevices.enumerateDevices();
28
+        return devices
29
+          .filter(device => device.kind === "videoinput")
30
+          .map(device => new FilterInfo(device.deviceId, device.label));
31
+    }
32
+
33
+    public async getDevices(): Promise<CapDevice[]> {
34
+        const monikers = await CapDevice.getDeviceMonikers();
35
+        return monikers.map(moniker => new CapDevice(moniker.MonikerString));
36
+    }
37
+
38
+    public get BitmapSource(): HTMLCanvasElement | null {
39
+        return this._bitmapSource;
40
+    }
41
+
42
+    public get Name(): string {
43
+        return this._name;
44
+    }
45
+
46
+    public get MonikerString(): string {
47
+        return this._monikerString;
48
+    }
49
+
50
+    public set MonikerString(value: string) {
51
+        this._monikerString = value;
52
+        this.stop();
53
+        if (value) {
54
+            this.initializeDeviceForMoniker(value);
55
+            this.start();
56
+        }
57
+    }
58
+
59
+    public get Framerate(): number {
60
+        return this._framerate;
61
+    }
62
+
63
+    public set Framerate(value: number) {
64
+        this._framerate = value;
65
+    }
66
+
67
+    public get IsRunning(): boolean {
68
+        return this._worker !== null &&!this._stopSignal;
69
+    }
70
+
71
+    private async initializeDeviceForMoniker(moniker: string) {
72
+        const devices = await CapDevice.getDeviceMonikers();
73
+        const device = devices.find(d => d.MonikerString === moniker);
74
+        if (device) {
75
+            this._name = device.Name;
76
+        }
77
+    }
78
+
79
+    public async start() {
80
+        if (!this._monikerString) return;
81
+        if (this.IsRunning) {
82
+            this.stop();
83
+        }
84
+        this._stopSignal = false;
85
+        this._worker = this.runWorker();
86
+    }
87
+
88
+    public async stop() {
89
+        this._stopSignal = true;
90
+        if (this._worker) {
91
+            await this._worker;
92
+        }
93
+        this.release();
94
+    }
95
+
96
+    private release() {
97
+        this._worker = null;
98
+        if (this._stream) {
99
+            this._stream.getTracks().forEach(track => track.stop());
100
+            this._stream = null;
101
+        }
102
+        this._videoElement = null;
103
+        this._bitmapSource = null;
104
+    }
105
+
106
+    private async runWorker() {
107
+        try {
108
+            const constraints = { video: { deviceId: { exact: this._monikerString } } };
109
+            this._stream = await navigator.mediaDevices.getUserMedia(constraints);
110
+            this._videoElement = document.createElement("video");
111
+            this._videoElement.srcObject = this._stream;
112
+            this._videoElement.autoplay = true;
113
+            this._bitmapSource = document.createElement("canvas");
114
+            const ctx = this._bitmapSource.getContext("2d");
115
+            if (ctx) {
116
+                this._timer = performance.now();
117
+                this._frames = 0;
118
+                const drawFrame = () => {
119
+                    if (this._stopSignal) return;
120
+                    ctx.drawImage(this._videoElement!, 0, 0, this._bitmapSource!.width, this._bitmapSource!.height);
121
+                    this._frames++;
122
+                    const now = performance.now();
123
+                    if (now - this._timer >= 1000) {
124
+                        this._framerate = Math.round(this._frames * 1000 / (now - this._timer));
125
+                        this._timer = now;
126
+                        this._frames = 0;
127
+                    }
128
+                    if (this.NewBitmapReady) {
129
+                        this.NewBitmapReady();
130
+                    }
131
+                    requestAnimationFrame(drawFrame);
132
+                };
133
+                requestAnimationFrame(drawFrame);
134
+            }
135
+        } catch (error) {
136
+            console.error("Error starting video capture:", error);
137
+        }
138
+    }
139
+}
140
+
141
+export default CapDevice;

+ 74
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapGrabber.ts View File

@@ -0,0 +1,74 @@
1
+// 定义 PropertyChangedEventHandler 类型
2
+type PropertyChangedEventHandler = (sender: any, args: { propertyName: string }) => void;
3
+// 定义 EventHandler 类型
4
+type EventHandler = (sender: any, args: any) => void;
5
+
6
+// 模拟 ISampleGrabberCB 接口
7
+interface ISampleGrabberCB {
8
+    SampleCB(sampleTime: number, sample: ArrayBuffer): number;
9
+    BufferCB(sampleTime: number, buffer: ArrayBuffer, bufferLen: number): number;
10
+}
11
+
12
+// 模拟 INotifyPropertyChanged 接口
13
+interface INotifyPropertyChanged {
14
+    PropertyChanged: PropertyChangedEventHandler | null;
15
+}
16
+
17
+class CapGrabber implements ISampleGrabberCB, INotifyPropertyChanged {
18
+    private _height: number = 0;
19
+    private _width: number = 0;
20
+    public Map: ArrayBuffer | null = null;
21
+
22
+    public PropertyChanged: PropertyChangedEventHandler | null = null;
23
+    public NewFrameArrived: EventHandler | null = null;
24
+
25
+    constructor() {
26
+        // 构造函数逻辑
27
+    }
28
+
29
+    public SampleCB(sampleTime: number, sample: ArrayBuffer): number {
30
+        return 0;
31
+    }
32
+
33
+    public BufferCB(sampleTime: number, buffer: ArrayBuffer, bufferLen: number): number {
34
+        if (this.Map) {
35
+            const target = new Uint8Array(this.Map);
36
+            const source = new Uint8Array(buffer);
37
+            target.set(source.subarray(0, bufferLen));
38
+            this.onNewFrameArrived();
39
+        }
40
+        return 0;
41
+    }
42
+
43
+    private onNewFrameArrived() {
44
+        if (this.NewFrameArrived) {
45
+            this.NewFrameArrived(this, null);
46
+        }
47
+    }
48
+
49
+    private onPropertyChanged(name: string) {
50
+        if (this.PropertyChanged) {
51
+            this.PropertyChanged(this, { propertyName: name });
52
+        }
53
+    }
54
+
55
+    public get Width(): number {
56
+        return this._width;
57
+    }
58
+
59
+    public set Width(value: number) {
60
+        this._width = value;
61
+        this.onPropertyChanged("Width");
62
+    }
63
+
64
+    public get Height(): number {
65
+        return this._height;
66
+    }
67
+
68
+    public set Height(value: number) {
69
+        this._height = value;
70
+        this.onPropertyChanged("Height");
71
+    }
72
+}
73
+
74
+export default CapGrabber;

+ 47
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapHelper.ts View File

@@ -0,0 +1,47 @@
1
+// 假设这些接口和类型已经定义
2
+interface IBaseFilter {
3
+    EnumPins(): IEnumPins | null;
4
+}
5
+
6
+interface IPin {
7
+    QueryDirection(): PinDirection;
8
+    // 这里假设存在释放资源的方法
9
+    release(): void;
10
+}
11
+
12
+interface IEnumPins {
13
+    Next(count: number): IPin | null;
14
+}
15
+
16
+enum PinDirection {
17
+    // 假设这里定义了具体的方向值
18
+    Input,
19
+    Output
20
+}
21
+
22
+class CapHelper {
23
+    static GetPin(filter: IBaseFilter, dir: PinDirection, num: number): IPin | null {
24
+        let pin: IPin | null = null;
25
+        const pinsEnum = filter.EnumPins();
26
+
27
+        if (pinsEnum) {
28
+            while ((pin = pinsEnum.Next(1)) !== null) {
29
+                const pinDir = pin.QueryDirection();
30
+
31
+                if (pinDir === dir) {
32
+                    if (num === 0) {
33
+                        return pin;
34
+                    }
35
+                    num--;
36
+                }
37
+
38
+                pin.release();
39
+                pin = null;
40
+            }
41
+        }
42
+
43
+        return null;
44
+    }
45
+}
46
+
47
+export default CapHelper;

+ 159
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapInterfaces.ts View File

@@ -0,0 +1,159 @@
1
+// 假设 AMMediaType、PinInfo、PinDirection 等类型已经定义
2
+// 这里简单用 any 代替,实际使用时需要根据具体情况定义
3
+type AMMediaType = any;
4
+type PinInfo = any;
5
+type PinDirection = any;
6
+type IBaseFilter = any;
7
+type IPin = any;
8
+type IEnumPins = any;
9
+type IFilterGraph = any;
10
+type IPropertyBag = any;
11
+type ISampleGrabberCB = any;
12
+type IEnumMoniker = any;
13
+
14
+interface IGraphBuilder {
15
+    AddFilter(filter: IBaseFilter, name: string): number;
16
+    RemoveFilter(filter: IBaseFilter): number;
17
+    EnumFilters(): number;
18
+    FindFilterByName(name: string): number;
19
+    ConnectDirect(pinOut: IPin, pinIn: IPin, mediaType: AMMediaType): number;
20
+    Reconnect(pin: IPin): number;
21
+    Disconnect(pin: IPin): number;
22
+    SetDefaultSyncSource(): number;
23
+    Connect(pinOut: IPin, pinIn: IPin): number;
24
+    Render(pinOut: IPin): number;
25
+    RenderFile(file: string, playList: string): number;
26
+    AddSourceFilter(fileName: string, filterName: string): number;
27
+    SetLogFile(hFile: number): number;
28
+    Abort(): number;
29
+    ShouldOperationContinue(): number;
30
+}
31
+
32
+interface IBaseFilter {
33
+    GetClassID(): number;
34
+    Stop(): number;
35
+    Pause(): number;
36
+    Run(start: number): number;
37
+    GetState(milliSecsTimeout: number): number;
38
+    SetSyncSource(clock: number): number;
39
+    GetSyncSource(): number;
40
+    EnumPins(): number;
41
+    FindPin(id: string): number;
42
+    QueryFilterInfo(): number;
43
+    JoinFilterGraph(graph: IFilterGraph, name: string): number;
44
+    QueryVendorInfo(): number;
45
+}
46
+
47
+interface IPin {
48
+    Connect(receivePin: IPin, mediaType: AMMediaType): number;
49
+    ReceiveConnection(receivePin: IPin, mediaType: AMMediaType): number;
50
+    Disconnect(): number;
51
+    ConnectedTo(): number;
52
+    ConnectionMediaType(): number;
53
+    QueryPinInfo(): number;
54
+    QueryDirection(): number;
55
+    QueryId(): number;
56
+    QueryAccept(mediaType: AMMediaType): number;
57
+    EnumMediaTypes(): number;
58
+    QueryInternalConnections(): number;
59
+    EndOfStream(): number;
60
+    BeginFlush(): number;
61
+    EndFlush(): number;
62
+    NewSegment(start: number, stop: number, rate: number): number;
63
+}
64
+
65
+interface IEnumPins {
66
+    Next(cPins: number): number;
67
+    Skip(cPins: number): number;
68
+    Reset(): number;
69
+    Clone(): number;
70
+}
71
+
72
+interface IFilterGraph {
73
+    AddFilter(filter: IBaseFilter, name: string): number;
74
+    RemoveFilter(filter: IBaseFilter): number;
75
+    EnumFilters(): number;
76
+    FindFilterByName(name: string): number;
77
+    ConnectDirect(pinOut: IPin, pinIn: IPin, mediaType: AMMediaType): number;
78
+    Reconnect(pin: IPin): number;
79
+    Disconnect(pin: IPin): number;
80
+    SetDefaultSyncSource(): number;
81
+}
82
+
83
+interface IPropertyBag {
84
+    Read(propertyName: string, pVar: any): number;
85
+    Write(propertyName: string, pVar: any): number;
86
+}
87
+
88
+interface ISampleGrabber {
89
+    SetOneShot(oneShot: boolean): number;
90
+    SetMediaType(mediaType: AMMediaType): number;
91
+    GetConnectedMediaType(): number;
92
+    SetBufferSamples(bufferThem: boolean): number;
93
+    GetCurrentBuffer(bufferSize: number): number;
94
+    GetCurrentSample(): number;
95
+    SetCallback(callback: ISampleGrabberCB, whichMethodToCallback: number): number;
96
+}
97
+
98
+interface ISampleGrabberCB {
99
+    SampleCB(sampleTime: number, sample: number): number;
100
+    BufferCB(sampleTime: number, buffer: number, bufferLen: number): number;
101
+}
102
+
103
+interface ICreateDevEnum {
104
+    CreateClassEnumerator(type: any): number;
105
+}
106
+
107
+interface IVideoWindow {
108
+    put_Caption(caption: string): number;
109
+    get_Caption(): number;
110
+    put_WindowStyle(windowStyle: number): number;
111
+    get_WindowStyle(): number;
112
+    put_WindowStyleEx(windowStyleEx: number): number;
113
+    get_WindowStyleEx(): number;
114
+    put_AutoShow(autoShow: boolean): number;
115
+    get_AutoShow(): number;
116
+    put_WindowState(windowState: number): number;
117
+    get_WindowState(): number;
118
+    put_BackgroundPalette(backgroundPalette: boolean): number;
119
+    get_BackgroundPalette(): number;
120
+    put_Visible(visible: boolean): number;
121
+    get_Visible(): number;
122
+    put_Left(left: number): number;
123
+    get_Left(): number;
124
+    put_Width(width: number): number;
125
+    get_Width(): number;
126
+    put_Top(top: number): number;
127
+    get_Top(): number;
128
+    put_Height(height: number): number;
129
+    get_Height(): number;
130
+    put_Owner(owner: number): number;
131
+    get_Owner(): number;
132
+    put_MessageDrain(drain: number): number;
133
+    get_MessageDrain(): number;
134
+    get_BorderColor(): number;
135
+    put_BorderColor(color: number): number;
136
+    get_FullScreenMode(): number;
137
+    put_FullScreenMode(fullScreenMode: boolean): number;
138
+    SetWindowForeground(focus: number): number;
139
+    NotifyOwnerMessage(hwnd: number, msg: number, wParam: number, lParam: number): number;
140
+    SetWindowPosition(left: number, top: number, width: number, height: number): number;
141
+    GetWindowPosition(): number;
142
+    GetMinIdealImageSize(): number;
143
+    GetMaxIdealImageSize(): number;
144
+    GetRestorePosition(): number;
145
+    HideCursor(hideCursor: boolean): number;
146
+    IsCursorHidden(): number;
147
+}
148
+
149
+interface IMediaControl {
150
+    Run(): number;
151
+    Pause(): number;
152
+    Stop(): number;
153
+    GetState(timeout: number): number;
154
+    RenderFile(fileName: string): number;
155
+    AddSourceFilter(fileName: string): number;
156
+    get_FilterCollection(): number;
157
+    get_RegFilterCollection(): number;
158
+    StopWhenReady(): number;
159
+}

+ 85
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapPlayer.ts View File

@@ -0,0 +1,85 @@
1
+// 假设 CapDevice 类的定义如下
2
+class CapDevice {
3
+    public BitmapSource: any;
4
+    public static FramerateProperty: any;
5
+    public NewBitmapReady: (sender: any, e: any) => void;
6
+    public Dispose(): void {}
7
+    public Stop(): void {}
8
+}
9
+
10
+// CapPlayer 类的 TypeScript 实现
11
+class CapPlayer {
12
+    private _device: CapDevice | null = null;
13
+    private _rotation: number = 0;
14
+    private _framerate: number = 0;
15
+    private _imageElement: HTMLImageElement;
16
+
17
+    constructor(imageElement: HTMLImageElement) {
18
+        this._imageElement = imageElement;
19
+    }
20
+
21
+    public get Device(): CapDevice | null {
22
+        return this._device;
23
+    }
24
+
25
+    public set Device(value: CapDevice | null) {
26
+        if (this._device) {
27
+            this.cleanUpDevice(this._device);
28
+        }
29
+        this._device = value;
30
+        if (this._device) {
31
+            this._device.NewBitmapReady = this.device_OnNewBitmapReady.bind(this);
32
+        }
33
+    }
34
+
35
+    public get Rotation(): number {
36
+        return this._rotation;
37
+    }
38
+
39
+    public set Rotation(value: number) {
40
+        this._rotation = value;
41
+        this._imageElement.style.transform = `rotate(${value}deg)`;
42
+    }
43
+
44
+    public get Framerate(): number {
45
+        return this._framerate;
46
+    }
47
+
48
+    public set Framerate(value: number) {
49
+        this._framerate = value;
50
+    }
51
+
52
+    public get CurrentBitmap(): any {
53
+        if (this._device) {
54
+            // 这里简化处理,实际中需要实现图像旋转和变换
55
+            return this._device.BitmapSource;
56
+        }
57
+        return null;
58
+    }
59
+
60
+    public dispose(): void {
61
+        if (this._device) {
62
+            this._device.Dispose();
63
+            this._device = null;
64
+        }
65
+    }
66
+
67
+    private cleanUpDevice(device: CapDevice): void {
68
+        device.Stop();
69
+        device.NewBitmapReady = () => {};
70
+    }
71
+
72
+    private device_OnNewBitmapReady(sender: any, e: any): void {
73
+        // 简化绑定逻辑
74
+        this._framerate = sender.Framerate;
75
+        if (sender) {
76
+            this._imageElement.src = sender.BitmapSource;
77
+        }
78
+    }
79
+}
80
+
81
+// 使用示例
82
+const imageElement = document.createElement('img');
83
+const capPlayer = new CapPlayer(imageElement);
84
+const device = new CapDevice();
85
+capPlayer.Device = device;

+ 90
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CapStructures.ts View File

@@ -0,0 +1,90 @@
1
+// 定义 PinDirection 枚举
2
+enum PinDirection {
3
+    Input,
4
+    Output
5
+}
6
+
7
+// 定义 AMMediaType 类
8
+class AMMediaType {
9
+    MajorType: string;
10
+    SubType: string;
11
+    FixedSizeSamples: boolean = true;
12
+    TemporalCompression: boolean;
13
+    SampleSize: number = 1;
14
+    FormatType: string;
15
+    unkPtr: number;
16
+    FormatSize: number;
17
+    FormatPtr: number;
18
+
19
+    constructor() {
20
+        this.MajorType = '';
21
+        this.SubType = '';
22
+        this.TemporalCompression = false;
23
+        this.unkPtr = 0;
24
+        this.FormatSize = 0;
25
+        this.FormatPtr = 0;
26
+    }
27
+
28
+    dispose() {
29
+        // 在 TypeScript 中没有直接的非托管资源释放,这里只是占位
30
+    }
31
+}
32
+
33
+// 定义 IBaseFilter 接口
34
+interface IBaseFilter {}
35
+
36
+// 定义 PinInfo 类
37
+class PinInfo {
38
+    Filter: IBaseFilter;
39
+    Direction: PinDirection;
40
+    Name: string;
41
+
42
+    constructor() {
43
+        this.Filter = {} as IBaseFilter;
44
+        this.Direction = PinDirection.Input;
45
+        this.Name = '';
46
+    }
47
+}
48
+
49
+// 定义 RECT 接口
50
+interface RECT {
51
+    Left: number;
52
+    Top: number;
53
+    Right: number;
54
+    Bottom: number;
55
+}
56
+
57
+// 定义 BitmapInfoHeader 接口
58
+interface BitmapInfoHeader {
59
+    Size: number;
60
+    Width: number;
61
+    Height: number;
62
+    Planes: number;
63
+    BitCount: number;
64
+    Compression: number;
65
+    ImageSize: number;
66
+    XPelsPerMeter: number;
67
+    YPelsPerMeter: number;
68
+    ColorsUsed: number;
69
+    ColorsImportant: number;
70
+}
71
+
72
+// 定义 VideoInfoHeader 接口
73
+interface VideoInfoHeader {
74
+    SrcRect: RECT;
75
+    TargetRect: RECT;
76
+    BitRate: number;
77
+    BitErrorRate: number;
78
+    AverageTimePerFrame: number;
79
+    BmiHeader: BitmapInfoHeader;
80
+}
81
+
82
+export {
83
+    PinDirection,
84
+    AMMediaType,
85
+    IBaseFilter,
86
+    PinInfo,
87
+    RECT,
88
+    BitmapInfoHeader,
89
+    VideoInfoHeader
90
+};

+ 45
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/CaptureImageCommands.ts View File

@@ -0,0 +1,45 @@
1
+// 定义命令类型
2
+type Command = {
3
+  name: string;
4
+  displayText: string;
5
+  execute: () => void;
6
+};
7
+
8
+// 定义 CaptureImageCommands 类
9
+export class CaptureImageCommands {
10
+  static CaptureImage: Command = {
11
+    name: "CaptureImage",
12
+    displayText: "Capture image",
13
+    execute: () => {
14
+      // 这里可以实现捕获图像的具体逻辑
15
+      console.log("Capturing image...");
16
+    },
17
+  };
18
+
19
+  static RemoveImage: Command = {
20
+    name: "RemoveImage",
21
+    displayText: "Remove image",
22
+    execute: () => {
23
+      // 这里可以实现移除图像的具体逻辑
24
+      console.log("Removing image...");
25
+    },
26
+  };
27
+
28
+  static ClearAllImages: Command = {
29
+    name: "ClearAllImages",
30
+    displayText: "Clear all images",
31
+    execute: () => {
32
+      // 这里可以实现清除所有图像的具体逻辑
33
+      console.log("Clearing all images...");
34
+    },
35
+  };
36
+
37
+  static ClickImage: Command = {
38
+    name: "ClickImage",
39
+    displayText: "Click Image",
40
+    execute: () => {
41
+      // 这里可以实现点击图像的具体逻辑
42
+      console.log("Clicking image...");
43
+    },
44
+  };
45
+}

+ 122
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/FilterInfo.ts View File

@@ -0,0 +1,122 @@
1
+// 假设这些接口和类型已经定义
2
+interface IBindCtx {}
3
+interface IMoniker {}
4
+interface IBaseFilter {}
5
+interface IPropertyBag {
6
+    Read(name: string, value: any, zero: any): number;
7
+}
8
+
9
+// 假设这些函数已经实现
10
+function CreateBindCtx(reserved: number): IBindCtx | null {
11
+    // 实现创建绑定上下文的逻辑
12
+    return null;
13
+}
14
+
15
+function MkParseDisplayName(pbc: IBindCtx, szUserName: string): IMoniker | null {
16
+    // 实现解析显示名称的逻辑
17
+    return null;
18
+}
19
+
20
+class FilterInfo implements IComparable {
21
+    private readonly _name: string;
22
+    private readonly _monikerString: string;
23
+
24
+    constructor(monikerString: string);
25
+    constructor(moniker: IMoniker);
26
+    constructor(arg: string | IMoniker) {
27
+        if (typeof arg === 'string') {
28
+            this._monikerString = arg;
29
+            this._name = this.GetName(arg);
30
+        } else {
31
+            this._monikerString = this.GetMonikerString(arg);
32
+            this._name = this.GetName(this._monikerString);
33
+        }
34
+    }
35
+
36
+    get Name(): string {
37
+        return this._name;
38
+    }
39
+
40
+    get MonikerString(): string {
41
+        return this._monikerString;
42
+    }
43
+
44
+    static CreateFilter(filterMoniker: string): IBaseFilter | null {
45
+        let filterObject: IBaseFilter | null = null;
46
+        let bindCtx = CreateBindCtx(0);
47
+        if (bindCtx) {
48
+            let moniker = MkParseDisplayName(bindCtx, filterMoniker);
49
+            if (moniker) {
50
+                // 假设这里有绑定到对象的逻辑
51
+                // moniker.BindToObject(null, null, ref filterId, out filterObject);
52
+                // 清理逻辑
53
+                // moniker = null;
54
+            }
55
+            // 清理逻辑
56
+            // bindCtx = null;
57
+        }
58
+        return filterObject;
59
+    }
60
+
61
+    private GetMonikerString(moniker: IMoniker): string {
62
+        let result = "";
63
+        // 假设这里有获取显示名称的逻辑
64
+        // moniker.GetDisplayName(null, null, out result);
65
+        return result;
66
+    }
67
+
68
+    private GetName(moniker: IMoniker): string;
69
+    private GetName(monikerString: string): string;
70
+    private GetName(arg: IMoniker | string): string {
71
+        if (typeof arg === 'string') {
72
+            let bindCtx = CreateBindCtx(0);
73
+            if (bindCtx) {
74
+                let moniker = MkParseDisplayName(bindCtx, arg);
75
+                if (moniker) {
76
+                    let name = this.GetName(moniker);
77
+                    // 清理逻辑
78
+                    // moniker = null;
79
+                }
80
+                // 清理逻辑
81
+                // bindCtx = null;
82
+            }
83
+            return "";
84
+        } else {
85
+            let bagObj: IPropertyBag | null = null;
86
+            try {
87
+                // 假设这里有绑定到存储的逻辑
88
+                // arg.BindToStorage(null, null, ref bagId, out bagObj);
89
+                if (bagObj) {
90
+                    let val: any = "";
91
+                    let hr = bagObj.Read("FriendlyName", val, null);
92
+                    if (hr === 0) {
93
+                        let result = val as string;
94
+                        if (result) {
95
+                            return result;
96
+                        }
97
+                    }
98
+                }
99
+            } catch (e) {
100
+                // 异常处理
101
+            } finally {
102
+                // 清理逻辑
103
+                bagObj = null;
104
+            }
105
+            return "";
106
+        }
107
+    }
108
+
109
+    CompareTo(value: any): number {
110
+        let f = value as FilterInfo;
111
+        if (!f) {
112
+            return 1;
113
+        }
114
+        return this.Name.localeCompare(f.Name);
115
+    }
116
+}
117
+
118
+interface IComparable {
119
+    CompareTo(value: any): number;
120
+}
121
+
122
+export { FilterInfo };

+ 28
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/CamPlayer/ThreeFourthConverter.ts View File

@@ -0,0 +1,28 @@
1
+// 定义一个类似 IValueConverter 的接口
2
+interface IValueConverter {
3
+    convert(value: any, targetType: any, parameter: any, culture: any): any;
4
+    convertBack(value: any, targetType: any, parameter: any, culture: any): any;
5
+}
6
+
7
+// 定义 ThreeFourthConverter 类
8
+class ThreeFourthConverter implements IValueConverter {
9
+    convert(value: any, targetType: any, parameter: any, culture: any): any {
10
+        let width = 0;
11
+        try {
12
+            width = parseFloat(value);
13
+            if (isNaN(width)) {
14
+                throw new Error();
15
+            }
16
+        } catch (error) {
17
+            console.error(`Failed to cast '${value}' to number`);
18
+            return 0;
19
+        }
20
+        return width > 0 ? (width / 4) * 3 : 0;
21
+    }
22
+
23
+    convertBack(value: any, targetType: any, parameter: any, culture: any): any {
24
+        throw new Error('Not implemented');
25
+    }
26
+}
27
+
28
+export default ThreeFourthConverter;

+ 434
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBox.xaml View File

@@ -0,0 +1,434 @@
1
+<UserControl x:Class="Platform.Controls.ComponentContainer.DataBox"
2
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+             xmlns:base="clr-namespace:Platform.Controls.BaseContainer"
5
+             xmlns:controlHelper="clr-namespace:Platform.Controls.ControlsHelper"
6
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7
+             xmlns:dhcc="http://www.dhcc.com.cn"
8
+             xmlns:helper="clr-namespace:Platform.Controls.ControlsHelper"
9
+             xmlns:local="clr-namespace:Platform.Controls.ComponentContainer"
10
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11
+             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
12
+             xmlns:table="clr-namespace:Platform.Controls.TableContainer"
13
+             x:Name="dataBox"
14
+             Height="300"
15
+             MinHeight="150"
16
+             HorizontalAlignment="Stretch"
17
+             d:DesignHeight="300"
18
+             d:DesignWidth="600"
19
+             mc:Ignorable="d">
20
+    <UserControl.Resources>
21
+        <Storyboard x:Key="OnMouseEnter1">
22
+            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="textBlock" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
23
+                <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="90" />
24
+            </DoubleAnimationUsingKeyFrames>
25
+        </Storyboard>
26
+        <Storyboard x:Key="OnMouseLeave1">
27
+            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="textBlock" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
28
+                <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-90" />
29
+            </DoubleAnimationUsingKeyFrames>
30
+        </Storyboard>
31
+        <ContextMenu x:Key="menuFilter" dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}" />
32
+
33
+        <dhcc:BoolToVisibilityConverter x:Key="BoolToVisibility" />
34
+
35
+        <DataGridTemplateColumn x:Key="RadioColumn" Visibility="{Binding IsShowRadioColumn, ElementName=dataBox, Converter={StaticResource BoolToVisibility}}" />
36
+
37
+        <DataTemplate x:Key="RadioButtonColumn">
38
+            <RadioButton HorizontalAlignment="Center"
39
+                         VerticalAlignment="Center"
40
+                         dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
41
+                         IsChecked="{Binding IsSelected,
42
+                                             RelativeSource={RelativeSource AncestorType=DataGridRow,
43
+                                                                            Mode=FindAncestor}}"
44
+                         Style="{x:Null}" />
45
+        </DataTemplate>
46
+
47
+        <DataTemplate x:Key="CheckBoxColumn">
48
+            <CheckBox x:Name="cellCheckBox"
49
+                      HorizontalAlignment="Center"
50
+                      VerticalAlignment="Center"
51
+                      Checked="cellCheckBox_CheckedChanged"
52
+                      dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
53
+                      IsChecked="{Binding Path=(helper:DataGridHelper.IsChecked),
54
+                                          RelativeSource={RelativeSource AncestorType=DataGridRow,
55
+                                                                         Mode=FindAncestor}}"
56
+                      Style="{x:Null}"
57
+                      Unchecked="cellCheckBox_CheckedChanged" />
58
+        </DataTemplate>
59
+
60
+        <DataTemplate x:Key="CheckBoxColumnHeader">
61
+            <CheckBox x:Name="headerCheckBox"
62
+                      HorizontalAlignment="Center"
63
+                      VerticalAlignment="Center"
64
+                      Checked="headerCheckBox_Checked"
65
+                      dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
66
+                      IsChecked="{Binding Path=(helper:DataGridHelper.IsChecked),
67
+                                          ElementName=dhccDataGrid}"
68
+                      Style="{x:Null}"
69
+                      Unchecked="headerCheckBox_Unchecked" />
70
+        </DataTemplate>
71
+    </UserControl.Resources>
72
+    <Grid>
73
+        <Grid.RowDefinitions>
74
+            <RowDefinition Height="Auto" />
75
+            <RowDefinition Height="*" />
76
+            <RowDefinition Height="Auto" />
77
+        </Grid.RowDefinitions>
78
+
79
+        <Grid Margin="0,0,0,3">
80
+            <Grid.Resources>
81
+
82
+
83
+
84
+                <LinearGradientBrush x:Key="TextBoxBorder" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,20">
85
+                    <GradientStop Offset="0.05" Color="#ABADB3" />
86
+                    <GradientStop Offset="0.07" Color="#E2E3EA" />
87
+                    <GradientStop Offset="1" Color="#E3E9EF" />
88
+                </LinearGradientBrush>
89
+
90
+                <!--  TextBoxFilter  -->
91
+                <Style x:Key="TextBoxFilter"
92
+                       BasedOn="{StaticResource {x:Type TextBox}}"
93
+                       TargetType="{x:Type TextBox}">
94
+                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
95
+                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
96
+                    <Setter Property="BorderThickness" Value="1" />
97
+                    <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}" />
98
+                    <Setter Property="AllowDrop" Value="true" />
99
+                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
100
+                    <Setter Property="Template">
101
+                        <Setter.Value>
102
+                            <ControlTemplate TargetType="{x:Type TextBox}">
103
+                                <Microsoft_Windows_Themes:ListBoxChrome x:Name="Bd"
104
+                                                                        Background="{TemplateBinding Background}"
105
+                                                                        BorderBrush="{TemplateBinding BorderBrush}"
106
+                                                                        BorderThickness="{TemplateBinding BorderThickness}"
107
+                                                                        RenderFocused="{TemplateBinding IsKeyboardFocusWithin}"
108
+                                                                        RenderMouseOver="{TemplateBinding IsMouseOver}"
109
+                                                                        SnapsToDevicePixels="true">
110
+
111
+                                    <ScrollViewer x:Name="PART_ContentHost"
112
+                                                  Margin="18,0,18,0"
113
+                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
114
+
115
+                                </Microsoft_Windows_Themes:ListBoxChrome>
116
+                                <ControlTemplate.Triggers>
117
+                                    <Trigger Property="IsEnabled" Value="false">
118
+                                        <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
119
+                                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
120
+                                    </Trigger>
121
+                                </ControlTemplate.Triggers>
122
+                            </ControlTemplate>
123
+                        </Setter.Value>
124
+                    </Setter>
125
+                </Style>
126
+                <!--  TextBoxFilter  -->
127
+                <!--  ComboBoxItem  -->
128
+                <Style TargetType="{x:Type ComboBoxItem}">
129
+                    <Setter Property="SnapsToDevicePixels" Value="true" />
130
+                    <Setter Property="OverridesDefaultStyle" Value="true" />
131
+                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
132
+                    <Setter Property="Cursor" Value="Hand" />
133
+                    <Setter Property="Template">
134
+                        <Setter.Value>
135
+                            <ControlTemplate TargetType="ComboBoxItem">
136
+                                <Border Name="Border"
137
+                                        dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
138
+                                        Padding="2"
139
+                                        SnapsToDevicePixels="true">
140
+                                    <ContentPresenter />
141
+                                </Border>
142
+                                <ControlTemplate.Triggers>
143
+                                    <Trigger Property="IsHighlighted" Value="true">
144
+                                        <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBoxItem_Select_Background}" />
145
+                                    </Trigger>
146
+                                    <Trigger Property="IsEnabled" Value="false">
147
+                                        <Setter Property="Foreground" Value="{DynamicResource ComboBoxItem_Enable_Foreground}" />
148
+                                    </Trigger>
149
+                                </ControlTemplate.Triggers>
150
+                            </ControlTemplate>
151
+                        </Setter.Value>
152
+                    </Setter>
153
+                </Style>
154
+                <!--  ComboBoxItem  -->
155
+
156
+                <!--  ComBoxFilter  -->
157
+                <Style x:Key="ComboBoxFilter"
158
+                       BasedOn="{StaticResource {x:Type ComboBox}}"
159
+                       TargetType="{x:Type ComboBox}">
160
+                    <Setter Property="Width" Value="22" />
161
+                    <Setter Property="Height" Value="22" />
162
+                    <Setter Property="HorizontalAlignment" Value="Left" />
163
+                    <Setter Property="VerticalAlignment" Value="Center" />
164
+                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
165
+                    <Setter Property="Padding" Value="1" />
166
+                    <Setter Property="Template">
167
+                        <Setter.Value>
168
+                            <ControlTemplate TargetType="{x:Type ComboBox}">
169
+                                <Grid x:Name="RootElement" MinWidth="100">
170
+                                    <Grid.Resources>
171
+                                        <Style x:Key="ToggleButtonFilter" TargetType="{x:Type ToggleButton}">
172
+                                            <Setter Property="Width" Value="22" />
173
+                                            <Setter Property="Height" Value="22" />
174
+                                            <Setter Property="Cursor" Value="Hand" />
175
+                                            <Setter Property="HorizontalAlignment" Value="Left" />
176
+                                            <Setter Property="VerticalAlignment" Value="Center" />
177
+                                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
178
+                                            <Setter Property="Padding" Value="1" />
179
+                                            <Setter Property="Template">
180
+                                                <Setter.Value>
181
+                                                    <ControlTemplate TargetType="{x:Type ToggleButton}">
182
+                                                        <Grid>
183
+                                                            <Rectangle Margin="2"
184
+                                                                       Fill="Transparent"
185
+                                                                       RadiusX="2.5"
186
+                                                                       RadiusY="2.5"
187
+                                                                       Stroke="#FF000000"
188
+                                                                       StrokeThickness="0" />
189
+                                                            <Ellipse Width="10"
190
+                                                                     Height="10"
191
+                                                                     Margin="0,4,5,0"
192
+                                                                     HorizontalAlignment="Right"
193
+                                                                     VerticalAlignment="Top"
194
+                                                                     Stroke="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
195
+                                                                     StrokeThickness="2" />
196
+                                                            <Path Width="7"
197
+                                                                  Height="7"
198
+                                                                  Margin="0,7,7,0"
199
+                                                                  Data="M0,0 L1,-1"
200
+                                                                  Fill="Black"
201
+                                                                  Stretch="Fill"
202
+                                                                  Stroke="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
203
+                                                                  StrokeThickness="2" />
204
+                                                            <Path x:Name="path"
205
+                                                                  Width="6"
206
+                                                                  Height="6"
207
+                                                                  Margin="0,0,2,0"
208
+                                                                  HorizontalAlignment="Right"
209
+                                                                  VerticalAlignment="Bottom"
210
+                                                                  Data="M0,0L6,0 3,3z"
211
+                                                                  Fill="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
212
+                                                        </Grid>
213
+                                                        <ControlTemplate.Triggers>
214
+                                                            <Trigger Property="IsChecked" Value="true">
215
+                                                                <Setter TargetName="path" Property="Visibility" Value="Collapsed" />
216
+                                                            </Trigger>
217
+                                                            <Trigger Property="IsChecked" Value="false">
218
+                                                                <Setter TargetName="path" Property="Visibility" Value="Visible" />
219
+                                                            </Trigger>
220
+                                                        </ControlTemplate.Triggers>
221
+                                                    </ControlTemplate>
222
+                                                </Setter.Value>
223
+                                            </Setter>
224
+                                        </Style>
225
+                                    </Grid.Resources>
226
+                                    <Popup x:Name="PART_Popup"
227
+                                           Grid.ColumnSpan="2"
228
+                                           Margin="1"
229
+                                           AllowsTransparency="true"
230
+                                           IsOpen="{Binding IsDropDownOpen,
231
+                                                            RelativeSource={RelativeSource TemplatedParent}}"
232
+                                           Placement="Bottom"
233
+                                           PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
234
+                                        <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw"
235
+                                                                                         MinWidth="{Binding ActualWidth,
236
+                                                                                                            ElementName=RootElement}"
237
+                                                                                         MaxHeight="{TemplateBinding MaxDropDownHeight}"
238
+                                                                                         Color="Transparent">
239
+                                            <Border x:Name="DropDownBorder"
240
+                                                    Background="{DynamicResource ComboBoxDropdown_Normal_Background}"
241
+                                                    BorderBrush="{DynamicResource ComboBoxDropdown_Normal_BorderBrush}"
242
+                                                    BorderThickness="{DynamicResource ComboBoxDropdown_Normal_BorderThickness}"
243
+                                                    CornerRadius="3"
244
+                                                    Focusable="False">
245
+                                                <Grid>
246
+                                                    <Grid.Resources>
247
+                                                        <Style x:Key="SeparatorLineStyle" TargetType="{x:Type Line}">
248
+                                                            <Setter Property="X2" Value="1" />
249
+                                                            <Setter Property="Height" Value="1" />
250
+                                                            <Setter Property="Stretch" Value="Fill" />
251
+                                                            <Setter Property="StrokeEndLineCap" Value="Square" />
252
+                                                            <Setter Property="StrokeStartLineCap" Value="Square" />
253
+                                                            <Setter Property="StrokeThickness" Value="{Binding Height, RelativeSource={RelativeSource Self}}" />
254
+                                                            <Setter Property="Stroke" Value="{DynamicResource ComboBoxDropdown_Normal_BorderBrush}" />
255
+                                                        </Style>
256
+                                                        <Style TargetType="{x:Type ListBoxItem}">
257
+                                                            <Setter Property="Template">
258
+                                                                <Setter.Value>
259
+                                                                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
260
+                                                                        <CheckBox Content="{TemplateBinding Content}"
261
+                                                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
262
+                                                                                  ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
263
+                                                                                  dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
264
+                                                                                  FocusVisualStyle="{TemplateBinding FocusVisualStyle}"
265
+                                                                                  IsChecked="{Binding IsSelected,
266
+                                                                                                      RelativeSource={RelativeSource TemplatedParent}}"
267
+                                                                                  Style="{x:Null}" />
268
+                                                                    </ControlTemplate>
269
+                                                                </Setter.Value>
270
+                                                            </Setter>
271
+                                                        </Style>
272
+                                                    </Grid.Resources>
273
+                                                    <Grid.RowDefinitions>
274
+                                                        <RowDefinition Height="Auto" />
275
+                                                        <RowDefinition Height="Auto" />
276
+                                                        <RowDefinition Height="*" />
277
+                                                    </Grid.RowDefinitions>
278
+
279
+                                                    <CheckBox x:Name="chbxAll"
280
+                                                              Margin="2"
281
+                                                              Checked="chbxAll_Checked"
282
+                                                              Content="全选"
283
+                                                              dhcc:FocusManager.OnlyMouseControlHandled="{x:Static dhcc:ControlHelper.EmptyMouseHandled}"
284
+                                                              Style="{x:Null}"
285
+                                                              Unchecked="chbxAll_Unchecked" />
286
+
287
+                                                    <Line Grid.Row="1" Style="{StaticResource SeparatorLineStyle}" />
288
+                                                    <ListBox Name="checkListBox"
289
+                                                             Grid.Row="2"
290
+                                                             Margin="2"
291
+                                                             BorderThickness="0"
292
+                                                             SelectionChanged="checkListBox_SelectionChanged"
293
+                                                             SelectionMode="Multiple"
294
+                                                             Style="{x:Null}" />
295
+                                                </Grid>
296
+
297
+                                            </Border>
298
+                                        </Microsoft_Windows_Themes:SystemDropShadowChrome>
299
+                                    </Popup>
300
+                                    <ToggleButton Grid.ColumnSpan="2"
301
+                                                  Background="{DynamicResource ComboBox_Normal_Background}"
302
+                                                  BorderBrush="#FFBCBDBD"
303
+                                                  BorderThickness="1"
304
+                                                  ClickMode="Press"
305
+                                                  Focusable="false"
306
+                                                  IsChecked="{Binding Path=IsDropDownOpen,
307
+                                                                      Mode=TwoWay,
308
+                                                                      RelativeSource={RelativeSource TemplatedParent}}"
309
+                                                  Style="{StaticResource ToggleButtonFilter}" />
310
+
311
+                                </Grid>
312
+
313
+
314
+                            </ControlTemplate>
315
+                        </Setter.Value>
316
+                    </Setter>
317
+                </Style>
318
+                <!--  ComBoxFilter  -->
319
+
320
+                <!--  ButtonClear  -->
321
+                <Style x:Key="ButtonClear"
322
+                       BasedOn="{StaticResource {x:Type Button}}"
323
+                       TargetType="{x:Type Button}">
324
+                    <Setter Property="Margin" Value="0" />
325
+                    <Setter Property="Width" Value="22" />
326
+                    <Setter Property="Height" Value="22" />
327
+                    <Setter Property="Cursor" Value="Hand" />
328
+                    <Setter Property="HorizontalAlignment" Value="Right" />
329
+                    <Setter Property="VerticalAlignment" Value="Center" />
330
+                    <Setter Property="Padding" Value="1" />
331
+                    <Setter Property="Template">
332
+                        <Setter.Value>
333
+                            <ControlTemplate TargetType="{x:Type Button}">
334
+                                <TextBlock x:Name="textBlock"
335
+                                           HorizontalAlignment="Center"
336
+                                           VerticalAlignment="Center"
337
+                                           Cursor="Hand"
338
+                                           FontFamily="Bodoni MT Black"
339
+                                           FontSize="18"
340
+                                           FontWeight="Bold"
341
+                                           Foreground="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
342
+                                           RenderTransformOrigin="0.5,0.5"
343
+                                           Text="×"
344
+                                           ToolTip="关闭">
345
+                                    <TextBlock.RenderTransform>
346
+                                        <TransformGroup>
347
+                                            <ScaleTransform />
348
+                                            <SkewTransform />
349
+                                            <RotateTransform />
350
+                                            <TranslateTransform />
351
+                                        </TransformGroup>
352
+                                    </TextBlock.RenderTransform>
353
+                                </TextBlock>
354
+                                <ControlTemplate.Triggers>
355
+                                    <EventTrigger RoutedEvent="Mouse.MouseEnter">
356
+                                        <BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}" />
357
+                                    </EventTrigger>
358
+                                    <EventTrigger RoutedEvent="Mouse.MouseLeave">
359
+                                        <BeginStoryboard Storyboard="{StaticResource OnMouseLeave1}" />
360
+                                    </EventTrigger>
361
+                                </ControlTemplate.Triggers>
362
+                            </ControlTemplate>
363
+                        </Setter.Value>
364
+                    </Setter>
365
+                </Style>
366
+                <!--  ButtonClear  -->
367
+            </Grid.Resources>
368
+            <TextBox x:Name="txtFilter"
369
+                     Grid.Column="1"
370
+                     Width="Auto"
371
+                     HorizontalAlignment="Stretch"
372
+                     VerticalContentAlignment="Center"
373
+                     controlHelper:TextBoxHelper.Placeholder="请输入筛选条件…"
374
+                     controlHelper:TextBoxHelper.PlaceholderOffset="23,5"
375
+                     Style="{StaticResource TextBoxFilter}"
376
+                     TextChanged="txt_TextChanged"
377
+                     Visibility="{Binding IsShowSelectBar,
378
+                                          ElementName=dataBox,
379
+                                          Converter={StaticResource BoolToVisibility}}" />
380
+            <ComboBox x:Name="cbxFilter"
381
+                      Style="{StaticResource ComboBoxFilter}"
382
+                      Visibility="{Binding IsShowSelectBar,
383
+                                           ElementName=dataBox,
384
+                                           Converter={StaticResource BoolToVisibility}}" />
385
+
386
+            <Button x:Name="btnClear"
387
+                    Click="btnClear_Click"
388
+                    Style="{StaticResource ButtonClear}"
389
+                    Visibility="Collapsed" />
390
+        </Grid>
391
+        <table:DHCCDataGrid x:Name="dhccDataGrid"
392
+                            Grid.Row="1"
393
+                            Height="Auto"
394
+                            MinHeight="150"
395
+                            MaxHeight="1000"
396
+                            dhcc:FocusManager.LostFocus="dhccDataGrid_LostFocus"
397
+                            IsReadOnly="True"
398
+                            SelectionMode="Single" />
399
+        <Grid Grid.Row="2" DataContext="{Binding Path=., ElementName=dataBox}">
400
+            <Grid.ColumnDefinitions>
401
+                <ColumnDefinition Width="*" />
402
+                <ColumnDefinition Width="Auto" />
403
+            </Grid.ColumnDefinitions>
404
+            <local:DataPager x:Name="dataPager"
405
+                             Margin="3"
406
+                             dhcc:FocusManager.OnlyMouseControlHandled="{x:Static helper:ControlHelper.EmptyMouseHandled}"
407
+                             PageChanged="dataPager_PageChanged"
408
+                             PageSizeList="{Binding PageSizeLis}"
409
+                             Total="{Binding Total}"
410
+                             Visibility="{Binding IsShowPageBar,
411
+                                                  Converter={StaticResource BoolToVisibility}}" />
412
+
413
+            <StackPanel x:Name="Operator"
414
+                        Grid.Column="1"
415
+                        Orientation="Horizontal">
416
+                <base:ImageButton x:Name="btnPrint"
417
+                                  Margin="3"
418
+                                  GrayImageSource="/Platform.Controls;component/Resource/pagination_loading.gif"
419
+                                  ImageSource="/Platform.Controls;component/Resource/FilePrint.png"
420
+                                  ToolTip="打印"
421
+                                  Visibility="{Binding IsShowPrintButton,
422
+                                                       Converter={StaticResource BoolToVisibility}}" />
423
+                <base:ImageButton x:Name="btnExport"
424
+                                  Margin="3"
425
+                                  GrayImageSource="/Platform.Controls;component/Resource/pagination_loading.gif"
426
+                                  ImageSource="/Platform.Controls;component/Resource/MenuTree_TradeSelected.png"
427
+                                  ToolTip="导出"
428
+                                  Visibility="{Binding IsShowExportButton,
429
+                                                       Converter={StaticResource BoolToVisibility}}" />
430
+            </StackPanel>
431
+        </Grid>
432
+
433
+    </Grid>
434
+</UserControl>

+ 1484
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBox.xaml.cs
File diff suppressed because it is too large
View File


+ 20
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxItem.xaml View File

@@ -0,0 +1,20 @@
1
+<dhcc:TradePage x:Class="Platform.Controls.ComponentContainer.DataBoxItem"
2
+                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+                xmlns:dhcc="http://www.dhcc.com.cn"
6
+                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+                Width="800"
8
+                MinHeight="200"
9
+                MaxHeight="600"
10
+                d:DesignHeight="300"
11
+                d:DesignWidth="700"
12
+                mc:Ignorable="d">
13
+    <Grid>
14
+        <FlowDocumentScrollViewer Name="viewer">
15
+            <FlowDocument FontFamily="SimSun">
16
+                <Paragraph TextAlignment="Center">无数据</Paragraph>
17
+            </FlowDocument>
18
+        </FlowDocumentScrollViewer>
19
+    </Grid>
20
+</dhcc:TradePage>

+ 67
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxItem.xaml.cs View File

@@ -0,0 +1,67 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Navigation;
13
+using System.Windows.Shapes;
14
+using Platform.Common.LogSystem;
15
+
16
+namespace Platform.Controls.ComponentContainer
17
+{
18
+    /// <summary>
19
+    /// DataItems.xaml 的交互逻辑
20
+    /// </summary>
21
+    public partial class DataBoxItem
22
+    {
23
+        public DataBoxItem(List<Tuple<string, string>> list)
24
+        {
25
+            InitializeComponent();
26
+            init(list);
27
+        }
28
+
29
+        private void init(List<Tuple<string, string>> list)
30
+        {
31
+            try
32
+            {
33
+                if (list == null || list.Count == 0)
34
+                    return;
35
+                //若数据为奇数,需要补位一个空项,解决奇数尾项不显示的问题
36
+                if (list.Count % 2 == 1)
37
+                    list.Add(new Tuple<string, string>("", ""));
38
+                var table = new Table { FontFamily = new FontFamily("SimSun"), CellSpacing = 0, BorderBrush = Brushes.Black, BorderThickness = new Thickness(1, 1, 1, 0) };
39
+                //设置列
40
+                table.Columns.Add(new TableColumn { Background = Brushes.LightSkyBlue, Width = new GridLength(120) });
41
+                table.Columns.Add(new TableColumn { Width = new GridLength(250) });
42
+                table.Columns.Add(new TableColumn { Background = Brushes.LightSkyBlue, Width = new GridLength(120) });
43
+                table.Columns.Add(new TableColumn { Width = new GridLength(250) });
44
+                //设置行
45
+                var rowGroup = new TableRowGroup();
46
+                var row = new TableRow();
47
+                list.ForEach(x =>
48
+                {
49
+                    row.Cells.Add(new TableCell(new Paragraph(new Run(x.Item1))) { Padding = new Thickness(2), BorderBrush = Brushes.Black, TextAlignment = TextAlignment.Right, BorderThickness = new Thickness(0, 0, 0, 1) });
50
+                    row.Cells.Add(new TableCell(new Paragraph(new Run(x.Item2))) { Padding = new Thickness(2), BorderBrush = Brushes.Black, BorderThickness = new Thickness(0, 0, 0, 1) });
51
+                    if (row.Cells.Count > 3)
52
+                    {
53
+                        rowGroup.Rows.Add(row);
54
+                        row = new TableRow();
55
+                    }
56
+                });
57
+                //组装
58
+                table.RowGroups.Add(rowGroup);
59
+                viewer.Document = new FlowDocument(table);
60
+            }
61
+            catch (Exception ex)
62
+            {
63
+                PlatformLogger.SystemErrorInfo("DataBoxItem:展示发生异常!", ex);
64
+            }
65
+        }
66
+    }
67
+}

+ 50
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxShowData.xaml View File

@@ -0,0 +1,50 @@
1
+<Window x:Class="Platform.Controls.ComponentContainer.DataBoxShowData"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:dhcc="http://www.dhcc.com.cn"
5
+        xmlns:local="clr-namespace:Platform.Controls.BaseContainer"
6
+        Title="详细信息"
7
+        MaxWidth="700"
8
+        MaxHeight="500"
9
+        SizeToContent="WidthAndHeight"
10
+        PreviewKeyDown="Window_PreviewKeyDown"
11
+        WindowStartupLocation="CenterOwner">
12
+    <dhcc:PageContainer Margin="5">
13
+        <dhcc:TradePage Margin="0" x:Name="trade" dhcc:FocusManager.EnableFocusControl="True">
14
+            <Grid>
15
+                <Grid.ColumnDefinitions>
16
+                    <ColumnDefinition Width="382*" />
17
+                    <ColumnDefinition Width="618*" />
18
+                </Grid.ColumnDefinitions>
19
+                <Grid.RowDefinitions>
20
+                    <RowDefinition Height="Auto" />
21
+                    <RowDefinition Height="*" />
22
+                </Grid.RowDefinitions>
23
+
24
+                <!--
25
+                    <StackPanel Grid.ColumnSpan="2"
26
+                    VerticalAlignment="Center"
27
+                    Orientation="Horizontal">
28
+                    
29
+                    <local:ImageButton x:Name="btnFirst"
30
+                    Click="btnFirst_Click"
31
+                    GrayImageSource="/Platform.Controls;component/Resource/pagination_first_gray.gif"
32
+                    ImageSource="/Platform.Controls;component/Resource/pagination_first.gif" />
33
+                    <local:ImageButton x:Name="btnPrev"
34
+                    Click="btnPrev_Click"
35
+                    GrayImageSource="/Platform.Controls;component/Resource/pagination_prev_gray.gif"
36
+                    ImageSource="/Platform.Controls;component/Resource/pagination_prev.gif" />
37
+                    <local:ImageButton x:Name="btnNext"
38
+                    Click="btnNext_Click"
39
+                    GrayImageSource="/Platform.Controls;component/Resource/pagination_next_gray.gif"
40
+                    ImageSource="/Platform.Controls;component/Resource/pagination_next.gif" />
41
+                    <local:ImageButton x:Name="btnLast"
42
+                    Click="btnLast_Click"
43
+                    GrayImageSource="/Platform.Controls;component/Resource/pagination_last_gray.gif"
44
+                    ImageSource="/Platform.Controls;component/Resource/pagination_last.gif" />
45
+                    </StackPanel>
46
+                -->
47
+            </Grid>
48
+        </dhcc:TradePage>
49
+    </dhcc:PageContainer>
50
+</Window>

+ 35
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataBox/DataBoxShowData.xaml.cs View File

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Shapes;
13
+
14
+namespace Platform.Controls.ComponentContainer
15
+{
16
+    /// <summary>
17
+    /// DataBoxShowData.xaml 的交互逻辑
18
+    /// </summary>
19
+    public partial class DataBoxShowData : Window
20
+    {
21
+        public DataBoxShowData()
22
+        {
23
+            InitializeComponent();
24
+        }
25
+
26
+        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
27
+        {
28
+            if (e.Key == Key.Escape || e.Key == Key.Enter)
29
+            {
30
+                this.Close();
31
+                e.Handled = true;
32
+            }
33
+        }
34
+    }
35
+}

+ 91
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataPager/DataPager.xaml View File

@@ -0,0 +1,91 @@
1
+<UserControl x:Class="Platform.Controls.ComponentContainer.DataPager"
2
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+             xmlns:dhcc="http://www.dhcc.com.cn"
6
+             xmlns:Helper="clr-namespace:Platform.Controls.ControlsHelper"
7
+             xmlns:local="clr-namespace:Platform.Controls.BaseContainer"
8
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9
+             x:Name="dp"
10
+             Margin="3"
11
+             d:DesignHeight="46"
12
+             d:DesignWidth="577"
13
+             Loaded="DataPager_Loaded"
14
+             mc:Ignorable="d">
15
+    <Grid>
16
+
17
+        <Grid.Resources>
18
+            <!--
19
+                <Style TargetType="{x:Type Image}">
20
+                <Setter Property="Margin" Value="3,0,3,0" />
21
+                <Setter Property="Cursor" Value="Hand" />
22
+                </Style>
23
+            -->
24
+        </Grid.Resources>
25
+
26
+        <Grid.ColumnDefinitions>
27
+            <ColumnDefinition Width="Auto" />
28
+            <ColumnDefinition />
29
+            <ColumnDefinition Width="Auto" />
30
+        </Grid.ColumnDefinitions>
31
+        <ComboBox Name="cboPageSize" MinWidth="40"
32
+                  VerticalAlignment="Center"
33
+                  ItemsSource="{Binding Path=PageSizeItems,
34
+                                        ElementName=dp}"
35
+                  SelectedItem="{Binding PageSize,
36
+                                         Mode=TwoWay,
37
+                                         ElementName=dp}"
38
+                  SelectionChanged="cbpPageSize_SelectionChanged"
39
+                  Height="21"
40
+                  Style="{x:Null}" HorizontalAlignment="Left" Margin="0,6" Width="40" />
41
+        <StackPanel Grid.Column="1"
42
+                    VerticalAlignment="Center"
43
+                    Orientation="Horizontal">
44
+
45
+            <local:ImageButton x:Name="btnFirst"
46
+                               Click="btnFirst_Click" Style="{x:Null}"
47
+                               GrayImageSource="/Platform.Controls;component/Resource/pagination_first_gray.gif"
48
+                               ImageSource="/Platform.Controls;component/Resource/pagination_first.gif" />
49
+            <local:ImageButton x:Name="btnPrev"
50
+                               Click="btnPrev_Click" Style="{x:Null}"
51
+                               GrayImageSource="/Platform.Controls;component/Resource/pagination_prev_gray.gif"
52
+                               ImageSource="/Platform.Controls;component/Resource/pagination_prev.gif" />
53
+
54
+            <TextBox Name="tbPageIndex"
55
+                     Width="{Binding Path=PageCountLength}" 
56
+                     Margin="5,0,0,0"
57
+                     VerticalContentAlignment="Center"
58
+                     LostFocus="tbPageIndex_LostFocus"
59
+                     PreviewKeyDown="tbPageIndex_PreviewKeyDown"
60
+                     Style="{x:Null}"
61
+                     Text="{Binding Path=PageIndex,
62
+                                    ElementName=dp}" />
63
+            <TextBlock Margin="5,0,0,0"
64
+                       VerticalAlignment="Center" Style="{x:Null}"
65
+                       Text="/" />
66
+            <TextBlock Margin="5,0" Style="{x:Null}"
67
+                       VerticalAlignment="Center"
68
+                       Text="{Binding Path=PageCount,
69
+                                      ElementName=dp}" />
70
+
71
+            <local:ImageButton x:Name="btnNext" Style="{x:Null}"
72
+                               Click="btnNext_Click"
73
+                               GrayImageSource="/Platform.Controls;component/Resource/pagination_next_gray.gif"
74
+                               ImageSource="/Platform.Controls;component/Resource/pagination_next.gif" />
75
+            <local:ImageButton x:Name="btnLast" Style="{x:Null}"
76
+                               Click="btnLast_Click"
77
+                               GrayImageSource="/Platform.Controls;component/Resource/pagination_last_gray.gif"
78
+                               ImageSource="/Platform.Controls;component/Resource/pagination_last.gif" />
79
+            <local:ImageButton Click="btnRefresh_Click" Style="{x:Null}"
80
+                               GrayImageSource="/Platform.Controls;component/Resource/pagination_loading.gif"
81
+                               ImageSource="/Platform.Controls;component/Resource/pagination_load.png" />
82
+        </StackPanel>
83
+        <TextBlock Grid.Column="2" Style="{x:Null}"
84
+                   HorizontalAlignment="Right"
85
+                   VerticalAlignment="Center">
86
+            共
87
+            <TextBlock Text="{Binding Path=Total, ElementName=dp}" Style="{x:Null}"/>
88
+            条记录
89
+        </TextBlock>
90
+    </Grid>
91
+</UserControl>

+ 344
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/DataPager/DataPager.xaml.cs View File

@@ -0,0 +1,344 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Navigation;
13
+using System.Windows.Shapes;
14
+using System.ComponentModel;
15
+using System.Data;
16
+
17
+namespace Platform.Controls.ComponentContainer
18
+{
19
+    /// <summary>
20
+    /// DataPager.xaml 的交互逻辑
21
+    /// </summary>
22
+    public partial class DataPager : UserControl, INotifyPropertyChanged
23
+    {
24
+        public DataPager()
25
+        {
26
+            InitializeComponent();
27
+        }
28
+
29
+        #region 依赖属性和事件
30
+        public int PageSize
31
+        {
32
+            get { return (int)GetValue(PageSizeProperty); }
33
+            set { SetValue(PageSizeProperty, value); }
34
+        }
35
+
36
+        // Using a DependencyProperty as the backing store for PageSize.  This enables animation, styling, binding, etc...
37
+        public static readonly DependencyProperty PageSizeProperty =
38
+            DependencyProperty.Register("PageSize", typeof(int), typeof(DataPager), new UIPropertyMetadata(10));
39
+
40
+        public int Total
41
+        {
42
+            get 
43
+            {
44
+                return (int)GetValue(TotalProperty); 
45
+            }
46
+            set { SetValue(TotalProperty, value); }
47
+        }
48
+
49
+        // Using a DependencyProperty as the backing store for Total.  This enables animation, styling, binding, etc...
50
+        public static readonly DependencyProperty TotalProperty =
51
+            DependencyProperty.Register("Total", typeof(int), typeof(DataPager), new UIPropertyMetadata(0));
52
+
53
+
54
+        public int PageIndex
55
+        {
56
+            get { return (int)GetValue(PageIndexProperty); }
57
+            set { SetValue(PageIndexProperty, value); }
58
+        }
59
+
60
+        // Using a DependencyProperty as the backing store for PageIndex.  This enables animation, styling, binding, etc...
61
+        public static readonly DependencyProperty PageIndexProperty =
62
+            DependencyProperty.Register("PageIndex", typeof(int), typeof(DataPager), new UIPropertyMetadata(1));
63
+
64
+
65
+
66
+        public string PageSizeList
67
+        {
68
+            get { return (string)GetValue(PageSizeListProperty); }
69
+            set { SetValue(PageSizeListProperty, value); }
70
+        }
71
+
72
+        // Using a DependencyProperty as the backing store for PageSizeList.  This enables animation, styling, binding, etc...
73
+        public static readonly DependencyProperty PageSizeListProperty =
74
+            DependencyProperty.Register("PageSizeList", typeof(string), typeof(DataPager), new UIPropertyMetadata("10,20,30", (s, e) =>
75
+            {
76
+                DataPager dp = s as DataPager;
77
+                if (dp.PageSizeItems == null) dp.PageSizeItems = new List<int>();
78
+                else dp.PageSizeItems.Clear();
79
+                dp.RaisePropertyChanged("PageSizeItems");
80
+            }));
81
+
82
+        public static readonly RoutedEvent PageChangedEvent = EventManager.RegisterRoutedEvent("PageChanged", RoutingStrategy.Bubble, typeof(PageChangedEventHandler), typeof(DataPager));
83
+        /// <summary>
84
+        /// 分页更改事件
85
+        /// </summary>
86
+        public event PageChangedEventHandler PageChanged
87
+        {
88
+            add
89
+            {
90
+                AddHandler(PageChangedEvent, value);
91
+            }
92
+            remove
93
+            {
94
+                RemoveHandler(PageChangedEvent, value);
95
+            }
96
+        }
97
+        #endregion
98
+
99
+
100
+        #region 通知属性
101
+        private List<int> _pageSizeItems;
102
+        /// <summary>
103
+        /// 显示每页记录数集合
104
+        /// </summary>
105
+        public List<int> PageSizeItems
106
+        {
107
+            get
108
+            {
109
+                if (_pageSizeItems == null)
110
+                {
111
+                    _pageSizeItems = new List<int>();
112
+                }
113
+                if (PageSizeList != null)
114
+                {
115
+                    List<string> strs = PageSizeList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
116
+                    _pageSizeItems.Clear();
117
+                    strs.ForEach(c =>
118
+                    {
119
+                        _pageSizeItems.Add(Convert.ToInt32(c));
120
+                    });
121
+                }
122
+                return _pageSizeItems;
123
+            }
124
+            set
125
+            {
126
+                if (_pageSizeItems != value)
127
+                {
128
+                    _pageSizeItems = value;
129
+                    RaisePropertyChanged("PageSizeItems");
130
+                }
131
+            }
132
+        }
133
+
134
+        private int _pageCount;
135
+        /// <summary>
136
+        /// 总页数
137
+        /// </summary>
138
+        public int PageCount
139
+        {
140
+            get { return _pageCount; }
141
+            set
142
+            {
143
+                if (_pageCount != value)
144
+                {
145
+                    _pageCount = value;
146
+                    RaisePropertyChanged("PageCount");
147
+                }
148
+            }
149
+        }
150
+
151
+        private int _pageCountLength;
152
+        /// <summary>
153
+        /// 总页数的文本长度
154
+        /// </summary>
155
+        public int PageCountLength
156
+        {
157
+            get { return _pageCountLength; }
158
+            set
159
+            {
160
+                if (_pageCountLength != value)
161
+                {
162
+                    _pageCountLength = value;
163
+                    RaisePropertyChanged("PageCountLength");
164
+                }
165
+            }
166
+        }
167
+
168
+        public event PropertyChangedEventHandler PropertyChanged;
169
+        public void RaisePropertyChanged(string propertyName)
170
+        {
171
+            if (PropertyChanged != null)
172
+            {
173
+                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
174
+            }
175
+        }
176
+        #endregion
177
+
178
+        #region 字段、属性、委托
179
+        public delegate void PageChangedEventHandler(object sender, PageChangedEventArgs args);
180
+        private PageChangedEventArgs pageChangedEventArgs;
181
+        #endregion
182
+
183
+
184
+
185
+        #region 引发分页更改事件
186
+        /// <summary>
187
+        /// 引发分页更改事件
188
+        /// </summary>
189
+        public void RaisePageChanged()
190
+        {
191
+            if (pageChangedEventArgs == null)
192
+            {
193
+                pageChangedEventArgs = new PageChangedEventArgs(PageChangedEvent, PageSize, PageIndex);
194
+            }
195
+            else
196
+            {
197
+                pageChangedEventArgs.PageSize = this.PageSize;
198
+                pageChangedEventArgs.PageIndex = this.PageIndex;
199
+            }
200
+            RaiseEvent(pageChangedEventArgs);
201
+            //calc start、end
202
+            if (Total != 0)
203
+            {
204
+                if (Total % PageSize != 0)
205
+                {
206
+                    PageCount = Total / PageSize + 1;
207
+                }
208
+                else
209
+                {
210
+                    PageCount = Total / PageSize;
211
+                }
212
+
213
+                PageCountLength = PageCount.ToString().Length;
214
+            }
215
+            else
216
+            {
217
+                PageCount = 0;
218
+            }
219
+
220
+            //调整图片的显示
221
+            btnFirst.IsEnabled = btnPrev.IsEnabled = (PageIndex != 1);
222
+            btnNext.IsEnabled = btnLast.IsEnabled = (PageIndex != PageCount);
223
+        }
224
+        #endregion
225
+
226
+        #region 分页操作事件
227
+        void DataPager_Loaded(object sender, RoutedEventArgs e)
228
+        {
229
+            cboPageSize.SelectedIndex = 0;
230
+            //if (this.IsVisible)
231
+            //{
232
+            //    RaisePageChanged();
233
+            //}
234
+        }
235
+
236
+        private void cbpPageSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
237
+        {
238
+            if (this.IsLoaded)
239
+            {
240
+                PageSize = (int)cboPageSize.SelectedItem;
241
+                PageIndex = 1;
242
+                RaisePageChanged();
243
+            }
244
+        }
245
+
246
+        private void btnFirst_Click(object sender, RoutedEventArgs e)
247
+        {
248
+            PageIndex = 1;
249
+            RaisePageChanged();
250
+        }
251
+
252
+        private void btnPrev_Click(object sender, RoutedEventArgs e)
253
+        {
254
+            if (PageIndex > 1)
255
+            {
256
+                --PageIndex;
257
+            }
258
+            RaisePageChanged();
259
+        }
260
+
261
+        private void btnNext_Click(object sender, RoutedEventArgs e)
262
+        {
263
+            if (Total % PageSize != 0)
264
+            {
265
+                PageCount = Total / PageSize + 1;
266
+            }
267
+            else
268
+            {
269
+                PageCount = Total / PageSize;
270
+            }
271
+
272
+            if (PageIndex < PageCount)
273
+            {
274
+                ++PageIndex;
275
+            }
276
+            RaisePageChanged();
277
+        }
278
+
279
+        private void btnLast_Click(object sender, RoutedEventArgs e)
280
+        {
281
+            if (Total % PageSize != 0)
282
+            {
283
+                PageCount = Total / PageSize + 1;
284
+            }
285
+            else
286
+            {
287
+                PageCount = Total / PageSize;
288
+            }
289
+            PageIndex = PageCount;
290
+            RaisePageChanged();
291
+        }
292
+        private void btnRefresh_Click(object sender, RoutedEventArgs e)
293
+        {
294
+            RaisePageChanged();
295
+        }
296
+
297
+        private void tbPageIndex_PreviewKeyDown(object sender, KeyEventArgs e)
298
+        {
299
+            if (e.Key == Key.Enter)
300
+            {
301
+                tbPageIndex_LostFocus(sender, null);
302
+            }
303
+        }
304
+
305
+        private void tbPageIndex_LostFocus(object sender, RoutedEventArgs e)
306
+        {
307
+            int pIndex = 0;
308
+
309
+            bool flg = int.TryParse(tbPageIndex.Text, out pIndex);
310
+            if (!flg) pIndex = 1;
311
+
312
+            if (pIndex < 1) PageIndex = 1;
313
+            else if (pIndex > PageCount)
314
+            { 
315
+                PageIndex = PageCount;
316
+                tbPageIndex.Text = PageIndex.ToString();
317
+            }
318
+            else PageIndex = pIndex;
319
+
320
+            RaisePageChanged();
321
+        }
322
+        #endregion
323
+
324
+
325
+
326
+
327
+    }
328
+
329
+    /// <summary>
330
+    /// 分页更改参数
331
+    /// </summary>
332
+    public class PageChangedEventArgs : RoutedEventArgs
333
+    {
334
+        public int PageSize { get; set; }
335
+        public int PageIndex { get; set; }
336
+
337
+        public PageChangedEventArgs(RoutedEvent routeEvent, int pageSize, int pageIndex)
338
+            : base(routeEvent)
339
+        {
340
+            this.PageSize = pageSize;
341
+            this.PageIndex = pageIndex;
342
+        }
343
+    }
344
+}

+ 37
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorDialog.xaml View File

@@ -0,0 +1,37 @@
1
+<Window x:Class="Platform.Controls.ComponentContainer.ColorDialog"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:local="clr-namespace:Platform.Controls.ComponentContainer"
5
+        Title="颜色选择器"
6
+        Width="520"
7
+        Height="410"
8
+        Icon="/Platform.Controls;component/Resource/ColorSwatchSquare.png"
9
+        KeyDown="Window_KeyDown"
10
+        WindowStartupLocation="CenterOwner">
11
+    <Grid>
12
+        <Grid.RowDefinitions>
13
+            <RowDefinition Height="*" />
14
+            <RowDefinition Height="40" />
15
+        </Grid.RowDefinitions>
16
+
17
+
18
+        <local:ColorPicker x:Name="colorPicker" />
19
+        <StackPanel Grid.Row="1"
20
+                    Margin="5"
21
+                    HorizontalAlignment="Right"
22
+                    Orientation="Horizontal">
23
+            <Button x:Name="btnOk"
24
+                    Width="60"
25
+                    Height="25"
26
+                    Margin="10,0,0,0"
27
+                    Click="btnOk_Click"
28
+                    Content="确定" />
29
+            <Button x:Name="btnCancel"
30
+                    Width="60"
31
+                    Height="25"
32
+                    Margin="10,0,10,0"
33
+                    Click="btnCancel_Click"
34
+                    Content="取消" />
35
+        </StackPanel>
36
+    </Grid>
37
+</Window>

+ 72
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorDialog.xaml.cs View File

@@ -0,0 +1,72 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Shapes;
13
+using System.ComponentModel;
14
+
15
+namespace Platform.Controls.ComponentContainer
16
+{
17
+    /// <summary>
18
+    /// ColorDialog.xaml 的交互逻辑
19
+    /// </summary>
20
+    [DesignTimeVisible(false)]
21
+    public partial class ColorDialog : Window
22
+    {
23
+        #region 初始化
24
+        public ColorDialog()
25
+        {
26
+            InitializeComponent();
27
+        }
28
+        #endregion
29
+
30
+        #region 公共属性
31
+        public Color SelectedColor
32
+        {
33
+            get { return colorPicker.SelectedColor; }
34
+        }
35
+        #endregion
36
+
37
+        #region 私有方法
38
+        /// <summary>
39
+        /// Enter键关闭窗口
40
+        /// </summary>
41
+        /// <param name="sender"></param>
42
+        /// <param name="e"></param>
43
+        private void Window_KeyDown(object sender, KeyEventArgs e)
44
+        {
45
+            if (e.Key == Key.Enter)
46
+            {
47
+                this.Close();
48
+            }
49
+        }
50
+
51
+        /// <summary>
52
+        /// 确定
53
+        /// </summary>
54
+        /// <param name="sender"></param>
55
+        /// <param name="e"></param>
56
+        private void btnOk_Click(object sender, RoutedEventArgs e)
57
+        {
58
+            DialogResult = true;
59
+        }
60
+
61
+        /// <summary>
62
+        /// 取消
63
+        /// </summary>
64
+        /// <param name="sender"></param>
65
+        /// <param name="e"></param>
66
+        private void btnCancel_Click(object sender, RoutedEventArgs e)
67
+        {
68
+            DialogResult = false;
69
+        }
70
+        #endregion
71
+    }
72
+}

+ 339
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorPicker.xaml View File

@@ -0,0 +1,339 @@
1
+
2
+<UserControl x:Class="Platform.Controls.ComponentContainer.ColorPicker"
3
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+             d:DesignHeight="340"
8
+             d:DesignWidth="510"
9
+             mc:Ignorable="d">
10
+    <UserControl.Resources>
11
+        <DrawingBrush x:Key="CheckerboardBrush"
12
+                      AlignmentX="Left"
13
+                      AlignmentY="Top"
14
+                      Stretch="None"
15
+                      TileMode="Tile"
16
+                      Viewport="0,0,10,10"
17
+                      ViewportUnits="Absolute">
18
+            <DrawingBrush.Drawing>
19
+                <DrawingGroup>
20
+                    <GeometryDrawing Brush="sc# 1,1,1">
21
+                        <GeometryDrawing.Geometry>
22
+                            <RectangleGeometry Rect="0,0,10,10" />
23
+                        </GeometryDrawing.Geometry>
24
+                    </GeometryDrawing>
25
+                    <GeometryDrawing Brush="sc# 0.5,0.5,0.5">
26
+                        <GeometryDrawing.Geometry>
27
+                            <RectangleGeometry Rect="0,0,5,5" />
28
+                        </GeometryDrawing.Geometry>
29
+                    </GeometryDrawing>
30
+                    <GeometryDrawing Brush="sc# 0.5,0.5,0.5">
31
+                        <GeometryDrawing.Geometry>
32
+                            <RectangleGeometry Rect="5,5,5,5" />
33
+                        </GeometryDrawing.Geometry>
34
+                    </GeometryDrawing>
35
+                </DrawingGroup>
36
+            </DrawingBrush.Drawing>
37
+        </DrawingBrush>
38
+    </UserControl.Resources>
39
+
40
+    <Grid Background="White">
41
+        <Grid.RowDefinitions>
42
+            <RowDefinition Height="35" />
43
+            <RowDefinition Height="230" />
44
+            <RowDefinition Height="70" />
45
+        </Grid.RowDefinitions>
46
+
47
+        <StackPanel Grid.Row="0"
48
+                    Height="35"
49
+                    HorizontalAlignment="Stretch"
50
+                    Background="Black"
51
+                    Orientation="Horizontal">
52
+            <Label VerticalAlignment="Center"
53
+                   Content="调色器"
54
+                   FontWeight="Bold"
55
+                   Foreground="White" />
56
+            <Image x:Name="ImgSqaure1"
57
+                   Width="20"
58
+                   Height="20"
59
+                   Margin="45,0,0,0"
60
+                   MouseLeftButtonDown="Swatch_MouseLeftButtonDown"
61
+                   Source="/Platform.Controls;component/Resource/ColorSwatchSquare.png"
62
+                   ToolTip="Square swatch1" />
63
+            <Image x:Name="ImgSqaure2"
64
+                   Width="20"
65
+                   Height="20"
66
+                   Margin="5,0,0,0"
67
+                   MouseLeftButtonDown="Swatch_MouseLeftButtonDown"
68
+                   Source="/Platform.Controls;component/Resource/ColorSwatchSquare2.png"
69
+                   ToolTip="Square swatch2" />
70
+            <Image x:Name="ImgCircle1"
71
+                   Width="20"
72
+                   Height="20"
73
+                   Margin="5,0,0,0"
74
+                   MouseLeftButtonDown="Swatch_MouseLeftButtonDown"
75
+                   Source="/Platform.Controls;component/Resource/ColorSwatchCircle.png"
76
+                   ToolTip="Circle swatch1" />
77
+        </StackPanel>
78
+
79
+        <Grid Grid.Row="1"
80
+              Height="230"
81
+              VerticalAlignment="Top">
82
+            <Grid.ColumnDefinitions>
83
+                <ColumnDefinition Width="170" />
84
+                <ColumnDefinition Width="170" />
85
+                <ColumnDefinition Width="170" />
86
+            </Grid.ColumnDefinitions>
87
+
88
+            <!--  Colorbox, Column1  -->
89
+            <Grid Grid.Row="0"
90
+                  Grid.Column="0"
91
+                  Margin="10,30,0,0">
92
+                <Border Width="154"
93
+                        Height="154"
94
+                        HorizontalAlignment="Center"
95
+                        VerticalAlignment="Top"
96
+                        Background="White"
97
+                        BorderBrush="Black"
98
+                        BorderThickness="2" />
99
+                <Image x:Name="ColorImage"
100
+                       Width="150"
101
+                       Height="150"
102
+                       Margin="2"
103
+                       HorizontalAlignment="Center"
104
+                       VerticalAlignment="Top"
105
+                       Source="/Platform.Controls;component/Resource/ColorSwatchSquare.png" />
106
+
107
+                <Canvas x:Name="CanvImage"
108
+                        Width="150"
109
+                        Height="150"
110
+                        Margin="2"
111
+                        HorizontalAlignment="Center"
112
+                        VerticalAlignment="Top"
113
+                        Background="Transparent"
114
+                        MouseDown="CanvImage_MouseDown"
115
+                        MouseMove="CanvImage_MouseMove"
116
+                        MouseUp="CanvImage_MouseUp">
117
+                    <Ellipse x:Name="ellipsePixel"
118
+                             Canvas.Left="0"
119
+                             Canvas.Top="0"
120
+                             Width="10"
121
+                             Height="10"
122
+                             Fill="White"
123
+                             Stroke="Black" />
124
+                </Canvas>
125
+            </Grid>
126
+
127
+            <!--  Preview, Column1  -->
128
+            <StackPanel Grid.Column="1" Orientation="Vertical">
129
+                <Label Margin="5,0,0,0"
130
+                       HorizontalAlignment="Left"
131
+                       VerticalAlignment="Center"
132
+                       Content="颜色预览:"
133
+                       FontWeight="Bold"
134
+                       Foreground="Black" />
135
+
136
+                <Border Width="154"
137
+                        Height="154"
138
+                        Margin="4,5,10,0"
139
+                        HorizontalAlignment="Left"
140
+                        Background="{StaticResource CheckerboardBrush}"
141
+                        BorderBrush="Black"
142
+                        BorderThickness="2">
143
+                    <InkPresenter Name="previewPresenter"
144
+                                  Width="150"
145
+                                  Height="150"
146
+                                  Margin="0"
147
+                                  Strokes="AOcBAxdIEESAgYAERYQBGwIAJAFGhAEbAgAkAQUBOBkgMgkA9P8CAekiOkUzCQD4nwIBWiA6RTgIAP4DAAAAgH8RAACAPx8JEQAAAAAAAPA/CpYBNIfm3uajgcQgUUiUkjUelEal0KkUBh0HichlM1mtJotZp9JodDl8jk8ZgcBiUOjUYl08m0+l0+lFCjksjESAh+kg6auNwaEwSBQiEQyLRKTRiVSiUSSORyLQ6JQSBIPFYnKZTL5fOZfMZXL4/H47DYLBYHFoJLIpEo9GgIP3OB5PlxLCJiZmU1MISSi4SJiS74+D4+4o" />
148
+                </Border>
149
+
150
+            </StackPanel>
151
+
152
+            <!--  TextBoxes, Column2  -->
153
+            <StackPanel Grid.Column="2" Orientation="Vertical">
154
+                <StackPanel Margin="0,30,0,0" Orientation="Horizontal">
155
+                    <Label Margin="5,0,0,0"
156
+                           HorizontalAlignment="Left"
157
+                           VerticalAlignment="Center"
158
+                           Content="A"
159
+                           FontWeight="Bold"
160
+                           Foreground="Black" />
161
+                    <Border Width="50"
162
+                            Height="30"
163
+                            Background="LightGray"
164
+                            BorderBrush="Black"
165
+                            BorderThickness="2"
166
+                            CornerRadius="5">
167
+                        <TextBox x:Name="txtAlpha"
168
+                                 Margin="5,1,5,1"
169
+                                 Background="LightGray"
170
+                                 BorderBrush="Transparent"
171
+                                 BorderThickness="0"
172
+                                 IsReadOnly="True" />
173
+                    </Border>
174
+                    <Border Width="50"
175
+                            Height="30"
176
+                            Margin="10,0,0,0"
177
+                            Background="LightGray"
178
+                            BorderBrush="Black"
179
+                            BorderThickness="2"
180
+                            CornerRadius="5">
181
+                        <TextBox x:Name="txtAlphaHex"
182
+                                 Margin="5,1,5,1"
183
+                                 Background="LightGray"
184
+                                 BorderBrush="Transparent"
185
+                                 BorderThickness="0"
186
+                                 IsReadOnly="True" />
187
+                    </Border>
188
+                </StackPanel>
189
+
190
+                <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
191
+                    <Label Margin="5,0,0,0"
192
+                           HorizontalAlignment="Left"
193
+                           VerticalAlignment="Center"
194
+                           Content="R"
195
+                           FontWeight="Bold"
196
+                           Foreground="Black" />
197
+                    <Border Width="50"
198
+                            Height="30"
199
+                            Background="LightGray"
200
+                            BorderBrush="Black"
201
+                            BorderThickness="2"
202
+                            CornerRadius="5">
203
+                        <TextBox x:Name="txtRed"
204
+                                 Margin="5,1,5,1"
205
+                                 Background="LightGray"
206
+                                 BorderBrush="Transparent"
207
+                                 BorderThickness="0"
208
+                                 IsReadOnly="True" />
209
+                    </Border>
210
+                    <Border Width="50"
211
+                            Height="30"
212
+                            Margin="10,0,0,0"
213
+                            Background="LightGray"
214
+                            BorderBrush="Black"
215
+                            BorderThickness="2"
216
+                            CornerRadius="5">
217
+                        <TextBox x:Name="txtRedHex"
218
+                                 Margin="5,1,5,1"
219
+                                 Background="LightGray"
220
+                                 BorderBrush="Transparent"
221
+                                 BorderThickness="0"
222
+                                 IsReadOnly="True" />
223
+                    </Border>
224
+                </StackPanel>
225
+
226
+                <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
227
+                    <Label Margin="5,0,0,0"
228
+                           HorizontalAlignment="Left"
229
+                           VerticalAlignment="Center"
230
+                           Content="G"
231
+                           FontWeight="Bold"
232
+                           Foreground="Black" />
233
+                    <Border Width="50"
234
+                            Height="30"
235
+                            Background="LightGray"
236
+                            BorderBrush="Black"
237
+                            BorderThickness="2"
238
+                            CornerRadius="5">
239
+                        <TextBox x:Name="txtGreen"
240
+                                 Margin="5,1,5,1"
241
+                                 Background="LightGray"
242
+                                 BorderBrush="Transparent"
243
+                                 BorderThickness="0"
244
+                                 IsReadOnly="True" />
245
+                    </Border>
246
+                    <Border Width="50"
247
+                            Height="30"
248
+                            Margin="10,0,0,0"
249
+                            Background="LightGray"
250
+                            BorderBrush="Black"
251
+                            BorderThickness="2"
252
+                            CornerRadius="5">
253
+                        <TextBox x:Name="txtGreenHex"
254
+                                 Margin="5,1,5,1"
255
+                                 Background="LightGray"
256
+                                 BorderBrush="Transparent"
257
+                                 BorderThickness="0"
258
+                                 IsReadOnly="True" />
259
+                    </Border>
260
+                </StackPanel>
261
+
262
+                <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
263
+                    <Label Margin="5,0,0,0"
264
+                           HorizontalAlignment="Left"
265
+                           VerticalAlignment="Center"
266
+                           Content="B"
267
+                           FontWeight="Bold"
268
+                           Foreground="Black" />
269
+                    <Border Width="50"
270
+                            Height="30"
271
+                            Background="LightGray"
272
+                            BorderBrush="Black"
273
+                            BorderThickness="2"
274
+                            CornerRadius="5">
275
+                        <TextBox x:Name="txtBlue"
276
+                                 Margin="5,1,5,1"
277
+                                 Background="LightGray"
278
+                                 BorderBrush="Transparent"
279
+                                 BorderThickness="0"
280
+                                 IsReadOnly="True" />
281
+                    </Border>
282
+                    <Border Width="50"
283
+                            Height="30"
284
+                            Margin="10,0,0,0"
285
+                            Background="LightGray"
286
+                            BorderBrush="Black"
287
+                            BorderThickness="2"
288
+                            CornerRadius="5">
289
+                        <TextBox x:Name="txtBlueHex"
290
+                                 Margin="5,1,5,1"
291
+                                 Background="LightGray"
292
+                                 BorderBrush="Transparent"
293
+                                 BorderThickness="0"
294
+                                 IsReadOnly="True" />
295
+                    </Border>
296
+                </StackPanel>
297
+
298
+                <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
299
+                    <Border Width="112"
300
+                            Height="30"
301
+                            Margin="22,0,0,0"
302
+                            Background="LightGray"
303
+                            BorderBrush="Black"
304
+                            BorderThickness="2"
305
+                            CornerRadius="5">
306
+                        <TextBox x:Name="txtAll"
307
+                                 Margin="5,1,5,1"
308
+                                 Background="LightGray"
309
+                                 BorderBrush="Transparent"
310
+                                 BorderThickness="0"
311
+                                 IsReadOnly="True" />
312
+                    </Border>
313
+                </StackPanel>
314
+            </StackPanel>
315
+        </Grid>
316
+
317
+        <!--  AlphaSlider  -->
318
+        <Border x:Name="AlphaBorder"
319
+                Grid.Row="2"
320
+                Grid.ColumnSpan="2"
321
+                Height="60"
322
+                Margin="10,5,10,5"
323
+                BorderBrush="Black"
324
+                BorderThickness="2"
325
+                CornerRadius="5">
326
+            <Slider x:Name="AlphaSlider"
327
+                    Margin="5"
328
+                    VerticalAlignment="Center"
329
+                    LargeChange="25"
330
+                    Maximum="255"
331
+                    Minimum="0"
332
+                    Orientation="Horizontal"
333
+                    SmallChange="1"
334
+                    ValueChanged="AlphaSlider_ValueChanged"
335
+                    Value="255" />
336
+        </Border>
337
+    </Grid>
338
+</UserControl>
339
+

+ 216
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/ColorPicker.xaml.cs View File

@@ -0,0 +1,216 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Navigation;
13
+using System.Windows.Shapes;
14
+using System.Windows.Ink;
15
+using System.ComponentModel;
16
+
17
+namespace Platform.Controls.ComponentContainer
18
+{
19
+    /// <summary>
20
+    /// ColorPicker.xaml 的交互逻辑
21
+    /// </summary>
22
+    [DesignTimeVisible(false)]
23
+    public partial class ColorPicker : UserControl
24
+    {
25
+
26
+        #region 变量
27
+        private DrawingAttributes drawingAttributes = new DrawingAttributes();
28
+        private Color selectedColor = Colors.Transparent;
29
+        private Boolean IsMouseDown = false;
30
+        #endregion
31
+
32
+        #region 初始化
33
+        public ColorPicker()
34
+        {
35
+            InitializeComponent();
36
+            this.Loaded += new RoutedEventHandler(ColorPicker_Loaded);
37
+        }
38
+        #endregion
39
+
40
+        #region 公共属性
41
+        /// <summary>
42
+        /// 颜色选择器
43
+        /// </summary>
44
+        public Color SelectedColor
45
+        {
46
+            get { return selectedColor; }
47
+            private set
48
+            {
49
+                if (selectedColor != value)
50
+                {
51
+                    selectedColor = value;
52
+                    CreateAlphaLinearBrush();
53
+                    UpdateTextBoxes();
54
+                    UpdateInk();
55
+                }
56
+            }
57
+        }
58
+        #endregion
59
+
60
+        #region 私有方法
61
+        /// <summary>
62
+        /// 颜色选择器加载时,默认的颜色值
63
+        /// </summary>
64
+        /// <param name="sender"></param>
65
+        /// <param name="e"></param>
66
+        private void ColorPicker_Loaded(object sender, RoutedEventArgs e)
67
+        {
68
+            SelectedColor = Colors.Black;
69
+        }
70
+
71
+        /// <summary>
72
+        /// 为滑动条创建一个默认的渐变色
73
+        /// </summary>
74
+        private void CreateAlphaLinearBrush()
75
+        {
76
+            Color startColor = Color.FromArgb(
77
+                    (byte)0,
78
+                    SelectedColor.R,
79
+                    SelectedColor.G,
80
+                    SelectedColor.B);
81
+
82
+            Color endColor = Color.FromArgb(
83
+                    (byte)255,
84
+                    SelectedColor.R,
85
+                    SelectedColor.G,
86
+                    SelectedColor.B);
87
+
88
+            LinearGradientBrush alphaBrush =
89
+                new LinearGradientBrush(startColor, endColor,
90
+                    new Point(0, 0), new Point(1, 0));
91
+
92
+            AlphaBorder.Background = alphaBrush;
93
+        }
94
+
95
+
96
+        /// <summary>
97
+        /// 选择调色器图案
98
+        /// </summary>
99
+        /// <param name="sender"></param>
100
+        /// <param name="e"></param>
101
+        private void Swatch_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
102
+        {
103
+            System.Windows.Controls.Image img = (sender as System.Windows.Controls.Image);
104
+            ColorImage.Source = img.Source;
105
+        }
106
+
107
+
108
+        /// <summary>
109
+        /// 鼠标指针移动时发生
110
+        /// </summary>
111
+        /// <param name="sender"></param>
112
+        /// <param name="e"></param>
113
+        private void CanvImage_MouseMove(object sender, MouseEventArgs e)
114
+        {
115
+            if (!IsMouseDown)
116
+                return;
117
+
118
+            try
119
+            {
120
+                CroppedBitmap cb = new CroppedBitmap(ColorImage.Source as BitmapSource,
121
+                    new Int32Rect((int)Mouse.GetPosition(CanvImage).X,
122
+                        (int)Mouse.GetPosition(CanvImage).Y, 1, 1));
123
+
124
+                byte[] pixels = new byte[4];
125
+
126
+                try
127
+                {
128
+                    cb.CopyPixels(pixels, 4, 0);
129
+                }
130
+                catch (Exception)
131
+                {
132
+
133
+                }
134
+
135
+                //当鼠标指针选择该点的时候,填充该点的颜色
136
+                ellipsePixel.SetValue(Canvas.LeftProperty, (double)(Mouse.GetPosition(CanvImage).X - 5));
137
+                ellipsePixel.SetValue(Canvas.TopProperty, (double)(Mouse.GetPosition(CanvImage).Y - 5));
138
+                CanvImage.InvalidateVisual();
139
+                SelectedColor = Color.FromArgb((byte)AlphaSlider.Value, pixels[2], pixels[1], pixels[0]);
140
+            }
141
+            catch (Exception)
142
+            {
143
+
144
+            }
145
+        }
146
+        /// <summary>
147
+        /// 按下任何鼠标按钮时发生
148
+        /// </summary>
149
+        /// <param name="sender"></param>
150
+        /// <param name="e"></param>
151
+        private void CanvImage_MouseDown(object sender, MouseButtonEventArgs e)
152
+        {
153
+            IsMouseDown = true;
154
+        }
155
+
156
+        /// <summary>
157
+        /// 释放任何鼠标按钮时发生
158
+        /// </summary>
159
+        /// <param name="sender"></param>
160
+        /// <param name="e"></param>
161
+        private void CanvImage_MouseUp(object sender, MouseButtonEventArgs e)
162
+        {
163
+            IsMouseDown = false;
164
+        }
165
+        /// <summary>
166
+        /// 更新TextBox颜色值
167
+        /// </summary>
168
+        private void UpdateTextBoxes()
169
+        {
170
+            txtAlpha.Text = SelectedColor.A.ToString();
171
+            txtAlphaHex.Text = SelectedColor.A.ToString("X");
172
+            txtRed.Text = SelectedColor.R.ToString();
173
+            txtRedHex.Text = SelectedColor.R.ToString("X");
174
+            txtGreen.Text = SelectedColor.G.ToString();
175
+            txtGreenHex.Text = SelectedColor.G.ToString("X");
176
+            txtBlue.Text = SelectedColor.B.ToString();
177
+            txtBlueHex.Text = SelectedColor.B.ToString("X");
178
+            txtAll.Text = String.Format("#{0}{1}{2}{3}",
179
+                    txtAlphaHex.Text, txtRedHex.Text,
180
+                    txtGreenHex.Text, txtBlueHex.Text);
181
+        }
182
+
183
+        /// <summary>
184
+        /// 在调色器选中颜色值后,更改预览的颜色
185
+        /// </summary>
186
+        private void UpdateInk()
187
+        {
188
+            drawingAttributes.Color = SelectedColor;
189
+            drawingAttributes.StylusTip = StylusTip.Ellipse;
190
+            drawingAttributes.Width = 5;
191
+            foreach (Stroke s in previewPresenter.Strokes)
192
+            {
193
+                s.DrawingAttributes = drawingAttributes;
194
+            }
195
+        }
196
+
197
+        /// <summary>
198
+        /// 滑动条更改的事件
199
+        /// </summary>
200
+        /// <param name="sender"></param>
201
+        /// <param name="e"></param>
202
+        private void AlphaSlider_ValueChanged(object sender,
203
+            RoutedPropertyChangedEventArgs<double> e)
204
+        {
205
+            SelectedColor =
206
+                Color.FromArgb(
207
+                    (byte)AlphaSlider.Value,
208
+                    SelectedColor.R,
209
+                    SelectedColor.G,
210
+                    SelectedColor.B);
211
+        }
212
+
213
+
214
+        #endregion
215
+    }
216
+}

+ 47
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/FontHeight.ts View File

@@ -0,0 +1,47 @@
1
+class FontHeight {
2
+    private fontSizes: string[];
3
+
4
+    constructor() {
5
+        this.fontSizes = [
6
+            "8",
7
+            "9",
8
+            "10",
9
+            "11",
10
+            "12",
11
+            "14",
12
+            "16",
13
+            "18",
14
+            "20",
15
+            "22",
16
+            "24",
17
+            "26",
18
+            "28",
19
+            "36",
20
+            "48",
21
+            "72"
22
+            // 可以取消注释添加中文表示的字体大小
23
+            // "初号",
24
+            // "小初",
25
+            // "一号",
26
+            // "小一",
27
+            // "二号",
28
+            // "三号",
29
+            // "小三",
30
+            // "四号",
31
+            // "小四",
32
+            // "五号",
33
+            // "小五",
34
+            // "六号",
35
+            // "小六",
36
+            // "七号",
37
+            // "八号"
38
+        ];
39
+    }
40
+
41
+    // 获取字体大小集合
42
+    getFontSizes(): string[] {
43
+        return this.fontSizes;
44
+    }
45
+}
46
+
47
+export default FontHeight;

+ 35
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/FontList.ts View File

@@ -0,0 +1,35 @@
1
+import { makeObservable, observable, action } from 'mobx';
2
+
3
+class FontList {
4
+    @observable fonts: string[] = [];
5
+
6
+    constructor() {
7
+        this.initializeFonts();
8
+        this.sort();
9
+    }
10
+
11
+    private initializeFonts() {
12
+        const systemFonts = this.getSystemFonts();
13
+        systemFonts.forEach((fontFamily) => {
14
+            const familyName = this.getFamilyName(fontFamily);
15
+            this.fonts.push(familyName);
16
+        });
17
+    }
18
+
19
+    private getSystemFonts(): string[] {
20
+        // 在浏览器环境中,无法直接获取系统字体,这里简单模拟
21
+        return ['Arial', 'Times New Roman', 'Courier New'];
22
+    }
23
+
24
+    private getFamilyName(fontFamily: string): string {
25
+        // 在浏览器环境中,无法使用 WPF 的相关方法,直接返回字体名称
26
+        return fontFamily;
27
+    }
28
+
29
+    @action
30
+    private sort() {
31
+        this.fonts.sort();
32
+    }
33
+}
34
+
35
+export default FontList;

+ 349
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/RtfEditorBox.xaml View File

@@ -0,0 +1,349 @@
1
+
2
+<UserControl x:Class="Platform.Controls.ComponentContainer.RtfEditorBox"
3
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+             xmlns:RtfEditor="clr-namespace:Platform.Controls.ComponentContainer"
8
+             Focusable="True"
9
+             Loaded="RtfEditor_Loaded"
10
+             mc:Ignorable="d">
11
+    <UserControl.Resources>
12
+        <ObjectDataProvider x:Key="FontListKlasse"
13
+                            ObjectType="{x:Type RtfEditor:FontList}"
14
+                            d:IsDataSource="True" />
15
+        <ObjectDataProvider x:Key="FontHeightKlasse"
16
+                            ObjectType="{x:Type RtfEditor:FontHeight}"
17
+                            d:IsDataSource="True" />
18
+        <Style x:Key="formatComboxboxStyle" TargetType="{x:Type ComboBox}">
19
+            <Setter Property="FontFamily" Value="宋体" />
20
+            <Setter Property="FontSize" Value="12" />
21
+            <Setter Property="Height" Value="23" />
22
+            <Setter Property="Margin" Value="1" />
23
+        </Style>
24
+        <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
25
+            <Setter Property="FontFamily" Value="宋体" />
26
+            <Setter Property="FontSize" Value="12" />
27
+            <Setter Property="Width" Value="23" />
28
+            <Setter Property="Height" Value="23" />
29
+            <Setter Property="Margin" Value="1" />
30
+            <Setter Property="Template">
31
+                <Setter.Value>
32
+                    <ControlTemplate TargetType="Button">
33
+                        <Border x:Name="bd"
34
+                                Background="#FFEFF1F3"
35
+                                BorderBrush="{x:Null}"
36
+                                BorderThickness="0">
37
+                            <ContentPresenter x:Name="content"
38
+                                              HorizontalAlignment="Center"
39
+                                              VerticalAlignment="Center"
40
+                                              Content="{TemplateBinding Content}" />
41
+                        </Border>
42
+
43
+                        <!--  触发器  -->
44
+                        <ControlTemplate.Triggers>
45
+                            <Trigger Property="IsFocused" Value="true">
46
+                                <Setter TargetName="bd" Property="BorderBrush" Value="#FFDECFAC" />
47
+                                <Setter TargetName="bd" Property="Background" Value="#FFFFE876" />
48
+                                <Setter TargetName="bd" Property="BorderThickness" Value="1" />
49
+                                <Setter TargetName="bd" Property="CornerRadius" Value="3" />
50
+                                <Setter Property="Cursor" Value="Hand" />
51
+                            </Trigger>
52
+                            <Trigger Property="IsMouseOver" Value="True">
53
+                                <Setter TargetName="bd" Property="BorderBrush" Value="#FFDECFAC" />
54
+                                <Setter TargetName="bd" Property="Background" Value="#FFFFE876" />
55
+                                <Setter TargetName="bd" Property="BorderThickness" Value="1" />
56
+                                <Setter TargetName="bd" Property="CornerRadius" Value="3" />
57
+                                <Setter Property="Cursor" Value="Hand" />
58
+                            </Trigger>
59
+                        </ControlTemplate.Triggers>
60
+                    </ControlTemplate>
61
+                </Setter.Value>
62
+            </Setter>
63
+        </Style>
64
+        <Style x:Key="ImgStyle" TargetType="{x:Type Image}">
65
+            <Setter Property="Width" Value="17" />
66
+            <Setter Property="Height" Value="17" />
67
+            <Setter Property="HorizontalAlignment" Value="Center" />
68
+            <Setter Property="VerticalAlignment" Value="Center" />
69
+            <Setter Property="Cursor" Value="Hand" />
70
+            <Setter Property="Stretch" Value="Fill" />
71
+            <Setter Property="Margin" Value="2,4" />
72
+        </Style>
73
+
74
+    </UserControl.Resources>
75
+    <Grid>
76
+        <Grid.RowDefinitions>
77
+            <RowDefinition Height="Auto" />
78
+            <RowDefinition Height="*" />
79
+        </Grid.RowDefinitions>
80
+        <Border Name="toolBarPanel"
81
+                Grid.Row="0"
82
+                Height="30"
83
+                BorderBrush="#5555"
84
+                BorderThickness="1"
85
+                CornerRadius="3"
86
+                Focusable="True"
87
+                Style="{x:Null}">
88
+            <Border.Background>
89
+                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
90
+                    <GradientBrush.GradientStops>
91
+                        <GradientStopCollection>
92
+                            <GradientStop Offset="1" Color="#FFEFF1F3" />
93
+                        </GradientStopCollection>
94
+                    </GradientBrush.GradientStops>
95
+                </LinearGradientBrush>
96
+            </Border.Background>
97
+            <WrapPanel Grid.Row="0"
98
+                       VerticalAlignment="Top"
99
+                       FocusManager.IsFocusScope="True"
100
+                       Orientation="Horizontal"
101
+                       Style="{x:Null}">
102
+                <Button x:Name="ToolStripButtonOpen"
103
+                        Click="ToolStripButtonOpen_Click"
104
+                        Style="{StaticResource ButtonStyle}"
105
+                        ToolTip="打开(Ctrl+O)">
106
+                    <Button.Content>
107
+                        <Image Source="/Platform.Controls;component/Resource/fileopen.png" Style="{StaticResource ImgStyle}" />
108
+                    </Button.Content>
109
+                </Button>
110
+                <Button x:Name="ToolStripButtonCut"
111
+                        Command="ApplicationCommands.Cut"
112
+                        CommandTarget="{Binding ElementName=RichTextControl}"
113
+                        Style="{StaticResource ButtonStyle}"
114
+                        ToolTip="剪切(Ctrl+X)">
115
+                    <Button.Content>
116
+                        <Image Source="/Platform.Controls;component/Resource/Cut.png" Style="{StaticResource ImgStyle}" />
117
+                    </Button.Content>
118
+                </Button>
119
+                <Button x:Name="ToolStripButtonCopy"
120
+                        Command="ApplicationCommands.Copy"
121
+                        CommandTarget="{Binding ElementName=RichTextControl}"
122
+                        Style="{StaticResource ButtonStyle}"
123
+                        ToolTip="复制(Ctrl+C)">
124
+                    <Button.Content>
125
+                        <Image Source="/Platform.Controls;component/Resource/Copy.png" Style="{StaticResource ImgStyle}" />
126
+                    </Button.Content>
127
+                </Button>
128
+                <Button x:Name="ToolStripButtonPaste"
129
+                        Command="ApplicationCommands.Paste"
130
+                        CommandTarget="{Binding ElementName=RichTextControl}"
131
+                        Style="{StaticResource ButtonStyle}"
132
+                        ToolTip="粘贴(Ctrl+V)">
133
+                    <Button.Content>
134
+                        <Image Source="/Platform.Controls;component/Resource/Paste.png" Style="{StaticResource ImgStyle}" />
135
+                    </Button.Content>
136
+
137
+                </Button>
138
+                <Button x:Name="ToolStripButtonUndo"
139
+                        Command="ApplicationCommands.Undo"
140
+                        CommandTarget="{Binding ElementName=RichTextControl}"
141
+                        Style="{StaticResource ButtonStyle}"
142
+                        ToolTip="撤销(Ctrl+Z)">
143
+                    <Button.Content>
144
+                        <Image Source="/Platform.Controls;component/Resource/Undo.png" Style="{StaticResource ImgStyle}" />
145
+                    </Button.Content>
146
+                </Button>
147
+                <Button x:Name="ToolStripButtonRedo"
148
+                        Command="ApplicationCommands.Redo"
149
+                        CommandTarget="{Binding ElementName=RichTextControl}"
150
+                        Style="{StaticResource ButtonStyle}"
151
+                        ToolTip="重做(Ctrl+Y)">
152
+                    <Button.Content>
153
+                        <Image Source="/Platform.Controls;component/Resource/Redo.png" Style="{StaticResource ImgStyle}" />
154
+                    </Button.Content>
155
+                </Button>
156
+                <ComboBox x:Name="Fonttype"
157
+                          DropDownClosed="Fonttype_DropDownClosed"
158
+                          ItemsSource="{Binding Mode=OneWay,
159
+                                                Source={StaticResource FontListKlasse}}"
160
+                          Style="{StaticResource formatComboxboxStyle}" />
161
+                <ComboBox x:Name="Fontheight"
162
+                          DropDownClosed="Fontheight_DropDownClosed"
163
+                          ItemsSource="{Binding Mode=OneWay,
164
+                                                Source={StaticResource FontHeightKlasse}}"
165
+                          Style="{StaticResource formatComboxboxStyle}" />
166
+                <Button x:Name="ToolStripButtonTextcolor"
167
+                        Click="ToolStripButtonTextcolor_Click"
168
+                        CommandTarget="{Binding ElementName=RichTextControl}"
169
+                        Style="{StaticResource ButtonStyle}">
170
+                    <Button.Content>
171
+                        <Image Source="/Platform.Controls;component/Resource/Textcolor.png" Style="{StaticResource ImgStyle}" />
172
+                    </Button.Content>
173
+                </Button>
174
+                <Button x:Name="ToolStripButtonBackcolor"
175
+                        Click="ToolStripButtonBackcolor_Click"
176
+                        CommandTarget="{Binding ElementName=RichTextControl}"
177
+                        Style="{StaticResource ButtonStyle}">
178
+                    <Button.Content>
179
+                        <Image Source="/Platform.Controls;component/Resource/Backcolor.png" Style="{StaticResource ImgStyle}" />
180
+                    </Button.Content>
181
+                </Button>
182
+                <Button x:Name="ToolStripButtonBold"
183
+                        Command="EditingCommands.ToggleBold"
184
+                        CommandTarget="{Binding ElementName=RichTextControl}"
185
+                        Style="{StaticResource ButtonStyle}"
186
+                        ToolTip="加粗(Ctrl+B)">
187
+                    <Button.Content>
188
+                        <TextBlock HorizontalAlignment="Center"
189
+                                   VerticalAlignment="Center"
190
+                                   FontSize="15"
191
+                                   FontWeight="Bold"
192
+                                   Text="B" />
193
+                    </Button.Content>
194
+                </Button>
195
+                <Button x:Name="ToolStripButtonItalic"
196
+                        Command="EditingCommands.ToggleItalic"
197
+                        CommandTarget="{Binding ElementName=RichTextControl}"
198
+                        Style="{StaticResource ButtonStyle}"
199
+                        ToolTip="倾斜(Ctrl+I)">
200
+                    <Button.Content>
201
+                        <TextBlock HorizontalAlignment="Center"
202
+                                   VerticalAlignment="Center"
203
+                                   FontSize="15"
204
+                                   FontStyle="Italic"
205
+                                   FontWeight="Bold"
206
+                                   Text="I" />
207
+                    </Button.Content>
208
+                </Button>
209
+                <Button x:Name="ToolStripButtonUnderline"
210
+                        Command="EditingCommands.ToggleUnderline"
211
+                        CommandTarget="{Binding ElementName=RichTextControl}"
212
+                        Style="{StaticResource ButtonStyle}"
213
+                        ToolTip="下划线(Ctrl+U)">
214
+                    <Button.Content>
215
+                        <TextBlock HorizontalAlignment="Center"
216
+                                   VerticalAlignment="Center"
217
+                                   FontSize="15"
218
+                                   FontWeight="Bold"
219
+                                   Text="U"
220
+                                   TextDecorations="Underline" />
221
+                    </Button.Content>
222
+                </Button>
223
+                <Button x:Name="ToolStripButtonStrikeout"
224
+                        Click="ToolStripButtonStrikeout_Click"
225
+                        CommandTarget="{Binding ElementName=RichTextControl}"
226
+                        Style="{StaticResource ButtonStyle}"
227
+                        ToolTip="删除线">
228
+                    <Button.Content>
229
+                        <TextBlock HorizontalAlignment="Center"
230
+                                   VerticalAlignment="Center"
231
+                                   FontSize="15"
232
+                                   FontWeight="Bold"
233
+                                   Text="S"
234
+                                   TextDecorations="Strikethrough" />
235
+                    </Button.Content>
236
+                </Button>
237
+                <Button x:Name="ToolStripButtonAlignLeft"
238
+                        Command="EditingCommands.AlignLeft"
239
+                        CommandTarget="{Binding ElementName=RichTextControl}"
240
+                        Style="{StaticResource ButtonStyle}"
241
+                        ToolTip="文本左对齐(Ctrl+L)">
242
+                    <Button.Content>
243
+
244
+                        <Image Source="/Platform.Controls;component/Resource/AlignLeft.png" Style="{StaticResource ImgStyle}" />
245
+                    </Button.Content>
246
+
247
+                </Button>
248
+                <Button x:Name="ToolStripButtonAlignCenter"
249
+                        Command="EditingCommands.AlignCenter"
250
+                        CommandTarget="{Binding ElementName=RichTextControl}"
251
+                        Style="{StaticResource ButtonStyle}"
252
+                        ToolTip="居中对齐(Ctrl+E)">
253
+                    <Button.Content>
254
+                        <Image Source="/Platform.Controls;component/Resource/AlignCenter.png" Style="{StaticResource ImgStyle}" />
255
+                    </Button.Content>
256
+                </Button>
257
+                <Button x:Name="ToolStripButtonAlignRight"
258
+                        Command="EditingCommands.AlignRight"
259
+                        CommandTarget="{Binding ElementName=RichTextControl}"
260
+                        Style="{StaticResource ButtonStyle}"
261
+                        ToolTip="右对齐(Ctrl+R)">
262
+                    <Button.Content>
263
+                        <Image Source="/Platform.Controls;component/Resource/AlignRight.png" Style="{StaticResource ImgStyle}" />
264
+                    </Button.Content>
265
+                </Button>
266
+                <Button x:Name="ToolStripButtonAlignFullJustify"
267
+                        Command="EditingCommands.AlignJustify"
268
+                        CommandTarget="{Binding ElementName=RichTextControl}"
269
+                        Style="{StaticResource ButtonStyle}"
270
+                        ToolTip="两端对齐(Ctrl+J)">
271
+                    <Button.Content>
272
+                        <Image Source="/Platform.Controls;component/Resource/AlignFullJustify.png" Style="{StaticResource ImgStyle}" />
273
+                    </Button.Content>
274
+                </Button>
275
+                <Button x:Name="ToolStripButtonIndent"
276
+                        Command="EditingCommands.IncreaseIndentation"
277
+                        CommandTarget="{Binding ElementName=RichTextControl}"
278
+                        Style="{StaticResource ButtonStyle}"
279
+                        ToolTip="增加缩进">
280
+                    <Button.Content>
281
+                        <Image Source="/Platform.Controls;component/Resource/Indent.png" Style="{StaticResource ImgStyle}" />
282
+                    </Button.Content>
283
+                </Button>
284
+                <Button x:Name="ToolStripButtonIndentDelete"
285
+                        Command="EditingCommands.DecreaseIndentation"
286
+                        CommandTarget="{Binding ElementName=RichTextControl}"
287
+                        Style="{StaticResource ButtonStyle}"
288
+                        ToolTip="减少缩进">
289
+                    <Button.Content>
290
+                        <Image Source="/Platform.Controls;component/Resource/IndentRemove.png" Style="{StaticResource ImgStyle}" />
291
+                    </Button.Content>
292
+                </Button>
293
+                <Button x:Name="ToolStripButtonBulletList"
294
+                        Command="EditingCommands.ToggleBullets"
295
+                        CommandTarget="{Binding ElementName=RichTextControl}"
296
+                        Style="{StaticResource ButtonStyle}"
297
+                        ToolTip="符号列表">
298
+                    <Button.Content>
299
+                        <Image Source="/Platform.Controls;component/Resource/listbullets.png" Style="{StaticResource ImgStyle}" />
300
+                    </Button.Content>
301
+                </Button>
302
+                <Button x:Name="ToolStripButtonNumbersList"
303
+                        Command="EditingCommands.ToggleNumbering"
304
+                        CommandTarget="{Binding ElementName=RichTextControl}"
305
+                        Style="{StaticResource ButtonStyle}"
306
+                        ToolTip="编号列表">
307
+                    <Button.Content>
308
+                        <Image Source="/Platform.Controls;component/Resource/listnumbering.png" Style="{StaticResource ImgStyle}" />
309
+                    </Button.Content>
310
+                </Button>
311
+                <Button Command="EditingCommands.IncreaseFontSize"
312
+                        CommandTarget="{Binding ElementName=RichTextControl}"
313
+                        Style="{StaticResource ButtonStyle}"
314
+                        ToolTip="增大字体(Ctrl + &gt;)">
315
+                    <Button.Content>
316
+                        <Image Source="/Platform.Controls;component/Resource/CharacterGrowFont.png" Style="{StaticResource ImgStyle}" />
317
+                    </Button.Content>
318
+                </Button>
319
+                <Button Command="EditingCommands.DecreaseFontSize"
320
+                        CommandTarget="{Binding ElementName=RichTextControl}"
321
+                        Style="{StaticResource ButtonStyle}"
322
+                        ToolTip="减小字体(Ctrl+ &lt;)">
323
+                    <Button.Content>
324
+                        <Image Source="/Platform.Controls;component/Resource/CharacterShrinkFont.png" Style="{StaticResource ImgStyle}" />
325
+                    </Button.Content>
326
+                </Button>
327
+            </WrapPanel>
328
+        </Border>
329
+
330
+        <!--  文本区域  -->
331
+        <RichTextBox x:Name="RichTextControl"
332
+                     Grid.Row="1"
333
+                     MinWidth="400"
334
+                     MinHeight="200"
335
+                     MaxWidth="1000"
336
+                     AcceptsReturn="True"
337
+                     AcceptsTab="True"
338
+                     Focusable="True"
339
+                     FocusManager.IsFocusScope="True"
340
+                     FontFamily="宋体"
341
+                     HorizontalScrollBarVisibility="Auto"
342
+                     KeyDown="RichTextControl_KeyDown"
343
+                     KeyUp="RichTextControl_KeyUp"
344
+                     SpellCheck.IsEnabled="False"
345
+                     TextChanged="RichTextControl_TextChanged"
346
+                     VerticalScrollBarVisibility="Auto" />
347
+    </Grid>
348
+</UserControl>
349
+

+ 341
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ComponentContainer/RtfEditor/RtfEditorBox.xaml.cs View File

@@ -0,0 +1,341 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Windows;
6
+using System.Windows.Controls;
7
+using System.Windows.Data;
8
+using System.Windows.Documents;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Media.Imaging;
12
+using System.Windows.Navigation;
13
+using System.Windows.Shapes;
14
+using System.IO;
15
+using System.ComponentModel;
16
+using System.Drawing;
17
+using Platform.Common.RunningParameters;
18
+using System.Globalization;
19
+
20
+namespace Platform.Controls.ComponentContainer
21
+{
22
+    /// <summary>
23
+    /// RtfEditorBox.xaml 的交互逻辑
24
+    /// </summary>    
25
+    public partial class RtfEditorBox : UserControl
26
+    {
27
+
28
+        /// <summary>
29
+        /// 记录文本格式
30
+        /// </summary>
31
+        private string _txtType = null;
32
+        /// <summary>
33
+        /// 初始化RtfEditorBox
34
+        /// </summary>
35
+        public RtfEditorBox()
36
+        {
37
+            InitializeComponent();
38
+        }
39
+        /// <summary>
40
+        /// 文本编辑框Loaded事件
41
+        /// </summary>
42
+        /// <param name="sender"></param>
43
+        /// <param name="e"></param>
44
+        private void RtfEditor_Loaded(object sender, RoutedEventArgs e)
45
+        {
46
+            RichTextControl.Width = this.Width;
47
+            RichTextControl.Document.PageWidth = RichTextControl.MaxWidth;
48
+            //文本选中区域
49
+            TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End);            
50
+            //默认字体
51
+            Fonttype.SelectedValue = range.GetPropertyValue(FlowDocument.FontFamilyProperty).ToString();
52
+            //默认字体大小
53
+            Fontheight.SelectedValue = range.GetPropertyValue(FlowDocument.FontSizeProperty).ToString();
54
+            RichTextControl.Focus();
55
+
56
+        }
57
+
58
+        public string text
59
+        {
60
+            get
61
+            {
62
+                TextRange range = new TextRange(RichTextControl.Document.ContentStart, RichTextControl.Document.ContentEnd);
63
+                return range.Text;
64
+            }
65
+            set
66
+            {
67
+                _txtType = value;
68
+            }
69
+        }
70
+        /// <summary>
71
+        /// 打开对话框,加载文本文件
72
+        /// </summary>
73
+        /// <param name="sender"></param>
74
+        /// <param name="e"></param>
75
+        private void ToolStripButtonOpen_Click(object sender, System.Windows.RoutedEventArgs e)
76
+        {
77
+            // 初始化对话框
78
+            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
79
+            dlg.FileName = ""; // 默认文件的名称
80
+            dlg.DefaultExt = ".rtf"; //默认文件的扩展名
81
+            dlg.Filter = "RichText documents (.rtf)|*.rtf|Text documents (.txt)|*.txt"; // 过滤文件的后缀名
82
+            // 显示文本对话框
83
+            dlg.ValidateNames = true;
84
+            dlg.CheckFileExists = true;
85
+            dlg.CheckPathExists = true;
86
+
87
+            Nullable<bool> result = dlg.ShowDialog();
88
+
89
+            // 打开文件返回的值
90
+            if (result == true)
91
+            {
92
+                string path = dlg.FileName;
93
+                TextRange range;
94
+                FileStream fStream;
95
+                var filter = path.Substring(path.LastIndexOf('.') + 1, 3);
96
+                if (filter == "txt" || filter == "rtf")
97
+                {
98
+                    if (File.Exists(path))
99
+                    {
100
+                        range = new TextRange(RichTextControl.Document.ContentStart, RichTextControl.Document.ContentEnd);
101
+
102
+                        if (filter == "rtf")
103
+                        {
104
+                            fStream = new FileStream(path, FileMode.OpenOrCreate);
105
+                            range.Load(fStream, DataFormats.Rtf);
106
+                            fStream.Close();
107
+                        }
108
+                        if (filter == "txt")
109
+                        {
110
+                            using (StreamReader read = new StreamReader(path, PlatformSettings.Encoding))
111
+                            {
112
+                                RichTextControl.AppendText(read.ReadToEnd());
113
+                            }
114
+                        }
115
+
116
+                    }
117
+                }
118
+                else
119
+                {
120
+
121
+                    MessageBox.Show("不支持" + filter + "格式,请重新选择支持的格式", "提示框");
122
+                    return;
123
+                }
124
+
125
+            }
126
+            RichTextControl.Focus();
127
+        }
128
+        /// <summary>
129
+        /// 删除线
130
+        /// </summary>
131
+        /// <param name="sender"></param>
132
+        /// <param name="e"></param>
133
+        private void ToolStripButtonStrikeout_Click(object sender, System.Windows.RoutedEventArgs e)
134
+        {
135
+            TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End);
136
+
137
+            TextDecorationCollection tdc = (TextDecorationCollection)RichTextControl.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
138
+
139
+            if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
140
+            {
141
+                tdc = TextDecorations.Strikethrough;
142
+
143
+            }
144
+            else
145
+            {
146
+                tdc = new TextDecorationCollection();
147
+            }
148
+            range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc);
149
+
150
+        }
151
+
152
+        /// <summary>
153
+        /// 文本前景色事件
154
+        /// </summary>
155
+        /// <param name="sender"></param>
156
+        /// <param name="e"></param>
157
+        private void ToolStripButtonTextcolor_Click(object sender, RoutedEventArgs e)
158
+        {
159
+            ColorDialog colorDialog = new ColorDialog();
160
+            if ((bool)colorDialog.ShowDialog())
161
+            {
162
+                TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End);
163
+
164
+                range.ApplyPropertyValue(FlowDocument.ForegroundProperty, new SolidColorBrush(colorDialog.SelectedColor));
165
+            }
166
+            RichTextControl.Focus();
167
+        }
168
+
169
+        /// <summary>
170
+        /// 文本背景色事件
171
+        /// </summary>
172
+        /// <param name="sender"></param>
173
+        /// <param name="e"></param>
174
+        private void ToolStripButtonBackcolor_Click(object sender, RoutedEventArgs e)
175
+        {
176
+            ColorDialog colorDialog = new ColorDialog();
177
+            if ((bool)colorDialog.ShowDialog())
178
+            {
179
+                TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End);
180
+
181
+                range.ApplyPropertyValue(FlowDocument.BackgroundProperty, new SolidColorBrush(colorDialog.SelectedColor));
182
+            }
183
+            RichTextControl.Focus();
184
+        }
185
+
186
+        /// <summary>
187
+        /// 字体大小更改事件
188
+        /// </summary>
189
+        /// <param name="sender"></param>
190
+        /// <param name="e"></param>
191
+        private void Fontheight_DropDownClosed(object sender, EventArgs e)
192
+        {
193
+            string fontHeight = (string)Fontheight.SelectedItem;
194
+
195
+            if (fontHeight != null)
196
+            {
197
+                RichTextControl.Selection.ApplyPropertyValue(System.Windows.Controls.RichTextBox.FontSizeProperty, fontHeight);
198
+            }
199
+            RichTextControl.Focus();
200
+        }
201
+
202
+        /// <summary>
203
+        /// 字体格式更改事件
204
+        /// </summary>
205
+        /// <param name="sender"></param>
206
+        /// <param name="e"></param>
207
+        private void Fonttype_DropDownClosed(object sender, EventArgs e)
208
+        {
209
+            string fontName = (string)Fonttype.SelectedItem;
210
+
211
+            if (fontName != null)
212
+            {
213
+                RichTextControl.Selection.ApplyPropertyValue(System.Windows.Controls.RichTextBox.FontFamilyProperty, fontName);
214
+            }
215
+            RichTextControl.Focus();
216
+        }
217
+        private void RichTextControl_TextChanged(object sender, TextChangedEventArgs e)
218
+        {
219
+            RichTextControl.Focus();
220
+        }
221
+        private void AdjustWidth()
222
+        {
223
+            Rect rectStart = RichTextControl.Document.ContentStart.GetCharacterRect(LogicalDirection.Forward);
224
+            Rect rectEnd = RichTextControl.Document.ContentEnd.GetCharacterRect(LogicalDirection.Forward);
225
+            var width = rectEnd.Right - rectStart.Left;
226
+            var mywidth = Math.Min(RichTextControl.MaxWidth, width);
227
+            if (mywidth > this.Width)
228
+            {
229
+                RichTextControl.Document.PageWidth = mywidth;
230
+            }
231
+        }
232
+
233
+      
234
+
235
+      
236
+     
237
+
238
+
239
+        /// <summary>
240
+        /// RichTextControl_KeyDown事件
241
+        /// </summary>
242
+        /// <param name="sender"></param>
243
+        /// <param name="e"></param>
244
+        private void RichTextControl_KeyDown(object sender, KeyEventArgs e)
245
+        {
246
+            string fontName = (string)Fonttype.SelectedValue;
247
+            string fontHeight = (string)Fontheight.SelectedValue;
248
+            TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End);
249
+
250
+            if (!string.IsNullOrEmpty(fontName))
251
+            {
252
+                range.ApplyPropertyValue(TextElement.FontFamilyProperty, fontName);
253
+            }
254
+            if (!string.IsNullOrEmpty(fontHeight))
255
+            {
256
+                range.ApplyPropertyValue(TextElement.FontSizeProperty, fontHeight);
257
+            }
258
+
259
+        }
260
+
261
+        /// <summary>
262
+        ///  打开对话框快捷键
263
+        /// </summary>
264
+        /// <param name="sender"></param>
265
+        /// <param name="e"></param>
266
+        private void RichTextControl_KeyUp(object sender, KeyEventArgs e)
267
+        {
268
+            // Ctrl + O
269
+            if ((Keyboard.Modifiers == ModifierKeys.Control) && (e.Key == Key.O))
270
+            {
271
+                ToolStripButtonOpen_Click(sender, e);
272
+            }
273
+        }
274
+
275
+        /// <summary>
276
+        /// 清空文本框
277
+        /// </summary>
278
+        public void Clear()
279
+        {
280
+            RichTextControl.Document.Blocks.Clear();
281
+        }
282
+
283
+        /// <summary>
284
+        /// 设置Rtf文本文件
285
+        /// </summary>
286
+        /// <param name="rtf"></param>
287
+        public void SetRTF(string rtf)
288
+        {
289
+            TextRange range = new TextRange(RichTextControl.Document.ContentStart, RichTextControl.Document.ContentEnd);
290
+            try
291
+            {
292
+                using (MemoryStream rtfMemoryStream = new MemoryStream())
293
+                {
294
+                    using (StreamWriter rtfStreamWriter = new StreamWriter(rtfMemoryStream))
295
+                    {
296
+
297
+                        rtfStreamWriter.Write(rtf);
298
+                        rtfStreamWriter.Flush();
299
+                        rtfMemoryStream.Seek(0, SeekOrigin.Begin);
300
+                        range.Load(rtfMemoryStream, DataFormats.Rtf);
301
+                    }
302
+                }
303
+            }
304
+            catch (Exception)
305
+            {
306
+                throw;
307
+            }
308
+        }
309
+        /// <summary>
310
+        /// 得到trf文本文件
311
+        /// </summary>
312
+        /// <returns></returns>
313
+        public string GetRTF()
314
+        {
315
+            TextRange range = new TextRange(RichTextControl.Document.ContentStart, RichTextControl.Document.ContentEnd);
316
+            try
317
+            {
318
+                using (MemoryStream rtfMemoryStream = new MemoryStream())
319
+                {
320
+                    using (StreamWriter rtfStreamWriter = new StreamWriter(rtfMemoryStream))
321
+                    {
322
+                        range.Save(rtfMemoryStream, DataFormats.Rtf);
323
+
324
+                        rtfMemoryStream.Flush();
325
+                        rtfMemoryStream.Position = 0;
326
+                        StreamReader sr = new StreamReader(rtfMemoryStream);
327
+                        return sr.ReadToEnd();
328
+                    }
329
+                }
330
+            }
331
+            catch (Exception)
332
+            {
333
+                throw;
334
+            }
335
+        }
336
+        public void HideToorBar()
337
+        {
338
+            toolBarPanel.Visibility = Visibility.Collapsed;
339
+        }
340
+    }
341
+}

+ 38
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/BufferTimer.ts View File

@@ -0,0 +1,38 @@
1
+// 定义 BufferTimer 类
2
+export class BufferTimer {
3
+    // 静态属性,用于单例模式
4
+    private static _instance: BufferTimer;
5
+    // 缓冲区,使用数组模拟队列
6
+    private _buffer: any[] = [];
7
+    // 缓冲持续时间,单位为毫秒
8
+    private _timeSpan: number;
9
+
10
+    // 构造函数,接收缓冲持续时间作为参数
11
+    constructor(timeSpan: number) {
12
+        this._timeSpan = timeSpan;
13
+    }
14
+
15
+    // 静态方法,获取单例实例
16
+    public static get Instance(): BufferTimer {
17
+        if (!this._instance) {
18
+            this._instance = new BufferTimer(1000); // 1000 毫秒即 1 秒
19
+        }
20
+        return this._instance;
21
+    }
22
+
23
+    // 添加数据到缓冲区
24
+    public Add(o: any): void {
25
+        if (this._buffer.length === 0) {
26
+            // 开始计时
27
+            setTimeout(() => {
28
+                this._buffer = [];
29
+            }, this._timeSpan);
30
+        }
31
+        this._buffer.push(o);
32
+    }
33
+
34
+    // 获取缓冲区数据
35
+    public GetBuffer(): any[] {
36
+        return [...this._buffer];
37
+    }
38
+}

+ 59
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ButtonHelper.ts View File

@@ -0,0 +1,59 @@
1
+// 假设 FocusHandledResult 枚举定义如下
2
+enum FocusHandledResult {
3
+    System,
4
+    Self,
5
+    Forward
6
+}
7
+
8
+// 假设 Button 类型定义如下
9
+class Button {
10
+    // 这里简单模拟按钮的点击事件触发方法
11
+    click() {
12
+        console.log('Button clicked');
13
+    }
14
+}
15
+
16
+// 假设 FocusManager 类定义如下
17
+class FocusManager {
18
+    static SetFocusHandled(btn: Button, handler: (sender: Button, e: any) => FocusHandledResult) {
19
+        // 这里简单模拟设置焦点处理方法
20
+        console.log('Focus handled method set');
21
+    }
22
+}
23
+
24
+class ButtonHelper {
25
+    static ButtonFocusHandled = (sender: Button, e: any): FocusHandledResult => {
26
+        if (!sender) return FocusHandledResult.System;
27
+
28
+        if (e.key === 'Enter' || e.key === ' ') {
29
+            return FocusHandledResult.Self;
30
+        }
31
+
32
+        return FocusHandledResult.System;
33
+    };
34
+
35
+    static ButtonAutoMoveFocusHandled = (sender: Button, e: any): FocusHandledResult => {
36
+        if (!sender) return FocusHandledResult.System;
37
+
38
+        if (e.key === 'Enter') {
39
+            sender.click();
40
+            return FocusHandledResult.Forward;
41
+        }
42
+
43
+        return FocusHandledResult.System;
44
+    };
45
+
46
+    static setIsAutoMoveFocus(btn: Button, value: boolean) {
47
+        if (!btn) {
48
+            throw new Error('只能给Button控件设置此属性');
49
+        }
50
+
51
+        if (value) {
52
+            FocusManager.SetFocusHandled(btn, ButtonHelper.ButtonAutoMoveFocusHandled);
53
+        } else {
54
+            FocusManager.SetFocusHandled(btn, ButtonHelper.ButtonFocusHandled);
55
+        }
56
+    }
57
+}
58
+
59
+export { ButtonHelper, FocusHandledResult };

+ 325
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ComboBoxHelper.ts View File

@@ -0,0 +1,325 @@
1
+import { ref, watchEffect, onBeforeUnmount } from 'vue';
2
+
3
+// 模拟 FocusHandledResult 枚举
4
+enum FocusHandledResult {
5
+  System,
6
+  Self
7
+}
8
+
9
+// 模拟 Platform.Hotkeys.HotKeyHelper
10
+class HotKeyHelper {
11
+  static GetKeyName(key: KeyboardEvent['key']): string {
12
+    // 简单实现,实际需要根据具体逻辑修改
13
+    return key;
14
+  }
15
+}
16
+
17
+// 模拟 BufferTimer
18
+class BufferTimer {
19
+  private buffer: KeyboardEvent['key'][] = [];
20
+  private static instance: BufferTimer;
21
+
22
+  private constructor() {}
23
+
24
+  static get Instance() {
25
+    if (!this.instance) {
26
+      this.instance = new BufferTimer();
27
+    }
28
+    return this.instance;
29
+  }
30
+
31
+  Add(key: KeyboardEvent['key']) {
32
+    this.buffer.push(key);
33
+  }
34
+
35
+  GetBuffer() {
36
+    return this.buffer;
37
+  }
38
+}
39
+
40
+// ComboBoxHelper 类
41
+export class ComboBoxHelper {
42
+  static readonly PartEditableTextBox = 'PART_EditableTextBox';
43
+
44
+  private interval: ReturnType<typeof setTimeout> | null = null;
45
+  private editTextBox: HTMLInputElement | null = null;
46
+  private isKeyEvent = ref(false);
47
+  private coll: any[] = [];
48
+  private oldSelStart = 0;
49
+  private oldSelLength = 0;
50
+  private oldText = '';
51
+
52
+  // 自动完成功能相关
53
+  static GetIsAutoComplete(obj: any): boolean {
54
+    return obj.IsAutoComplete;
55
+  }
56
+
57
+  static SetIsAutoComplete(obj: any, value: boolean) {
58
+    obj.IsAutoComplete = value;
59
+    if (value) {
60
+      obj.style = 'AutoCompleteComboBox';
61
+    } else {
62
+      obj.style = 'default';
63
+    }
64
+  }
65
+
66
+  RefreshSource(cbx: HTMLSelectElement, items: any[]) {
67
+    this.coll = items;
68
+
69
+    if (this.interval) {
70
+      clearTimeout(this.interval);
71
+    }
72
+
73
+    this.interval = setTimeout(() => {
74
+      this.isKeyEvent.value = false;
75
+      cbx.open = true;
76
+      // 刷新数据源视图,这里简单模拟
77
+      this.filterItems(cbx);
78
+    }, 600);
79
+
80
+    if (this.editTextBox) {
81
+      this.editTextBox.addEventListener('input', this.handleTextChanged);
82
+    }
83
+  }
84
+
85
+  RegisteAutoComplete(cbx: HTMLSelectElement, items: any[]) {
86
+    this.editTextBox = cbx.querySelector<HTMLInputElement>(`[name="${ComboBoxHelper.PartEditableTextBox}"]`);
87
+    if (!this.editTextBox) {
88
+      return false;
89
+    }
90
+
91
+    if (this.interval) {
92
+      clearTimeout(this.interval);
93
+    }
94
+
95
+    this.interval = setTimeout(() => {
96
+      this.isKeyEvent.value = false;
97
+      cbx.open = true;
98
+      // 刷新数据源视图,这里简单模拟
99
+      this.filterItems(cbx);
100
+    }, 600);
101
+
102
+    this.editTextBox.addEventListener('input', this.handleTextChanged);
103
+    this.editTextBox.addEventListener('keydown', this.handlePreviewKeyDown);
104
+
105
+    cbx.addEventListener('mousedown', this.handleGotMouseCapture);
106
+    cbx.addEventListener('open', this.handleDropDownOpened);
107
+    cbx.addEventListener('focus', this.handleGotFocus);
108
+    cbx.addEventListener('change', this.handleSelectionChanged);
109
+    cbx.addEventListener('blur', this.handleLostFocus);
110
+
111
+    this.coll = items;
112
+    this.filterItems(cbx);
113
+
114
+    return true;
115
+  }
116
+
117
+  private handleTextChanged = () => {
118
+    if (!this.editTextBox) {
119
+      return;
120
+    }
121
+
122
+    if (this.editTextBox.value === '') {
123
+      // 刷新数据源视图,这里简单模拟
124
+      this.filterItems(this.editTextBox.closest('select') as HTMLSelectElement);
125
+    } else if (this.isKeyEvent.value) {
126
+      const cbx = this.editTextBox.closest('select') as HTMLSelectElement;
127
+      cbx.selectedIndex = -1;
128
+      if (this.interval) {
129
+        clearTimeout(this.interval);
130
+      }
131
+      this.interval = setTimeout(() => {
132
+        this.isKeyEvent.value = false;
133
+        cbx.open = true;
134
+        // 刷新数据源视图,这里简单模拟
135
+        this.filterItems(cbx);
136
+      }, 600);
137
+    }
138
+  };
139
+
140
+  private handlePreviewKeyDown = (e: KeyboardEvent) => {
141
+    const pressKey = HotKeyHelper.GetKeyName(e.key);
142
+    if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown' && pressKey !== 'UNFOLD') {
143
+      this.isKeyEvent.value = true;
144
+    }
145
+  };
146
+
147
+  private handleGotMouseCapture = () => {
148
+    if (this.editTextBox) {
149
+      this.oldSelStart = this.editTextBox.selectionStart || 0;
150
+      this.oldSelLength = this.editTextBox.selectionLength || 0;
151
+      this.oldText = this.editTextBox.value;
152
+    }
153
+  };
154
+
155
+  private handleDropDownOpened = () => {
156
+    if (this.editTextBox) {
157
+      this.editTextBox.value = this.oldText;
158
+      this.editTextBox.selectionStart = this.oldSelStart;
159
+      this.editTextBox.selectionLength = this.oldSelLength;
160
+    }
161
+  };
162
+
163
+  private handleGotFocus = () => {
164
+    if (this.editTextBox) {
165
+      this.editTextBox.focus();
166
+    }
167
+  };
168
+
169
+  private handleSelectionChanged = () => {
170
+    if (this.interval) {
171
+      clearTimeout(this.interval);
172
+    }
173
+  };
174
+
175
+  private handleLostFocus = () => {
176
+    this.isKeyEvent.value = false;
177
+    const cbx = this.editTextBox?.closest('select') as HTMLSelectElement;
178
+    cbx.open = false;
179
+
180
+    if (cbx.selectedIndex === -1) {
181
+      if (this.editTextBox) {
182
+        this.editTextBox.value = '';
183
+      }
184
+    } else {
185
+      if (this.editTextBox) {
186
+        const selectedItem = cbx.options[cbx.selectedIndex];
187
+        this.editTextBox.value = selectedItem.textContent || '';
188
+      }
189
+    }
190
+
191
+    if (this.interval) {
192
+      clearTimeout(this.interval);
193
+    }
194
+
195
+    try {
196
+      if (this.editTextBox) {
197
+        this.editTextBox.selectionStart = 0;
198
+      }
199
+    } catch (error) {
200
+      // 忽略异常
201
+    }
202
+  };
203
+
204
+  private filterItems(cbx: HTMLSelectElement) {
205
+    if (!this.editTextBox) {
206
+      return;
207
+    }
208
+
209
+    const filterText = this.editTextBox.value.toUpperCase();
210
+    for (let i = 0; i < cbx.options.length; i++) {
211
+      const option = cbx.options[i];
212
+      if (filterText === '' || option.textContent?.toUpperCase().includes(filterText)) {
213
+        option.style.display = 'block';
214
+      } else {
215
+        option.style.display = 'none';
216
+      }
217
+    }
218
+  }
219
+
220
+  // 焦点处理方法
221
+  static ComboBoxFocusHandled = (sender: HTMLSelectElement, e: KeyboardEvent): FocusHandledResult => {
222
+    if (!sender) {
223
+      return FocusHandledResult.System;
224
+    }
225
+
226
+    if (sender.open && (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Enter')) {
227
+      if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
228
+        return FocusHandledResult.Self;
229
+      } else {
230
+        // 执行焦点移动操作,这里简单模拟
231
+        console.log('Move focus');
232
+        return FocusHandledResult.Self;
233
+      }
234
+    }
235
+
236
+    const pressKey = HotKeyHelper.GetKeyName(e.key);
237
+    if (e.key === '+' || e.key === 'F2') {
238
+      pressKey = 'UNFOLD';
239
+    }
240
+
241
+    if (pressKey === 'UNFOLD') {
242
+      sender.open = !sender.open;
243
+      return FocusHandledResult.Self;
244
+    }
245
+
246
+    if (sender.options.length > 0) {
247
+      BufferTimer.Instance.Add(e.key);
248
+      const keys = BufferTimer.Instance.GetBuffer().map((key) => {
249
+        const keyCode = key.charCodeAt(0);
250
+        let result = ' ';
251
+        if (keyCode > 47 && keyCode < 58) {
252
+          result = (keyCode - 48).toString();
253
+        } else if (keyCode > 95 && keyCode < 106) {
254
+          result = (keyCode - 96).toString();
255
+        }
256
+        return result;
257
+      });
258
+
259
+      if (keys.length === (sender.options.length - 1).toString().length) {
260
+        const indexBuffer = keys.join('');
261
+        const index = parseInt(indexBuffer, 10);
262
+        if (!isNaN(index) && index >= 0 && index < sender.options.length) {
263
+          sender.selectedIndex = index;
264
+        }
265
+      }
266
+    }
267
+
268
+    return FocusHandledResult.System;
269
+  };
270
+
271
+  static ComboBoxNormalFocusHandled = (sender: HTMLSelectElement, e: KeyboardEvent): FocusHandledResult => {
272
+    if (!sender) {
273
+      return FocusHandledResult.System;
274
+    }
275
+
276
+    if (sender.open && (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Enter')) {
277
+      return FocusHandledResult.Self;
278
+    }
279
+
280
+    const pressKey = HotKeyHelper.GetKeyName(e.key);
281
+    if (pressKey === 'UNFOLD') {
282
+      sender.open = !sender.open;
283
+      return FocusHandledResult.Self;
284
+    }
285
+
286
+    return FocusHandledResult.System;
287
+  };
288
+
289
+  // 鼠标事件处理
290
+  static ComboBoxHandled = (sender: HTMLSelectElement, e: MouseEvent): FocusHandledResult => {
291
+    if (!sender) {
292
+      return FocusHandledResult.System;
293
+    }
294
+
295
+    const originalSourceElement = e.target as HTMLElement;
296
+    const clickedElement = originalSourceElement.closest('option');
297
+
298
+    if (sender.open && e.button === 0 && clickedElement) {
299
+      // 执行焦点移动操作,这里简单模拟
300
+      console.log('Move focus');
301
+      return FocusHandledResult.Self;
302
+    }
303
+
304
+    return FocusHandledResult.System;
305
+  };
306
+
307
+  // 延迟事件处理
308
+  static DoWork(action: () => void, millisecond = 100) {
309
+    setTimeout(action, millisecond);
310
+  }
311
+
312
+  static DoMouseWork(action: () => void, millisecond = 250) {
313
+    setTimeout(action, millisecond);
314
+  }
315
+
316
+  static MoveFocusHandled() {
317
+    // 焦点移动,这里简单模拟
318
+    console.log('Move focus');
319
+  }
320
+
321
+  static MouseMoveFocusHandled() {
322
+    // 焦点移动,这里简单模拟
323
+    console.log('Move focus');
324
+  }
325
+}

+ 134
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ControlHelper.ts View File

@@ -0,0 +1,134 @@
1
+// 假设这些类型和接口的定义
2
+interface IPage {
3
+    // 这里可以定义 IPage 接口的具体属性和方法
4
+}
5
+
6
+interface TipAdornerPlacement {
7
+    // 这里可以定义 TipAdornerPlacement 接口的具体属性和方法
8
+}
9
+
10
+interface TipAdorner {
11
+    Placement: TipAdornerPlacement;
12
+    Message: string;
13
+    // 这里可以定义 TipAdorner 接口的其他方法
14
+}
15
+
16
+interface FocusManager {
17
+    GetManagerInstance(target: any): FocusManager | null;
18
+    CurrentFocusedElement: any;
19
+    SetFocus(element: any): void;
20
+    IsFocusContinue: boolean;
21
+}
22
+
23
+enum FocusHandledResult {
24
+    System
25
+}
26
+
27
+class ControlHelper {
28
+    static ShowTip(target: any, placement: TipAdornerPlacement, message: string): boolean {
29
+        if (target instanceof IPage) {
30
+            const fm = FocusManager.GetManagerInstance(target);
31
+            if (!fm || !fm.CurrentFocusedElement) {
32
+                return false;
33
+            }
34
+            target = fm.CurrentFocusedElement;
35
+        }
36
+        // 这里假设可以通过某种方式获取 AdornerLayer
37
+        const layer = this.getAdornerLayer(target);
38
+        if (layer) {
39
+            this.RemoveTipAdorner(target, layer);
40
+            const tip: TipAdorner = {
41
+                Placement: placement,
42
+                Message: message ? message.trim() : "输入错误"
43
+            };
44
+            if (target instanceof HTMLInputElement) {
45
+                target.select();
46
+            }
47
+            // 这里假设可以添加装饰器
48
+            this.addTipToLayer(tip, layer);
49
+            target.addEventListener('blur', () => this.OnLostFocus(target));
50
+        }
51
+        return false;
52
+    }
53
+
54
+    static ShowTipSimple(target: any, message: string): boolean {
55
+        // 假设存在一个默认的底部位置
56
+        const defaultPlacement = {} as TipAdornerPlacement;
57
+        return this.ShowTip(target, defaultPlacement, message);
58
+    }
59
+
60
+    static RemoveTipAdorner(target: any, layer: any): void {
61
+        if (!layer) {
62
+            return;
63
+        }
64
+        const adorners = this.getAdorners(target, layer);
65
+        if (!adorners) {
66
+            return;
67
+        }
68
+        adorners.forEach((ad: any) => {
69
+            if (this.isTipAdorner(ad)) {
70
+                this.removeAdornerFromLayer(ad, layer);
71
+            }
72
+        });
73
+    }
74
+
75
+    static OnLostFocus(target: any): void {
76
+        target.removeEventListener('blur', () => this.OnLostFocus(target));
77
+        const layer = this.getAdornerLayer(target);
78
+        this.RemoveTipAdorner(target, layer);
79
+    }
80
+
81
+    static RemoveTip(target: any): void {
82
+        if (!target) {
83
+            return;
84
+        }
85
+        const layer = this.getAdornerLayer(target);
86
+        if (layer) {
87
+            this.RemoveTipAdorner(target, layer);
88
+        }
89
+    }
90
+
91
+    static SetFocus(target: IPage, element?: any): void {
92
+        const focusManager = FocusManager.GetManagerInstance(target);
93
+        if (!focusManager) {
94
+            return;
95
+        }
96
+        if (element) {
97
+            focusManager.SetFocus(element);
98
+        }
99
+        focusManager.IsFocusContinue = false;
100
+    }
101
+
102
+    static get EmptyMouseHandled(): (sender: any, e: any) => void {
103
+        return (sender, e) => { };
104
+    }
105
+
106
+    static get EmptyFocusHandled(): (sender: any, e: any) => FocusHandledResult {
107
+        return (sender, e) => {
108
+            return FocusHandledResult.System;
109
+        };
110
+    }
111
+
112
+    // 以下是模拟的辅助方法,需要根据实际情况实现
113
+    private static getAdornerLayer(target: any): any {
114
+        return null;
115
+    }
116
+
117
+    private static getAdorners(target: any, layer: any): any[] {
118
+        return [];
119
+    }
120
+
121
+    private static isTipAdorner(ad: any): boolean {
122
+        return false;
123
+    }
124
+
125
+    private static addTipToLayer(tip: TipAdorner, layer: any): void {
126
+        // 实现添加装饰器的逻辑
127
+    }
128
+
129
+    private static removeAdornerFromLayer(ad: any, layer: any): void {
130
+        // 实现移除装饰器的逻辑
131
+    }
132
+}
133
+
134
+export default ControlHelper;

+ 16
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/CurrencyEditorHelper.ts View File

@@ -0,0 +1,16 @@
1
+// 假设 FocusHandledResult 是一个枚举类型
2
+export enum FocusHandledResult {
3
+    Self,
4
+    System
5
+}
6
+
7
+// 定义 CurrencyEditorHelper 模块
8
+export class CurrencyEditorHelper {
9
+    // 静态方法,实现焦点处理逻辑
10
+    public static CurrencyEditorFocusHandled(sender: any, e: { key: string }): FocusHandledResult {
11
+        if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
12
+            return FocusHandledResult.Self;
13
+        }
14
+        return FocusHandledResult.System;
15
+    }
16
+}

+ 23
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/CurrencyRateEditorHelper.ts View File

@@ -0,0 +1,23 @@
1
+// 定义 FocusHandledResult 枚举
2
+enum FocusHandledResult {
3
+    Self = 'Self',
4
+    System = 'System'
5
+}
6
+
7
+// 定义 KeyEventArgs 接口,模拟 C# 中的 KeyEventArgs 类
8
+interface KeyEventArgs {
9
+    key: string;
10
+}
11
+
12
+// 定义 CurrencyRateEditorHelper 类
13
+class CurrencyRateEditorHelper {
14
+    // 定义静态属性 CurrencyRateEditorFocusHandled
15
+    static CurrencyRateEditorFocusHandled: (sender: any, e: KeyEventArgs) => FocusHandledResult = (sender, e) => {
16
+        if (e.key === 'Left' || e.key === 'Right') {
17
+            return FocusHandledResult.Self;
18
+        }
19
+        return FocusHandledResult.System;
20
+    };
21
+}
22
+
23
+export { CurrencyRateEditorHelper, FocusHandledResult };

+ 52
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/DataGridHelper.ts View File

@@ -0,0 +1,52 @@
1
+// 定义 DataGridRow 类型
2
+type DataGridRow = any;
3
+
4
+// 定义 DataGrid 类型
5
+type DataGrid = {
6
+    items: any[];
7
+    selectedIndex: number;
8
+    selectedItem: any;
9
+    updateLayout: () => void;
10
+    scrollIntoView: (item: any) => void;
11
+    itemContainerGenerator: {
12
+        containerFromIndex: (index: number) => DataGridRow;
13
+    };
14
+};
15
+
16
+// 定义 IsChecked 附加属性相关
17
+class DataGridHelper {
18
+    static getIsChecked(obj: any): boolean | null {
19
+        return obj['IsChecked'] as boolean | null;
20
+    }
21
+
22
+    static setIsChecked(obj: any, value: boolean | null): void {
23
+        obj['IsChecked'] = value;
24
+    }
25
+
26
+    // 获取指定行
27
+    static getRow(datagrid: DataGrid, rowIndex: number): DataGridRow | null {
28
+        if (!datagrid || datagrid.items.length < 1) return null;
29
+        let row = datagrid.itemContainerGenerator.containerFromIndex(rowIndex);
30
+        if (!row) {
31
+            datagrid.updateLayout();
32
+            datagrid.scrollIntoView(datagrid.items[rowIndex]);
33
+            row = datagrid.itemContainerGenerator.containerFromIndex(rowIndex);
34
+        }
35
+        return row;
36
+    }
37
+
38
+    // 获取选择的行
39
+    static getSelectedRow(datagrid: DataGrid): DataGridRow | null {
40
+        if (!datagrid.selectedItem) return null;
41
+        return this.getRow(datagrid, datagrid.selectedIndex);
42
+    }
43
+
44
+    // 获取 DataGrid 的所有行
45
+    static* rows(datagrid: DataGrid): Generator<DataGridRow | null> {
46
+        for (let i = 0; i < datagrid.items.length; i++) {
47
+            yield this.getRow(datagrid, i);
48
+        }
49
+    }
50
+}
51
+
52
+export default DataGridHelper;

+ 31
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/DataViewFilter.ts View File

@@ -0,0 +1,31 @@
1
+// 定义数据行类型
2
+type DataRow = { [key: string]: any };
3
+
4
+// 筛选函数
5
+function Filter(data: DataRow[], text: string, columns?: string[]): DataRow[] {
6
+    const dec = parseFloat(text);
7
+    const isDec = !isNaN(dec);
8
+    const time = new Date(text);
9
+    const isTime = !isNaN(time.getTime());
10
+
11
+    return data.filter((row) => {
12
+        return Object.entries(row).some(([columnName, value]) => {
13
+            if (columns && !columns.includes(columnName)) {
14
+                return false;
15
+            }
16
+
17
+            if (typeof value === 'string') {
18
+                return value.includes(text);
19
+            } else if (value instanceof Date && isTime) {
20
+                const nextDay = new Date(time);
21
+                nextDay.setDate(nextDay.getDate() + 1);
22
+                return value > time && value < nextDay;
23
+            } else if (isDec && (typeof value === 'number')) {
24
+                return value === dec;
25
+            }
26
+            return false;
27
+        });
28
+    });
29
+}
30
+
31
+export { Filter };

+ 94
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/GridHelper.ts View File

@@ -0,0 +1,94 @@
1
+import { ref, computed, onMounted, nextTick } from 'vue';
2
+
3
+// 定义 GridHelper 类
4
+class GridHelper {
5
+    // 静态方法,用于获取和设置附加属性
6
+    static getShowBorder(el: HTMLElement): boolean {
7
+        return el.dataset.showBorder === 'true';
8
+    }
9
+
10
+    static setShowBorder(el: HTMLElement, value: boolean) {
11
+        el.dataset.showBorder = value.toString();
12
+    }
13
+
14
+    static getGridLineThickness(el: HTMLElement): number {
15
+        return parseFloat(el.dataset.gridLineThickness || '1');
16
+    }
17
+
18
+    static setGridLineThickness(el: HTMLElement, value: number) {
19
+        el.dataset.gridLineThickness = value.toString();
20
+    }
21
+
22
+    static getGridLineBrush(el: HTMLElement): string {
23
+        return el.dataset.gridLineBrush || 'lightgray';
24
+    }
25
+
26
+    static setGridLineBrush(el: HTMLElement, value: string) {
27
+        el.dataset.gridLineBrush = value;
28
+    }
29
+
30
+    // 模拟 GridLoaded 方法 TODO 这里Grid.rows 报错 需要重构
31
+    static gridLoaded(grid: HTMLElement) {
32
+        const children = Array.from(grid.children) as HTMLElement[];
33
+        const rowCount = 1;//grid.rows ? grid.rows.length : 1;
34
+        const columnCount = 1;//grid.columns ? grid.columns.length : 1;
35
+
36
+        children.forEach((item, index) => {
37
+            const row = parseInt(item.dataset.row || '0', 10);
38
+            const column = parseInt(item.dataset.column || '0', 10);
39
+            const rowSpan = parseInt(item.dataset.rowSpan || '1', 10);
40
+            const columnSpan = parseInt(item.dataset.columnSpan || '1', 10);
41
+
42
+            const settingThickness = this.getGridLineThickness(grid);
43
+            let thicknessLeft = settingThickness / 2;
44
+            let thicknessTop = settingThickness / 2;
45
+            let thicknessRight = settingThickness / 2;
46
+            let thicknessBottom = settingThickness / 2;
47
+
48
+            if (row === 0) thicknessTop = settingThickness;
49
+            if (row + rowSpan === rowCount) thicknessBottom = settingThickness;
50
+            if (column === 0) thicknessLeft = settingThickness;
51
+            if (column + columnSpan === columnCount) thicknessRight = settingThickness;
52
+
53
+            const border = document.createElement('div');
54
+            border.style.border = `${thicknessTop}px ${this.getGridLineBrush(grid)} solid`;
55
+            border.style.borderLeftWidth = `${thicknessLeft}px`;
56
+            border.style.borderRightWidth = `${thicknessRight}px`;
57
+            border.style.borderBottomWidth = `${thicknessBottom}px`;
58
+            border.style.padding = '0.5px';
59
+
60
+            grid.removeChild(item);
61
+            border.appendChild(item);
62
+            grid.insertBefore(border, grid.children[index]);
63
+        });
64
+    }
65
+}
66
+
67
+// 定义 Vue 组合函数
68
+export function useGridHelper(elRef: any) {
69
+    const isShowBorder = ref(false);
70
+    const gridLineThickness = ref(1);
71
+    const gridLineBrush = ref('lightgray');
72
+
73
+    const applyGridBorder = () => {
74
+        if (elRef.value && isShowBorder.value) {
75
+            GridHelper.setShowBorder(elRef.value, isShowBorder.value);
76
+            GridHelper.setGridLineThickness(elRef.value, gridLineThickness.value);
77
+            GridHelper.setGridLineBrush(elRef.value, gridLineBrush.value);
78
+            GridHelper.gridLoaded(elRef.value);
79
+        }
80
+    };
81
+
82
+    onMounted(() => {
83
+        nextTick(() => {
84
+            applyGridBorder();
85
+        });
86
+    });
87
+
88
+    return {
89
+        isShowBorder,
90
+        gridLineThickness,
91
+        gridLineBrush,
92
+        applyGridBorder
93
+    };
94
+}

+ 113
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ItemsControlHelper.ts View File

@@ -0,0 +1,113 @@
1
+// 模拟 ComboBoxHelper 类
2
+class ComboBoxHelper {
3
+    static GetIsAutoComplete(target: any): boolean {
4
+        // 模拟实现,实际使用时需根据业务逻辑修改
5
+        return target.isAutoComplete || false;
6
+    }
7
+
8
+    RefreshSource(cbx: any, items: any[]) {
9
+        // 模拟实现,实际使用时需根据业务逻辑修改
10
+        cbx.itemsSource = items;
11
+    }
12
+
13
+    RegisteAutoComplete(cbx: any, items: any[]) {
14
+        // 模拟实现,实际使用时需根据业务逻辑修改
15
+        cbx.itemsSource = items;
16
+    }
17
+}
18
+
19
+// 模拟 ItemsControl 类
20
+class ItemsControl {
21
+    items: any[] = [];
22
+    itemsSource: any[] | null = null;
23
+    isLoaded: boolean = false;
24
+    isAutoComplete: boolean = false;
25
+
26
+    constructor() {
27
+        this.items = [];
28
+    }
29
+
30
+    addEventListener(event: string, callback: (event: any) => void) {
31
+        // 模拟实现,实际使用时需根据业务逻辑修改
32
+    }
33
+}
34
+
35
+// 模拟 Selector 类
36
+class Selector extends ItemsControl {
37
+    selectedIndex: number = -1;
38
+    selectedItem: any = null;
39
+}
40
+
41
+// ItemsControlHelper 类
42
+class ItemsControlHelper {
43
+    private static ComboBoxHelperPropertyKey = Symbol('ComboBoxHelper');
44
+
45
+    static GetComboBoxHelper(obj: any): ComboBoxHelper | null {
46
+        return obj[this.ComboBoxHelperPropertyKey] as ComboBoxHelper;
47
+    }
48
+
49
+    static SetComboBoxHelper(obj: any, value: ComboBoxHelper) {
50
+        obj[this.ComboBoxHelperPropertyKey] = value;
51
+    }
52
+
53
+    static AddItems(target: ItemsControl, items: any[]) {
54
+        if (!items) return;
55
+
56
+        for (const item of items) {
57
+            if (this.isKeyValuePair(item)) {
58
+                target.items.push(item);
59
+            }
60
+        }
61
+    }
62
+
63
+    static SetItems(target: ItemsControl, items: any[]) {
64
+        if (!items) return;
65
+
66
+        if (ComboBoxHelper.GetIsAutoComplete(target)) {
67
+            const cbx = target as Selector;
68
+            if (!cbx) return;
69
+
70
+            if (cbx.itemsSource) {
71
+                const helper = this.GetComboBoxHelper(cbx);
72
+                if (helper) {
73
+                    helper.RefreshSource(cbx, items);
74
+                }
75
+            } else {
76
+                const helper = new ComboBoxHelper();
77
+                this.SetComboBoxHelper(cbx, helper);
78
+                if (cbx.isLoaded) {
79
+                    helper.RegisteAutoComplete(cbx, items);
80
+                } else {
81
+                    cbx.addEventListener('loaded', () => {
82
+                        helper.RegisteAutoComplete(cbx, items);
83
+                    });
84
+                }
85
+            }
86
+        } else {
87
+            target.items = [];
88
+            this.AddItems(target, items);
89
+            const selector = target as Selector;
90
+            if (selector) {
91
+                selector.selectedIndex = 0;
92
+            }
93
+            // 模拟刷新操作
94
+            target.itemsSource = [...target.items];
95
+        }
96
+    }
97
+
98
+    static GetSelectedKey(target: Selector): string {
99
+        let result = '';
100
+        if (target.selectedItem) {
101
+            if (this.isKeyValuePair(target.selectedItem)) {
102
+                result = target.selectedItem.key;
103
+            }
104
+        }
105
+        return result;
106
+    }
107
+
108
+    private static isKeyValuePair(obj: any): obj is { key: string; value: string } {
109
+        return obj && typeof obj.key === 'string' && typeof obj.value === 'string';
110
+    }
111
+}
112
+
113
+export { ItemsControlHelper, ItemsControl, Selector, ComboBoxHelper };

+ 145
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/PasswordBoxHelper.ts View File

@@ -0,0 +1,145 @@
1
+import { DirectiveBinding } from 'vue';
2
+
3
+// 焦点管理器模拟
4
+class FocusManager {
5
+    static IsFocusContinue = true;
6
+    static SetFocus(element: HTMLElement) {
7
+        element.focus();
8
+    }
9
+}
10
+
11
+// 消息提示模拟
12
+const showTip = (element: HTMLElement, message: string) => {
13
+    console.log(`提示: ${message}`);
14
+};
15
+
16
+// 检查密码是否简单
17
+const IsSimplepwd = (s: string, pwd: string[]): boolean => {
18
+    const c = s.split('');
19
+
20
+    // 密码长度小于等于3位不通过
21
+    if (c.length <= 3) return true;
22
+
23
+    // 密码每个字符都是一样的不通过
24
+    const a = c[0];
25
+    let clen = 0;
26
+    for (let i = 0; i < c.length; i++) {
27
+        if (c[i] === a) clen++;
28
+    }
29
+    if (clen === c.length) return true;
30
+
31
+    // 每个字符的ascii码是升序不通过
32
+    const asciiAsc = c.map(char => char.charCodeAt(0));
33
+    clen = 0;
34
+    for (let i = 0; i < asciiAsc.length; i++) {
35
+        if (asciiAsc[0] + i === asciiAsc[i]) clen++;
36
+    }
37
+    if (clen === asciiAsc.length) return true;
38
+
39
+    // 每个字符的ascii码是降序不通过
40
+    const asciiDesc = c.map(char => char.charCodeAt(0));
41
+    clen = 0;
42
+    for (let i = 0; i < asciiDesc.length; i++) {
43
+        if (asciiDesc[0] - i === asciiDesc[i]) clen++;
44
+    }
45
+    if (clen === asciiDesc.length) return true;
46
+
47
+    // 密码和指定的任意一组字符串相同不通过
48
+    for (let i = 0; i < pwd.length; i++) {
49
+        if (pwd[i] === s) return true;
50
+    }
51
+
52
+    return false;
53
+};
54
+
55
+// 自定义指令
56
+export const PasswordBoxHelper = {
57
+    // 禁用粘贴
58
+    forbidPaste: {
59
+        mounted(el: HTMLInputElement) {
60
+            el.addEventListener('paste', (e) => {
61
+                e.preventDefault();
62
+                showTip(el, '重复输入的要素不允许进行数据粘贴');
63
+            });
64
+        },
65
+    },
66
+    // 是否需要重复输入
67
+    isRepeatInput: {
68
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<boolean>) {
69
+            if (binding.value) {
70
+                let firstInput = '';
71
+                el.addEventListener('blur', () => {
72
+                    if (!firstInput) {
73
+                        firstInput = el.value.trim();
74
+                        showTip(el, '请重新输入一遍,两次的数据必须完全相同');
75
+                        el.value = '';
76
+                        el.addEventListener('blur', () => {
77
+                            if (firstInput !== el.value.trim()) {
78
+                                showTip(el, '两次输入的数据不一致,请重新输入');
79
+                                el.value = '';
80
+                                firstInput = '';
81
+                            }
82
+                        }, { once: true });
83
+                    }
84
+                });
85
+            }
86
+        },
87
+    },
88
+    // 自动选择全部
89
+    isAutoSelectedAll: {
90
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<boolean>) {
91
+            if (binding.value) {
92
+                el.addEventListener('focus', () => {
93
+                    el.select();
94
+                });
95
+            }
96
+        },
97
+    },
98
+    // 获得焦点时自动清空值
99
+    isAutoClearVal: {
100
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<boolean>) {
101
+            if (binding.value) {
102
+                el.addEventListener('focus', () => {
103
+                    el.value = '';
104
+                });
105
+            }
106
+        },
107
+    },
108
+    // 密码最小长度检查
109
+    minLength: {
110
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<number>) {
111
+            el.addEventListener('blur', () => {
112
+                const pwd = el.value.trim();
113
+                const len = binding.value;
114
+                if (len > pwd.length) {
115
+                    showTip(el, `密码长度不足${len}位。`);
116
+                    FocusManager.SetFocus(el);
117
+                    FocusManager.IsFocusContinue = false;
118
+                }
119
+            });
120
+        },
121
+    },
122
+    // 禁止使用简单密码
123
+    breakSimplePassword: {
124
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<boolean>) {
125
+            if (binding.value) {
126
+                el.addEventListener('blur', () => {
127
+                    const pwd = el.value;
128
+                    if (IsSimplepwd(pwd, [])) {
129
+                        showTip(el, '密码过于简单。');
130
+                        FocusManager.SetFocus(el);
131
+                        FocusManager.IsFocusContinue = false;
132
+                    }
133
+                });
134
+            }
135
+        },
136
+    },
137
+    // 只读
138
+    isReadOnly: {
139
+        mounted(el: HTMLInputElement, binding: DirectiveBinding<boolean>) {
140
+            if (binding.value) {
141
+                el.readOnly = true;
142
+            }
143
+        },
144
+    },
145
+};

+ 148
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/TextBoxHelper.ts View File

@@ -0,0 +1,148 @@
1
+import { DirectiveBinding, nextTick, ref, watch } from 'vue';
2
+
3
+// 定义 PlaceholderAdorner 等装饰器类的模拟,这里简化处理
4
+class PlaceholderAdorner {
5
+  constructor(private textBox: HTMLInputElement, private placeholder: string) {}
6
+}
7
+
8
+class TextLengthAdorner {
9
+  constructor(private textBox: HTMLInputElement) {}
10
+}
11
+
12
+class CircleAdorner {
13
+  constructor(private textBox: HTMLInputElement) {}
14
+}
15
+
16
+// 定义 InputType 枚举
17
+export enum InputType {
18
+  String = 0,
19
+  Date = 1,
20
+  Int = 2,
21
+  Decimal = 3,
22
+  Email = 4,
23
+  IDCard = 5,
24
+}
25
+
26
+// 定义 FocusHandledResult 枚举
27
+enum FocusHandledResult {
28
+  System,
29
+  Self,
30
+}
31
+
32
+// 定义 RegexValidationRules 类
33
+class RegexValidationRules {
34
+  private _rules: { [key: string]: [string, string] } = {};
35
+  private static _instance: RegexValidationRules;
36
+
37
+  private constructor() {
38
+    this.addRule('Date', '^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:0229))|(?:(?:(?:1[6-9]|[2-9]\\d)\\d{2})(?:(?:(?:0[13578]|1[02])31)|(?:(?:0[13-9]|1[0-2])(?:29|30))|(?:(?:0[1-9])|(?:1[0-2]))(?:0[1-9]|1\\d|2[0-8]))))$', '日期格式 20120101。');
39
+    this.addRule('Decimal', '^[0-9]+\\.{0,1}[0-9]{0,2}$', '请输入数字,格式 000.00。');
40
+    this.addRule('Int', '^\\d+$', '请输入整数数字。');
41
+    this.addRule('Email', '^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$', '请输入邮件地址类型。');
42
+    this.addRule('IDCard', '^\\d{17}[\\d|x|X]$|^\\d{15}$', '请输入有效身份证号。');
43
+    this.addRule('String', null, '');
44
+  }
45
+
46
+  static get Instance() {
47
+    if (!this._instance) {
48
+      this._instance = new RegexValidationRules();
49
+    }
50
+    return this._instance;
51
+  }
52
+
53
+  addRule(name: string, regex: string | null, errorMsg: string) {
54
+    if (this._rules[name]) {
55
+      delete this._rules[name];
56
+    }
57
+    this._rules[name] = [regex, errorMsg];
58
+  }
59
+
60
+  removeRule(name: string) {
61
+    if (this._rules[name]) {
62
+      delete this._rules[name];
63
+    }
64
+  }
65
+
66
+  bindingRule(element: HTMLElement, name: string) {
67
+    if (!element || !this._rules[name]) {
68
+      return false;
69
+    }
70
+    // 这里模拟绑定验证规则
71
+    return false;
72
+  }
73
+}
74
+
75
+// 定义 TextBoxHelper 类
76
+export class TextBoxHelper {
77
+  // Placeholder 相关
78
+  static placeholderOffset = ref<{ x: number; y: number }>({ x: 4, y: 2 });
79
+  static placeholder = ref('');
80
+
81
+  static onPlaceholderChanged(el: HTMLInputElement) {
82
+    nextTick(() => {
83
+      const updatePlaceholder = () => {
84
+        const isShow = el.value.length === 0;
85
+        // 这里简化处理装饰器的添加和移除
86
+        if (isShow) {
87
+          new PlaceholderAdorner(el, this.placeholder.value);
88
+        }
89
+      };
90
+
91
+      el.addEventListener('input', updatePlaceholder);
92
+      updatePlaceholder();
93
+    });
94
+  }
95
+
96
+  // IsMultiLine 相关
97
+  static isMultiLine = ref(false);
98
+
99
+  static onIsMultiLineChanged(el: HTMLInputElement) {
100
+    if (this.isMultiLine.value) {
101
+      el.setAttribute('wrap', 'soft');
102
+      el.setAttribute('rows', '2');
103
+    } else {
104
+      el.removeAttribute('wrap');
105
+      el.setAttribute('rows', '1');
106
+    }
107
+  }
108
+
109
+  // 其他功能类似实现,这里省略部分功能的完整实现,仅展示结构
110
+  // ...
111
+
112
+  // 输入类型验证
113
+  static inputType = ref(InputType.String);
114
+
115
+  static onInputTypeChanged(el: HTMLInputElement) {
116
+    switch (this.inputType.value) {
117
+      case InputType.Date:
118
+        RegexValidationRules.Instance.bindingRule(el, 'Date');
119
+        break;
120
+      case InputType.Decimal:
121
+        RegexValidationRules.Instance.bindingRule(el, 'Decimal');
122
+        break;
123
+      // 其他 case 类似
124
+    }
125
+  }
126
+}
127
+
128
+// 定义自定义指令,模拟附加属性
129
+export const vTextBoxHelper = {
130
+  mounted(el: HTMLInputElement, binding: DirectiveBinding) {
131
+    const { value } = binding;
132
+
133
+    if (value.placeholder) {
134
+      TextBoxHelper.placeholder.value = value.placeholder;
135
+      TextBoxHelper.onPlaceholderChanged(el);
136
+    }
137
+
138
+    if (value.isMultiLine !== undefined) {
139
+      TextBoxHelper.isMultiLine.value = value.isMultiLine;
140
+      TextBoxHelper.onIsMultiLineChanged(el);
141
+    }
142
+
143
+    if (value.inputType !== undefined) {
144
+      TextBoxHelper.inputType.value = value.inputType;
145
+      TextBoxHelper.onInputTypeChanged(el);
146
+    }
147
+  },
148
+};

+ 33
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/ControlsHelper/ToggleSwitchHelper.ts View File

@@ -0,0 +1,33 @@
1
+// 假设 FocusHandledResult 枚举的定义
2
+export enum FocusHandledResult {
3
+    System = 'System',
4
+    Self = 'Self'
5
+}
6
+
7
+// 假设 KeyEventArgs 接口的定义
8
+export interface KeyEventArgs {
9
+    key: string;
10
+}
11
+
12
+// 假设 ToggleSwitch 类的定义
13
+export class ToggleSwitch {}
14
+
15
+// 定义 ToggleSwitchHelper 命名空间
16
+export namespace ToggleSwitchHelper {
17
+    /**
18
+     * ToggleSwitch焦点处理方法
19
+     */
20
+    export const ToggleSwitchFocusHandled = (sender: any, e: KeyEventArgs): FocusHandledResult => {
21
+        const btn = sender as ToggleSwitch;
22
+
23
+        if (!btn) {
24
+            return FocusHandledResult.System;
25
+        }
26
+
27
+        if (e.key === 'Enter' || e.key === ' ') {
28
+            return FocusHandledResult.Self;
29
+        }
30
+
31
+        return FocusHandledResult.System;
32
+    };
33
+}

+ 269
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyBase.ts View File

@@ -0,0 +1,269 @@
1
+// 定义货币符号类型枚举
2
+export enum CurrencySymbolType {
3
+  None,
4
+  AsSystem,
5
+  UserSetting
6
+}
7
+
8
+// 定义控制辅助类
9
+class ControlHelper {
10
+  static ShowTip(element: any, message: string) {
11
+    console.log(message);
12
+  }
13
+}
14
+
15
+export class CurrencyBase {
16
+  private _currentIndex: number = 0;
17
+  private _oldText: string = "";
18
+  private _firstInputZero: boolean = true;
19
+  private _isInputDot: boolean = false;
20
+  private _isDelete: boolean = false;
21
+  private _formatType: string = "";
22
+  private _txtValue: string = "";
23
+  private _initTxtLength: number = 0;
24
+
25
+  private _decimalAccuracy: number = 0;
26
+  private _minValue: number = 0;
27
+  private _maxValue: number = 9999999999999999.00000;
28
+  private _accuracy: number = 2;
29
+
30
+  private _text: string = "";
31
+  private _caretIndex: number = 0;
32
+
33
+  get Val() {
34
+    return this._text.replace(/,/g, "");
35
+  }
36
+
37
+  get Text() {
38
+    return this._text;
39
+  }
40
+
41
+  set Text(value: string) {
42
+    this._text = value;
43
+  }
44
+
45
+  get CaretIndex() {
46
+    return this._caretIndex;
47
+  }
48
+
49
+  set CaretIndex(value: number) {
50
+    this._caretIndex = value;
51
+  }
52
+
53
+  get MinValue() {
54
+    return this._minValue;
55
+  }
56
+
57
+  set MinValue(value: number) {
58
+    this._minValue = value;
59
+  }
60
+
61
+  get MaxValue() {
62
+    return this._maxValue;
63
+  }
64
+
65
+  set MaxValue(value: number) {
66
+    this._maxValue = value;
67
+  }
68
+
69
+  get Accuracy() {
70
+    return this._accuracy;
71
+  }
72
+
73
+  set Accuracy(value: number) {
74
+    this._accuracy = value;
75
+  }
76
+
77
+  // 模拟获取焦点事件
78
+  OnGotFocus() {
79
+    if (this._text.trim() !== "" && parseFloat(this._text.trim()) === 0) {
80
+      this._text = "";
81
+      this._oldText = this._txtValue;
82
+    }
83
+    // 模拟全选
84
+    this.CaretIndex = this._text.length;
85
+  }
86
+
87
+  // 模拟失去焦点事件
88
+  OnLostFocus() {
89
+    this._firstInputZero = true;
90
+    this._isInputDot = false;
91
+    if (this._text.trim() !== "") {
92
+      if (this._text[0] === "-") {
93
+        let value = parseFloat(this._text.substring(1));
94
+        this._text = "-" + this.FormatType(this._formatType, value);
95
+      } else {
96
+        let value = parseFloat(this._text);
97
+        this._text = this.FormatType(this._formatType, value);
98
+      }
99
+    }
100
+    if (this._text === "") {
101
+      this._text = this._txtValue;
102
+    }
103
+  }
104
+
105
+  // 模拟键盘按下事件
106
+  OnPreviewKeyDown(key: string) {
107
+    if (key.includes("Control") || key.includes("Shift") || key.includes("Alt")) {
108
+      return;
109
+    }
110
+    this._isInputDot = false;
111
+    this._isDelete = false;
112
+
113
+    if (key === ".") {
114
+      this._isInputDot = true;
115
+      this.CaretIndex = this._text.indexOf(".") + 1;
116
+      this._currentIndex = this.CaretIndex;
117
+      return;
118
+    } else if (key === "Backspace") {
119
+      this._isDelete = true;
120
+      if (this._text !== "" && this.CaretIndex !== 0) {
121
+        if (this._text[this.CaretIndex - 1] === "," || this._text[this.CaretIndex - 1] === ".") {
122
+          this.CaretIndex--;
123
+          this._currentIndex = this.CaretIndex - 1;
124
+        } else {
125
+          this._currentIndex = this.CaretIndex - 1;
126
+        }
127
+      }
128
+      this._firstInputZero = false;
129
+    } else if (key === "Delete") {
130
+      this._isDelete = true;
131
+      if (this._text !== "" && this.CaretIndex !== this._text.length) {
132
+        if (this._text[this.CaretIndex] === "," || this._text[this.CaretIndex] === ".") {
133
+          this.CaretIndex++;
134
+          this._currentIndex = this.CaretIndex;
135
+        } else {
136
+          this._currentIndex = this.CaretIndex;
137
+        }
138
+      }
139
+      this._firstInputZero = false;
140
+    } else if (key === "-") {
141
+      if (this._text.indexOf("-") >= 0 || this.CaretIndex !== 0) {
142
+        this._currentIndex = this.CaretIndex;
143
+        return;
144
+      } else {
145
+        this._currentIndex = this.CaretIndex + 1;
146
+      }
147
+    } else if (!this.IsDigitalKey(key)) {
148
+      this._currentIndex = this.CaretIndex;
149
+      return;
150
+    } else {
151
+      if (this._text.length === 0 || this._text === "-") {
152
+        this._firstInputZero = true;
153
+      } else {
154
+        this._firstInputZero = false;
155
+      }
156
+      this._currentIndex = this.CaretIndex + 1;
157
+    }
158
+
159
+    if (this._text.trim() !== "") {
160
+      let olddec = parseFloat(this._text);
161
+      this._oldText = this.FormatType(this._formatType, olddec);
162
+    }
163
+    let doubleText = parseFloat(this._oldText);
164
+    if (doubleText < this._minValue || doubleText > this._maxValue) {
165
+      return;
166
+    }
167
+  }
168
+
169
+  // 模拟文本更改事件
170
+  OnTextChanged() {
171
+    if (this._text.trim() !== "") {
172
+      let text = "0";
173
+      let value = 0;
174
+      if (this._minValue < 0 && this._text[0] === "-") {
175
+        if (this._text === "-") {
176
+          this.CaretIndex = this._currentIndex;
177
+          return;
178
+        }
179
+        value = parseFloat("0" + this._text.substring(1));
180
+        text = "-" + this.FormatType(this._formatType, value);
181
+      } else {
182
+        value = parseFloat(this._text);
183
+        text = this.FormatType(this._formatType, value);
184
+      }
185
+
186
+      if (parseFloat(text) < this._minValue) {
187
+        this._text = "0.00";
188
+        ControlHelper.ShowTip(this, "最小值为" + this._minValue);
189
+        return;
190
+      }
191
+      if (parseFloat(text) > this._maxValue) {
192
+        this._text = "0.00";
193
+        ControlHelper.ShowTip(this, "最大值为" + this._maxValue);
194
+        return;
195
+      }
196
+
197
+      this._text = text;
198
+
199
+      if (parseFloat(text) >= this._minValue && parseFloat(text) <= this._maxValue) {
200
+        if (value === 0) {
201
+          if (this._firstInputZero) {
202
+            if (this._text[0] === "-") {
203
+              this._text = "-" + this._txtValue;
204
+            } else {
205
+              this._text = this._txtValue;
206
+            }
207
+            let n = this._text.indexOf(".");
208
+            this.CaretIndex = n !== -1 ? n : this.CaretIndex;
209
+          } else if (this._isDelete) {
210
+            this.CaretIndex = 1;
211
+          } else {
212
+            if (!this._isInputDot && this._text.indexOf(".") >= 0 && this.CaretIndex > this._text.indexOf(".")) {
213
+              if (this.CaretIndex === this._text.indexOf(".") + 1) {
214
+                this.CaretIndex = this._text.indexOf(".");
215
+                return;
216
+              }
217
+            }
218
+            this.CaretIndex = this._currentIndex;
219
+          }
220
+          return;
221
+        }
222
+        if (this._oldText) {
223
+          if (this._oldText.length - this._text.length === 2 && value !== 0) {
224
+            if (this._currentIndex > 1) {
225
+              this.CaretIndex = this._currentIndex - 1;
226
+            } else if (this._currentIndex === 1) {
227
+              this.CaretIndex = 1;
228
+            } else if (this._currentIndex === 0) {
229
+              this.CaretIndex = 0;
230
+            }
231
+          } else if (this._text.length - this._oldText.length === 2 && !this._isDelete) {
232
+            this.CaretIndex = this._currentIndex + 1;
233
+          } else {
234
+            this.CaretIndex = this._currentIndex;
235
+            if (this._currentIndex < this._text.indexOf(".")) {
236
+              if (this._text[0] === "-" && !this._isDelete) {
237
+                this._currentIndex = this._text.indexOf(".") + 1;
238
+                this.CaretIndex = this._currentIndex;
239
+              }
240
+            }
241
+            if (this._text.indexOf(".") + 1 === this.CaretIndex && !this._isInputDot) {
242
+              let n = this._text.indexOf(".");
243
+              this.CaretIndex = n !== -1 ? n : this._currentIndex + 1;
244
+            }
245
+          }
246
+        } else {
247
+          this.CaretIndex = this._text.length;
248
+        }
249
+      }
250
+    } else {
251
+      this._text = "0.00";
252
+      this.CaretIndex = 1;
253
+    }
254
+  }
255
+
256
+  // 判断是否为数字键
257
+  private IsDigitalKey(key: string) {
258
+    return /^\d$/.test(key);
259
+  }
260
+
261
+  // 格式化数值
262
+  private FormatType(formatType: string, value: number) {
263
+    if (value.toString().indexOf(".") > -1) {
264
+      let s = value.toString().split(".");
265
+      value = parseFloat(s[0] + "." + s[1].substring(0, this._accuracy));
266
+    }
267
+    return value.toFixed(this._accuracy);
268
+  }
269
+}

+ 93
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyEditor.ts View File

@@ -0,0 +1,93 @@
1
+import { defineComponent, ref, onMounted, watch } from 'vue';
2
+
3
+// 假设 CurrencyBase 的类型定义
4
+interface CurrencyBase {
5
+    _initTxtLength: number;
6
+    _formatType: string;
7
+    _txtValue: string;
8
+    onPreviewKeyDown?: (e: KeyboardEvent) => void;
9
+    onTextChanged?: (e: Event) => void;
10
+    onGotFocus?: (e: FocusEvent) => void;
11
+    onLostFocus?: (e: FocusEvent) => void;
12
+}
13
+//TODO这里方法重复了需要处理
14
+// 模拟 CurrencyBase 类
15
+class CurrencyBase {
16
+    _initTxtLength: number = 0;
17
+    _formatType: string = '';
18
+    _txtValue: string = '';
19
+
20
+    // onPreviewKeyDown(e: KeyboardEvent) {
21
+    //     // 基类默认处理逻辑
22
+    // }
23
+
24
+    // onTextChanged(e: Event) {
25
+    //     // 基类默认处理逻辑
26
+    // }
27
+
28
+    // onGotFocus(e: FocusEvent) {
29
+    //     // 基类默认处理逻辑
30
+    // }
31
+
32
+    // onLostFocus(e: FocusEvent) {
33
+    //     // 基类默认处理逻辑
34
+    // }
35
+}
36
+
37
+export default defineComponent({
38
+    name: 'CurrencyEditor',
39
+    setup() {
40
+        const text = ref('0.00');
41
+        const base = new CurrencyBase();
42
+
43
+        onMounted(() => {
44
+            // 模拟禁用输入法
45
+            // 在 Web 中没有直接禁用输入法的方法,可通过 inputmode 属性限制输入
46
+        });
47
+
48
+        const handleKeyDown = (e: KeyboardEvent) => {
49
+            base._initTxtLength = 4;
50
+            base._formatType = '{0:n}';
51
+            base.onPreviewKeyDown?.(e);
52
+        };
53
+
54
+        const handleTextChange = (e: Event) => {
55
+            base._txtValue = '0.00';
56
+            base._formatType = '{0:n}';
57
+            base.onTextChanged?.(e);
58
+        };
59
+
60
+        const handleGotFocus = (e: FocusEvent) => {
61
+            base._txtValue = '0.00';
62
+            base.onGotFocus?.(e);
63
+        };
64
+
65
+        const handleLostFocus = (e: FocusEvent) => {
66
+            base._txtValue = '0.00';
67
+            base._formatType = '{0:n}';
68
+            base.onLostFocus?.(e);
69
+        };
70
+
71
+        watch(text, (newValue) => {
72
+            // 模拟文本更改事件
73
+            const event = new Event('input');
74
+            handleTextChange(event);
75
+        });
76
+
77
+        return {
78
+            text,
79
+            handleKeyDown,
80
+            handleGotFocus,
81
+            handleLostFocus
82
+        };
83
+    },
84
+    template: `
85
+        <input
86
+            :value="text"
87
+            @keydown="handleKeyDown"
88
+            @focus="handleGotFocus"
89
+            @blur="handleLostFocus"
90
+            inputmode="numeric"
91
+        />
92
+    `
93
+});

+ 70
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/CurrencyRateEditor.ts View File

@@ -0,0 +1,70 @@
1
+// 假设 CurrencyBase 的类型定义
2
+class CurrencyBase {
3
+    public Accuracy: number = 0;
4
+    public CurrencySymbol: string = "";
5
+    public CurrencySymbolType: any;
6
+    public _initTxtLength: number = 0;
7
+    public _formatType: string = "";
8
+    public _txtValue: string = "";
9
+
10
+    public OnPreviewKeyDown(e: any) {}
11
+    public OnTextChanged(e: any) {}
12
+    public OnGotFocus(e: any) {}
13
+    public OnLostFocus(e: any) {}
14
+}
15
+
16
+// 假设 CurrencySymbolType 的枚举定义
17
+enum CurrencySymbolType {
18
+    UserSetting
19
+}
20
+
21
+export class CurrencyRateEditor extends CurrencyBase {
22
+    constructor() {
23
+        super();
24
+        // 禁用输入法,Vue 中没有直接对应方法,这里注释说明
25
+        // 可以在组件中通过 input 元素的相关属性实现
26
+        this.Accuracy = 6;
27
+        this.updateText();
28
+        this.CurrencySymbol = "%";
29
+        this.CurrencySymbolType = CurrencySymbolType.UserSetting;
30
+    }
31
+
32
+    private updateText() {
33
+        this._txtValue = this.GetTxtValue();
34
+    }
35
+
36
+    public OnPreviewKeyDown(e: any) {
37
+        this._initTxtLength = this.GetInitTxtLength();
38
+        this._formatType = this.GetFormatType();
39
+        super.OnPreviewKeyDown(e);
40
+    }
41
+
42
+    public OnTextChanged(e: any) {
43
+        this.updateText();
44
+        this._formatType = this.GetFormatType();
45
+        super.OnTextChanged(e);
46
+    }
47
+
48
+    public OnGotFocus(e: any) {
49
+        this.updateText();
50
+        super.OnGotFocus(e);
51
+    }
52
+
53
+    public OnLostFocus(e: any) {
54
+        this.updateText();
55
+        this._formatType = this.GetFormatType();
56
+        super.OnLostFocus(e);
57
+    }
58
+
59
+    private GetTxtValue(): string {
60
+        return "0.".padEnd(this.Accuracy + 2, '0');
61
+    }
62
+
63
+    private GetFormatType(): string {
64
+        return `{0:F${this.Accuracy}}`;
65
+    }
66
+
67
+    private GetInitTxtLength(): number {
68
+        return this.Accuracy + 2;
69
+    }
70
+}

+ 75
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/NumericContainer/ProportionalEditor.ts View File

@@ -0,0 +1,75 @@
1
+import { defineComponent, ref, onMounted, watch } from 'vue';
2
+
3
+// 模拟 CurrencyBase 类
4
+class CurrencyBase {
5
+    _initTxtLength: number = 0;
6
+    _formatType: string = '';
7
+    _txtValue: string = '';
8
+    CurrencySymbol: string = '';
9
+    CurrencySymbolType: string = '';
10
+    Accuracy: number = 2; // 默认精度为 2
11
+}
12
+
13
+export default defineComponent({
14
+    name: 'ProportionalEditor',
15
+    setup() {
16
+        const currencyBase = new CurrencyBase();
17
+        const text = ref('');
18
+
19
+        // 禁用输入法
20
+        const disableInputMethod = () => {
21
+            // 在 Vue 中无法直接禁用输入法,此为模拟
22
+        };
23
+
24
+        const getTxtValue = () => {
25
+            return '0.'.padEnd(currencyBase.Accuracy + 2, '0');
26
+        };
27
+
28
+        const getFormatType = () => {
29
+            return `{0:F${currencyBase.Accuracy}}`;
30
+        };
31
+
32
+        const getInitTxtLength = () => {
33
+            return currencyBase.Accuracy + 2;
34
+        };
35
+
36
+        const onPreviewKeyDown = (e: KeyboardEvent) => {
37
+            currencyBase._initTxtLength = getInitTxtLength();
38
+            currencyBase._formatType = getFormatType();
39
+            // 模拟父类处理
40
+        };
41
+
42
+        const onTextChanged = () => {
43
+            currencyBase._txtValue = getTxtValue();
44
+            currencyBase._formatType = getFormatType();
45
+            // 模拟父类处理
46
+        };
47
+
48
+        const onGotFocus = () => {
49
+            currencyBase._txtValue = getTxtValue();
50
+            // 模拟父类处理
51
+        };
52
+
53
+        const onLostFocus = () => {
54
+            currencyBase._txtValue = getTxtValue();
55
+            currencyBase._formatType = getFormatType();
56
+            // 模拟父类处理
57
+        };
58
+
59
+        onMounted(() => {
60
+            disableInputMethod();
61
+            text.value = getTxtValue();
62
+            currencyBase.CurrencySymbol = '%';
63
+            currencyBase.CurrencySymbolType = 'UserSetting';
64
+        });
65
+
66
+        watch(text, onTextChanged);
67
+
68
+        return {
69
+            text,
70
+            onPreviewKeyDown,
71
+            onGotFocus,
72
+            onLostFocus
73
+        };
74
+    }
75
+});

BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/3.ico View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/9.ico View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignCenter.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignFullJustify.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignLeft.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/AlignRight.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Backcolor.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchCircle.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchSquare.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/ColorSwatchSquare2.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Expanded.ico View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/FilePrint.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Indent.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/IndentRemove.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/MainICO.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/MenuTree_TradeSelected.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/NotExpanded.ico View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_error.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_information.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_question.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/PageMessageBox_warning.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Subscript.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Superscript.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/Textcolor.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/charactergrowfont.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/charactershrinkfont.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/copy.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/cut.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/fileopen.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/filesave.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/listbullets.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/listnumbering.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_first.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_first_gray.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_last.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_last_gray.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_load.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_loading.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_next.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_next_gray.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_prev.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/pagination_prev_gray.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/paste.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/redo.png View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/sign.gif View File


BIN
ant-design-pro-vue3/src/views/front/platfrom/controls/Resource/undo.png View File


+ 0
- 0
ant-design-pro-vue3/src/views/front/platfrom/controls/TableContainer/ComboBoxDataGrid/ComboBoxDataGrid.ts View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save