Ejemplo n.º 1
0
        public void AddPreviewControl(string thumbname, string movieName, int duration, DateTime createdDate, bool first)
        {
            var pb = new PreviewBox();
            bool add = true;
            string thumb = thumbname;
            try
            {
                if (!File.Exists(thumb))
                {
                    thumb = Program.AppPath + @"WebServerRoot\notfound.jpg";
                }
                using (FileStream f = File.Open(thumb, FileMode.Open, FileAccess.Read))
                {
                    pb.Image = Image.FromStream(f);
                    f.Close();
                }

            }
            catch (Exception)
            {
                add = false;
            }
            if (add)
            {
                lock (flowPreview.Controls)
                {
                    pb.Duration = duration;
                    pb.Width = pb.Image.Width;
                    pb.Height = pb.Image.Height + 20;
                    pb.Cursor = Cursors.Hand;
                    pb.Selected = false;
                    pb.FileName = movieName;
                    pb.CreatedDate = createdDate;
                    pb.MouseDown += pb_MouseDown;
                    toolTip1.SetToolTip(pb, createdDate.ToString(CultureInfo.InvariantCulture));
                    UISync.Execute(() => flowPreview.Controls.Add(pb));
                    if (first)
                    {
                        try
                        {
                            UISync.Execute(() => flowPreview.Controls.SetChildIndex(pb, 0));
                        }
                        catch
                        {
                        }
                    }
                    if (flowPreview.Controls.Count > Conf.PreviewItems)
                        UISync.Execute(() => flowPreview.Controls.RemoveAt(flowPreview.Controls.Count - 1));
                }
            }
            else
            {
                pb.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void DeletePreviewBox(PreviewBox pb)
        {
            _toDelete.Enqueue(pb.FileName);

            string[] parts = pb.FileName.Split('\\');
            string fn = parts[parts.Length - 1];

            try
            {

                switch (pb.Otid)
                {
                    case 1:
                        var vl = GetVolumeLevel(pb.Oid);
                        if (vl != null)
                        {
                            vl.RemoveFile(fn);
                        }
                        break;
                    case 2:
                        var cw = GetCameraWindow(Convert.ToInt32(pb.Oid));
                        if (cw != null)
                        {
                            cw.RemoveFile(fn);
                        }
                        break;
                }

            }
            catch (Exception ex)
            {
                LogExceptionToFile(ex);
            }
            flowPreview.Controls.Remove(pb);
            pb.MouseDown -= PbMouseDown;
            pb.MouseEnter -= PbMouseEnter;
            pb.Dispose();

            NeedsMediaRefresh = Helper.Now;
        }
Ejemplo n.º 3
0
        private void RemovePreviewBox(PreviewBox pb)
        {
            string[] parts = pb.FileName.Split('\\');
            string fn = parts[parts.Length - 1];
            string id = fn.Substring(0, fn.IndexOf('_'));

            try
            {
                //movie
                FileOperations.Delete(pb.FileName);
                GetCameraWindow(Convert.ToInt32(id)).FileList.RemoveAll(p => p.Filename == fn);
                MasterFileList.RemoveAll(p => p.Filename == fn);

                //preview
                string dir = pb.FileName.Substring(0, pb.FileName.LastIndexOf("\\", StringComparison.Ordinal));

                var lthumb = dir + "\\thumbs\\" + fn.Substring(0, fn.LastIndexOf(".", StringComparison.Ordinal)) + "_large.jpg";
                FileOperations.Delete(lthumb);

                lthumb = dir + "\\thumbs\\" + fn.Substring(0, fn.LastIndexOf(".", StringComparison.Ordinal)) + ".jpg";
                FileOperations.Delete(lthumb);
            }
            catch (Exception ex)
            {
                Log.Error("", ex);
            }
            flowPreview.Controls.Remove(pb);
            pb.Dispose();
        }