Пример #1
0
        private void btnAddCommand_Click(object sender, EventArgs e)
        {
            string name    = txtName.Text.Trim();
            string execute = txtExecute.Text.Trim();

            if (OC != null)
            {
                OC.name         = name;
                OC.command      = execute;
                OC.emitshortcut = txtShortcutKeys.Text.Trim();
                DialogResult    = DialogResult.OK;
                Close();
                return;
            }

            if (MainForm.RemoteCommands.SingleOrDefault(p => p.name == name) != null)
            {
                MessageBox.Show(LocRm.GetString("UniqueNameCommand"));
                return;
            }

            var oc = new objectsCommand {
                name = name, command = execute, id = MainForm.NextCommandId, emitshortcut = txtShortcutKeys.Text.Trim()
            };

            MainForm.RemoteCommands.Add(oc);
            DialogResult = DialogResult.OK;
            Close();
        }
Пример #2
0
        private void btnAddCommand_Click(object sender, EventArgs e)
        {
            string name = txtName.Text.Trim();
            string execute = txtExecute.Text.Trim();

            if (OC != null)
            {
                OC.name = name;
                OC.command = execute;
                OC.emitshortcut = txtShortcutKeys.Text.Trim();
                DialogResult = DialogResult.OK;
                Close();
                return;
            }

            if (MainForm.RemoteCommands.SingleOrDefault(p => p.name == name) != null)
            {
                MessageBox.Show(LocRm.GetString("UniqueNameCommand"));
                return;
            }

            var oc = new objectsCommand { name = name, command = execute, id = MainForm.NextCommandId, emitshortcut = txtShortcutKeys.Text.Trim()};

            MainForm.RemoteCommands.Add(oc);
            DialogResult = DialogResult.OK;
            Close();
        }
Пример #3
0
        private void Constrain(objectsCommand cmd)
        {
            var loc = cmd.location.Split(',');
            var sz  = cmd.size.Split('x');
            var x   = Convert.ToInt32(loc[0]);
            var y   = Convert.ToInt32(loc[1]);
            var w   = Convert.ToInt32(sz[0]);
            var h   = Convert.ToInt32(sz[1]);

            w = Math.Min(Width, w);
            h = Math.Min(Height, h);
            var nx = Math.Max(x, 0);
            var ny = Math.Max(y, 0);

            nx = Math.Min(nx, Width - w);
            ny = Math.Min(ny, Height - h);


            //snap w/h to nearest grid

            w  = Convert.ToInt32(((int)Math.Round(w / SnapGrid)) * SnapGrid);
            h  = Convert.ToInt32(((int)Math.Round(h / SnapGrid)) * SnapGrid);
            nx = Convert.ToInt32(((int)Math.Round(nx / SnapGrid)) * SnapGrid);
            ny = Convert.ToInt32(((int)Math.Round(ny / SnapGrid)) * SnapGrid);


            cmd.location = nx + "," + ny;
            cmd.size     = w + "x" + h;
        }
Пример #4
0
 public void Reposition()
 {
     if (CurButton != null)
     {
         _editing = CurButton;
         Invalidate();
     }
 }
Пример #5
0
 private void TmrRefreshTick(object sender, EventArgs e)
 {
     if (_flashButton != null && (DateTime.UtcNow - _flashTime).TotalMilliseconds > 500)
     {
         _flashButton = null;
         Invalidate();
     }
 }
Пример #6
0
 public void Reposition()
 {
     if (CurButton != null)
     {
         _editing = CurButton;
         Invalidate();
     }
 }
Пример #7
0
        private void RunCommand(int commandIndex)
        {
            objectsCommand oc = RemoteCommands.FirstOrDefault(p => p.id == commandIndex);

            if (oc != null)
            {
                RunCommand(oc.command);
            }
        }
