111,076
社区成员




public partial class LocationIndicator : UserControl
{
public LocationIndicator()
{
InitializeComponent();
this.exLabel1.Size = new Size(57, 21);
ChangeStatusSwitch = true;
this.pictureBox1.Visible = true;
this.mapIndicator1.Visible = false;
this.exLabel1.Visible = false;
this.ContextMenuStrip = this.contextMenuStrip1;
}
public LocationIndicator(Point LocationOfStation,Point LocationOfMap)
: this()
{
try
{
StationLocation = LocationOfStation;
MapLocation = LocationOfMap;
this.Left = StationLocation.X;
this.Top = StationLocation.Y;
this.mapIndicator1.usercontrollocation = LocationOfStation;
}
catch
{
}
}
public LocationIndicator(Point LocationOfStation, Point LocationOfMap, String sinformation)
: this()
{
StationLocation = LocationOfStation;
MapLocation = LocationOfMap;
this.Left = StationLocation.X;
this.Top = StationLocation.Y;
this.Information = sinformation;
ChangeStatusSwitch = false;
}
public Point StationLocation;
private Point MapLocation;
public String information;
public EventHandler OperationAdd;
public EventHandler OperationDelete;
public String Information
{
get { return information; }
set { information = value; }
}
private Int32 x1 = 0;
private Int32 y1 = 0;
private Int32 x2 = 0;
private Int32 y2 = 0;
private bool changeStatusSwitch;
public bool ChangeStatusSwitch
{
get { return changeStatusSwitch; }
set { changeStatusSwitch = value; }
}
public void ChangeStatus()
{
if (ChangeStatusSwitch == true)
{
this.pictureBox1.Image = global::Ark.Controls.Business.Properties.Resources.StandardImage;
this.mapIndicator1.Visible = true;
this.mapIndicator1.Size = new Size(28, 21);
this.exLabel1.Visible = false;
if (this.Information != null)
{
this.mapIndicator1.Text = this.Information;
}
ChangeStatusSwitch = false;
this.mapIndicator1.Focus();
}
else
{
this.pictureBox1.Image = global::Ark.Controls.Business.Properties.Resources.ActiveImage;
this.mapIndicator1.Visible = false;
this.exLabel1.Visible = true;
this.exLabel1.Text = this.Information;
ChangeStatusSwitch = true;
}
}
private void LocationIndicator_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
if (this.mapIndicator1.Text == String.Empty)
{
MessageBox.Show("not empty");
return;
}
this.Information = this.mapIndicator1.Text;
this.ChangeStatus();
if (this.OperationAdd != null)
{
EventHandler tmp = this.OperationAdd;
tmp(sender, null);
}
}
}
private void LocationIndicator_MouseMove(object sender, MouseEventArgs e)
{
this.Cursor = System.Windows.Forms.Cursors.SizeAll;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
x1 = e.X;
y1 = e.Y;
}
}
private void LocationIndicator_MouseUp(object sender, MouseEventArgs e)
{
x2 = e.X;
y2 = e.Y;
if (e.Button == MouseButtons.Left)
{
if (x1 != 0 && y1 != 0)
{
this.Left = this.Left + x2 - x1;
this.Top = this.Top + y2 - y1;
}
if (x2 != x1 && y2 != y1)
{
this.ChangeStatus();
}
}
}
private void LocationIndicator_DoubleClick(object sender, EventArgs e)
{
this.ChangeStatus();
}
void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
Control c = contextMenuStrip1.SourceControl as Control;
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add("Edit");
contextMenuStrip1.Items.Add("-");
contextMenuStrip1.Items.Add("Delete");
e.Cancel = false;
}
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
this.ChangeStatus();
}
public void editToolStripMenuItem_Click(object sender, EventArgs e)
{
this.ChangeStatus();
}
public void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Dispose();
if (this.OperationDelete != null)
{
EventHandler tmp = this.OperationDelete;
tmp(sender, null);
}
}
}
[ToolboxItem(true)]
public partial class Station : Control
{
public Station()
{
InitializeComponent();
System.Resources.ResourceManager rm =
new System.Resources.ResourceManager("Ark.Controls.Business.Station",
System.Reflection.Assembly.GetExecutingAssembly());
try
{
standardImage = (Bitmap)rm.GetObject("StandImage");
//TODO: if other tickets
}
catch
{
}
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
Bitmap standardImage;
public Bitmap StandardImage
{
get { return standardImage; }
set { standardImage = value; }
}
Bitmap activeImage;
public Bitmap ActiveImage
{
get { return activeImage; }
set { activeImage = value; }
}
private Int32 x1 = 0;
private Int32 y1 = 0;
private List<MapIndicator> mapIndicators = new List<MapIndicator>();
private List<Point> points = new List<Point>();
protected override void OnMouseMove(MouseEventArgs e)
{
this.Cursor = System.Windows.Forms.Cursors.SizeAll;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
x1 = e.X;
y1 = e.Y;
}
base.OnMouseMove(e);
}
protected override void OnMouseUp(MouseEventArgs mevent)
{
if (x1 != 0 && y1 != 0)
{
this.Left = this.Left + x1;
this.Top = this.Top + y1;
}
base.OnMouseUp(mevent);
}
protected override void OnMouseDoubleClick(MouseEventArgs e)
{
if (mapIndicators.Count == 0)
{
points.Add(new Point(this.Left, this.Top));
MapIndicator one = new MapIndicator(points[0]);
one.Show();
mapIndicators.Add(one);
}
base.OnMouseDoubleClick(e);
}