00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 using System;
00054 using System.Drawing;
00055
00056 namespace NPlot
00057 {
00061 public class TextItem : IDrawable
00062 {
00063 private void Init()
00064 {
00065 FontFamily fontFamily = new FontFamily("Arial");
00066 font_ = new Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel);
00067 }
00068
00074 public TextItem( PointD position, string text )
00075 {
00076 start_ = position;
00077 text_ = text;
00078 Init();
00079 }
00080
00081
00085 public string Text
00086 {
00087 get
00088 {
00089 return text_;
00090 }
00091 set
00092 {
00093 text_ = value;
00094 }
00095 }
00096 private string text_ = "";
00097
00098
00102 public PointD Start
00103 {
00104 get
00105 {
00106 return start_;
00107 }
00108 set
00109 {
00110 start_ = value;
00111 }
00112 }
00113 private PointD start_;
00114
00115
00122 public void Draw( System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
00123 {
00124 Point startPoint = new Point(
00125 (int)xAxis.WorldToPhysical( start_.X, true ).X,
00126 (int)yAxis.WorldToPhysical( start_.Y, true ).Y );
00127
00128 g.DrawString(text_, font_, textBrush_,(int)startPoint.X,(int)startPoint.Y);
00129 }
00130
00131
00135 public Brush TextBrush
00136 {
00137 get
00138 {
00139 return textBrush_;
00140 }
00141 set
00142 {
00143 textBrush_ = value;
00144 }
00145 }
00146
00147
00151 public Color TextColor
00152 {
00153 set
00154 {
00155 textBrush_ = new SolidBrush( value );
00156 }
00157 }
00158
00162 public Font TextFont
00163 {
00164 get
00165 {
00166 return this.font_;
00167 }
00168 set
00169 {
00170 this.font_ = value;
00171 }
00172 }
00173
00174 private Brush textBrush_ = new SolidBrush( Color.Black );
00175 private Pen pen_ = new Pen( Color.Black );
00176 private Font font_;
00177 }
00178 }