//----------------------------------------------------------------------------------------------------- private void thumbPanel_OnItemDoubleClick(object sender, EventArgs e) { PictureListItem item = (PictureListItem)sender; string file = item.Tag.ToString(); if (!File.Exists(file)) { return; } string dir = Path.GetDirectoryName(file); string category = dir.Substring(dir.LastIndexOf("\\") + 1); frmPassword frm = new frmPassword(category, file); if (frm.ShowDialog() == DialogResult.OK) { if (frm.IsPasswordValid) { PlayVideo(category, Path.GetFileName(file), frm.Password); } else { PopWindow.Warnning("密码不正确,请重新输入!"); } } }
//----------------------------------------------------------------------------------------------------- private void btnSearch_Click(object sender, EventArgs e) { if (txtSearch.TextLength > 0) { PictureListItem item = thumbPanel.SearchItem(txtSearch.Text); if (item != null) { thumbPanel.ScrollTo(item); } } }
//----------------------------------------------------------------------------------------------------- private void LoadThread(object obj) { string p = obj.ToString(); if (InvokeRequired) { BeginInvoke(new Action(() => { loading.BringToFront(); loading.Loading(); thumbPanel.SuspendLayout(); thumbPanel.Items.Clear(); thumbPanel.Controls.Clear(); string[] files = Directory.GetFiles(VideoDir + p); foreach (string file in files) { if (IsHandleCreated) { string thumb = Path.GetDirectoryName(file) + "\\thumb\\" + Path.GetFileNameWithoutExtension(file) + ".jpg"; PictureListItem item = new PictureListItem(); item.Tag = file; if (File.Exists(thumb)) { item.Image = Image.FromStream(new MemoryStream(File.ReadAllBytes(thumb))); } item.Title = Path.GetFileNameWithoutExtension(thumb); thumbPanel.Items.Add(item); } Application.DoEvents(); } loading.Finished(); loading.SendToBack(); thumbPanel.ResumeLayout(false); isLoading = false; })); } }
private void rbnCboSeriesID_SelectedIndexChanged(object sender, EventArgs e) { try { int SID = int.Parse(rbnCboSeriesID.SelectedItem); if (DBC.IsConnected) { //Firstly check all categories of this series with ID : SID #region Check Categories DBC.CommandText = "SELECT CatID FROM Series_Cats where SID= " + SID.ToString() + " ;"; DataSet ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < mListCats.Items.Count; i++) { mListCats.Items[i].CheckState = CheckState.Unchecked; } for (int i = 0; i < mListCats.Items.Count; i++) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { if (mListCats.Items[i].Description == ds.Tables[0].Rows[j].ItemArray[0].ToString()) { mListCats.Items[i].CheckState = CheckState.Checked; } } } } #endregion //Secondly fill the images of this series with ID (SID) in the picture list : #region Fill Picture List //Bring all images in the series DBC.CommandText = "SELECT ImageID,FileName FROM Image where FLOOR(ImageID/100)= " + SID.ToString() + " ;"; ds = DBC.ExecuteQuery(); //Bring the folder where images of series are copied DBC.CommandText = "SELECT FolderPath FROM Series WHERE SID = " + SID.ToString() + " ;"; DataSet sds = DBC.ExecuteQuery(); //Images folder is . . . string imgFld = sds.Tables[0].Rows[0].ItemArray[0].ToString(); //Now put all images in the series in the picture list (picLstSerImage) for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string fname = ds.Tables[0].Rows[i].ItemArray[1].ToString(); string ImageID = ds.Tables[0].Rows[i].ItemArray[0].ToString(); imgFld = (imgFld.EndsWith("\\")) ? imgFld : imgFld + "\\"; imgFld = (imgFld.StartsWith("\\")) ? imgFld : "\\" + imgFld; string imgpath = this.SC.SettingsList[0].TrimEnd('\\') + imgFld + fname; Bitmap bmp = new Bitmap(imgpath); PictureListItem pItem = new PictureListItem(fname, bmp, true, null); ImageRecord = new imageRecord(ImageID, null, fname, null); pItem.Value = ImageRecord; pItem.Tag = imgpath; picLstSerImage.Items.Add(pItem); } #endregion //And finally fill the notes about the series #region Fill Series Notes DBC.CommandText = "SELECT Notes FROM Series_Notes where SID= " + SID.ToString() + " ;"; ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { rbnTxtNotes.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString(); } #endregion } else { throw new Exception("The database is not connected"); } #region Operations related to specific kind of data manipulation if (opr.ToLower() == "modify") //Modification { rbnBtnNotes.Visible = true; rbnBtnAddImage.Visible = true; rbnBtnRemoveImage.Visible = true; rbnBtnDelAll.Visible = true; rbnBtnManipulate.Visible = true; allowPatiantChange = true; } else //Deletion { int[] to_delete = new int[mListCats.Items.Count]; int j = 0; for (int i = 0; i < mListCats.Items.Count; i++) { if (mListCats.Items[i].CheckState == CheckState.Unchecked) { to_delete[j] = i; j++; } } for (int i = j; i >= 0; i--) { mListCats.Items.RemoveAt(i); } mListCats.ShowCheck = false; } #endregion } catch (Exception ex) { MessageBox.Show( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }