lixiaojun
2024-10-14 145dcc3a9ed1c3bcbc01c8da2b341aaa6ee5dbd2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
 
namespace Yw.WinFrmUI
{
    public partial class MapViewMarkerContainer : UserControl, IMapViewMarkerContainer
    {
        public MapViewMarkerContainer()
        {
            InitializeComponent();
        }
 
        public event Action LoadCompletedEvent;
        public event Action LoadFailedEvent;
        public event Action<HandingError> HandingErrorEvent;
 
        /// <summary>
        /// 交互对象
        /// </summary>
        public MapViewMarkerCallBackObj CallBackObj
        {
            get
            {
                if (_callBackObj == null)
                {
                    _callBackObj = new MapViewMarkerCallBackObj();
                }
                return _callBackObj;
            }
        }
        private MapViewMarkerCallBackObj _callBackObj;
 
        /// <summary>
        /// 是否初始化
        /// </summary>
        public bool IsInitialized
        {
            get { return _isInitialized; }
        }
        private bool _isInitialized;
 
        /// <summary>
        /// 初始话容器
        /// </summary>
        public async Task InitialContainer()
        {
            var callBackObj = this.CallBackObj;
            callBackObj.LoadCompletedEvent += CallBackObj_LoadCompletedEvent;
            callBackObj.LoadFailedEvent += CallBackObj_LoadFailedEvent;
            callBackObj.HandingErrorEvent += CallBackObj_HandingErrorEvent;
            await this.webViewControl1.InitialWebBrower(MapUrlHelper.ViewMarkerUrl, callBackObj, true);
        }
 
        //加载完成
        private void CallBackObj_LoadCompletedEvent()
        {
            _isInitialized = true;
            this.LoadCompletedEvent?.Invoke();
        }
 
        //加载失败
        private void CallBackObj_LoadFailedEvent()
        {
            this.LoadFailedEvent?.Invoke();
        }
 
        //处理错误
        private void CallBackObj_HandingErrorEvent(HandingError obj)
        {
            this.HandingErrorEvent?.Invoke(obj);
        }
 
        /// <summary>
        /// 加载点
        /// </summary>
        public async Task<bool> LoadMarker(Yw.Model.Map.Marker marker)
        {
            if (!this.IsInitialized)
            {
                return false;
            }
            return await this.webViewControl1.EvaluateScriptAsync<bool>("loadMarker", marker);
        }
 
        #region 边框
 
        /// <summary>
        /// 显示边框
        /// </summary>
        [Display(Name = "显示边框")]
        [DisplayName("显示边框")]
        [Browsable(true)]
        public bool ShowBorder
        {
            get { return this.webViewControl1.ShowBorder; }
            set { this.webViewControl1.ShowBorder = value; }
        }
 
        /// <summary>
        /// 边框颜色
        /// </summary>
        [Display(Name = "边框颜色")]
        [DisplayName("边框颜色")]
        [Browsable(true)]
        public Color BorderColor
        {
            get { return this.webViewControl1.BorderColor; }
            set { this.webViewControl1.BorderColor = value; }
        }
 
        /// <summary>
        /// 边框宽度
        /// </summary>
        [Display(Name = "边框宽度")]
        [DisplayName("边框宽度")]
        [Browsable(true)]
        public int BorderWidth
        {
            get { return this.webViewControl1.BorderWidth; }
            set { this.webViewControl1.BorderWidth = value; }
        }
 
        #endregion
 
 
    }
}