Пример #8
0
        void CommandButtonsMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                bool over = false;
                foreach (var btn in MainForm.RemoteCommands)
                {
                    if (btn.inwindow)
                    {
                        var loc = btn.location.Split(',');
                        var sz = btn.size.Split('x');
                        var x = Convert.ToInt32(loc[0]);
                        var y = Convert.ToInt32(loc[1]);
                        var w = Convert.ToInt32(sz[0]);
                        var h = Convert.ToInt32(sz[1]);

                        if (e.X > x && e.Y > y && e.X < x + w && e.Y < y + h)
                        {
                            CurButton = btn;
                            over = true;
                        }
                    }
                }
                if (!over)
                    CurButton = null;
            }
            else
            {
                if (_resizing!=null)
                {
                    var loc = _resizing.location.Split(',');
                    var x = Convert.ToInt32(loc[0]);
                    var y = Convert.ToInt32(loc[1]);
                    _resizing.size = Math.Max(Math.Min(e.Location.X,Width) - x,10) + "x" + Math.Max((Math.Min(e.Location.Y,Height) - y),10);
                    Constrain(_resizing);
                }
                else
                {
                    if (_editing!=null)
                    {
                        var nx = (e.Location.X - _dx);
                        var ny = (e.Location.Y - _dy);
                        _editing.location = nx + "," + ny;
                        Constrain(_editing);
                        
                        
                    }
                }
                   
                Invalidate();

            }
   
        }
Пример #9
0
        void TmrRefreshTick(object sender, EventArgs e)
        {
            if (_flashButton != null)
            {
                if ((DateTime.UtcNow - _flashTime).TotalMilliseconds > 500)
                {
                    _flashButton = null;
                    Invalidate();
                }

            }
        }
Пример #10
0
 public void Add(Point p)
 {
     using (var ecb = new AddCommandButton { location = p })
     {
         if (ecb.ShowDialog(this) == DialogResult.OK)
         {
             _editing = ecb.CMD;
             Constrain(_editing);
         }
     }
     Invalidate();
 }
Пример #11
0
        private void CommandButtonsMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                bool over = false;
                foreach (var btn in MainForm.RemoteCommands)
                {
                    if (btn.inwindow)
                    {
                        var loc = btn.location.Split(',');
                        var sz  = btn.size.Split('x');
                        var x   = Convert.ToInt32(loc[0]);
                        var y   = Convert.ToInt32(loc[1]);
                        var w   = Convert.ToInt32(sz[0]);
                        var h   = Convert.ToInt32(sz[1]);

                        if (e.X > x && e.Y > y && e.X < x + w && e.Y < y + h)
                        {
                            CurButton = btn;
                            over      = true;
                        }
                    }
                }
                if (!over)
                {
                    CurButton = null;
                }
            }
            else
            {
                if (_resizing != null)
                {
                    var loc = _resizing.location.Split(',');
                    var x   = Convert.ToInt32(loc[0]);
                    var y   = Convert.ToInt32(loc[1]);
                    _resizing.size = Math.Max(Math.Min(e.Location.X, Width) - x, 10) + "x" + Math.Max((Math.Min(e.Location.Y, Height) - y), 10);
                    Constrain(_resizing);
                }
                else
                {
                    if (_editing != null)
                    {
                        var nx = (e.Location.X - _dx);
                        var ny = (e.Location.Y - _dy);
                        _editing.location = nx + "," + ny;
                        Constrain(_editing);
                    }
                }

                Invalidate();
            }
        }
Пример #12
0
 private void lbManualAlerts_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lbManualAlerts.SelectedIndex > -1)
     {
         string al = lbManualAlerts.SelectedItem.ToString();
         al = al.Substring(0, al.IndexOf(":")).Trim();
         objectsCommand oc = MainForm.RemoteCommands.Where(p => p.id == Convert.ToInt32(al)).FirstOrDefault();
         if (oc != null)
         {
             lblCommand.Text = oc.command;
         }
     }
 }
Пример #13
0
 private void BtnDeleteClick(object sender, EventArgs e)
 {
     if (lbManualAlerts.SelectedIndex > -1)
     {
         var            c  = (MainForm.ListItem2)lbManualAlerts.SelectedItem;
         objectsCommand oc = MainForm.RemoteCommands.FirstOrDefault(p => p.id == c.Value);
         if (oc != null)
         {
             MainForm.RemoteCommands.Remove(oc);
             RenderCommands();
         }
     }
 }
