예제 #1
0
        private void AddFloorPlan()
        {
            var ofp = new objectsFloorplan
            {
                objects = new objectsFloorplanObjects { @object = new objectsFloorplanObjectsEntry[0] },
                id = -1,
                image = "",
                height = 480,
                width = 640,
                x = Convert.ToInt32(Random.NextDouble() * 100),
                y = Convert.ToInt32(Random.NextDouble() * 100),
                name = LocRm.GetString("FloorPlan") + " " + NextFloorPlanId
            };

            var fpc = new FloorPlanControl(ofp, this) { BackColor = Conf.BackColor.ToColor() };
            _pnlCameras.Controls.Add(fpc);

            fpc.Location = new Point(ofp.x, ofp.y);
            fpc.Size = new Size(320, 240);
            fpc.BringToFront();
            fpc.Tag = GetControlIndex();

            var afp = new AddFloorPlan { Fpc = fpc, Owner = this, MainClass = this };
            afp.ShowDialog(this);
            if (afp.DialogResult == DialogResult.OK)
            {
                UnlockLayout();
                afp.Fpc.Fpobject.id = NextFloorPlanId;
                FloorPlans.Add(ofp);
                SetFloorPlanEvents(fpc);
                SetNewStartPosition();
                fpc.Invalidate();
            }
            else
            {
                _pnlCameras.Controls.Remove(fpc);
                fpc.Dispose();
            }
            afp.Dispose();
        }
예제 #2
0
        internal void EditFloorplan(objectsFloorplan ofp, IWin32Window owner = null)
        {
            FloorPlanControl fpc = null;

            for (int index = 0; index < _pnlCameras.Controls.Count; index++)
            {
                Control c = _pnlCameras.Controls[index];
                if (c.GetType() != typeof(FloorPlanControl)) continue;
                var fp = (FloorPlanControl)c;
                if (fp.Fpobject.id != ofp.id) continue;
                fpc = fp;
                break;
            }

            if (fpc != null)
            {
                var afp = new AddFloorPlan { Fpc = fpc, MainClass = this };
                afp.ShowDialog(owner ?? this);
                afp.Dispose();
                fpc.Invalidate();
            }
        }