private void SaveChanges() { MainForm mainForm = (MainForm)base.Owner; ComicIssue comicIssue = (ComicIssue)CC.Issues[CurrentIssue]; if (!comicIssue.Missing) { comicIssue.SeriesID = ComicSeries.GetID(cboSeries.Text, comicIssue.GroupID, comicIssue.PublisherID); ComicSeries comicSeries = new ComicSeries(comicIssue.SeriesID); comicIssue.GroupName = comicSeries.GroupName; comicIssue.PublisherName = comicSeries.PublisherName; comicIssue.SeriesName = cboSeries.Text; comicIssue.Name = txtPlot.Text; comicIssue.SeriesVolume = (int)udVol.Value; comicIssue.Number = (int)udNumber.Value; comicIssue.Type = cboType.SelectedIndex; comicIssue.Comments = txtComments.Text; if (chkPublished.Checked) { comicIssue.Published = datePublished.Value; } comicIssue.SaveChanges(); if (Settings.Default.OrganizeMethod != 0) { comicIssue.OrganizeFile(); } mainForm.IssueList.Refresh(); } }
public int CompareTo(object o) { ComicIssue comicIssue = (ComicIssue)o; string a; if ((a = sortBy) != null && a == "series") { if (!(sortOrder == "ASC")) { return comicIssue.SeriesName.CompareTo(SeriesName); } return SeriesName.CompareTo(comicIssue.SeriesName); } return 0; }
//Clicking on the cover gives the option to select a new cover private void CoverPreview_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); MainForm mainForm = new MainForm(); ComicIssue comicIssue = (ComicIssue)CC.Issues[CurrentIssue]; openFileDialog.Filter = "JPEG Files|*.jpg;*.jpeg|GIF Files|*.gif|PNG Files|*.png|Bitmap Files|*.bmp"; openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { CC.CreateThumbnail(openFileDialog.FileName, Settings.Default.CoverDir + "\\" + comicIssue.ID + ".jpg"); mainForm.IssueCovers.Images.RemoveByKey(Convert.ToString(comicIssue.ID)); CoverPreview.Image = CC.GetIssueCover(comicIssue.ID); } }
//Delete a series and its issues public void Delete(bool Files) { SQL sQL = new SQL(); Query query = sQL.ExecQuery("SELECT id FROM issues WHERE series_id=" + ID); while (query.NextResult()) { ComicIssue comicIssue = new ComicIssue((int)query.hash["id"]); comicIssue.Delete(Files); } sQL.ExecQuery("DELETE FROM series WHERE id=" + ID); if (Settings.Default.OrganizeMethod != 0) { try { //Delete folder for series if file org is turned on Directory.Delete(Settings.Default.LibraryDir + "\\" + CC.URLize(PublisherName) + "\\" + CC.URLize(GroupName) + "\\" + CC.URLize(Name)); } catch { } } }
private void LoadIssue(int ItemIndex) { chkPublished.Checked = false; CurrentIssue = ItemIndex; ComicIssue comicIssue = (ComicIssue)CC.Issues[ItemIndex]; cmdNext.Enabled = ((CurrentIssue != CC.Issues.Count - 1) ? true : false); cmdPrev.Enabled = ((CurrentIssue != 0) ? true : false); txtPlot.Text = comicIssue.Name; cboSeries.Text = comicIssue.SeriesName; udNumber.Value = comicIssue.Number; udVol.Value = comicIssue.SeriesVolume; cboType.SelectedIndex = comicIssue.Type; txtComments.Text = comicIssue.Comments; try { datePublished.Value = comicIssue.Published; } catch { } lblPlot.Text = comicIssue.Name; lblSeries.Text = comicIssue.SeriesName; if (comicIssue.SeriesType != 2) { switch (comicIssue.Type) { case 0: lblNumber.Text = "Issue #" + comicIssue.Number; break; case 1: lblNumber.Text = "Annual " + comicIssue.Number; break; case 2: lblNumber.Text = "Special"; break; } } else { lblNumber.Text = "One-shot"; } lblNumber.Text = lblNumber.Text + " (" + comicIssue.Pages + " Pages)"; switch (Path.GetExtension(comicIssue.FileName)) { case ".cbr": lblKind.Text = "Comic Book RAR File"; break; case ".cbz": lblKind.Text = "Comic Book Zip File"; break; case ".pdf": lblKind.Text = "Comic Book PDF File"; break; } lblSize.Text = CC.ByteToString((double)comicIssue.FileSize); if (comicIssue.Published.Year != 1) { lblPublished.Text = comicIssue.Published.ToString("MM yyyy"); } else { lblPublished.Text = "Unknown"; } lblAdded.Text = comicIssue.DateAdded.ToString("M/d/yyyy h:mm tt"); CoverPreview.Image = CC.GetIssueCover(comicIssue.ID); lblFileName.Text = comicIssue.FileName; //If file organization is turned on and the issue is missing, disable everything. if (Settings.Default.OrganizeMethod != 0) { foreach (Control control in tabInfo.TabPages[1].Controls) { control.Enabled = !comicIssue.Missing; } OK_Button.Enabled = !comicIssue.Missing; } }
//set form properties based on selected issues private void LoadIssues(ListView.SelectedIndexCollection Indices) { ComicIssue comicIssue = null; //Generic variables names!!! bool flag = false; bool flag2 = true; bool flag3 = true; bool flag4 = true; bool flag5 = true; bool flag6 = true; Cursor = Cursors.AppStarting; ComicIssue comicIssue2 = (ComicIssue)CC.Issues[Indices[0]]; //get the first issue //If information in subsequent issues doesn't match, the field will be flagged and be blank on the form for (int i = 1; i <= Indices.Count - 1; i++) { if (comicIssue2.Missing) { flag = true; } comicIssue = (ComicIssue)CC.Issues[Indices[i]]; if (comicIssue2.Name != comicIssue.Name) { flag2 = false; } if (comicIssue2.SeriesName != comicIssue.SeriesName) { flag3 = false; } if (comicIssue2.SeriesVolume != comicIssue.SeriesVolume) { flag4 = false; } if (comicIssue2.Type != comicIssue.Type) { flag5 = false; } bool flag7 = comicIssue2.Published != comicIssue.Published; if (comicIssue2.Comments != comicIssue.Comments) { flag6 = false; } comicIssue2 = comicIssue; } txtPlot.Text = (flag2 ? comicIssue.Name : ""); txtComments.Text = (flag6 ? comicIssue.Comments : ""); cboSeries.Text = (flag3 ? comicIssue.SeriesName : ""); udVol.Value = (flag4 ? comicIssue.SeriesVolume : 0); cboType.SelectedIndex = (flag5 ? comicIssue.Type : 0); //If file organization is turned on and one of the issues is missing, disable everything. if (Settings.Default.OrganizeMethod != 0) { foreach (Control control in base.Controls) { control.Enabled = !flag; } } Cancel_Button.Enabled = true; Cursor = Cursors.Default; }
private void OK_Button_Click(object sender, EventArgs e) { int num = -1; DateTime published = datePublished.Value; ComicIssue comicIssue = null; Cursor = Cursors.WaitCursor; for (int i = 0; i < MainForm.Root.IssueList.SelectedIndices.Count; i++) { comicIssue = (ComicIssue)CC.Issues[MainForm.Root.IssueList.SelectedIndices[i]]; //set the plot title of the issue if checked //(sorry for the three different naming conventions here) if (chkStory.Checked) { comicIssue.Name = txtPlot.Text; } //set series name of the issue if checked if (chkSeries.Checked) { //Find the ID of the selected Series if (num == -1) { num = ComicSeries.GetID(cboSeries.Text, comicIssue.GroupID, comicIssue.PublisherID); } comicIssue.SeriesID = num; comicIssue.SeriesName = cboSeries.Text; } //set comments if checked if (chkComments.Checked) { comicIssue.Comments = txtComments.Text; } //set volume if checked if (chkVol.Checked) { comicIssue.SeriesVolume = (int)udVol.Value; } //set published date if checked if (chkPublished.Checked) { comicIssue.Published = published; //If the Auto-Date feature is being used then we're assuming //that the selected issues were published a set amount of time apart, sequentially if (cboAutoDate.SelectedIndex != -1) { switch (cboAutoDate.Text) { case "Weekly": published = published.AddDays(7.0); break; case "Bi-Weekly": published = published.AddDays(14.0); break; case "Monthly": published = published.AddMonths(1); break; case "Bi-Monthly": published = published.AddMonths(2); break; case "Yearly": published = published.AddYears(1); break; } } } //set issue type if checked if (chkType.Checked) { comicIssue.Type = cboType.SelectedIndex; } //set issue number if checked if (chkNumber.Checked) { //we're assuming that the issues were published sequentially after the start value comicIssue.Number = (int)((decimal)i + udStart.Value); comicIssue.Type = 0; //Normal Issue } comicIssue.SaveChanges(); //Since we've made changes, the files may need to be renamed or moved in accordance with user prefs if (Settings.Default.OrganizeMethod != 0) { comicIssue.OrganizeFile(); } } Cursor = Cursors.Default; base.DialogResult = DialogResult.OK; Close(); }