예제 #1
0
 public PreviewBox AddPreviewControl(FilePreview fp, string thumb, string movieName, string name)
 {
     Image bmp;
     try
     {
         if (!File.Exists(thumb))
         {
             bmp = Resources.notfound;
         }
         else
         {
             using (var f = File.Open(thumb, FileMode.Open, FileAccess.Read))
             {
                 bmp = Image.FromStream(f);
                 f.Close();
             }
         }
     }
     catch (Exception ex)
     {
         LogExceptionToFile(ex);
         return null;
     }
     return AddPreviewControl(fp, bmp, movieName, name);
 }
예제 #2
0
        public PreviewBox AddPreviewControl(FilePreview fp, Image thumb, string movieName, string name)
        {
            var pb = new PreviewBox(fp.ObjectTypeId, fp.ObjectId, this) {Image = thumb, Duration = fp.Duration};
            pb.Width = pb.Image.Width;
            pb.Height = pb.Image.Height + 20;
            pb.Cursor = Cursors.Hand;
            pb.Selected = false;
            pb.FileName = movieName;
            var dt = new DateTime(fp.CreatedDateTicks);
            pb.CreatedDate = dt;
            pb.MouseDown += PbMouseDown;
            pb.MouseEnter += PbMouseEnter;
            string txt = name + ": " + dt.ToString(CultureInfo.CurrentUICulture);
            pb.DisplayName = txt;
            pb.IsMerged = fp.IsMerged;
            lock (ThreadLock)
            {
                flowPreview.Controls.Add(pb);

            }
            return pb;
        }
예제 #3
0
        void FfmpegMergeProcessExited(object sender, EventArgs e)
        {
            if (_ffmpegProcess.ExitCode == 0)
            {
                if (_pbMerge.Count>0)
                {
                    var ma = 0d;
                    var fi = new FileInfo(_dir+_outfile);

                    var alertData = new StringBuilder();
                    int durationSeconds = 0;
                    foreach (var m in _pbMerge)
                    {
                        if (m.AlertData != "")
                        {
                            alertData.Append(m.AlertData);
                            alertData.Append(",");
                        }
                        durationSeconds += m.DurationSeconds;

                        if (m.MaxAlarm > ma)
                            ma = m.MaxAlarm;
                    }

                    var ff = new FilesFile
                             {
                                 CreatedDateTicks = DateTime.Now.Ticks,
                                 DurationSeconds = durationSeconds,
                                 IsTimelapse = false,
                                 TriggerLevel = _pbMerge.First().TriggerLevel,
                                 TriggerLevelMax = _pbMerge.First().TriggerLevelMax,
                                 Filename = _outfile,
                                 AlertData = Helper.GetMotionDataPoints(alertData),
                                 MaxAlarm = ma,
                                 SizeBytes = fi.Length,
                                 IsMergeFile = true,
                                 IsMergeFileSpecified = true
                             };

                    string name;
                    if (_currentObject.Ot == 1)
                    {
                        var vl = MainClass.GetVolumeLevel(_currentObject.ID);
                        vl.AddFile(ff);
                        name = vl.Micobject.name;
                    }
                    else
                    {
                        var cw = MainClass.GetCameraWindow(_currentObject.ID);
                        cw.AddFile(ff);
                        name = cw.Camobject.name;

                        var fpv = _pbMerge.First();
                        //get preview image
                        string imgname = fpv.Filename.Substring(0,
                            fpv.Filename.LastIndexOf(".", StringComparison.Ordinal));
                        var imgpath = _dir + "thumbs/" + imgname+"_large.jpg";

                        if (File.Exists(imgpath))
                        {
                            Image bmpPreview = Image.FromFile(imgpath);

                            string jpgname = _dir + "thumbs\\" + ff.Filename.Substring(0,
                                ff.Filename.LastIndexOf(".", StringComparison.Ordinal));

                            bmpPreview.Save(jpgname + "_large.jpg", MainForm.Encoder,
                                MainForm.EncoderParams);

                            Image.GetThumbnailImageAbort myCallback = ThumbnailCallback;
                            Image myThumbnail = bmpPreview.GetThumbnailImage(96, 72, myCallback, IntPtr.Zero);

                            myThumbnail.Save(jpgname + ".jpg", MainForm.Encoder,
                                MainForm.EncoderParams);

                            myThumbnail.Dispose();
                            bmpPreview.Dispose();
                        }

                    }

                    var fp = new FilePreview(_outfile, durationSeconds, name, ff.CreatedDateTicks, _currentObject.Ot,_currentObject.ID, ma,false,true);
                    MainForm.MasterFileAdd(fp);
                    MainForm.NeedsMediaRefresh = Helper.Now;
                }
                _pbMerge.Clear();
            }
            else
            {
                MainForm.LogErrorToFile("FFMPEG process exited with code " + _ffmpegProcess.ExitCode);
                MessageBox.Show(this, LocRm.GetString("ErrorCheckLogFile"));
            }
            DoClose();
        }
예제 #4
0
파일: MainForm.cs 프로젝트: flos-club/iSpy
 public static void MasterFileAdd(FilePreview fp)
 {
     lock (ThreadLock)
     {
         Masterfilelist.Add(fp);
     }
 }
예제 #5
0
 public static void MasterFileAdd(FilePreview fp)
 {
     lock (ThreadLock)
     {
         Masterfilelist.Add(fp);
     }
     MWS.WebSocketServer.SendToAll("new events|" + fp.Name);
 }