public void Update(IVehicleControl paramControl) { IVehicleControl control = ControlFactory.GetSingleton().VehicleControl; AbsoluteDirection direction = control.GetDirection(); if (control.GetSpeed() < 0) { direction = (AbsoluteDirection)(((int)direction + 2) % 4); } string move = string.Empty; if (control.GetSpeed() != 0) { move = control.GetName() + " heading " + direction.ToString() + " at speed: " + control.GetSpeed().ToString(); } else { move = control.GetName() + " is parked facing " + direction.ToString(); } SetControlPropertyThreadSafe(this.label1, "Text", move); int maxSpeed = (control.GetSpeed() > 0) ? control.GetMaxSpeed() : control.GetMaxReverseSpeed(); SetControlPropertyThreadSafe(this.pBar, "Value", (maxSpeed == 0) ? 0 : control.GetSpeed() * 100 / maxSpeed); }
public IVehicleControl CreateVehicleControl(Type type, IVehicleModel model) { List <IVehicleView> aList = null; if (control != null) { aList = control.GetObservers(); } control = Activator.CreateInstance(type, model) as IVehicleControl; if (aList != null) { foreach (IVehicleView paramView in aList) { control.AddObserver(paramView); } } return(control); }
public void Update(IVehicleControl paramControl) { AbsoluteDirection direction = paramControl.GetDirection(); if (paramControl.GetSpeed() < 0) { direction = (AbsoluteDirection)(((int)direction + 2) % 4); } string move = string.Empty; if (paramControl.GetSpeed() != 0) { move = paramControl.GetName() + " heading " + direction.ToString() + " at speed: " + paramControl.GetSpeed().ToString(); } else { move = paramControl.GetName() + " is parked facing " + direction.ToString(); } System.Console.WriteLine(move); }
private void WrapUp(IVehicleControl control, IVehicleModule module) { }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle rectangle = new Rectangle(10, 10, 300, 300); Brush brush = new SolidBrush(Color.Black); e.Graphics.FillEllipse(brush, rectangle); rectangle = new Rectangle(15, 15, 290, 290); Pen pen = new Pen(Color.Wheat, 5); Pen thinPen = new Pen(Color.Wheat, 2); e.Graphics.DrawArc(pen, rectangle, 0, 360); int cijfer = 0; string drawString = cijfer.ToString(); Font drawFont = new System.Drawing.Font("Arial", 16); SolidBrush drawBrush = new SolidBrush(Color.Wheat); IVehicleControl control = ControlFactory.GetSingleton().VehicleControl; int maxSpeed = control.GetMaxSpeed(); int displayInterval = control.GetDisplayInterval(); int nbr = maxSpeed / displayInterval + 1; float rotateN = 270f / nbr; float rotateF = rotateN / (displayInterval / 5); this.kmPointer.RotateRatioPerKm = rotateN / displayInterval; e.Graphics.TranslateTransform(160.0f, 160.0f); e.Graphics.RotateTransform(-135.0f); for (int i = 0; i <= nbr; i++) { SizeF size = e.Graphics.MeasureString(drawString, drawFont); float corrWidth = size.Width / 2; float corrHeight = size.Height / 2; e.Graphics.TranslateTransform(0.0f, -85.0f); e.Graphics.RotateTransform((-135.0f + i * rotateN) * -1.0f); e.Graphics.TranslateTransform(-corrWidth, -corrHeight); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, 0); e.Graphics.TranslateTransform(corrWidth, corrHeight); e.Graphics.RotateTransform(-135.0f + i * rotateN); e.Graphics.TranslateTransform(0.0f, 85.0f); cijfer += displayInterval; drawString = cijfer.ToString(); e.Graphics.DrawLine(pen, 0, -130, 0, -110); e.Graphics.RotateTransform(rotateF); if (i < nbr) { for (int x = 0; x < displayInterval / 5 - 1; x++) { if ((x % 2) == 0) { e.Graphics.DrawLine(thinPen, 0, -130, 0, -115); } else { e.Graphics.DrawLine(thinPen, 0, -130, 0, -110); } e.Graphics.RotateTransform(rotateF); } } } e.Graphics.ResetTransform(); }
public void Update(IVehicleControl paramControl) { IVehicleControl control = ControlFactory.GetSingleton().VehicleControl; this.kmPointer.KM = control.GetSpeed(); }
public void WireUp(IVehicleControl paramControl, IVehicleModel paramModel) { if(Model != null) { Model.RemoveObserver(this); } Model = paramModel; Control = paramControl; Control.SetModel(Model); Control.SetView(this); Model.AddObserver(this); }