You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

991 lines
36 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.IO;
namespace GeoSigmaViewer
{
public partial class Viewer : UserControl
{
GeoSigma geoSigma;
//Bitmap img;
private bool isNewFile = true;
//IntPtr pDC = IntPtr.Zero;
//RectangleD mapRange = RectangleD.Empty;
private double smallScollFactor = 0.02;
private double largeScrollFactor = 0.9;
private int scrollPositionYLast = 0;
private bool needHScrollToEnd = false;
private bool needHScrollToBegin = false;
private bool needVScrollToTop = false;
private bool needVScrollToBottom = false;
public int ID { get; set; }
public Viewer()
{
System.Security.Cryptography.RNGCryptoServiceProvider csp = new System.Security.Cryptography.RNGCryptoServiceProvider();
byte[] byteCsp = new byte[10];
csp.GetBytes(byteCsp);
ID=BitConverter.ToInt32(byteCsp, 0);
InitializeComponent();
//this.MouseWheel+=Viewer_MouseWheel;
//this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.drawer1.SetScrollBar+=SetScrollBar;
Application.Idle+=delegate { SetStateOfControls(); };
}
public void Redraw()
{
drawer1.ReDraw();
}
public GeoSigma GetGeoSigma()
{
return geoSigma;
}
//private DrawToolType activeTool; // active drawing tool
//private DrawTool[] tools; // array of tools
/// <summary>
/// Active drawing tool.
/// </summary>
public DrawToolType ActiveTool
{
get
{
return drawer1.ActiveTool;
}
set
{
drawer1.ActiveTool=value;
}
}
private void SetStateOfControls()
{
if (needHScrollToEnd)
{
scrollH.Value=scrollH.Maximum-scrollH.LargeChange+1;
needHScrollToEnd=false;
}
if (needHScrollToBegin)
{
scrollH.Value=scrollH.Minimum;
needHScrollToBegin=false;
}
if (needVScrollToBottom)
{
scrollV.Value=scrollV.Maximum-scrollV.LargeChange+1;
needVScrollToBottom=false;
}
if (needVScrollToTop)
{
scrollV.Value=scrollV.Minimum;
needVScrollToTop=false;
}
}
private void Viewer_Load(object sender, EventArgs e)
{
//this.pcbDrawer.Location=new Point(0, 0);
//pcbDrawer.Width=0;
//pcbDrawer.Height=0;
//this.pcbDrawer.Location=new Point(0, 0);
//this.pcbDrawer.Width=1104;
//this.pcbDrawer.Height=820;
//pcbDrawer.Image =
//pDC=this.CreateGraphics().GetHdc();
}
public bool OpenFile(string drawFile)
{
//if (geoSigma!=null)
//{
// geoSigma.Dispose();
//}
//geoSigma=null;
//geoSigma=new GeoSigma();
//geoSigma.OpenDocument(drawFile);
//isNewFile=true;
////pcbDrawer.Invalidate();
////this.drawer1.Invalidate();
//this.Invalidate();
try
{
geoSigma = drawer1.OpenFile(drawFile);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
//SetScrollBar();
if(geoSigma==null)
{
return false;
}
return true;
}
public string GetLayers()
{
return geoSigma.GetLayers();
}
public string GetCurrentLayer()
{
return geoSigma.GetCurrentLayer();
}
public void SetCurrentLayer(string layerName)
{
geoSigma.SetCurrentLayer(layerName);
}
public bool RemoveCurveStyle(string layerName, int index)
{
if( geoSigma.RemoveCurveStyle(layerName, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerHowtoViewPoint(string layerName, string data)
{
if (geoSigma.SetLayerHowtoViewPoint(layerName, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerHowtoViewCurve(string layerName, string data, int index)
{
if (geoSigma.SetLayerHowtoViewCurve(layerName, data, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool RemovePointStyle(string layerName)
{
if (geoSigma.RemovePointStyle(layerName))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public void SetLayerState(string layerName, LayerStatus status)
{
geoSigma.SetLayerState(layerName, status);
geoSigma.EnableRedraw(true);
}
//private void Viewer_MouseWheel(object sender, MouseEventArgs e)
//{
// if (geoSigma==null) return;
// // 屏幕坐标偏移量
// int nOffsetScreen = this.VerticalScroll.Value -this.scrollPositionYLast;
// int nScreenAllVert = this.VerticalScroll.Maximum-this.VerticalScroll.Minimum;
// // 实际坐标偏移量
// double dOffsetReal = ((double)nOffsetScreen/nScreenAllVert)* this.mapRange.Height;
// geoSigma.Scroll((int)ScrollOrientation.VerticalScroll, dOffsetReal);
// scrollPositionYLast=this.VerticalScroll.Value;
// geoSigma.EnableRedraw(true);
//}
private void SetScrollBar(object sender, EventArgs e)
{
ScrollArgs args = e as ScrollArgs;
int hMax = 0, vMax = 0, hPage = 0, vPage = 0, hPos = 0, vPos = 0;
geoSigma.SetScrollBar(ref hMax, ref vMax, ref hPage, ref vPage, ref hPos, ref vPos);
// nMin、nPage、nPos与控件Min,LargeChange、value类似
// 但nMax相当于Max+LargeChange-1
int nMaxValueH = hMax;// hMax-hPage+1;
int nMaxValueV = vMax;
this.scrollH.Minimum=0;
this.scrollH.Maximum=nMaxValueH;
this.scrollH.LargeChange=(int)(hPage*largeScrollFactor+0.5);
this.scrollH.SmallChange=(int)(hPage*0.2+0.5);
if (hPos>=this.scrollH.Minimum&&hPos<=this.scrollH.Maximum)
this.scrollH.Value=hPos;
this.scrollV.Minimum=0;
this.scrollV.Maximum=nMaxValueV;
this.scrollV.LargeChange=vPage;
this.scrollV.SmallChange=(int)(vPage*0.2+0.5);
if (vPos>=this.scrollV.Minimum&&vPos<=this.scrollV.Maximum)
{ this.scrollV.Value=vPos; }
//////////////////////////////////////////////////////////////////////
//int WM_HSCROLL = 0x114;
//int WM_VSCROLL = 0x115;
//int SB_THUMBPOSITION = 4;
//int SB_HORZ=0;
//int SB_VERT = 1;
//int SB_CTL = 2;
//int SB_BOTH = 3;
//if (geoSigma==null ||geoSigma.GetElementCount()==0)
//{
// Win32API.SetScrollRange(scrollH.Handle, SB_HORZ, 0, 1000,0);
// SCROLLINFO barInfo=new SCROLLINFO();
// Win32API.GetScrollInfo(scrollH.Handle, SB_HORZ, ref barInfo);
// barInfo.nPage=980;
// Win32API.SetScrollInfo(scrollH.Handle, SB_HORZ, ref barInfo, 0);
// Win32API.SetScrollRange(scrollV.Handle, SB_VERT, 0, 1000,0);
// Win32API.GetScrollInfo(scrollV.Handle, SB_VERT, ref barInfo);
// barInfo.nPage=980;
// Win32API.SetScrollInfo(scrollV.Handle, SB_VERT, ref barInfo, 0);
// return;
//}
////获得整图范围
//RectangleD rect = args.RealRect;
//double dx = rect.Width;
//double dy = rect.Height;
//int hts = geoSigma.GetScreenWidth(dx);
//int vts = geoSigma.GetScreenHeight(Math.Abs(dy));
//vts= Math.Abs(vts);
//if (hts>8000) hts=8000;
//if (vts>8000) vts=8000;
//if (hts<100) hts=100;
//if (vts<100) vts=100;
//Win32API.SetScrollRange(scrollH.Handle, SB_HORZ, 0, hts,1);
//Win32API.PostMessage(scrollH.Handle, WM_HSCROLL, SB_THUMBPOSITION+10000*0, 0);
//Win32API.SetScrollRange(scrollV.Handle, SB_VERT, 0, vts,1);
////获得屏幕范围
//Rectangle rcScreen = args.ScreenRect;
//double dLeft = 0.0, dTop = 0.0, dRight = 0.0, dBottom = 0.0;
//geoSigma.GetScreenReal(rcScreen.Left, rcScreen.Top, rcScreen.Right, rcScreen.Bottom, ref dLeft, ref dTop, ref dRight, ref dBottom);
//SCROLLINFO bar = new SCROLLINFO();
//Win32API.GetScrollInfo(scrollH.Handle, SB_HORZ, ref bar);
//bar.nPage=(uint)((dRight-dLeft)/dx*hts);
//if (bar.nPage>(uint)(hts-5)) bar.nPage=(uint)(hts-5);
//Win32API.SetScrollInfo(scrollH.Handle, SB_HORZ, ref bar, 1);
//Win32API.PostMessage(scrollH.Handle, WM_HSCROLL, SB_THUMBPOSITION+10000*bar.nPos, 0);
//Win32API.GetScrollInfo(scrollV.Handle, SB_VERT, ref bar);
//bar.nPage=(uint)((dTop-dBottom)/dy*vts);
//if (bar.nPage>(uint)(vts-5)) bar.nPage=(uint)(vts-5);
//Win32API.SetScrollInfo(scrollV.Handle, SB_VERT, ref bar,1);
////设置当前滚动条位置
//double xm = dLeft-rect.Left;
//double ym = rect.Top-dTop;
//xm=xm/dx*hts;
//ym=ym/dy*vts;
//if (xm<0) xm=0; if (xm>hts) xm=hts;
//if (ym<0) ym=0; if (ym>vts) ym=vts;
//Win32API.SetScrollPos(scrollH.Handle, SB_HORZ, (int)xm, true);
//Win32API.PostMessage(scrollH.Handle, WM_HSCROLL, SB_THUMBPOSITION+10000*(int)xm, 0);
//Win32API.GetScrollInfo(scrollH.Handle, SB_HORZ, ref bar);
//bar.nPos=(int)xm;
//Win32API.SetScrollInfo(scrollH.Handle, SB_HORZ, ref bar, 1);
//Win32API.GetScrollInfo(scrollV.Handle, SB_VERT, ref bar);
//bar.nPos=(int)ym;
//Win32API.SetScrollInfo(scrollV.Handle, SB_VERT, ref bar, 1);
//Win32API.SetScrollPos(scrollH.Handle, SB_HORZ, (uint)(xm));
//SetScrollPos(SB_VERT, AfxGetPublicFunction()->FloatToLong(ym));
/////////////////////////////////////////////////////////////////////////////////////////
//ScrollArgs args = e as ScrollArgs;
////RectangleD mapRange = drawer1.MapRange;
////Rectangle rectS = drawer1.ClientRectangle;
//// 屏幕尺寸
//Rectangle rectS = args.ScreenRect;
//double dLeft = 0.0, dTop = 0.0, dRight = 0.0, dBottom = 0.0;
//// 获得屏幕范围内的实际坐标范围
//geoSigma.GetScreenReal(rectS.Left, rectS.Top, rectS.Right, rectS.Bottom, ref dLeft, ref dTop, ref dRight, ref dBottom);
//// 全图的实际坐标范围
//RectangleD mapRange = args.RealRect;
//int dLeftA = 0, dTopA = 0, dRightA = 0, dBottomA = 0;
//geoSigma.GetRealScreen(mapRange.Left, mapRange.Top, mapRange.Right, mapRange.Bottom
// , ref dLeftA, ref dTopA, ref dRightA, ref dBottomA);
//// 屏幕全图宽度
//double dScreenAx = dRightA-dLeftA;
//double dScreenAy = dBottomA-dTopA;
//// 屏幕显示实际宽度
//double dScreenWidthReal = dRight-dLeft;
//// 屏幕显示实际高度
//double dScreenHeightReal = Math.Abs(dTop-dBottom);
//// 全图的实际宽度
//double dMapWidthReal = mapRange.Width;
//// 全图的实际高度
//double dMapHeightReal = Math.Abs(mapRange.Height);
////// 屏幕全图宽度
////double dScreenAx = (dMapWidthReal/dScreenWidthReal)*rectS.Width;
////double dScreenAy = (dMapHeightReal/dScreenHeightReal)*rectS.Height;
//// 滚动范围设置
//scrollH.Minimum=0;
//scrollV.Minimum=0;
//scrollH.Maximum=(int)(dScreenAx+0.5);
//scrollV.Maximum=(int)(dScreenAy+0.5);
//// 滚动量设置
//int nHLargeChange = (int)(rectS.Width*largeScrollFactor);
//int nHSmallChange = (int)(nHLargeChange*0.2);
//// 水平滚动条滚动量设置
//this.scrollH.LargeChange=nHLargeChange;
//this.scrollH.SmallChange=nHSmallChange;
//int nVLargeChange = (int)(rectS.Height*largeScrollFactor);
//int nVSmallChange = (int)(nVLargeChange*0.2);
//// 垂直滚动条滚动量设置
//this.scrollV.LargeChange=nVLargeChange;
//this.scrollV.SmallChange=nVSmallChange;
//// 计算滚动条位置
//// Fl=Sl/(Sr-Large+1)
//double dFlx = (dLeft-mapRange.X)/dMapWidthReal;
////int nScrollX = (int)(dFlx*(scrollH.Maximum-nHLargeChange+1));
//int nScrollX = (int)(dFlx*(scrollH.Maximum+1));
//double dFly = (mapRange.Top-dTop)/dMapHeightReal;
//// int nScrollY = (int)(dFly*(scrollV.Maximum-nVLargeChange+1));
//int nScrollY = (int)(dFly*(scrollV.Maximum+1));
//// 当前滚动条位置设置
////if (nScrollX<0)
////{
//// scrollH.Value=0;
////}
////else if (nScrollX>scrollH.Maximum)
////{
//// scrollH.Value=scrollH.Maximum;
////}
//scrollH.Value=nScrollX;
//scrollV.Value=nScrollY;
}
/// <summary>
/// 添加并激活新图层
/// </summary>
/// <param name="strLayerName"></param>
/// <param name="doActive">是否激活</param>
public void FindAddLayer(string strLayerName, bool doActive=true)
{
geoSigma.FindAddLayer(strLayerName, doActive);
}
public void DeleteLayer(List<string> layers)
{
geoSigma.DeleteLayer(layers.ToArray());
}
public bool GetLayerStyleData(string layerName, ref string curveStyle, ref string pointStyle)
{
return geoSigma.GetLayerStyleData(layerName, ref curveStyle, ref pointStyle);
}
/// <summary>
/// 滚动条事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Viewer_Scroll(object sender, ScrollEventArgs e)
{
if(e.Type ==ScrollEventType.EndScroll)
{
//Scroll2(800);
return;
}
if (geoSigma==null) return;
if (e.ScrollOrientation==ScrollOrientation.HorizontalScroll)
{
Viewer_ScrollHori(sender, e);
}
else if (e.ScrollOrientation==ScrollOrientation.VerticalScroll)
{
Viewer_ScrollVert(sender, e);
}
scrollPositionYLast=this.VerticalScroll.Value;
}
/// <summary>
/// 水平滚动条
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Viewer_ScrollHori(object sender, ScrollEventArgs e)
{
int nOrientation = (int)(e.ScrollOrientation);//纵向、横向
int nType = (int)e.Type;
//geoSigma.HScroll(nType, e.NewValue, scrollH.Maximum-scrollH.LargeChange+1);
// 屏幕总宽度
int nScreenAllHor = this.scrollH.Maximum-this.scrollH.Minimum;
// 滚动条变化量
int nValue = e.NewValue-e.OldValue;
// 屏幕宽度 Ws
int nWs = drawer1.Width;
// 屏幕实际距离 Wr
double dWtest = geoSigma.GetRealWidth(nValue);
double dWs = geoSigma.GetRealWidth(nWs);
// dOffset = Wr*nValue/Ws;
Console.WriteLine(string.Format("{0}\t{1}", e.NewValue, e.OldValue));
double dOffset = 0;
if (Math.Abs(nValue)<0.01)
{
// TODO:需要进一步修改屏幕滚动范围
if (e.Type==ScrollEventType.SmallIncrement)
{
nValue=this.scrollH.SmallChange;
scrollH.Maximum=scrollH.Maximum+nValue;
double dF = (double)nValue/nWs;
dOffset=dWs*dF;
//drawer1.enlargeRight(dOffset);
needHScrollToEnd=true;
}
else if (e.Type==ScrollEventType.SmallDecrement)
{
nValue=-this.scrollH.SmallChange;
scrollH.Minimum=scrollH.Minimum+nValue;
double dF = (double)nValue/nWs;
dOffset=dWs*dF;
//drawer1.enlargeLeft(Math.Abs(dOffset));
needHScrollToBegin=true;
}
else
{
return;
}
}
else
{
// 计算实际坐标变化量
// 变化比例
//double dF = (double)nValue/(nScreenAllHor-this.scrollH.LargeChange+1);
//dOffset=dF*drawer1.MapRange.Width;
double dF = (double)nValue/nWs;
dOffset=dWs*dF;
}
Console.WriteLine(string.Format("offset {0}", dOffset));
geoSigma.Scroll(nOrientation, dOffset);
geoSigma.EnableRedraw(true);
drawer1.ReDraw();
}
public void Scroll2(int scrollValue)
{
scrollH.Value=scrollValue;
}
/// <summary>
/// 垂直滚动条
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Viewer_ScrollVert(object sender, ScrollEventArgs e)
{
int nType = (int)e.Type;
int nScreenAllVert = this.scrollV.Maximum-this.scrollV.Minimum;
// 滚动条变化量
int nValue = e.NewValue-e.OldValue;
// 屏幕高度 Ws
int nHs = drawer1.Height;
// 屏幕实际距离 Wr
double dHs = geoSigma.GetRealHeight(nHs);
double dOffset = 0;
if (Math.Abs(nValue)<0.01)
{
if (e.Type==ScrollEventType.SmallIncrement)
{
nValue=this.scrollV.SmallChange;
scrollV.Maximum=scrollV.Maximum+nValue;
double dF = (double)nValue/nHs;
dOffset=dHs*dF;
//dOffset=((double)nValue/nScreenAllVert)*drawer1.MapRange.Height;
//drawer1.enlargeBottom(dOffset);
needVScrollToBottom=true;
}
else if (e.Type==ScrollEventType.SmallDecrement)
{
nValue=-this.scrollV.SmallChange;
scrollV.Minimum=scrollV.Minimum+nValue;
double dF = (double)nValue/nHs;
dOffset=dHs*dF;
//dOffset=((double)nValue/nScreenAllVert)*drawer1.MapRange.Height;
//drawer1.enlargeTop(dOffset);
needVScrollToTop=true;
}
else { return; }
}
else
{
//double dF = (double)nValue/(nScreenAllVert-this.scrollV.LargeChange+1);
//dOffset=dF* drawer1.MapRange.Height;
double dF = (double)nValue/nHs;
dOffset=dHs*dF;
}
geoSigma.Scroll((int)(e.ScrollOrientation), -dOffset);
geoSigma.EnableRedraw(true);
drawer1.ReDraw();
//this.InvokePaint(drawer1, new PaintEventArgs(drawer1.CreateGraphics(), drawer1.ClientRectangle));
}
public void ZoomIn()
{
drawer1.ZoomIn();
}
public void ZoomOut()
{
drawer1.ZoomOut();
}
public void ViewAll()
{
drawer1.ViewAll();
}
private void Viewer_Resize(object sender, EventArgs e)
{
//drawer1.ReDraw();
}
public void ReDrawWindow()
{
drawer1.ReDrawWindow();
}
///// <summary>
/////
///// </summary>
///// <param name="Bitmap"></param>
///// <returns></returns>
//private static Image Bitmap2Image(System.Drawing.Bitmap Bi)
//{
// MemoryStream ms = new MemoryStream();
// Bi.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
// BitmapImage bImage = new BitmapImage();
// bImage.BeginInit();
// bImage.StreamSource=new MemoryStream(ms.ToArray());
// bImage.EndInit();
// ms.Dispose();
// Bi.Dispose();
// Image i = new Image();
// i.Source=bImage;
// return i;
//}
}
public struct RectangleD
{
//
// 摘要:
// 表示实例 System.Drawing.RectangleF 未初始化其成员的类。
/// <summary>
/// 左下角为X,Y
/// </summary>
public static RectangleD Empty
{
get
{
return new RectangleD(0, 0, 0, 0);
}
}
////
//// 摘要:
//// 用指定的位置和大小初始化 System.Drawing.RectangleF 类的新实例。
////
//// 参数:
//// location:
//// System.Drawing.PointF它表示矩形区域的左上角。
////
//// size:
//// System.Drawing.SizeF它表示矩形区域的宽度和高度。
//public RectangleD(PointF location, SizeF size);
//
// 摘要:
// 用指定的位置和大小初始化 System.Drawing.RectangleF 类的新实例。
//
// 参数:
// x:
// 矩形左上角的 x 坐标。
//
// y:
// 矩形左上角的 y 坐标。
//
// width:
// 矩形的宽度。
//
// height:
// 矩形的高度。
public RectangleD(double x, double y, double width, double height)
{
this.X=x;
this.Y=y;
this.Width=width;
this.Height=height;
//this._Top=this.Y;
}
//
// 摘要:
// 获取是之和的 x 坐标 System.Drawing.RectangleF.X 和 System.Drawing.RectangleF.Width 此 System.Drawing.RectangleF
// 结构。
//
// 返回结果:
// 之和的 x 坐标 System.Drawing.RectangleF.X 和 System.Drawing.RectangleF.Width 此 System.Drawing.RectangleF
// 结构。
[Browsable(false)]
public double Right { get { return this.X+this.Width; } }
//private double _Top;
//
// 摘要:
// 获取此 System.Drawing.RectangleF 结构上边缘的 y 坐标。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构上边缘的 y 坐标。
[Browsable(false)]
public double Top { get { return this.Y+this.Height; } }
//private double _Left;
//
// 摘要:
// 获取此 System.Drawing.RectangleF 结构左边缘的 x 坐标。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构左边缘的 x 坐标。
[Browsable(false)]
public double Left { get { return this.X; } }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 结构的高度。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构的高度。 默认值为 0。
public double Height { get; set; }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 结构的宽度。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构的宽度。 默认值为 0。
public double Width { get; set; }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 结构左上角的 y 坐标。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构左上角的 y 坐标。 默认值为 0。
public double Y { get; set; }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 结构左上角的 x 坐标。
//
// 返回结果:
// 此 System.Drawing.RectangleF 结构左上角的 x 坐标。 默认值为 0。
public double X { get; set; }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 的大小。
//
// 返回结果:
// System.Drawing.SizeF它表示此 System.Drawing.RectangleF 结构的宽度和高度。
//[Browsable(false)]
//public SizeF Size { get; set; }
//
// 摘要:
// 获取或设置此 System.Drawing.RectangleF 结构左上角的坐标。
//
// 返回结果:
// System.Drawing.PointF它表示此 System.Drawing.RectangleF 结构的左上角。
//[Browsable(false)]
//public PointF Location { get; set; }
//
// 摘要:
// 获取是之和的 y 坐标 System.Drawing.RectangleF.Y 和 System.Drawing.RectangleF.Height 此
// System.Drawing.RectangleF 结构。
//
// 返回结果:
// 之和的 y 坐标 System.Drawing.RectangleF.Y 和 System.Drawing.RectangleF.Height 此 System.Drawing.RectangleF
// 结构。
[Browsable(false)]
public double Bottom {
get
{
return this.Y;
}
}
//
// 摘要:
// 测试是否 System.Drawing.RectangleF.Width 或 System.Drawing.RectangleF.Height 属性 System.Drawing.RectangleF
// 值为零。
//
// 返回结果:
// 此属性返回 true 如果 System.Drawing.RectangleF.Width 或 System.Drawing.RectangleF.Height
// 属性 System.Drawing.RectangleF 值为零; 否则为 false。
[Browsable(false)]
public bool IsEmpty
{
get
{
return false;
}
}
//
// 摘要:
// 创建 System.Drawing.RectangleF 结构具有窗口左上角和右下角位于指定位置。
//
// 参数:
// left:
// 该矩形区域的左上角 x 坐标。
//
// top:
// 该矩形区域的左上角 y 坐标。
//
// right:
// 该矩形区域的右下角 x 坐标。
//
// bottom:
// 该矩形区域的右下角 y 坐标。
//
// 返回结果:
// 此方法创建的新 System.Drawing.RectangleF。
public static RectangleD FromLTRB(double left, double top, double right, double bottom)
{
return new RectangleD(left, bottom, right-left, top-bottom);
}
//
// 摘要:
// 创建并返回指定 System.Drawing.RectangleF 结构的放大副本。 该副本被放大指定量并不修改原始矩形。
//
// 参数:
// rect:
// 要复制的 System.Drawing.RectangleF。 不修改此矩形。
//
// x:
// 水平副本的矩形的放大量。
//
// y:
// 副本的矩形垂直放大量。
//
// 返回结果:
// 放大的 System.Drawing.RectangleF。
//public static RectangleD Inflate(RectangleD rect, double x, double y);
//
// 摘要:
// 返回 System.Drawing.RectangleF 结构,它表示两个矩形交集。 如果没有重叠和空 System.Drawing.RectangleF
// 返回。
//
// 参数:
// a:
// 要相交的矩形。
//
// b:
// 要相交的矩形。
//
// 返回结果:
// 第三个 System.Drawing.RectangleF 结构的大小表示两个指定的矩形的重叠的区域。
//public static RectangleD Intersect(RectangleD a, RectangleD b);
//
// 摘要:
// 创建可以包含两个形成并集的两个矩形的最小可能第三个矩形。
//
// 参数:
// a:
// 要合并的矩形。
//
// b:
// 要合并的矩形。
//
// 返回结果:
// 第三个 System.Drawing.RectangleF 结构,其中包含这两个形成并集的两个矩形。
//public static RectangleD Union(RectangleD a, RectangleD b);
//
// 摘要:
// 确定指定的点是否包含在此 System.Drawing.RectangleF 结构内。
//
// 参数:
// x:
// 要测试的点的 X 坐标。
//
// y:
// 要测试的点的 Y 坐标。
//
// 返回结果:
// 如果 x 和 y 定义的点包含在此 System.Drawing.RectangleF 结构中,此方法将返回 true否则将返回 false。
public bool Contains(double x, double y)
{
return (x>=this.Left&&x<=this.Right
&& y>=this.Bottom && y<=this.Top);
}
//
// 摘要:
// 确定指定的点是否包含在此 System.Drawing.RectangleF 结构内。
//
// 参数:
// pt:
// 要测试的 System.Drawing.PointF。
//
// 返回结果:
// 此方法返回 true 如果表示的点 pt 参数包含在此 System.Drawing.RectangleF 结构; 否则为 false。
//public bool Contains(PointF pt);
//
// 摘要:
// 确定 rect 表示的矩形区域是否完全包含在此 System.Drawing.RectangleF 结构内。
//
// 参数:
// rect:
// 要测试的 System.Drawing.RectangleF。
//
// 返回结果:
// 此方法返回 true 如果表示矩形区域 rect 所表示的矩形区域范围内完全包含 System.Drawing.RectangleF; 否则为 false。
//public bool Contains(RectangleD rect);
//
// 摘要:
// 测试是否 obj 是 System.Drawing.RectangleF 具有相同的位置和大小的 System.Drawing.RectangleF。
//
// 参数:
// obj:
// 要测试的 System.Object。
//
// 返回结果:
// 此方法返回 true 如果 obj 是 System.Drawing.RectangleF 并将其 X, Y, Width, ,和 Height 的对应属性相等
// System.Drawing.RectangleF; 否则为 false。
public override bool Equals(object obj)
{
return this==(RectangleD)obj;
}
//
// 摘要:
// 获取此哈希代码 System.Drawing.RectangleF 结构。 有关使用哈希代码的信息,请参阅 Object.GetHashCode。
//
// 返回结果:
// 此 System.Drawing.RectangleF 的哈希代码。
//public override int GetHashCode()
//{
// return 1;
//}
//
// 摘要:
// 将此 System.Drawing.RectangleF 放大指定量。
//
// 参数:
// size:
// 此矩形的放大量。
//public void Inflate(SizeF size);
//
// 摘要:
// 这将放大 System.Drawing.RectangleF 结构指定的量。
//
// 参数:
// x:
// 这样的放大量 System.Drawing.RectangleF 结构的水平。
//
// y:
// 这样的放大量 System.Drawing.RectangleF 结构的垂直。
//public void Inflate(float x, float y);
//
// 摘要:
// 将此 System.Drawing.RectangleF 结构替换为其自身与指定的 System.Drawing.RectangleF 结构的交集。
//
// 参数:
// rect:
// 要相交的矩形。
//public void Intersect(RectangleD rect);
//
// 摘要:
// 确定此矩形是否与 rect 相交。
//
// 参数:
// rect:
// 要测试的矩形。
//
// 返回结果:
// 此方法返回 true 如果重叠。
//public bool IntersectsWith(RectangleD rect);
//
// 摘要:
// 将此矩形的位置调整指定的量。
//
// 参数:
// x:
// 该位置的水平偏移量。
//
// y:
// 该位置的垂直偏移量。
public void Offset(double x, double y)
{
this.X+=x;
this.Y+=y;
}
//
// 摘要:
// 将此矩形的位置调整指定的量。
//
// 参数:
// pos:
// 该位置的偏移量。
//public void Offset(PointF pos);
//
// 摘要:
// 将转换 Location 和 System.Drawing.Size 此 System.Drawing.RectangleF 到用户可读字符串。
//
// 返回结果:
// 一个字符串,包含位置、 宽度和高度这 System.Drawing.RectangleF 结构。 例如,"{X = 20Y = 20Width = 100Height
// = 50}"。
//public override string ToString();
//
// 摘要:
// 测试两个 System.Drawing.RectangleF 结构的位置和大小是否相同。
//
// 参数:
// left:
// 相等运算符左侧的 System.Drawing.RectangleF 结构。
//
// right:
// 相等运算符右侧的 System.Drawing.RectangleF 结构。
//
// 返回结果:
// 此运算符可返回 true 如果两个指定 System.Drawing.RectangleF 结构具有相等 System.Drawing.RectangleF.X,
// System.Drawing.RectangleF.Y, System.Drawing.RectangleF.Width, ,和 System.Drawing.RectangleF.Height
// 属性。
public static bool operator ==(RectangleD left, RectangleD right)
{
if(left.Left == right.Left && left.Top == right.Top
&& left.Right==right.Right && left.Bottom ==right.Bottom)
{
return true;
}
return false;
}
//
// 摘要:
// 测试两个 System.Drawing.RectangleF 结构的位置或大小是否不同。
//
// 参数:
// left:
// 不等运算符左侧的 System.Drawing.RectangleF 结构。
//
// right:
// 不等运算符右侧的 System.Drawing.RectangleF 结构。
//
// 返回结果:
// 此运算符可返回 true 如果任一 System.Drawing.RectangleF.X , System.Drawing.RectangleF.Y,
// System.Drawing.RectangleF.Width, ,或 System.Drawing.RectangleF.Height 的两个属性 System.Drawing.Rectangle
// 结构是否不相等; 否则为 false。
public static bool operator !=(RectangleD left, RectangleD right)
{
return !(left==right);
}
//
// 摘要:
// 将指定 System.Drawing.Rectangle 结构 System.Drawing.RectangleF 结构。
//
// 参数:
// r:
// System.Drawing.Rectangle 要转换的结构。
//
// 返回结果:
// System.Drawing.RectangleF 结构,它是从指定转换 System.Drawing.Rectangle 结构。
public static implicit operator RectangleD(Rectangle r)
{
return new RectangleD(r.X, r.Y, r.Width, r.Height);
}
}
}