internal void SelectMediaRange(PreviewBox controlFrom, PreviewBox controlTo) { lock (ThreadLock) { if (controlFrom != null && controlTo != null) { if (flowPreview.Controls.Contains(controlFrom) && flowPreview.Controls.Contains(controlTo)) { bool start = false; foreach (Control c in flowPreview.Controls) { var p = c as PreviewBox; if (p != null) { if (p == controlFrom) { start = true; } if (start) p.Selected = true; if (p == controlTo) break; } } start = false; foreach (Control c in flowPreview.Controls) { var p = c as PreviewBox; if (p != null) { if (p == controlTo) { start = true; } if (start) p.Selected = true; if (p == controlFrom) break; } } } } flowPreview.Invalidate(true); } }
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; }
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; }
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(); } }
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(); }