Пример #14
0
 private void BtnDeleteClick(object sender, EventArgs e)
 {
     if (lbManualAlerts.SelectedIndex > -1)
     {
         string al = lbManualAlerts.SelectedItem.ToString();
         al = al.Substring(0, al.IndexOf(":")).Trim();
         objectsCommand oc = MainForm.RemoteCommands.Where(p => p.id == Convert.ToInt32(al)).FirstOrDefault();
         if (oc != null)
         {
             MainForm.RemoteCommands.Remove(oc);
             RenderCommands();
         }
     }
 }
Пример #15
0
 public void Add(Point p)
 {
     using (var ecb = new AddCommandButton {
         location = p
     })
     {
         if (ecb.ShowDialog(this) == DialogResult.OK)
         {
             _editing = ecb.CMD;
             Constrain(_editing);
         }
     }
     Invalidate();
 }
Пример #16
0
 private void button1_Click(object sender, EventArgs e)
 {
     CMD = MainForm.RemoteCommands.FirstOrDefault(p => p.id == ((MainForm.ListItem2)ddlCommand.SelectedItem).Value);
     if (CMD != null)
     {
         CMD.font = CustomFont.SerializeFontAttribute;
         CMD.color = color.ToRGBString();
         CMD.backcolor = backColor.ToRGBString();
         CMD.size = numW.Value + "x" + numH.Value;
         CMD.location = locX.Value + "," + locY.Value;
         CMD.inwindow = true;
         DialogResult = DialogResult.OK;
     }
     Close();
 }
Пример #17
0
 private void button1_Click(object sender, EventArgs e)
 {
     CMD = MainForm.RemoteCommands.FirstOrDefault(p => p.id == ((MainForm.ListItem2)ddlCommand.SelectedItem).Value);
     if (CMD != null)
     {
         CMD.font      = CustomFont.SerializeFontAttribute;
         CMD.color     = color.ToRGBString();
         CMD.backcolor = backColor.ToRGBString();
         CMD.size      = numW.Value + "x" + numH.Value;
         CMD.location  = locX.Value + "," + locY.Value;
         CMD.inwindow  = true;
         DialogResult  = DialogResult.OK;
     }
     Close();
 }
Пример #18
0
        private void BtnAddCommandClick(object sender, EventArgs e)
        {
            string name = txtName.Text.Trim();
            string execute = txtExecute.Text.Trim();

            if (MainForm.RemoteCommands.SingleOrDefault(p => p.name == name) != null)
            {
                MessageBox.Show(LocRm.GetString("UniqueNameCommand"));
                return;
            }

            var oc = new objectsCommand { name = name, command = execute, id = MainForm.NextCommandId };

            MainForm.RemoteCommands.Add(oc);
            RenderCommands();
        }
Пример #19
0
 private void lbManualAlerts_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lbManualAlerts.SelectedIndex > -1)
     {
         var            c  = (MainForm.ListItem)lbManualAlerts.SelectedItem;
         objectsCommand oc = MainForm.RemoteCommands.FirstOrDefault(p => p.id == (int)c.Value);
         if (oc != null)
         {
             string s = oc.command;
             if (!string.IsNullOrEmpty(oc.emitshortcut) && oc.emitshortcut != "")
             {
                 s = oc.emitshortcut + " & " + oc.command;
             }
             lblCommand.Text = s;
         }
     }
     btnDelete.Enabled = btnEditCommand.Enabled = lbManualAlerts.SelectedIndex > -1;
 }
Пример #20
0
        private void BtnAddCommandClick(object sender, EventArgs e)
        {
            string name    = txtName.Text.Trim();
            string execute = txtExecute.Text.Trim();

            if (MainForm.RemoteCommands.SingleOrDefault(p => p.name == name) != null)
            {
                MessageBox.Show(LocRm.GetString("UniqueNameCommand"));
                return;
            }

            var oc = new objectsCommand {
                name = name, command = execute, id = MainForm.NextCommandId
            };

            MainForm.RemoteCommands.Add(oc);
            RenderCommands();
        }
Пример #21
0
 private void btnEditCommand_Click(object sender, EventArgs e)
 {
     if (lbManualAlerts.SelectedIndex > -1)
     {
         var            c  = (MainForm.ListItem2)lbManualAlerts.SelectedItem;
         objectsCommand oc = MainForm.RemoteCommands.FirstOrDefault(p => p.id == c.Value);
         if (oc != null)
         {
             using (var arc = new AddRemoteCommand {
                 OC = oc
             })
             {
                 if (arc.ShowDialog(this) == DialogResult.OK)
                 {
                     RenderCommands();
                 }
             }
         }
     }
 }
