Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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);
                            }
                        }
                    }
                }
            }
        }