public TargetForm(TargetComponent targetTarget) { InitializeComponent(); typeComboBox.DataSource = Enum.GetValues(typeof(PositionType)); SetPositionType(targetTarget.TargetPosition.Type); hComponent = targetTarget; Tag = targetTarget; RefreshValues(); Text = hComponent.TargetName + " (Target)"; }
public void AddRandomTarget(TargetType type) { Int32 seed = Convert.ToInt32(DateTime.Now.Ticks % 0x7fffffff); Random generator = new Random(seed); double longitude = generator.NextDouble() * 360.0 - 180.0; double latitude = generator.NextDouble() * 180.0 - 90.0; TargetComponent newTarget = new TargetComponent(latitude, longitude); newTarget.Type = type; AddTarget(newTarget); }
public object Clone() { // Returns a deep (value-wise) copy of the object TargetComponent copy = new TargetComponent(); copy._maxTimes = _maxTimes; copy._targetName = _targetName; copy._task = _task; copy._type = _type; copy._value = _value; return(copy); }
public void AddTarget(TargetComponent newTarget) { string targetName = "Target " + (Targets.Count + 1).ToString(); newTarget.TargetName = targetName; Targets.Add(newTarget); TreeNode newTargetNode = new TreeNode(targetName); newTargetNode.Tag = newTarget; if (hNode != null) { hNode.Nodes.Add(newTargetNode); } }
public void Clone(object value) { // Writes a deep (value-wise) copy onto the object from value if (value.GetType() == typeof(TargetComponent)) { TargetComponent v = (TargetComponent)value; _maxTimes = v._maxTimes; _targetName = v._targetName; _task = v._task; _type = v._type; _value = v._value; TargetPosition = (Position)(v.TargetPosition.Clone()); } }
public override bool Deserialize(string filename) { // Clears targetdeck, then imports all targets from given file Targets.Clear(); XmlDocument xDoc = new XmlDocument(); xDoc.Load(filename); XmlNodeList targets = xDoc.GetElementsByTagName("TARGET"); foreach (XmlNode node in targets) { TargetComponent newTarget = new TargetComponent((XmlElement)node); Targets.Add(newTarget); } return(true); }
public void AddNewTarget(double latitude, double longitude) { TargetdeckComponent before = (TargetdeckComponent)hComponent.Clone(); // Create new component TargetComponent newTarget = new TargetComponent(latitude, longitude); hComponent.AddTarget(newTarget); // Create new icon double x = (longitude + 180.0) * worldMap.Size.Width / 360.0; double y = (latitude + 90.0) * worldMap.Size.Height / 180.0; TargetIcon newIcon = new TargetIcon(newTarget); newIcon.Location = new Point((int)x, (int)y); newIcon.Visible = true; newIcon.Tag = newTarget; targetIcons.Add(newIcon); Controls.Add(newIcon); newIcon.BringToFront(); // Register event _mManager.RegisterEvent(before, hComponent, hComponent, "Add Target"); }
public TargetIcon(TargetComponent h) { Cursor = Cursors.Hand; InitializeComponent(); Tag = h; }