Inheritance: AForge.Controls.PictureBox, ISpyControl
Esempio n. 1
0
        public void ResetLayout()
        {
            foreach (LayoutItem li in SavedLayout)
            {
                switch (li.ObjectTypeId)
                {
                case 1:
                    VolumeLevel vl = MainForm.InstanceReference.GetVolumeLevel(li.ObjectId);
                    if (vl != null)
                    {
                        vl.Location = new Point(li.LayoutRectangle.X, li.LayoutRectangle.Y);
                        vl.Size     = new Size(li.LayoutRectangle.Width, li.LayoutRectangle.Height);
                    }
                    break;

                case 2:
                    CameraWindow cw = MainForm.InstanceReference.GetCameraWindow(li.ObjectId);
                    if (cw != null)
                    {
                        cw.Location = new Point(li.LayoutRectangle.X, li.LayoutRectangle.Y);
                        cw.Size     = new Size(li.LayoutRectangle.Width, li.LayoutRectangle.Height);
                    }
                    break;

                case 3:
                    FloorPlanControl fp = MainForm.InstanceReference.GetFloorPlan(li.ObjectId);
                    if (fp != null)
                    {
                        fp.Location = new Point(li.LayoutRectangle.X, li.LayoutRectangle.Y);
                        fp.Size     = new Size(li.LayoutRectangle.Width, li.LayoutRectangle.Height);
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        private void FloorPlanControlClick(object sender, MouseEventArgs e)
        {
            var    local      = new Point(e.X, e.Y);
            double xRat       = Convert.ToDouble(Width) / ImageWidth;
            double yRat       = Convert.ToDouble(Height) / ImageHeight;
            double hittargetw = 22 * xRat;
            double hittargeth = 22 * yRat;

            double wrat = Convert.ToDouble(ImageWidth) / 533d;
            double hrat = Convert.ToDouble(ImageHeight) / 400d;

            foreach (objectsFloorplanObjectsEntry fpoe in Fpobject.objects.@object)
            {
                if (((fpoe.x * wrat) - hittargetw) * xRat <= local.X && ((fpoe.x * wrat) + hittargetw) * xRat > local.X &&
                    ((fpoe.y * hrat) - hittargeth) * yRat <= local.Y && ((fpoe.y * hrat) + hittargeth) * yRat > local.Y)
                {
                    switch (fpoe.type)
                    {
                    case "camera":
                        CameraWindow cw = Owner.GetCameraWindow(fpoe.id);
                        cw.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                        cw.BringToFront();
                        break;

                    case "microphone":
                        VolumeLevel vl = Owner.GetMicrophone(fpoe.id);
                        vl.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                        vl.BringToFront();
                        break;
                    }
                    break;
                }
            }
        }
Esempio n. 3
0
        public void DisplayMicrophone(objectsMicrophone mic)
        {
            var micControl = new VolumeLevel(mic,this);
            SetMicrophoneEvents(micControl);
            micControl.BackColor = Conf.BackColor.ToColor();
            _pnlCameras.Controls.Add(micControl);
            micControl.Location = new Point(mic.x, mic.y);
            micControl.Size = new Size(mic.width, mic.height);
            micControl.BringToFront();
            micControl.Tag = GetControlIndex();

            try
            {
                string path = Helper.GetMediaDirectory(1, mic.id) + "audio\\" + mic.directory + "\\";
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
            }
            catch (Exception ex)
            {
                LogExceptionToFile(ex);
            }
            micControl.GetFiles();
        }
Esempio n. 4
0
        private void FloorPlanControlClick(object sender, MouseEventArgs e)
        {
            var    local      = new Point(e.X, e.Y);
            double xRat       = Convert.ToDouble(Width) / ImageWidth;
            double yRat       = Convert.ToDouble(Height) / ImageHeight;
            double hittargetw = 22 * xRat;
            double hittargeth = 22 * yRat;

            double wrat = Convert.ToDouble(ImageWidth) / 533d;
            double hrat = Convert.ToDouble(ImageHeight) / 400d;


            bool changeHighlight = true;

            if (Highlighted)
            {
                foreach (objectsFloorplanObjectsEntry fpoe in Fpobject.objects.@object)
                {
                    if (((fpoe.x * wrat) - hittargetw) * xRat <= local.X && ((fpoe.x * wrat) + hittargetw) * xRat > local.X &&
                        ((fpoe.y * hrat) - hittargeth) * yRat <= local.Y && ((fpoe.y * hrat) + hittargeth) * yRat > local.Y)
                    {
                        switch (fpoe.type)
                        {
                        case "camera":
                            CameraWindow cw = MainClass.GetCameraWindow(fpoe.id);
                            if (cw != null)
                            {
                                //cw.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                                cw.BringToFront();
                                cw.Focus();
                            }

                            changeHighlight = false;
                            break;

                        case "microphone":
                            VolumeLevel vl = MainClass.GetVolumeLevel(fpoe.id);
                            if (vl != null)
                            {
                                //vl.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                                vl.BringToFront();
                                vl.Focus();
                            }

                            changeHighlight = false;
                            break;
                        }
                        break;
                    }
                }
            }

            if (changeHighlight)
            {
                bool hl = Highlighted;
                MainClass._pnlCameras.ClearHighlights();

                Highlighted = !hl;
            }
            if (Highlighted)
            {
                foreach (objectsFloorplanObjectsEntry fpoe in Fpobject.objects.@object)
                {
                    switch (fpoe.type)
                    {
                    case "camera":
                        CameraWindow cw = MainClass.GetCameraWindow(fpoe.id);
                        if (cw != null)
                        {
                            cw.Highlighted = true;
                        }
                        break;

                    case "microphone":
                        VolumeLevel vl = MainClass.GetVolumeLevel(fpoe.id);
                        if (vl != null)
                        {
                            vl.Highlighted = true;
                        }

                        break;
                    }
                }
            }

            MainClass.Invalidate(true);
        }
Esempio n. 5
0
        public void RemoveMicrophone(VolumeLevel volumeControl, bool confirm)
        {
            if (confirm &&
                MessageBox.Show(LocRm.GetString("AreYouSure"), LocRm.GetString("Confirm"), MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.Cancel)
                return;
            volumeControl.ShuttingDown = true;
            volumeControl.MouseDown -= VolumeControlMouseDown;
            volumeControl.MouseUp -= VolumeControlMouseUp;
            volumeControl.MouseMove -= VolumeControlMouseMove;
            volumeControl.DoubleClick -= VolumeControlDoubleClick;
            volumeControl.RemoteCommand -= VolumeControlRemoteCommand;
            volumeControl.Notification -= ControlNotificationHandler;
            if (volumeControl.Recording)
                volumeControl.RecordSwitch(false);

            volumeControl.Disable();
            volumeControl.SaveFileList();

            if (InvokeRequired)
                Invoke(new MicrophoneCommandDelegate(RemoveMicrophonePanel), volumeControl);
            else
                RemoveMicrophonePanel(volumeControl);
        }
Esempio n. 6
0
 private void VolumeControlRemoteCommand(object sender, VolumeLevel.ThreadSafeCommand e)
 {
     InvokeMethod i = DoInvoke;
     Invoke(i, new object[] { e.Command });
 }
Esempio n. 7
0
        internal void DisplayMicrophone(objectsMicrophone mic)
        {
            var micControl = new VolumeLevel(mic);
            SetMicrophoneEvents(micControl);
            micControl.BackColor = Conf.BackColor.ToColor();
            _pnlCameras.Controls.Add(micControl);
            micControl.Location = new Point(mic.x, mic.y);
            micControl.Size = new Size(mic.width, mic.height);
            micControl.BringToFront();
            micControl.Tag = GetControlIndex();

            if (Conf.AutoSchedule && mic.schedule.active && mic.schedule.entries.Count() > 0)
            {
                mic.settings.active = false;
                micControl.ApplySchedule();
            }
            else
            {
                if (mic.settings.active)
                    micControl.Enable();
            }

            string path = Conf.MediaDirectory + "audio\\" + mic.directory + "\\";
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
        }
Esempio n. 8
0
        private void RemoveMicrophonePanel(VolumeLevel volumeControl)
        {
            _pnlCameras.Controls.Remove(volumeControl);

            if (!_closing)
            {
                var control = volumeControl;
                var om = Microphones.SingleOrDefault(p => p.id == control.Micobject.id);
                if (om != null)
                {
                    lock (ThreadLock)
                    {
                        Masterfilelist.RemoveAll(p => p.ObjectId == om.id && p.ObjectTypeId == 1);
                    }
                    for (var index = 0; index < Cameras.Count(p => p.settings.micpair == om.id); index++)
                    {
                        var oc = Cameras.Where(p => p.settings.micpair == om.id).ToList()[index];
                        oc.settings.micpair = -1;
                    }
                    Actions.RemoveAll(p => p.objectid == control.Micobject.id && p.objecttypeid == 1);
                    Microphones.Remove(om);

                    foreach (var ofp in FloorPlans)
                        ofp.needsupdate = true;
                }
                SetNewStartPosition();
                NeedsSync = true;
            }
            Application.DoEvents();
            volumeControl.Dispose();
        }
Esempio n. 9
0
 public void SetVolumeLevel(int micid)
 {
     Camobject.settings.micpair = micid;
     if (micid == -1)
     {
         if (VolumeControl != null)
             VolumeControl.CameraControl = null;
         VolumeControl = null;
         return;
     }
     VolumeControl = MainClass.GetVolumeLevel(micid);
     if (VolumeControl != null)
     {
         VolumeControl.CameraControl = this;
         VolumeControl.Micobject.settings.buffer = Camobject.recorder.bufferseconds;
     }
 }
Esempio n. 10
0
 internal void ShowFiles(VolumeLevel vl)
 {
     string foldername = Helper.GetMediaDirectory(1, vl.Micobject.id) + "audio\\" + vl.Micobject.directory + "\\";
     if (!foldername.EndsWith(@"\"))
         foldername += @"\";
     Process.Start(foldername);
     vl.Micobject.newrecordingcount = 0;
 }
Esempio n. 11
0
 public void Init(VolumeLevel vl)
 {
     VL = vl;
     SetText();
 }
Esempio n. 12
0
        public void SetVolumeLevel(int micid)
        {
            Camobject.settings.micpair = micid;
            if (micid == -1)
            {
                if (VolumeControl != null)
                    VolumeControl.CameraControl = null;
                VolumeControl = null;
                return;
            }

            VolumeControl = MainClass.GetVolumeLevel(micid);
            if (VolumeControl != null)
                VolumeControl.CameraControl = this;
        }
Esempio n. 13
0
 public void Init(VolumeLevel vl)
 {
     VL = vl;
     SetText();
 }
Esempio n. 14
0
        public void RemoveMicrophone(VolumeLevel volumeControl, bool confirm)
        {
            if (confirm &&
                MessageBox.Show(LocRm.GetString("AreYouSure"), LocRm.GetString("Confirm"), MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.Cancel)
                return;

            var dr = DialogResult.No;
            if (confirm)
            {
                dr = MessageBox.Show(LocRm.GetString("DeleteAllAssociatedMedia"), LocRm.GetString("Confirm"),
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question);
            }
            if (dr == DialogResult.Cancel)
                return;

            string folder = volumeControl.Dir.Entry + "audio\\" + volumeControl.Micobject.directory + "\\";

            volumeControl.ShuttingDown = true;
            volumeControl.MouseDown -= VolumeControlMouseDown;
            volumeControl.MouseUp -= VolumeControlMouseUp;
            volumeControl.MouseMove -= VolumeControlMouseMove;
            volumeControl.DoubleClick -= VolumeControlDoubleClick;
            volumeControl.RemoteCommand -= VolumeControlRemoteCommand;
            volumeControl.Notification -= ControlNotification;
            if (volumeControl.Recording)
                volumeControl.RecordSwitch(false);

            volumeControl.Disable();
            volumeControl.SaveFileList();

            if (InvokeRequired)
                Invoke(new Delegates.MicrophoneCommandDelegate(RemoveMicrophonePanel), volumeControl);
            else
                RemoveMicrophonePanel(volumeControl);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    Directory.Delete(folder, true);
                }
                catch (Exception ex)
                {
                    LogExceptionToFile(ex);
                }
            }
        }
Esempio n. 15
0
        private VolumeLevel NewVolumeLevel(int audioSourceIndex)
        {
            var om = new objectsMicrophone
            {
                alerts = new objectsMicrophoneAlerts(),
                detector = new objectsMicrophoneDetector(),
                notifications = new objectsMicrophoneNotifications(),
                recorder = new objectsMicrophoneRecorder(),
                schedule = new objectsMicrophoneSchedule
                {
                    entries
                        =
                        new objectsMicrophoneScheduleEntry
                        [
                        0
                        ]
                },
                settings = new objectsMicrophoneSettings(),
                id = -1,
                directory = MainForm.RandomString(5),
                x = Convert.ToInt32(MainForm.Random.NextDouble() * 100),
                y = Convert.ToInt32(MainForm.Random.NextDouble() * 100),
                width = 160,
                height = 40,
                description = "",
                newrecordingcount = 0,
                name = LocRm.GetString("Microphone") + " " + MainForm.NextMicrophoneId
            };

            om.settings.typeindex = audioSourceIndex;
            om.settings.deletewav = true;
            om.settings.ffmpeg = MainForm.Conf.FFMPEG_Microphone;
            om.settings.buffer = 4;
            om.settings.samples = 8000;
            om.settings.bits = 16;
            om.settings.gain = 100;
            om.settings.channels = 1;
            om.settings.decompress = true;
            om.settings.smsnumber = MainForm.MobileNumber;
            om.settings.emailaddress = MainForm.EmailAddress;
            om.settings.active = false;
            om.settings.notifyondisconnect = false;
            if (VlcHelper.VlcInstalled)
                om.settings.vlcargs = "-I" + NL + "dummy" + NL + "--ignore-config";
            else
                om.settings.vlcargs = "";

            om.settings.storagemanagement = new objectsMicrophoneSettingsStoragemanagement
            {
                enabled = false,
                maxage = 72,
                maxsize = 1024

            };

            om.detector.sensitivity = 60;
            om.detector.nosoundinterval = 30;
            om.detector.soundinterval = 0;
            om.detector.recordondetect = true;

            om.alerts.mode = "sound";
            om.alerts.minimuminterval = 180;
            om.alerts.executefile = "";
            om.alerts.active = true;
            om.alerts.alertoptions = "false,false";
            om.alerts.trigger = "";

            om.recorder.inactiverecord = 5;
            om.recorder.maxrecordtime = 900;

            om.notifications.sendemail = false;
            om.notifications.sendsms = false;

            om.schedule.active = false;
            om.alertevents = new objectsMicrophoneAlertevents { entries = new objectsMicrophoneAlerteventsEntry[] { } };

            var volumeControl = new VolumeLevel(om) { BackColor = MainForm.Conf.BackColor.ToColor() };
            _pnlCameras.Controls.Add(volumeControl);

            volumeControl.Location = new Point(om.x, om.y);
            volumeControl.Size = new Size(160, 40);
            volumeControl.BringToFront();
            SetMicrophoneEvents(volumeControl);

            if (MainForm.Conf.AutoLayout)
                LayoutObjects(0, 0);

            volumeControl.Tag = GetControlIndex();

            return volumeControl;
        }
Esempio n. 16
0
        private VolumeLevel NewVolumeLevel(int audioSourceIndex)
        {
            var om = new objectsMicrophone
            {
                alerts = new objectsMicrophoneAlerts(),
                detector = new objectsMicrophoneDetector(),
                notifications = new objectsMicrophoneNotifications(),
                recorder = new objectsMicrophoneRecorder(),
                schedule = new objectsMicrophoneSchedule
                {
                    entries
                        =
                        new objectsMicrophoneScheduleEntry
                        [
                        0
                        ]
                },
                settings = new objectsMicrophoneSettings(),
                id = -1,
                directory = RandomString(5),
                x = Convert.ToInt32(Random.NextDouble() * 100),
                y = Convert.ToInt32(Random.NextDouble() * 100),
                width = 160,
                height = 40,
                description = "",
                newrecordingcount = 0
            };

            string friendlyName = LocRm.GetString("Microphone") + " " + NextMicrophoneId;

            string t = friendlyName;
            int i = 1;
            while (Microphones.FirstOrDefault(p => p.name == t) != null)
            {
                t = friendlyName + " (" + i + ")";
                i++;
            }

            om.name = t;

            om.settings.typeindex = audioSourceIndex;
            om.settings.deletewav = true;
            om.settings.ffmpeg = Conf.FFMPEG_Microphone;
            om.settings.buffer = 4;
            om.settings.samples = 8000;
            om.settings.bits = 16;
            om.settings.gain = 100;
            om.settings.channels = 1;
            om.settings.decompress = true;
            om.settings.smsnumber = MobileNumber;
            om.settings.emailaddress = EmailAddress;
            om.settings.active = false;
            om.settings.notifyondisconnect = false;
            om.settings.directoryIndex = Conf.MediaDirectories.First().ID;
            om.settings.vlcargs = VlcHelper.VlcInstalled ? "--rtsp-caching=100" : "";

            om.settings.storagemanagement = new objectsMicrophoneSettingsStoragemanagement
            {
                enabled = false,
                maxage = 72,
                maxsize = 1024

            };

            om.detector.sensitivity = 60;
            om.detector.minsensitivity = 60;
            om.detector.maxsensitivity = 100;

            om.detector.nosoundinterval = 30;
            om.detector.soundinterval = 0;
            om.detector.recordondetect = Conf.DefaultRecordOnDetect;
            om.detector.recordonalert = Conf.DefaultRecordOnAlert;

            om.alerts.mode = "sound";
            om.alerts.minimuminterval = 180;
            om.alerts.executefile = "";
            om.alerts.active = true;
            om.alerts.alertoptions = "false,false";
            om.alerts.trigger = "";

            om.recorder.inactiverecord = 5;
            om.recorder.maxrecordtime = 900;

            om.notifications.sendemail = false;
            om.notifications.sendsms = false;

            om.schedule.active = false;
            om.alertevents = new objectsMicrophoneAlertevents { entries = new objectsMicrophoneAlerteventsEntry[] { } };

            var volumeControl = new VolumeLevel(om,this) { BackColor = Conf.BackColor.ToColor() };
            _pnlCameras.Controls.Add(volumeControl);

            volumeControl.Location = new Point(om.x, om.y);
            volumeControl.Size = new Size(160, 40);
            volumeControl.BringToFront();
            SetMicrophoneEvents(volumeControl);

            if (Conf.AutoLayout)
                LayoutObjects(0, 0);

            volumeControl.Tag = GetControlIndex();

            return volumeControl;
        }
Esempio n. 17
0
        private void RemoveMicrophonePanel(VolumeLevel volumeControl)
        {
            _pnlCameras.Controls.Remove(volumeControl);

            if (!MainForm._closing)
            {
                var control = volumeControl;
                var om = MainForm.Microphones.SingleOrDefault(p => p.id == control.Micobject.id);
                if (om != null)
                {
                    if (ObjectRemoved!=null)
                    {
                        ObjectRemoved(this,new ObjectEventArgs(1,om.id));
                    }
                    for (var index = 0; index < MainForm.Cameras.Count(p => p.settings.micpair == om.id); index++)
                    {
                        var oc = MainForm.Cameras.Where(p => p.settings.micpair == om.id).ToList()[index];
                        oc.settings.micpair = -1;
                    }
                    MainForm.Microphones.Remove(om);

                    foreach (var ofp in MainForm.FloorPlans)
                        ofp.needsupdate = true;
                }
                SetNewStartPosition();
                MainForm.NeedsSync = true;
            }
            Application.DoEvents();
            volumeControl.Dispose();
        }
Esempio n. 18
0
 private void SetMicrophoneEvents(VolumeLevel vw)
 {
     vw.DoubleClick += VolumeControlDoubleClick;
     vw.MouseDown += VolumeControlMouseDown;
     vw.MouseUp += VolumeControlMouseUp;
     vw.MouseMove += VolumeControlMouseMove;
     vw.RemoteCommand += VolumeControlRemoteCommand;
     vw.Notification += ControlNotification;
     vw.FileListUpdated += VolumeControlFileListUpdated;
 }
Esempio n. 19
0
        private void RemoveMicrophonePanel(VolumeLevel volumeControl)
        {
            _pnlCameras.Controls.Remove(volumeControl);

            if (!_closing)
            {
                var control = volumeControl;
                var om = Microphones.SingleOrDefault(p => p.id == control.Micobject.id);
                if (om != null)
                {
                    for (var index = 0; index < Cameras.Count(p => p.settings.micpair == om.id); index++)
                    {
                        var oc = Cameras.Where(p => p.settings.micpair == om.id).ToList()[index];
                        oc.settings.micpair = -1;
                    }
                    Microphones.Remove(om);
                }
                SetNewStartPosition();
                NeedsSync = true;
            }
            Application.DoEvents();
            volumeControl.Dispose();
        }