public FormZoneCollisionData(UserRect activeRect, Map.ZoneColorDetection zoneColorDetection) { InitializeComponent(); Rectangle rect = activeRect.GetRectangle(); numericUpDownX.Value = rect.X; numericUpDownY.Value = rect.Y; numericUpDownW.Value = rect.Width; numericUpDownH.Value = rect.Height; switch (zoneColorDetection) { case Map.ZoneColorDetection.Flag0: radioButtonFlag0.Checked = true; break; case Map.ZoneColorDetection.Flag1: radioButtonFlag1.Checked = true; break; default: radioButtonAlways.Checked = true; break; } }
private UserRect AddInZones(Rectangle rect, float zoom = 1.0F) { UserRect userRect = new UserRect(rect, zoom); userRect.SetPictureBox(this.pictureBox1); userRects.Add(userRect); flags.Add(ZoneColorDetection.Always); pictureBox1.Invalidate(); return(userRect); }
private void mPictureBox_MouseDown(object sender, MouseEventArgs e) { UserRect newActiveRect = null; foreach (UserRect rect in userRects) { if (rect.isUnder(e.Location)) { newActiveRect = rect; } } if (newActiveRect != ActiveRect) { ActiveRect = newActiveRect; } ActiveRect?.mPictureBox_MouseDown(sender, e); }
private static void ImportColorDetection(XElement mapElemept, string tagName, ref TypeColorDetection ColpfDectection, ref List <Rectangle> ColpfDectectionRect, ref List <ZoneColorDetection> ColpfDetectionFlags) { if (mapElemept.Elements(tagName).Any()) { XElement Colpf2Dectection = mapElemept.Element(tagName); if (Colpf2Dectection.Elements("Type").Any()) { ColpfDectection = (TypeColorDetection)Enum.Parse(typeof(TypeColorDetection), Colpf2Dectection.Element("Type").Value.Trim()); if ((ColpfDectection == TypeColorDetection.Inside || ColpfDectection == TypeColorDetection.Outside) && Colpf2Dectection.Elements("Zones").Any()) { foreach (XElement item in Colpf2Dectection.Element("Zones").Descendants("rect")) { UserRect a = UserRect.FromXElement(item); if (a != null) { ColpfDectectionRect.Add(a.GetRectangle()); } } if (Colpf2Dectection.Elements("Flags").Any()) { foreach (XElement item in Colpf2Dectection.Element("Flags").Descendants("Flag")) { var zoneColorDetection = (ZoneColorDetection)Enum.Parse(typeof(ZoneColorDetection), item.Value.Trim()); ColpfDetectionFlags.Add(zoneColorDetection); } } if (ColpfDetectionFlags.Count != ColpfDectectionRect.Count) { ColpfDetectionFlags.Clear(); for (int i = 0; i < ColpfDectectionRect.Count; i++) { ColpfDetectionFlags.Add(ZoneColorDetection.Always); } } } } } }