做一个项目,有部分功能要实现点击一个地图上的某一个镇的区域就弹出一个窗体显示这个镇的一些信息。 地图(就是整个大窗体)的大小是可以改变的,可以拖大、拖小或是最大化之类;还有就是弹出的窗体不是矩形的,是不规则的的图形;还有就是大窗体的右上角放一个小的显示区域,也是个不规则的形状。 请问这样能实现么 , 用什么技术做比较好点? 希望高手帮帮忙!多谢了!!效果如图:
解决方案 »
- MS-SQL C#存储过程里怎样一次性执行大量sql语句?
- repeater js
- 浏览器视图化结果
- DLL的调用和共享数据
- 求C#中关于内存读取和计时的类和函数?
- vs2005 事务更新的严重问题
- 菜鸟求助
- (***高手求救!)Infragistics控件中的UltraWebGrid的Quick Design出现问题--"指定的转换无效"!
- 在NET中C#项目中如何添加ActiveX控件
- 请教:一个c写的dll提供函数bool Des_Go(char *Out,char *In,long datalen,const char *Key,int keylen,bool Type);
- 一个让人蛋疼的面试题啊
- 存储过程的问题
1.定义GraphicsPath
2、从上面定义Region
3、设置窗体的Region
private void frmShow_Load(object sender, EventArgs e)
{
this.panel1.Left = this.Width - this.panel1.Width;
this.panel1.Top = 0;
} private void panel1_Paint(object sender, PaintEventArgs e)
{
SetWindowRegion(this.panel1);
} public void SetWindowRegion(Panel pan)
{
System.Drawing.Drawing2D.GraphicsPath FormPath;
FormPath = new System.Drawing.Drawing2D.GraphicsPath(); Rectangle rect = new Rectangle(0, 0, pan.Width, pan.Height - 22);//this.Left-10,this.Top-10,this.Width-10,this.Height-10); FormPath = GetRoundedRectPath(rect, 30); pan.Region = new Region(FormPath);
} private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
{
int diameter = radius;
Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
GraphicsPath path = new GraphicsPath();
// 左上角
path.AddArc(arcRect, 180, 90);
// 右上角
arcRect.X = rect.Right - diameter; path.AddArc(arcRect, 270, 90);
// 右下角
arcRect.Y = rect.Bottom - diameter;
path.AddArc(arcRect, 0, 90);
// 左下角
arcRect.X = rect.Left;
path.AddArc(arcRect, 90, 90);
path.CloseFigure();
return path;
}
{ }
不就是判断Mouse的座标是否在那个区域上啊,
鼠标移动到按钮区域就显示提示
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;namespace WindowsApplication194
{
public partial class Form1 : Form, IMessageFilter
{
Button B = new Button();
PictureBox PB = new PictureBox();
Form F = new Form();
GraphicsPath GP = new GraphicsPath(); public Form1()
{
InitializeComponent(); Application.AddMessageFilter(this); B.Parent = this; GP.AddEllipse(0, 0, 80, 40);
GP.AddEllipse(20, 45, 40, 15);
GP.AddEllipse(25, 70, 20, 10); F.Opacity = 0;
F.FormBorderStyle = FormBorderStyle.None;
F.Size = new Size(100, 100);
F.Region = new Region(GP);
F.TopMost = true;
DoDraw(String.Empty);
F.Show(); PB.Parent = F;
PB.Dock = DockStyle.Fill;
} public bool PreFilterMessage(ref Message m)
{
int WM_MOUSEMOVE = 0x200; if (m.Msg == WM_MOUSEMOVE)
{
if (B.Bounds.Contains(this.PointToClient(Control.MousePosition)))
{
F.Location = Point.Add(Control.MousePosition, new Size(-25, -F.Height));
F.Show();
new Thread(new ParameterizedThreadStart(ShowFormThread)).Start("ABC");
this.Focus();
}
else
{
F.Opacity = 0;
F.Hide();
}
}
return false;
} void ShowFormThread(Object Obj)
{
try
{
String Text = Obj.ToString();
int StartTick = Environment.TickCount; this.Invoke(new Draw(DoDraw), new Object[] { Text });
while ((double)this.Invoke(new GetOpacity(DoGetOpacity)) < 0.8)
if (Environment.TickCount - StartTick > 200)
{
this.Invoke(new IncOpacity(DoIncOpacity)); StartTick = Environment.TickCount;
}
}
catch
{
// 忽略程序退出的异常
}
} delegate double GetOpacity();
delegate void IncOpacity();
delegate void Draw(String Text); double DoGetOpacity()
{
return F.Opacity;
} void DoIncOpacity()
{
F.Opacity += 0.1;
} void DoDraw(String Text)
{
Bitmap Bmp = new Bitmap(PB.ClientRectangle.Width, PB.ClientRectangle.Height); using (Graphics G = Graphics.FromImage(Bmp))
{
SizeF SF = G.MeasureString(Text, F.Font); G.Clear(Color.Yellow);
G.DrawPath(Pens.Black, GP);
G.DrawString(Text, F.Font, Brushes.Black, (80 - SF.Width) / 2, 10);
}
PB.Image = Bmp;
}
}
}
把地图的无用区域做成透明的png格式图片。
加载的时候,自动会去掉的。