Пример #22
0
        private void lbManualAlerts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbManualAlerts.SelectedIndex>-1)
            {
               string al = lbManualAlerts.SelectedItem.ToString();
                al = al.Substring(0, al.IndexOf(":", StringComparison.Ordinal)).Trim();
                objectsCommand oc = MainForm.RemoteCommands.FirstOrDefault(p => p.id == Convert.ToInt32(al));
                if (oc != null)
                {
                    string s = oc.command;
                    if (!String.IsNullOrEmpty(oc.emitshortcut))
                    {
                        if (oc.emitshortcut != "")
                            s = oc.emitshortcut + " & " + oc.command;
                    }
                    lblCommand.Text = s;
                }

            }
        }
Пример #23
0
        private void CommandButtonControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (_editing != null)
            {
                return;
            }
            if (e.Button == MouseButtons.Left)
            {
                bool over = false;
                foreach (var btn in MainForm.RemoteCommands)
                {
                    if (btn.inwindow)
                    {
                        var loc = btn.location.Split(',');
                        var sz  = btn.size.Split('x');
                        var x   = Convert.ToInt32(loc[0]);
                        var y   = Convert.ToInt32(loc[1]);
                        var w   = Convert.ToInt32(sz[0]);
                        var h   = Convert.ToInt32(sz[1]);

                        if (e.X > x && e.Y > y && e.X < x + w && e.Y < y + h)
                        {
                            CurButton = btn;
                            over      = true;
                        }
                    }
                }
                if (!over)
                {
                    CurButton = null;
                }

                if (CurButton == _cmdDown && CurButton != null)
                {
                    _flashButton = CurButton;
                    _flashTime   = DateTime.UtcNow;
                    Invalidate();
                    MainForm.InstanceReference.RunCommand(CurButton.id);
                }
            }
        }
Пример #24
0
        private void CommandButtonsMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_editing != null)
                {
                    var loc = _editing.location.Split(',');
                    var sz  = _editing.size.Split('x');
                    var x   = Convert.ToInt32(loc[0]);
                    var y   = Convert.ToInt32(loc[1]);
                    var w   = Convert.ToInt32(sz[0]);
                    var h   = Convert.ToInt32(sz[1]);

                    if (Math.Sqrt(Math.Pow((x + w) - e.Location.X, 2) + Math.Pow((y + h) - e.Location.Y, 2)) < 20)
                    {
                        _resizing = _editing;
                        return;
                    }
                    _resizing = null;
                }

                if (CurButton != _editing)
                {
                    _cmdDown  = CurButton;
                    _editing  = null;
                    _resizing = null;
                    Invalidate();
                }
                else
                {
                    if (_editing != null && CurButton == _editing)
                    {
                        var loc = _editing.location.Split(',');
                        var x   = Convert.ToInt32(loc[0]);
                        var y   = Convert.ToInt32(loc[1]);
                        _dx = e.Location.X - x;
                        _dy = e.Location.Y - y;
                    }
                }
            }
        }
Пример #25
0
        private void DrawButton(objectsCommand btn, Graphics g)
        {
            var loc = btn.location.Split(',');
            var sz  = btn.size.Split('x');
            var x   = Convert.ToInt32(loc[0]);
            var y   = Convert.ToInt32(loc[1]);
            var w   = Convert.ToInt32(sz[0]);
            var h   = Convert.ToInt32(sz[1]);

            using (var b = new SolidBrush(btn.backcolor.ToColor()))
            {
                g.FillRectangle(b, x, y, w, h);
            }

            var p = btn == _flashButton ? new Pen(Color.Red, 2) : new Pen(Color.DarkGray);

            g.DrawRectangle(p, x, y, w, h);
            p.Dispose();

            var f = FontXmlConverter.ConvertToFont(btn.font);
            var n = btn.name;

            if (n.StartsWith("cmd_"))
            {
                n = LocRm.GetString(n);
            }
            var ts = g.MeasureString(n, f);
            var fx = Convert.ToInt32(w / 2d - ts.Width / 2);
            var fy = Convert.ToInt32(h / 2d - ts.Height / 2);

            using (var b = new SolidBrush(btn.color.ToColor()))
            {
                g.DrawString(n, f, b, x + fx, y + fy);
            }
            if (_editing == btn)
            {
                g.FillEllipse(Brushes.Blue, x + w - 10, y + h - 10, 20, 20);
            }
        }
