public ZonePointsDatabase(string zone, MySqlConnection connection, QueryConfig config)
            : base(zone,config)
        {
            _connection = connection;
            string sql = String.Format(SelectString, SelectArgValues);
            var results = QueryHelper.RunQuery(_connection, sql);

            ZonePoint zp;

            if (results != null)
            {
                foreach (Dictionary<string, object> row in results)
                {
                    zp = new ZonePoint(_queryConfig);
                    zp.SetProperties(Queries, row);
                    zp.Created();
                    Points.Add(zp);
                }
            }

            Created();
        }
 public void ShowPoint(ZonePoint pt, DisplayFlags flags=DisplayFlags.None)
 {
     if (pt == null) return;
     CreatePoint(pt,flags);
 }
        private void HidePoint(ZonePoint pt)
        {
            Model3DGroup group = Model as Model3DGroup;
            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(pt))
            {
                foreach (Model3D model in _mapping[pt])
                {
                    group.Children.Remove(model);
                }
            }
        }
        private void CreatePoint(ZonePoint zp,DisplayFlags flags)
        {
            Model3DGroup group = Model as Model3DGroup;
            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(zp))
            {
                foreach (Model3D model in _mapping[zp])
                {
                    group.Children.Remove(model);
                }
            }

            double px, py, pz;
            px = zp.X == 999999 ? 0 : zp.X;
            py = zp.Y == 999999 ? 0 : zp.Y;
            pz = zp.Z == 999999 ? 0 : zp.Z;

            Point3D p = new Point3D(px,py,pz);

            if (!Clipping.DrawPoint(p)) return;

            MeshBuilder builder = new MeshBuilder();
            builder.AddBox(p, 20, 20, 2);

            //connect box to destination
            px = zp.TargetX == 999999 ? px : zp.TargetX;
            py = zp.TargetY == 999999 ? py : zp.TargetY;
            pz = zp.TargetZ == 999999 ? pz : zp.TargetZ;

            GeometryModel3D box;
            box = new GeometryModel3D(builder.ToMesh(), Materials.Red);
            collection.Add(box);

            builder = new MeshBuilder();
            Point3D destP = new Point3D(px, py, pz);
            builder.AddArrow(p, destP, 0.5);
            builder.AddBox(destP, 20, 20, 2);

            if (zp.X == 999999 || zp.Y == 999999 || zp.Z == 999999 ||
                zp.TargetX == 999999 || zp.TargetY == 999999 || zp.TargetZ == 999999)
            {
                box = new GeometryModel3D(builder.ToMesh(), Materials.Gold);
            }
            else
            {
                box = new GeometryModel3D(builder.ToMesh(), Materials.White);
            }

            collection.Add(box);

            if (flags != DisplayFlags.None)
            {
                builder = new MeshBuilder();

                if (flags.HasFlag(DisplayFlags.DarkGrayAura))
                {
                    builder.AddBox(p, 25,25, 1);
                    builder.AddBox(destP, 25, 25, 1);
                    box = new GeometryModel3D(builder.ToMesh(), Materials.DarkGray);
                    collection.Add(box);
                }
                else if (flags.HasFlag(DisplayFlags.GreenAura))
                {
                    builder.AddBox(p, 25, 25, 1);
                    builder.AddBox(destP, 25, 25, 1);
                    box = new GeometryModel3D(builder.ToMesh(), Materials.Green);
                    collection.Add(box);
                }
            }

            _mapping[zp] = collection;

            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }
        }
Beispiel #5
0
        public ZonePoint Create()
        {
            ZonePoint zp = new ZonePoint(_queryConfig);
            zp.Zone = Zone;
            if (_zonePoints.Count > 0)
            {
                zp.Number = _zonePoints.Max(x => x.Number) + 1;
            }
            else zp.Number = 1;
            zp.Created();
            Add(zp);

            return zp;
        }
Beispiel #6
0
        public void Add(ZonePoint zp)
        {
            if (Points.Contains(zp)) return;

            AddObject(zp);
            Points.Add(zp);
        }
Beispiel #7
0
 public void Remove(ZonePoint zp)
 {
     if (!Points.Contains(zp)) return;
     RemoveObject(zp);
     Points.Remove(zp);
 }