-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathBMarkerTipControl.cs
222 lines (208 loc) · 9.56 KB
/
BMarkerTipControl.cs
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace BMap.NET.WindowsForm
{
/// <summary>
/// 标记点信息显示控件
/// </summary>
public partial class BMarkerTipControl : UserControl
{
/// <summary>
/// 选项卡
/// </summary>
int _tab_index = 0;
/// <summary>
/// 构造方法
/// </summary>
public BMarkerTipControl()
{
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
UpdateStyles();
}
#region 事件处理
/// <summary>
/// 编辑标记信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void picEdit_Click(object sender, EventArgs e)
{
}
/// <summary>
/// 删除标记
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void picDelete_Click(object sender, EventArgs e)
{
}
/// <summary>
/// 关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void picClose_Click(object sender, EventArgs e)
{
Visible = false;
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BMarkerTipControl_Load(object sender, EventArgs e)
{
//显示形状
GraphicsPath gp = new GraphicsPath();
gp.AddLine(new Point(0, 0), new Point(Width, 0));
gp.AddLine(new Point(Width, 0), new Point(Width, Height - 40));
gp.AddLine(new Point(Width / 3 + 20, Height - 40), new Point(Width, Height - 40));
gp.AddLine(new Point(Width / 3 + 20, Height - 40), new Point(Width / 3 - 40, Height));
gp.AddLine(new Point(Width / 3 - 40, Height), new Point(Width / 3 - 20, Height - 40));
gp.AddLine(new Point(Width / 3 - 20, Height - 40), new Point(0, Height - 40));
this.Region = new Region(gp);
}
/// <summary>
/// 重绘
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BMarkerTipControl_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
//边框
GraphicsPath gp = new GraphicsPath();
gp.AddLine(new Point(0, 0), new Point(Width - 1, 0));
gp.AddLine(new Point(Width - 1, 0), new Point(Width - 1, Height - 40 - 1));
gp.AddLine(new Point(Width / 3 + 20 - 1, Height - 40 - 1), new Point(Width - 1, Height - 40 - 1));
gp.AddLine(new Point(Width / 3 + 20 - 1, Height - 40 - 1), new Point(Width / 3 - 40, Height - 1));
gp.AddLine(new Point(Width / 3 - 40, Height - 1), new Point(Width / 3 - 20 + 1, Height - 40 - 1));
gp.AddLine(new Point(Width / 3 - 20 + 1, Height - 40 - 1), new Point(0, Height - 40 - 1));
gp.AddLine(new Point(0, 0), new Point(0, Height - 40 - 1));
e.Graphics.DrawPath(Pens.Gray, gp);
using (Pen p = new Pen(Color.FromArgb(150, Color.LightGray)))
{
e.Graphics.DrawLine(p, new Point(0, 130 - 15), new Point(Width, 130 - 15));
e.Graphics.DrawLine(p, new Point(Width / 3, 130 + 26 - 15), new Point(Width / 3, 130 - 15));
e.Graphics.DrawLine(p, new Point(Width * 2 / 3, 130 + 26 - 15), new Point(Width * 2 / 3, 130 - 15));
e.Graphics.DrawImage(Properties.BMap.ico_destination, new Point(10, 130 + 5 - 15));
e.Graphics.DrawImage(Properties.BMap.ico_source, new Point(Width / 3 + 10, 130 + 5 - 15));
e.Graphics.DrawImage(Properties.BMap.ico_search_in_bound, new Rectangle(Width * 2 / 3 + 10, 130 + 5 - 15, 18, 18));
using (Font f = new Font("微软雅黑", 9))
{
if (_tab_index == 0) //到这里去
{
e.Graphics.DrawLine(p, new Point(Width / 3, 130 + 26 - 15), new Point(Width, 130 + 26 - 15));
e.Graphics.DrawString("到这里去", f, Brushes.Gray, new PointF(25, 130 + 5 - 15));
e.Graphics.DrawString("从这里出发", f, Brushes.Blue, new PointF(Width / 3 + 25, 130 + 5 - 15));
e.Graphics.DrawString("周边搜索", f, Brushes.Blue, new PointF(Width * 2 / 3 + 25, 130 + 5 - 15));
}
else if (_tab_index == 1) //从这里出发
{
e.Graphics.DrawLine(p, new Point(0, 130 + 26 - 15), new Point(Width / 3, 130 + 26 - 15));
e.Graphics.DrawLine(p, new Point(Width * 2 / 3, 130 + 26 - 15), new Point(Width, 130 + 26 - 15));
e.Graphics.DrawString("到这里去", f, Brushes.Blue, new PointF(25, 130 + 5 - 15));
e.Graphics.DrawString("从这里出发", f, Brushes.Gray, new PointF(Width / 3 + 25, 130 + 5 - 15));
e.Graphics.DrawString("周边搜索", f, Brushes.Blue, new PointF(Width * 2 / 3 + 25, 130 + 5 - 15));
}
else //周边搜索
{
e.Graphics.DrawLine(p, new Point(0, 130 + 26 - 15), new Point(Width * 2 / 3, 130 + 26 - 15));
e.Graphics.DrawString("到这里去", f, Brushes.Blue, new PointF(25, 130 + 5 - 15));
e.Graphics.DrawString("从这里出发", f, Brushes.Blue, new PointF(Width / 3 + 25, 130 + 5 - 15));
e.Graphics.DrawString("周边搜索", f, Brushes.Gray, new PointF(Width * 2 / 3 + 25, 130 + 5 - 15));
}
}
}
}
/// <summary>
/// 鼠标移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BMarkerTipControl_MouseMove(object sender, MouseEventArgs e)
{
if (new Rectangle(0, 130 - 15, Width, 26).Contains(e.Location))
{
Cursor = Cursors.Hand;
}
else
{
Cursor = Cursors.Arrow;
}
}
/// <summary>
/// 点击选项卡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BMarkerTipControl_Click(object sender, EventArgs e)
{
Point p = PointToClient(Cursor.Position);
if (new Rectangle(0, 130 - 15, Width / 3, 26).Contains(p)) //到这里去
{
_tab_index = 0;
lblPlace.Text = "起点";
lblPlace.Visible = true;
bPlaceBox.Visible = true;
btndriving.Visible = true;
btntransit.Visible = true;
txtNearby.Visible = false;
btnsearch.Visible = false;
lnknearby_bank.Visible = false;
lnknearby_bus_station.Visible = false;
lnknearby_eatting.Visible = false;
lnknearby_hospital.Visible = false;
lnknearby_hotel.Visible = false;
}
if (new Rectangle(Width / 3, 130 - 15, Width / 3, 26).Contains(p)) //从这里出发
{
_tab_index = 1;
lblPlace.Text = "终点";
lblPlace.Visible = true;
bPlaceBox.Visible = true;
btndriving.Visible = true;
btntransit.Visible = true;
txtNearby.Visible = false;
btnsearch.Visible = false;
lnknearby_bank.Visible = false;
lnknearby_bus_station.Visible = false;
lnknearby_eatting.Visible = false;
lnknearby_hospital.Visible = false;
lnknearby_hotel.Visible = false;
}
if (new Rectangle(Width * 2 / 3, 130 - 15, Width / 3, 26).Contains(p)) //周边搜索
{
_tab_index = 2;
lblPlace.Visible = false;
bPlaceBox.Visible = false;
btndriving.Visible = false;
btntransit.Visible = false;
txtNearby.Visible = true;
btnsearch.Visible = true;
lnknearby_bank.Visible = true;
lnknearby_bus_station.Visible = true;
lnknearby_eatting.Visible = true;
lnknearby_hospital.Visible = true;
lnknearby_hotel.Visible = true;
lnknearby_bank.Location = new Point(lnknearby_bank.Location.X, 232 - 15 - 54);
lnknearby_bus_station.Location = new Point(lnknearby_bus_station.Location.X, 232 - 15 - 54);
lnknearby_eatting.Location = new Point(lnknearby_eatting.Location.X, 232 - 15 - 54);
lnknearby_hospital.Location = new Point(lnknearby_hospital.Location.X, 232 - 15 - 54);
lnknearby_hotel.Location = new Point(lnknearby_hotel.Location.X, 232 - 15 - 54);
btnsearch.Location = new Point(btnsearch.Location.X, 225 - 15 - 54);
txtNearby.Location = new Point(txtNearby.Location.X, 226 - 15 - 54);
}
Invalidate();
}
#endregion
}
}