Пример #26
0
        public void RunCommand(int commandIndex)
        {
            objectsCommand oc = RemoteCommands.FirstOrDefault(p => p.id == commandIndex);

            if (oc != null)
            {
                if (!string.IsNullOrEmpty(oc.command))
                {
                    RunCommand(oc.command);
                }
                if (!string.IsNullOrEmpty(oc.emitshortcut))
                {
                    var converter = new KeysConverter();
                    var keys      = converter.ConvertFromString(oc.emitshortcut);
                    if (keys != null)
                    {
                        var shortcutKeys = (Keys)keys;
                        MainForm_KeyDown(this, new KeyEventArgs(shortcutKeys));
                    }
                }
            }
        }
Пример #27
0
        public static objectsCommand[] GenerateRemoteCommands()
        {
            //copy over
            var lcom = new List <objectsCommand>();
            var cmd  = new objectsCommand
            {
                command = "ispy ALLON",
                id      = 0,
                name    = "cmd_SwitchAllOn",
            };

            lcom.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALLOFF",
                id      = 1,
                name    = "cmd_SwitchAllOff",
            };
            lcom.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy APPLYSCHEDULE",
                id      = 2,
                name    = "cmd_ApplySchedule",
            };
            lcom.Add(cmd);

            if (Helper.HasFeature(Enums.Features.Recording))
            {
                cmd = new objectsCommand
                {
                    command = "ispy RECORDONDETECTON",
                    id      = 3,
                    name    = "cmd_RecordOnDetectAll",
                };
                lcom.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORDONALERTON",
                    id      = 4,
                    name    = "cmd_RecordOnAlertAll",
                };
                lcom.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORDINGOFF",
                    id      = 5,
                    name    = "cmd_RecordOffAll",
                };
                lcom.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORD",
                    id      = 8,
                    name    = "cmd_RecordAll",
                };
                lcom.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORDSTOP",
                    id      = 9,
                    name    = "cmd_RecordAllStop",
                };
                lcom.Add(cmd);
            }

            cmd = new objectsCommand
            {
                command = "ispy ALERTON",
                id      = 6,
                name    = "cmd_AlertsOnAll",
            };
            lcom.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALERTOFF",
                id      = 7,
                name    = "cmd_AlertsOffAll",
            };
            lcom.Add(cmd);

            if (Helper.HasFeature(Enums.Features.Save_Frames))
            {
                cmd = new objectsCommand
                {
                    command = "ispy SNAPSHOT",
                    id      = 10,
                    name    = "cmd_SnapshotAll",
                };
                lcom.Add(cmd);
            }
            return(lcom.ToArray());
        }
Пример #28
0
        public static void InitRemoteCommands()
        {
            //copy over
            _remotecommands.Clear();
            var cmd = new objectsCommand
            {
                command = "ispy ALLON",
                id = 0,
                name = "cmd_SwitchAllOn",
                smscommand = "ALL ON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALLOFF",
                id = 1,
                name = "cmd_SwitchAllOff",
                smscommand = "ALL OFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy APPLYSCHEDULE",
                id = 2,
                name = "cmd_ApplySchedule",
                smscommand = "APPLY SCHEDULE"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy RECORDONDETECTON",
                id = 3,
                name = "cmd_RecordOnDetectAll",
                smscommand = "RECORDONDETECTON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy RECORDONALERTON",
                id = 4,
                name = "cmd_RecordOnAlertAll",
                smscommand = "RECORDONALERTON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy RECORDINGOFF",
                id = 5,
                name = "cmd_RecordOffAll",
                smscommand = "RECORDINGOFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALERTON",
                id = 6,
                name = "cmd_AlertsOnAll",
                smscommand = "ALERTSON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALERTOFF",
                id = 7,
                name = "cmd_AlertsOffAll",
                smscommand = "ALERTSOFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy RECORD",
                id = 8,
                name = "cmd_RecordAll",
                smscommand = "RECORD"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy RECORDSTOP",
                id = 9,
                name = "cmd_RecordAllStop",
                smscommand = "RECORDSTOP"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy SNAPSHOT",
                id = 10,
                name = "cmd_SnapshotAll",
                smscommand = "SNAPSHOT"
            };
            _remotecommands.Add(cmd);
        }
