public void ISpyControlDown(Point p) { if (MainForm.LayoutMode == Enums.LayoutMode.AutoGrid) { _mDown = true; _dControl = GetiSpyControl(p); } }
public void ISpyControlDown(Point p) { if (MainForm.LayoutMode == Enums.LayoutMode.AutoGrid) { _mDown = true; _dControl = GetiSpyControl(p); } }
public static bool DeleteOrArchive(ISpyControl ctrl, string filePath, bool archive) { if (!archive || filePath.EndsWith(".jpg")) { return(Delete(filePath)); } Helper.ArchiveAndDelete(ctrl, filePath); return(true); }
private void DrawButton(Graphics gCam, int buttonIndex, ISpyControl ctrl, int modeIndex, GridViewConfig gvc, int x, int y) { Rectangle rSrc = GetButtonByIndex(buttonIndex, ctrl, modeIndex, gvc, out Rectangle rDest); if (rDest.X + rDest.Width < _itemwidth) { rDest.X = x + rDest.X; rDest.Y = y + 4; gCam.DrawImage(MainForm.Conf.BigButtons ? Properties.Resources.icons_big : Properties.Resources.icons, rDest, rSrc, GraphicsUnit.Pixel); } }
internal static bool ArchiveAndDelete(ISpyControl ctrl, string filename) { if (ArchiveFile(ctrl, filename) != "NOK") { try { File.Delete(filename); return(true); } catch (Exception ex) { Logger.LogException(ex); } } return(false); }
internal static string ArchiveFile(ISpyControl ctrl, string filename) { if (ctrl == null || !string.IsNullOrEmpty(MainForm.Conf.ArchiveNew)) { if (File.Exists(filename)) { string fn = filename.Substring(filename.LastIndexOf("\\", StringComparison.Ordinal) + 1); var isGrab = filename.EndsWith(".jpg") && filename.Contains(@"grabs\"); try { string ap = MainForm.Conf.ArchiveNew; ap = ap.Replace("{NAME}", (ctrl != null?ctrl.ObjectName:"Unknown")); ap = ap.Replace("{DIR}", (ctrl != null ? ctrl.Folder: "Unknown")); ap = ap.Replace("{GRABS}", isGrab ? @"grabs\" : ""); int j = 0; while (ap.IndexOf("{", StringComparison.Ordinal) != -1 && j < 20) { ap = string.Format(CultureInfo.InvariantCulture, ap, DateTime.Now); j++; } if (!ap.EndsWith(@"\")) { ap += @"\"; } if (!File.Exists(ap + fn)) { Directory.CreateDirectory(ap); File.Copy(filename, ap + fn); } return(ap); } catch (Exception ex) { Logger.LogException(ex); } } } return("NOK"); }
private void DoPaint(PaintEventArgs pe) { Graphics gGrid = pe.Graphics; gGrid.CompositingMode = CompositingMode.SourceOver; gGrid.CompositingQuality = CompositingQuality.HighSpeed; gGrid.PixelOffsetMode = PixelOffsetMode.HighSpeed; gGrid.SmoothingMode = SmoothingMode.None; gGrid.InterpolationMode = InterpolationMode.Default; try { int cols = _cols; int rows = _rows; if (_maximised != null) { cols = 1; rows = 1; } Rectangle rc = ClientRectangle; _itemwidth = (rc.Width - cols * Itempadding) / cols; _itemheight = (rc.Height - rows * Itempadding) / rows; //draw lines for (var i = 0; i < cols; i++) { var x = (i * (_itemwidth + Itempadding) - Itempadding / 2); gGrid.DrawLine(_pline, x, 0, x, rc.Height); } for (var i = 0; i < rows; i++) { var y = (i * (_itemheight + Itempadding) - Itempadding / 2); gGrid.DrawLine(_pline, 0, y, rc.Width, y); } var ind = 0; var j = 0; var k = 0; for (var i = 0; i < cols * rows; i++) { var x = j * (_itemwidth + Itempadding); var y = k * (_itemheight + Itempadding); var r = new Rectangle(x, y, _itemwidth, _itemheight); var gvc = _controls[ind]; if (_maximised != null) { gvc = _maximised; } ISpyControl alerted = null; var rect = new Rectangle(r.X, r.Y + r.Height - 20, r.Width, 20); if (gvc == null || gvc.ObjectIDs.Count == 0) { gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rect); switch (Cg.ModeIndex) { case 0: { string m = LocRm.GetString("AddObjects"); int txtOffline = Convert.ToInt32(gGrid.MeasureString(m, Iconfont).Width); gGrid.DrawString(m, Iconfont, OverlayBrush, x + _itemwidth / 2 - (txtOffline / 2), y + _itemheight / 2); } break; case 1: { string m = LocRm.GetString("NoMotionOrSound"); int txtOffline = Convert.ToInt32(gGrid.MeasureString(m, Iconfont).Width); gGrid.DrawString(m, Iconfont, OverlayBrush, x + _itemwidth / 2 - (txtOffline / 2), y + _itemheight / 2); } break; case 2: { string m = LocRm.GetString("NoAlerts"); int txtOffline = Convert.ToInt32(gGrid.MeasureString(m, Iconfont).Width); gGrid.DrawString(m, Iconfont, OverlayBrush, x + _itemwidth / 2 - (txtOffline / 2), y + _itemheight / 2); } break; } } else { if ((Helper.Now - gvc.LastCycle).TotalSeconds > gvc.Delay) { if (!gvc.Hold) { gvc.CurrentIndex++; gvc.LastCycle = Helper.Now; } } if (gvc.CurrentIndex >= gvc.ObjectIDs.Count) { gvc.CurrentIndex = 0; } var obj = gvc.ObjectIDs[gvc.CurrentIndex]; var rFeed = r; switch (obj.TypeID) { case 1: var vl = MainClass.GetVolumeLevel(obj.ObjectID); if (vl != null) { string txt = vl.Micobject.name; if (vl.IsEnabled && vl.Levels != null && !vl.AudioSourceErrorState) { int bh = (rFeed.Height) / vl.Micobject.settings.channels - (vl.Micobject.settings.channels - 1) * 2; if (bh <= 2) { bh = 2; } for (int m = 0; m < vl.Micobject.settings.channels; m++) { float f = 0f; if (m < vl.Levels.Length) { f = vl.Levels[m]; } if (f > 1) { f = 1; } int drawW = Convert.ToInt32(Convert.ToDouble(rFeed.Width * f) - 1.0); if (drawW < 1) { drawW = 1; } gGrid.FillRectangle(Lgb, rFeed.X + 2, rFeed.Y + 2 + m * bh + (m * 2), drawW - 4, bh); } var d = ((Convert.ToDouble(rFeed.Width - 4) / 100.00)); var mx1 = rFeed.X + (float)(d * Convert.ToDouble(vl.Micobject.detector.minsensitivity)); var mx2 = rFeed.X + (float)(d * Convert.ToDouble(vl.Micobject.detector.maxsensitivity)); gGrid.DrawLine(_vline, mx1, rFeed.Y + 1, mx1, rFeed.Y + rFeed.Height - 2); gGrid.DrawLine(_vline, mx2, rFeed.Y + 1, mx2, rFeed.Y + rFeed.Height - 2); if (vl.Recording) { gGrid.FillEllipse(RecordBrush, new Rectangle(rFeed.X + rFeed.Width - 12, rFeed.Y + 4, 8, 8)); } if (Cg.Overlays) { gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rect); gGrid.DrawString(txt, Drawfont, OverlayBrush, new PointF(rect.X + 5, rect.Y + 2)); } alerted = vl; } else { txt += ": " + (vl.Micobject.schedule.active ? LocRm.GetString("Scheduled") : LocRm.GetString("Offline")); gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rect); gGrid.DrawString(txt, Drawfont, OverlayBrush, new PointF(rect.X + 5, rect.Y + 2)); gGrid.DrawString(vl.Micobject.name, Drawfont, OverlayBrush, new PointF(r.X + 5, r.Y + 2)); gGrid.DrawString(vl.SourceType, Drawfont, OverlayBrush, new PointF(r.X + 5, r.Y + 20)); } if (vl.IsEnabled && (vl.AudioSourceErrorState || vl.Levels == null)) { var img = Properties.Resources.connecting; gGrid.DrawImage(img, x + _itemwidth - img.Width - 2, y + 2, img.Width, img.Height); } } else { gvc.ObjectIDs.Remove(gvc.ObjectIDs[gvc.CurrentIndex]); } gGrid.DrawRectangle(new Pen(vl.BorderColor), rFeed); break; case 2: var cw = MainClass.GetCameraWindow(obj.ObjectID); if (cw != null) { string txt = cw.Camobject.name; if (cw.IsEnabled) { if (cw.Camera != null && cw.GotImage) { var bmp = obj.LastFrame; if (bmp != null) { if (!Cg.Fill) { rFeed = GetArea(x, y, _itemwidth, _itemheight, bmp.Width, bmp.Height); } gGrid.CompositingMode = CompositingMode.SourceCopy; gGrid.DrawImage(bmp, rFeed); gGrid.CompositingMode = CompositingMode.SourceOver; } alerted = cw; if (cw.Recording) { gGrid.FillEllipse(RecordBrush, new Rectangle(rFeed.X + rFeed.Width - 12, rFeed.Y + 4, 8, 8)); } } if (Cg.Overlays) { gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rect); gGrid.DrawString(txt, Drawfont, OverlayBrush, new PointF(rect.X + 5, rect.Y + 2)); } } else { txt += ": " + (cw.Camobject.schedule.active ? LocRm.GetString("Scheduled") : LocRm.GetString("Offline")); gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rect); gGrid.DrawString(txt, Drawfont, OverlayBrush, new PointF(rect.X + 5, rect.Y + 2)); gGrid.DrawString(cw.Camobject.name, Drawfont, OverlayBrush, new PointF(r.X + 5, r.Y + 2)); gGrid.DrawString(cw.SourceType, Drawfont, OverlayBrush, new PointF(r.X + 5, r.Y + 20)); } if (cw.IsEnabled && (cw.VideoSourceErrorState || !cw.GotImage)) { var img = Properties.Resources.connecting; gGrid.DrawImage(img, x + _itemwidth - img.Width - 2, y + 2, img.Width, img.Height); } gGrid.DrawRectangle(new Pen(cw.BorderColor), rFeed); } else { gvc.ObjectIDs.Remove(gvc.ObjectIDs[gvc.CurrentIndex]); } break; case 3: var fp = MainClass.GetFloorPlan(obj.ObjectID); if (fp != null) { if (fp.Fpobject != null && fp.ImgPlan != null) { var bmp = fp.ImgView; if (!Cg.Fill) { rFeed = GetArea(x, y, _itemwidth, _itemheight, bmp.Width, bmp.Height); } if (bmp != null) { gGrid.DrawImage(bmp, rFeed); } if (Cg.Overlays) { gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, r.X, r.Y + r.Height - 20, r.Width, 20); gGrid.DrawString(fp.Fpobject.name, Drawfont, OverlayBrush, r.X + 5, r.Y + r.Height - 16); } } } else { gvc.ObjectIDs.Remove(gvc.ObjectIDs[gvc.CurrentIndex]); } break; } } if (_overControlIndex == ind && MainForm.Conf.ShowOverlayControls) { var rBp = ButtonPanel; rBp.X = r.X; rBp.Y = r.Y + r.Height - 20 - rBp.Height; if (rBp.Width > _itemwidth) { rBp.Width = _itemwidth; } if (gvc != null && gvc.ObjectIDs.Count != 0) { gGrid.FillRectangle(MainForm.OverlayBackgroundBrush, rBp); var c = gvc.ObjectIDs[gvc.CurrentIndex]; var ctrl = MainClass.GetISpyControl(c.TypeID, c.ObjectID); for (int b = 0; b < ButtonCount; b++) { DrawButton(gGrid, b, ctrl, Cg.ModeIndex, gvc, rBp.X, rBp.Y); } } } ind++; j++; if (j == cols) { j = 0; k++; } if (alerted != null) { var ra = new Rectangle(r.X, r.Y, r.Width, r.Height); ra.X += 1; ra.Y += 1; using (var p = new Pen(alerted.BorderColor)) { gGrid.DrawRectangle(p, ra); } } } } catch (Exception ex) { Logger.LogException(ex); } }
private Rectangle GetButtonByIndex(int buttonIndex, ISpyControl ctrl, int modeIndex, GridViewConfig gvc, out Rectangle destRect) { Rectangle rSrc = Rectangle.Empty; bool b = ctrl!=null && ctrl.IsEnabled; switch (buttonIndex) { case 0: rSrc = (modeIndex == 0) ? MainForm.RAdd : MainForm.RAddOff; break; case 1: rSrc = gvc.Hold ? MainForm.RHoldOn : MainForm.RHold; break; case 2: rSrc = (gvc.ObjectIDs.Count > 1) ? MainForm.RNext : MainForm.RNextOff; break; case 5://settings rSrc = MainForm.REdit; break; case 6://web rSrc = Helper.HasFeature(Enums.Features.Access_Media) ? MainForm.RWeb : MainForm.RWebOff; break; } if (ctrl != null) { switch (buttonIndex) { case 3: //power rSrc = ctrl.CanEnable ? (b ? MainForm.RPowerOn : MainForm.RPower) : MainForm.RPowerOff; break; case 4: //record rSrc = (ctrl.CanRecord && b) ? (ctrl.Recording ? MainForm.RRecordOn : MainForm.RRecord) : MainForm.RRecordOff; break; case 7: //grab rSrc = (ctrl.CanGrab && b) ? MainForm.RGrab : MainForm.RGrabOff; break; case 8: //talk rSrc = (ctrl.CanTalk && b) ? (ctrl.Talking ? MainForm.RTalkOn : MainForm.RTalk) : MainForm.RTalkOff; break; case 9: //listen rSrc = (ctrl.CanListen && b) ? (ctrl.Listening ? MainForm.RListenOn : MainForm.RListen) : MainForm.RListenOff; break; case 10: //files rSrc = ctrl.HasFiles ? MainForm.RFolder : MainForm.RFolderOff; break; } } if (MainForm.Conf.BigButtons) { rSrc.X -= 2; rSrc.Width += 8; rSrc.Height += 8; } var bp = ButtonPanel; destRect = new Rectangle(bp.X + buttonIndex * (bp.Width/ButtonCount) + 5, Height - 25 - rSrc.Height - 6, rSrc.Width, rSrc.Height); return rSrc; }
private void DrawButton(Graphics gCam, int buttonIndex, ISpyControl ctrl, int modeIndex, GridViewConfig gvc, int x, int y) { Rectangle rDest; Rectangle rSrc = GetButtonByIndex(buttonIndex, ctrl, modeIndex, gvc, out rDest); if (rDest.X + rDest.Width < _itemwidth) { rDest.X = x + rDest.X; rDest.Y = y + 4; gCam.DrawImage(MainForm.Conf.BigButtons ? Properties.Resources.icons_big : Properties.Resources.icons, rDest, rSrc, GraphicsUnit.Pixel); } }
public void Minimize(object obj, bool tocontents) { _maximised = null; if (obj == null) return; var window = obj as CameraWindow; if (window != null) { var cw = window; Rectangle r = cw.RestoreRect; if (r != Rectangle.Empty && !tocontents) { cw.Location = r.Location; cw.Height = r.Height; cw.Width = r.Width; } else { if (cw.Camera != null) { Bitmap bmp = cw.LastFrame; if (bmp != null) { cw.Width = bmp.Width + 2; cw.Height = bmp.Height + 26; bmp.Dispose(); } } else { cw.Width = 322; cw.Height = 266; } } cw.Invalidate(); } var level = obj as VolumeLevel; if (level != null) { var cw = level; Rectangle r = cw.RestoreRect; if (r != Rectangle.Empty && !tocontents) { cw.Location = r.Location; cw.Height = r.Height; cw.Width = r.Width; } else { cw.Width = 160; cw.Height = 40; } cw.Invalidate(); } var control = obj as FloorPlanControl; if (control != null) { var fp = control; Rectangle r = fp.RestoreRect; if (r != Rectangle.Empty && !tocontents) { fp.Location = r.Location; fp.Height = r.Height; fp.Width = r.Width; fp.Invalidate(); } else { if (fp.ImgPlan != null) { fp.Width = fp.ImgPlan.Width + 2; fp.Height = fp.ImgPlan.Height + 26; } else { fp.Width = 322; fp.Height = 266; } } } }
public void Maximise(object obj, bool minimiseIfMaximised) { if (obj == null) { return; } if (InvokeRequired) { BeginInvoke(new MaximiseDelegate(Maximise), obj, minimiseIfMaximised); return; } var window = obj as CameraWindow; if (window != null) { var cameraControl = window; cameraControl.BringToFront(); try { var r = cameraControl.RestoreRect; if (r.IsEmpty) { var s = "320x240"; if (!string.IsNullOrEmpty(cameraControl.Camobject.resolution)) { s = cameraControl.Camobject.resolution; } var wh = s.Split('x'); cameraControl.RestoreRect = new Rectangle(cameraControl.Location.X, cameraControl.Location.Y, cameraControl.Width, cameraControl.Height); double wFact = Convert.ToDouble(Width) / Convert.ToDouble(wh[0]); double hFact = Convert.ToDouble(Height) / Convert.ToDouble(wh[1]); if (cameraControl.VolumeControl != null) { hFact = Convert.ToDouble((Height - 40)) / Convert.ToDouble(wh[1]); } if (hFact <= wFact) { cameraControl.Width = Convert.ToInt32(((Convert.ToDouble(Width) * hFact) / wFact)); cameraControl.Height = Height; } else { cameraControl.Width = Width; cameraControl.Height = Convert.ToInt32((Convert.ToDouble(Height) * wFact) / hFact); } cameraControl.Location = new Point(((Width - cameraControl.Width) / 2), ((Height - cameraControl.Height) / 2)); if (cameraControl.VolumeControl != null) { cameraControl.Height -= 40; } _maximised = cameraControl; } else { if (minimiseIfMaximised) { Minimize(window, false); } cameraControl.RestoreRect = Rectangle.Empty; } } catch (Exception ex) { Logger.LogExceptionToFile(ex); } return; } var level = obj as VolumeLevel; if (level != null) { var vf = level; vf.BringToFront(); if (vf.Paired) { var c = MainForm.Cameras.Single(p => p.settings.micpair == vf.Micobject.id).id; CameraWindow cw = MainForm.InstanceReference.GetCameraWindow(c); if (vf.Width == Width) { if (minimiseIfMaximised) { Minimize(cw, false); } } else { Maximise(cw); } } else { var r = vf.RestoreRect; if (r.IsEmpty) { vf.RestoreRect = new Rectangle(vf.Location.X, vf.Location.Y, vf.Width, vf.Height); vf.Location = new Point(0, 0); vf.Width = Width; vf.Height = Height; _maximised = vf; } else { if (minimiseIfMaximised) { Minimize(vf, false); } vf.RestoreRect = Rectangle.Empty; } } return; } var control = obj as FloorPlanControl; if (control != null) { var fp = control; fp.BringToFront(); var r = fp.RestoreRect; if (r.IsEmpty) { fp.RestoreRect = new Rectangle(fp.Location.X, fp.Location.Y, fp.Width, fp.Height); var wFact = Convert.ToDouble(Width) / fp.Width; var hFact = Convert.ToDouble(Height) / fp.Height; if (hFact <= wFact) { fp.Width = (int)(Width / wFact * hFact); fp.Height = Height; } else { fp.Width = Width; fp.Height = (int)(Height / hFact * wFact); } fp.Location = new Point(((Width - fp.Width) / 2), ((Height - fp.Height) / 2)); _maximised = fp; } else { if (minimiseIfMaximised) { Minimize(control, false); } fp.RestoreRect = Rectangle.Empty; } return; } }
internal void ShowFiles(ISpyControl ctrl) { var cw = ctrl as CameraWindow; if (cw != null) { ShowFiles(cw); return; } var vl = ctrl as VolumeLevel; if (vl != null) { ShowFiles(vl); return; } }
public void RemoveObject(ISpyControl io, bool confirm = false) { var cw = io as CameraWindow; if (cw != null) RemoveCamera(cw, confirm); else { var vl = io as VolumeLevel; if (vl != null) RemoveMicrophone(vl, confirm); else { var fp = io as FloorPlanControl; if (fp!=null) RemoveFloorplan(fp,confirm); } } }
public void Minimize(object obj, bool tocontents) { _maximised = null; if (obj == null) { return; } var window = obj as CameraWindow; if (window != null) { var cw = window; Rectangle r = cw.RestoreRect; if (r != Rectangle.Empty && !tocontents) { cw.Location = r.Location; cw.Height = r.Height; cw.Width = r.Width; } else { if (cw.Camera != null) { Bitmap bmp = cw.LastFrame; if (bmp != null) { cw.Width = bmp.Width + 2; cw.Height = bmp.Height + 26; bmp.Dispose(); } } else { cw.Width = 322; cw.Height = 266; } } cw.Invalidate(); } var level = obj as VolumeLevel; if (level != null) { var cw = level; Rectangle r = cw.RestoreRect; if (r != Rectangle.Empty && !tocontents) { cw.Location = r.Location; cw.Height = r.Height; cw.Width = r.Width; } else { cw.Width = 160; cw.Height = 40; } cw.Invalidate(); } var control = obj as FloorPlanControl; if (control != null) { var fp = control; Rectangle r = fp.RestoreRect; if (r != Rectangle.Empty && !tocontents) { fp.Location = r.Location; fp.Height = r.Height; fp.Width = r.Width; fp.Invalidate(); } else { if (fp.ImgPlan != null) { fp.Width = fp.ImgPlan.Width + 2; fp.Height = fp.ImgPlan.Height + 26; } else { fp.Width = 322; fp.Height = 266; } } } }
private Rectangle GetButtonByIndex(int buttonIndex, ISpyControl ctrl, int modeIndex, GridViewConfig gvc, out Rectangle destRect) { Rectangle rSrc = Rectangle.Empty; bool b = ctrl != null && ctrl.IsEnabled; switch (buttonIndex) { case 0: rSrc = (modeIndex == 0) ? MainForm.RAdd : MainForm.RAddOff; break; case 1: rSrc = gvc.Hold ? MainForm.RHoldOn : MainForm.RHold; break; case 2: rSrc = (gvc.ObjectIDs.Count > 1) ? MainForm.RNext : MainForm.RNextOff; break; case 5: //settings rSrc = MainForm.REdit; break; case 6: //web rSrc = Helper.HasFeature(Enums.Features.Access_Media) ? MainForm.RWeb : MainForm.RWebOff; break; } if (ctrl != null) { switch (buttonIndex) { case 3: //power rSrc = ctrl.CanEnable ? (b ? MainForm.RPowerOn : MainForm.RPower) : MainForm.RPowerOff; break; case 4: //record rSrc = (ctrl.CanRecord && b) ? (ctrl.Recording ? MainForm.RRecordOn : MainForm.RRecord) : MainForm.RRecordOff; break; case 7: //grab rSrc = (ctrl.CanGrab && b) ? MainForm.RGrab : MainForm.RGrabOff; break; case 8: //talk rSrc = (ctrl.CanTalk && b) ? (ctrl.Talking ? MainForm.RTalkOn : MainForm.RTalk) : MainForm.RTalkOff; break; case 9: //listen rSrc = (ctrl.CanListen && b) ? (ctrl.Listening ? MainForm.RListenOn : MainForm.RListen) : MainForm.RListenOff; break; case 10: //files rSrc = ctrl.HasFiles ? MainForm.RFolder : MainForm.RFolderOff; break; } } if (MainForm.Conf.BigButtons) { rSrc.X -= 2; rSrc.Width += 8; rSrc.Height += 8; } var bp = ButtonPanel; destRect = new Rectangle(bp.X + buttonIndex * (bp.Width / ButtonCount) + 5, Height - 25 - rSrc.Height - 6, rSrc.Width, rSrc.Height); return(rSrc); }
internal void EditObject(ISpyControl ctrl, IWin32Window owner = null) { var cw = ctrl as CameraWindow; if (cw != null) { EditCamera(cw.Camobject,owner); return; } var vl = ctrl as VolumeLevel; if (vl != null) { EditMicrophone(vl.Micobject, owner); return; } var fp = ctrl as FloorPlanControl; if (fp == null) return; EditFloorplan(fp.Fpobject, owner); }
public void Maximise(object obj, bool minimiseIfMaximised) { if (obj == null) return; if (InvokeRequired) { BeginInvoke(new MaximiseDelegate(Maximise), obj, minimiseIfMaximised); return; } var window = obj as CameraWindow; if (window != null) { var cameraControl = window; cameraControl.BringToFront(); try { var r = cameraControl.RestoreRect; if (r.IsEmpty) { var s = "320x240"; if (!string.IsNullOrEmpty(cameraControl.Camobject.resolution)) s = cameraControl.Camobject.resolution; var wh = s.Split('x'); cameraControl.RestoreRect = new Rectangle(cameraControl.Location.X, cameraControl.Location.Y, cameraControl.Width, cameraControl.Height); double wFact = Convert.ToDouble(Width) / Convert.ToDouble(wh[0]); double hFact = Convert.ToDouble(Height) / Convert.ToDouble(wh[1]); if (cameraControl.VolumeControl != null) hFact = Convert.ToDouble((Height - 40)) / Convert.ToDouble(wh[1]); if (hFact <= wFact) { cameraControl.Width = Convert.ToInt32(((Convert.ToDouble(Width) * hFact) / wFact)); cameraControl.Height = Height; } else { cameraControl.Width = Width; cameraControl.Height = Convert.ToInt32((Convert.ToDouble(Height) * wFact) / hFact); } cameraControl.Location = new Point(((Width - cameraControl.Width) / 2), ((Height - cameraControl.Height) / 2)); if (cameraControl.VolumeControl != null) cameraControl.Height -= 40; _maximised = cameraControl; } else { if (minimiseIfMaximised) Minimize(window, false); cameraControl.RestoreRect = Rectangle.Empty; } } catch (Exception ex) { Logger.LogExceptionToFile(ex); } return; } var level = obj as VolumeLevel; if (level != null) { var vf = level; vf.BringToFront(); if (vf.Paired) { var c = MainForm.Cameras.Single(p => p.settings.micpair == vf.Micobject.id).id; CameraWindow cw = MainForm.InstanceReference.GetCameraWindow(c); if (vf.Width == Width) { if (minimiseIfMaximised) Minimize(cw, false); } else Maximise(cw); } else { var r = vf.RestoreRect; if (r.IsEmpty) { vf.RestoreRect = new Rectangle(vf.Location.X, vf.Location.Y, vf.Width, vf.Height); vf.Location = new Point(0, 0); vf.Width = Width; vf.Height = Height; _maximised = vf; } else { if (minimiseIfMaximised) Minimize(vf, false); vf.RestoreRect = Rectangle.Empty; } } return; } var control = obj as FloorPlanControl; if (control != null) { var fp = control; fp.BringToFront(); var r = fp.RestoreRect; if (r.IsEmpty) { fp.RestoreRect = new Rectangle(fp.Location.X, fp.Location.Y, fp.Width, fp.Height); var wFact = Convert.ToDouble(Width) / fp.Width; var hFact = Convert.ToDouble(Height) / fp.Height; if (hFact <= wFact) { fp.Width = (int)(Width / wFact * hFact); fp.Height = Height; } else { fp.Width = Width; fp.Height = (int)(Height / hFact * wFact); } fp.Location = new Point(((Width - fp.Width) / 2), ((Height - fp.Height) / 2)); _maximised = fp; } else { if (minimiseIfMaximised) Minimize(control, false); fp.RestoreRect = Rectangle.Empty; } return; } }