Exemplo n.º 1
0
        public FormColision(Map map, TypeColorDetection DetectionType, List <Rectangle> DetectionRects, List <ZoneColorDetection> DetectionFlags, String title)
        {
            InitializeComponent();

            Text = title ?? "Color Detection";

            Map = map;
            this.zoneCollisionUserControl1.Map = map;

            this.zoneCollisionUserControl1.Zones = DetectionRects;
            this.zoneCollisionUserControl1.Flags = DetectionFlags;

            this.comboBoxColorDetection.SelectedIndex = (int)DetectionType;
        }
Exemplo n.º 2
0
        static private XElement ExportColorDetection(string tagName, TypeColorDetection ColpfDectection, List <Rectangle> ColpfDectectionRect, List <ZoneColorDetection> ColpfDetectionFlags)
        {
            XElement XElementColpfDectection = new XElement(tagName, new XElement("Type", ColpfDectection));

            if (ColpfDectection == TypeColorDetection.Inside || ColpfDectection == TypeColorDetection.Outside)
            {
                XElement XElementZone = new XElement("Zones");
                foreach (RectangleF rect in ColpfDectectionRect)
                {
                    XElementZone.Add(new XElement("rect", new XElement("Top", rect.Top), new XElement("Left", rect.Left), new XElement("Bottom", rect.Bottom), new XElement("Right", rect.Right)));
                }

                XElementColpfDectection.Add(XElementZone);

                XElement XElementFlags = new XElement("Flags");
                foreach (ZoneColorDetection flag in ColpfDetectionFlags)
                {
                    XElementFlags.Add(new XElement("Flag", flag));
                }

                XElementColpfDectection.Add(XElementFlags);
            }
            return(XElementColpfDectection);
        }
Exemplo n.º 3
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);
                            }
                        }
                    }
                }
            }
        }