Пример #29
0
        public static void InitRemoteCommands()
        {
            //copy over
            _remotecommands.Clear();
            var cmd = new objectsCommand
            {
                command    = "ispy ALLON",
                id         = 0,
                name       = "cmd_SwitchAllOn",
                smscommand = "ALL ON"
            };

            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy ALLOFF",
                id         = 1,
                name       = "cmd_SwitchAllOff",
                smscommand = "ALL OFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy APPLYSCHEDULE",
                id         = 2,
                name       = "cmd_ApplySchedule",
                smscommand = "APPLY SCHEDULE"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy RECORDONDETECTON",
                id         = 3,
                name       = "cmd_RecordOnDetectAll",
                smscommand = "RECORDONDETECTON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy RECORDONALERTON",
                id         = 4,
                name       = "cmd_RecordOnAlertAll",
                smscommand = "RECORDONALERTON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy RECORDINGOFF",
                id         = 5,
                name       = "cmd_RecordOffAll",
                smscommand = "RECORDINGOFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy ALERTON",
                id         = 6,
                name       = "cmd_AlertsOnAll",
                smscommand = "ALERTSON"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy ALERTOFF",
                id         = 7,
                name       = "cmd_AlertsOffAll",
                smscommand = "ALERTSOFF"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy RECORD",
                id         = 8,
                name       = "cmd_RecordAll",
                smscommand = "RECORD"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy RECORDSTOP",
                id         = 9,
                name       = "cmd_RecordAllStop",
                smscommand = "RECORDSTOP"
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command    = "ispy SNAPSHOT",
                id         = 10,
                name       = "cmd_SnapshotAll",
                smscommand = "SNAPSHOT"
            };
            _remotecommands.Add(cmd);
        }
Пример #30
0
        public static void InitRemoteCommands()
        {
            //copy over
            _remotecommands.Clear();
            var cmd = new objectsCommand
            {
                command = "ispy ALLON",
                id = 0,
                name = "cmd_SwitchAllOn",
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALLOFF",
                id = 1,
                name = "cmd_SwitchAllOff",
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy APPLYSCHEDULE",
                id = 2,
                name = "cmd_ApplySchedule",
            };
            _remotecommands.Add(cmd);

            if (Helper.HasFeature(Enums.Features.Recording))
            {
                cmd = new objectsCommand
                      {
                          command = "ispy RECORDONDETECTON",
                          id = 3,
                          name = "cmd_RecordOnDetectAll",
                      };
                _remotecommands.Add(cmd);

                cmd = new objectsCommand
                      {
                          command = "ispy RECORDONALERTON",
                          id = 4,
                          name = "cmd_RecordOnAlertAll",
                      };
                _remotecommands.Add(cmd);

                cmd = new objectsCommand
                      {
                          command = "ispy RECORDINGOFF",
                          id = 5,
                          name = "cmd_RecordOffAll",
                      };
                _remotecommands.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORD",
                    id = 8,
                    name = "cmd_RecordAll",
                };
                _remotecommands.Add(cmd);

                cmd = new objectsCommand
                {
                    command = "ispy RECORDSTOP",
                    id = 9,
                    name = "cmd_RecordAllStop",
                };
                _remotecommands.Add(cmd);
            }

            cmd = new objectsCommand
            {
                command = "ispy ALERTON",
                id = 6,
                name = "cmd_AlertsOnAll",
            };
            _remotecommands.Add(cmd);

            cmd = new objectsCommand
            {
                command = "ispy ALERTOFF",
                id = 7,
                name = "cmd_AlertsOffAll",
            };
            _remotecommands.Add(cmd);

            if (Helper.HasFeature(Enums.Features.Save_Frames))
            {

                cmd = new objectsCommand
                      {
                          command = "ispy SNAPSHOT",
                          id = 10,
                          name = "cmd_SnapshotAll",
                      };
                _remotecommands.Add(cmd);
            }
        }
