コード例 #1
0
 public TargetForm(TargetComponent targetTarget)
 {
     InitializeComponent();
     typeComboBox.DataSource = Enum.GetValues(typeof(PositionType));
     SetPositionType(targetTarget.TargetPosition.Type);
     hComponent = targetTarget;
     Tag        = targetTarget;
     RefreshValues();
     Text = hComponent.TargetName + " (Target)";
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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());
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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");
        }
コード例 #8
0
 public TargetIcon(TargetComponent h)
 {
     Cursor = Cursors.Hand;
     InitializeComponent();
     Tag = h;
 }