Пример #31
0
        private void DrawButton(objectsCommand btn, Graphics g)
        {
            var loc = btn.location.Split(',');
            var sz = btn.size.Split('x');
            var x = Convert.ToInt32(loc[0]);
            var y = Convert.ToInt32(loc[1]);
            var w = Convert.ToInt32(sz[0]);
            var h = Convert.ToInt32(sz[1]);

            using (var b = new SolidBrush(btn.backcolor.ToColor()))
            {
                g.FillRectangle(b, x, y, w, h);
            }

            var p = btn == _flashButton ? new Pen(Color.Red, 2) : new Pen(Color.DarkGray);

            g.DrawRectangle(p, x, y, w, h);
            p.Dispose();

            var f = FontXmlConverter.ConvertToFont(btn.font);
            var n = btn.name;
            if (n.StartsWith("cmd_"))
                n = LocRm.GetString(n);
            var ts = g.MeasureString(n, f);
            var fx = Convert.ToInt32(w/2d - ts.Width/2);
            var fy = Convert.ToInt32(h/2d - ts.Height/2);

            using (var b = new SolidBrush(btn.color.ToColor()))
            {
                g.DrawString(n, f, b, x + fx, y + fy);
            }
            if (_editing == btn)
            {
                g.FillEllipse(Brushes.Blue, x + w - 10, y + h - 10, 20, 20);
            }
        }
Пример #32
0
        private void CommandButtonControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (_editing != null)
                return;
            if (e.Button == MouseButtons.Left)
            {
                bool over = false;
                foreach (var btn in MainForm.RemoteCommands)
                {
                    if (btn.inwindow)
                    {
                        var loc = btn.location.Split(',');
                        var sz = btn.size.Split('x');
                        var x = Convert.ToInt32(loc[0]);
                        var y = Convert.ToInt32(loc[1]);
                        var w = Convert.ToInt32(sz[0]);
                        var h = Convert.ToInt32(sz[1]);

                        if (e.X > x && e.Y > y && e.X < x + w && e.Y < y + h)
                        {
                            CurButton = btn;
                            over = true;
                        }
                    }
                }
                if (!over)
                    CurButton = null;

                if (CurButton == _cmdDown && CurButton!=null)
                {
                    _flashButton = CurButton;
                    _flashTime = DateTime.UtcNow;
                    Invalidate();
                    MainForm.InstanceReference.RunCommand(CurButton.id);
                }
            }
        }
Пример #33
0
        private void Constrain(objectsCommand cmd)
        {
            var loc = cmd.location.Split(',');
            var sz = cmd.size.Split('x');
            var x = Convert.ToInt32(loc[0]);
            var y = Convert.ToInt32(loc[1]);
            var w = Convert.ToInt32(sz[0]);
            var h = Convert.ToInt32(sz[1]);

            w = Math.Min(Width, w);
            h = Math.Min(Height, h);
            var nx = Math.Max(x, 0);
            var ny = Math.Max(y, 0);
            nx = Math.Min(nx, Width - w);
            ny = Math.Min(ny, Height - h);


            //snap w/h to nearest grid

            w = Convert.ToInt32(((int)Math.Round(w/SnapGrid)) * SnapGrid);
            h = Convert.ToInt32(((int)Math.Round(h / SnapGrid)) * SnapGrid);
            nx = Convert.ToInt32(((int)Math.Round(nx / SnapGrid)) * SnapGrid);
            ny = Convert.ToInt32(((int)Math.Round(ny / SnapGrid)) * SnapGrid);
            

            cmd.location = nx + "," + ny;
            cmd.size = w + "x" + h;
        }
Пример #34
0
        private static void LoadObjects(string path)
        {
            objects c;
            var s = new XmlSerializer(typeof (objects));
            var fs = new FileStream(path, FileMode.Open);
            TextReader reader = new StreamReader(fs);
            try
            {
                fs.Position = 0;
                c = (objects) s.Deserialize(reader);
                fs.Close();

                _cameras = c.cameras != null ? c.cameras.ToList() : new List<objectsCamera>();
                foreach (objectsCamera oc in _cameras)
                {
                    //will trigger error for old ispy configs
                    int rw = oc.settings.desktopresizewidth;
                    if (rw == 0)
                        throw new Exception("err_old_config");
                }

                _microphones = c.microphones != null ? c.microphones.ToList() : new List<objectsMicrophone>();

                _floorplans = c.floorplans != null ? c.floorplans.ToList() : new List<objectsFloorplan>();

                _remotecommands = c.remotecommands != null ? c.remotecommands.ToList() : new List<objectsCommand>();

                if (_remotecommands.Count == 0)
                {
                    //add default remote commands
                    var cmd = new objectsCommand
                                  {
                                      command = "ispy ALLON",
                                      id = 0,
                                      name = "Switch all on",
                                      smscommand = "ALL ON"
                                  };
                    _remotecommands.Add(cmd);
                    cmd = new objectsCommand
                              {
                                  command = "ispy ALLOFF",
                                  id = 1,
                                  name = "Switch all off",
                                  smscommand = "ALL OFF"
                              };
                    _remotecommands.Add(cmd);
                }

                int camid = 0;
                foreach (objectsCamera cam in _cameras)
                {
                    if (cam.id >= camid)
                        camid = cam.id + 1;

                    if (cam.settings.youtube == null)
                    {
                        cam.settings.youtube = new objectsCameraSettingsYoutube
                                                    {
                                                        autoupload = false,
                                                        category = iSpyServer.Default.YouTubeDefaultCategory,
                                                        tags = "iSpy, Motion Detection, Surveillance",
                                                        @public = true
                                                    };
                    }
                    cam.newrecordingcount = 0;
                    if (cam.directory == null)
                        throw new Exception("err_old_config");

                }
                int micid = 0;
                foreach (objectsMicrophone mic in _microphones)
                {
                    if (mic.id >= micid)
                        micid = mic.id + 1;
                    if (mic.directory == null)
                        throw new Exception("err_old_config");
                    mic.newrecordingcount = 0;
                }
                int fpid = 0;
                foreach (objectsFloorplan ofp in _floorplans)
                {
                    if (ofp.id >= fpid)
                        fpid = ofp.id + 1;
                }
                int rcid = 0;
                foreach (objectsCommand ocmd in _remotecommands)
                {
                    if (ocmd.id >= rcid)
                        rcid = ocmd.id + 1;
                }

                iSpyServer.Default.NextCameraID = camid;
                iSpyServer.Default.NextMicrophoneID = micid;
                iSpyServer.Default.NextFloorPlanID = fpid;
                iSpyServer.Default.NextCommandID = rcid;
                NeedsSync = true;
            }
            catch (Exception)
            {
                MessageBox.Show(LocRM.GetString("ConfigurationChanged"), LocRM.GetString("Error"));
                _cameras = new List<objectsCamera>();
                _microphones = new List<objectsMicrophone>();
                _remotecommands = new List<objectsCommand>();
                _floorplans = new List<objectsFloorplan>();
            }
            reader.Dispose();
            if (fs != null)
                fs.Dispose();
        }
Пример #35
0
        private void CommandButtonsMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_editing != null)
                {
                    var loc = _editing.location.Split(',');
                    var sz = _editing.size.Split('x');
                    var x = Convert.ToInt32(loc[0]);
                    var y = Convert.ToInt32(loc[1]);
                    var w = Convert.ToInt32(sz[0]);
                    var h = Convert.ToInt32(sz[1]);

                    if (Math.Sqrt(Math.Pow((x + w) - e.Location.X, 2) + Math.Pow((y + h) - e.Location.Y, 2)) < 20)
                    {
                        _resizing = _editing;
                        return;
                    }
                    _resizing = null;                    
                }

                if (CurButton != _editing)
                {
                    _cmdDown = CurButton;
                    _editing = null;
                    _resizing = null;
                    Invalidate();
                }
                else
                {
                    if (_editing!=null && CurButton == _editing)
                    {
                        var loc = _editing.location.Split(',');
                        var x = Convert.ToInt32(loc[0]);
                        var y = Convert.ToInt32(loc[1]);
                        _dx = e.Location.X - x;
                        _dy = e.Location.Y - y;

                    }    
                }
            }
            
        }