Exemple #1
0
 /// <summary>
 /// Commit shown divisions and move files into divisioned subdirectories.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDivide_Click(object sender, EventArgs e)
 {
     btnShowDiv.Enabled = false;
     if (folder.folderDivisions.Count > 1)
     {
         try
         {
             for (int i = 0; i <= folder.folderDivisions.Count - 1; i++)
             {
                 System.IO.Directory.CreateDirectory(folder.dirname + "\\" + (i + 1));
                 for (int j = 0; j <= folder.folderDivisions[i].Count - 1; j++)
                 {
                     FileInfo ff = new FileInfo(folder.folderDivisions[i][j]);
                     ff.MoveTo(folder.dirname + "\\" + (i + 1) + "\\" + ff.Name);
                 }
             }
             btnDivide.Enabled = false;
             BetterDialog.ShowDialog("Divide Complete", "Success", "", "", "OK", null, BetterDialog.ImageStyle.Icon);
             ddUrl_SelectedValueChanged(null, null);
         }
         catch (Exception ex)
         {
             BetterDialog.ShowDialog("", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
         }
     }
 }
Exemple #2
0
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Image img = Clipboard.GetImage();

            if (img != null)
            {
                if (gvContents.Rows.Count < 1)
                {
                    toolTip.Show("Title Required!", ddInsTitle);
                }
                else
                {
                    DialogResult result = DialogResult.OK;
                    if (imgTitle.Image != LFI.Properties.Resources.border)
                    {
                        result = BetterDialog.ShowDialog("Change Image", "Are you sure you want to overwrite this image?",
                                                         "", "Yes", "No", imgTitle.Image, BetterDialog.ImageStyle.Image);
                    }
                    if (result == DialogResult.OK)
                    {
                        img = Image_IO.resize_Image(img, imgTitle.Width, imgTitle.Height);
                        img.Save(string.Format("{0}\\{1}.jpg", Folder_IO.GetUserImagePath(), gvContents.SelectedRows[0].Cells[0].Value),
                                 System.Drawing.Imaging.ImageFormat.Jpeg);
                        imgTitle.Image = img;
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Prompt to delete selected row:
        /// Yes - Deletes title and image then refreshes gridview.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dlg = BetterDialog.ShowDialog("Delete Title?", "Are you sure you want to delete this title?",
                                                       gvTitles.SelectedCells[0].Value.ToString(), "Yes", "No",
                                                       Image_IO.getImage(gvTitles.SelectedCells[0].Value.ToString()), BetterDialog.ImageStyle.Image);

            if (dlg == DialogResult.OK)
            {
                int row = gvTitles.SelectedCells[0].RowIndex;
                DB_Handle.UpdateTable(string.Format(
                                          @"DELETE FROM TITLES WHERE title_id={0}",
                                          "\"" + gvTitles.SelectedCells[0].Value.ToString() + "\""));
                Image_IO.delete_Image(gvTitles.SelectedCells[0].Value.ToString());

                if (gvTitles.Rows.Count > 0 && row > 0)
                {
                    savedRow = row - 1;
                    gvTitles[0, row].Selected = true;
                }
                else
                {
                    savedRow = 0;
                }
                if (txtSearch.Text.Length != 0)
                {
                    txtSearch_TextChanged(null, null);
                }
                load_infoPane();

                gvTitles.Focus();
            }
        }
Exemple #4
0
        /// <summary>
        /// Save, resize, and format dragged image with lblTitle filename.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void infoPane_DragDrop(object sender, DragEventArgs e)
        {
            if (lblTitle.Text.Length < 1)
            {
                BetterDialog.ShowDialog("Image Save", "Error : Title Required", "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
            else
            {
                try
                {
                    int x = this.PointToClient(new Point(e.X, e.Y)).X;

                    int y = this.PointToClient(new Point(e.X, e.Y)).Y;

                    //inside imgTitle boundaries
                    if (x >= imgTitle.Location.X && x <= imgTitle.Location.X + imgTitle.Width &&
                        y >= imgTitle.Location.Y && y <= imgTitle.Location.Y + imgTitle.Height)
                    {
                        string[]   files = (string[])e.Data.GetData(DataFormats.FileDrop);
                        FileStream fs    = new FileStream(files[0], FileMode.Open);
                        Image      img   = Image.FromStream(fs);
                        fs.Close();
                        img = Image_IO.resize_Image(img, imgTitle.Width, imgTitle.Height);
                        img.Save(string.Format("{0}\\{1}.jpg", Folder_IO.GetUserImagePath(), lblTitle.Text),
                                 System.Drawing.Imaging.ImageFormat.Jpeg);
                        imgTitle.Image = img;
                    }
                }
                catch (Exception ex)
                {
                    BetterDialog.ShowDialog("Image Save", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
            }
            ParentForm.Activate();
        }
Exemple #5
0
        /// <summary>
        /// Public interface to load Info Pane.
        /// </summary>
        public void load_infoPane()
        {
            try
            {
                editPane.Disable();
                contentPane.Disable();
                if (gvTitles.Rows.Count > 0)
                {
                    scrollpos = gvTitles.FirstDisplayedScrollingRowIndex;
                }
                infoPane.Enable();
                gvTitles.Enabled = true;
                panel1.Enabled   = true;

                populateList();
                Enable();

                if (gvTitles.Rows.Count > 0)
                {
                    gvTitles.FirstDisplayedScrollingRowIndex = scrollpos;
                }
            }
            catch (Exception ex)
            {
                BetterDialog.ShowDialog("Main Load", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
        }
Exemple #6
0
        public static void MoveFileTo(string src, string dest)
        {
            FileInfo      file    = new FileInfo(src);
            DirectoryInfo fromdir = new DirectoryInfo(src);
            DirectoryInfo dir     = new DirectoryInfo(dest);

            if (dir.Exists && file.Exists)
            {
                DialogResult result = BetterDialog.ShowDialog("Move File", "Are you sure you want to move this file?",
                                                              string.Format("File: {0}\n-\nDestination: {1}", file.Name, dir.Name), "Yes", "No",
                                                              NativeMethods.GetSmallIcon(src).ToBitmap(), BetterDialog.ImageStyle.Icon);
                if (result == DialogResult.OK)
                {
                    file.MoveTo(Path.Combine(dir.FullName, file.Name));
                }
            }
            if (fromdir.Exists && dir.Exists && fromdir.FullName != dir.FullName)
            {
                DialogResult result = BetterDialog.ShowDialog("Move Folder", "Are you sure you want to move this folder?",
                                                              string.Format("Folder: {0}\n-\nDestination: {1}", fromdir.Name, dir.Name), "Yes", "No",
                                                              LFI.Properties.Resources.folder, BetterDialog.ImageStyle.Icon);
                if (result == DialogResult.OK)
                {
                    fromdir.MoveTo(Path.Combine(dir.FullName, fromdir.Name));
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Opens folder pointed at by ddUrl.
 /// </summary>
 /// <remarks>
 /// This refreshes the gridview if already open.
 /// </remarks>
 private void open_Folder()
 {
     Console.WriteLine("OPEN");
     try
     {
         folder           = new Folder_IO(ddUrl.Text);
         fileWatcher.Path = ddUrl.Text;
         countFolders();
         btnShowDiv.Enabled = true;
         btnDivide.Enabled  = false;
         dirname            = ddUrl.Text;
         lstDivs_Click(null, null);
         txtFilter.Enabled = true;
         dragRow           = -1; savedRow = 0;
         if (showFields)
         {
             LoadFormatFields();
         }
         if (gvFiles.SelectedCells.Count > 0)
         {
             caller.SetLabelItemSize(Folder_IO.Get_Item_Size(gvFiles.SelectedCells[3].Value.ToString()));
         }
     }
     catch (Exception ex)
     {
         BetterDialog.ShowDialog("", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
     }
 }
Exemple #8
0
 /// <summary>
 /// Removes selected title row from gridview.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (gvContents.Rows.Count > 0)
     {
         DialogResult result = BetterDialog.ShowDialog("Remove Record?",
                                                       "Record will be deleted permanently.  Are you sure?",
                                                       string.Format("{0}\nSeason {1}\nStart {2}\nEnd {3}",
                                                                     gvContents.SelectedCells[0].Value, gvContents.SelectedCells[1].Value,
                                                                     gvContents.SelectedCells[2].Value, gvContents.SelectedCells[3].Value),
                                                       "Yes", "No", Image_IO.getImage(gvContents.SelectedCells[0].Value.ToString()),
                                                       BetterDialog.ImageStyle.Image);
         if (result == DialogResult.OK)
         {
             if (gvContents.Rows[gvContents.SelectedCells[0].RowIndex].Cells[4].ToString() != "null")
             {
                 DB_Handle.UpdateTable(string.Format(
                                           @"DELETE FROM CONTENTS WHERE
                     content_id = '{0}'",
                                           gvContents.Rows[gvContents.SelectedCells[0].RowIndex].Cells[4].Value));
             }
             gvContents.Rows.Remove(gvContents.Rows[gvContents.SelectedCells[0].RowIndex]);
             loadPage();
             DButton.SelBtn.DButton_Click(null, null);
         }
     }
 }
Exemple #9
0
 /// <summary>
 /// Swap two disc slots in a location.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void swapMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (selDisc != string.Empty)
         {
             DB_Handle.UpdateTable(string.Format(
                                       @"INSERT OR REPLACE INTO DISCS 
                 VALUES ('{0}','{1}','{2}','{3}');",
                                       selDisc, Page, Slot, Location_ID));
         }
         if (Disc != string.Empty)
         {
             DB_Handle.UpdateTable(string.Format(
                                       @"INSERT OR REPLACE INTO DISCS 
                 VALUES ('{0}','{1}','{2}','{3}');",
                                       Disc, selPage, selSlot, Location_ID));
         }
         Caller.loadPage();
         OnClick(null);
     }
     catch (Exception ex)
     {
         BetterDialog.ShowDialog("Disc Move", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
     }
 }
Exemple #10
0
        /// <summary>
        /// Create a special dialog in the style of Windows XP or Vista. A dialog has a custom icon, an optional large
        /// title in the form, body text, window text, and one or two custom-labeled buttons.
        /// </summary>
        /// <param name="titleString">This string will be displayed in the system window frame.</param>
        /// <param name="bigString">This is the first string to appear in the dialog. It will be most prominent.</param>
        /// <param name="smallString">This string appears either under the big string, or is null, which means it is
        /// not displayed at all.</param>
        /// <param name="leftButton">This is the left button, typically the "accept" button--label it with an
        /// action verb (or "OK").</param>
        /// <param name="rightButton">The right button--typically "Cancel", but could be "No".</param>
        /// <param name="iconSet">An image to be displayed on the left side of the dialog. Should be 32 x 32 pixels.</param>
        static public DialogResult ShowDialog(string title, string largeHeading, string smallExplanation,
                                              string leftButton, string rightButton, Image iconSet, ImageStyle iconDock)
        {
            BetterDialog dlg = new BetterDialog(title, largeHeading, smallExplanation, leftButton,
                                                rightButton, iconSet, iconDock);

            dlg.Owner = MainForm.Main;
            return(dlg.ShowDialog());
        }
Exemple #11
0
        public void load_data(DataTable sel)
        {
            try
            {
                lblTitle.Text    = sel.Rows[0][0].ToString();
                lblEpisode.Text  = sel.Rows[0][1].ToString();
                lblCategory.Text = sel.Rows[0][2].ToString();
                lblYear.Text     = sel.Rows[0][3].ToString();
                lblStatus.Text   = sel.Rows[0][4].ToString();
            }
            catch (Exception ex)
            {
                BetterDialog.ShowDialog("Load Error", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }

            setImage(lblTitle.Text);
        }
Exemple #12
0
 /// <summary>
 /// Generates the next available disc_id from discs table.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnGenerate_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = DB_Handle.GetDataTable(string.Format(
                                                   @"select max(disc_id) from discs 
             where location_id = '{0}'", ddLocation.Text));
         if (dt.Rows[0][0] is DBNull)
         {
             txtDisc.Text = "001";
         }
         else
         {
             txtDisc.Text = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString("000");
         }
     }
     catch (Exception ex)
     {
         BetterDialog.ShowDialog("DiscID Generation", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
     }
 }
Exemple #13
0
        /// <summary>
        /// Prompt to delete record.
        /// Deletes disc and all content records on disc.
        /// </summary>
        /// <remarks>
        /// no foreign_key support in sqlite version so
        /// records are manually deleted from each table.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dlg = BetterDialog.ShowDialog("Delete Disc",
                                                       "Disc will be deleted permanently. Are you Sure?",
                                                       Location_ID + Disc, "Yes", "No", Image, BetterDialog.ImageStyle.Image);

            if (dlg == DialogResult.OK)
            {
                try
                {
                    DB_Handle.UpdateTable(string.Format(
                                              @"DELETE FROM DISCS WHERE disc_id='{0}' and location_id='{1}'",
                                              Disc, Location_ID));

                    DataTable dt = DB_Handle.GetDataTable(string.Format(
                                                              @"SELECT content_id from disc_contents WHERE disc_id='{0}' and location_id='{1}'",
                                                              Disc, Location_ID));

                    for (int i = 0; i <= dt.Rows.Count - 1; i++)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"DELETE FROM CONTENTS WHERE content_id='{0}'", dt.Rows[i][0]));
                    }

                    DB_Handle.UpdateTable(string.Format(
                                              @"DELETE FROM DISC_CONTENTS WHERE disc_id='{0}' and location_id='{1}'",
                                              Disc, Location_ID));
                }
                catch (Exception ex)
                {
                    BetterDialog.ShowDialog("Disc Delete", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                finally
                {
                    DButton.SelBtn.PerformClick();
                    Caller.loadPage();
                    OnClick(null);
                }
            }
        }
Exemple #14
0
        public static void DeleteFile(string filename)
        {
            FileInfo file = new FileInfo(filename);

            if (!file.Exists)
            {
                return;
            }
            DialogResult result = BetterDialog.ShowDialog("Delete File",
                                                          "Are you sure you want to move this file to the Recycle Bin?",
                                                          string.Format("{0}\nType: {1}\nSize: {2}",
                                                                        file.Name,
                                                                        NativeMethods.GetShellFileType(file.FullName),
                                                                        (file.Length / Math.Pow(1024, 2)).ToString("N3") + " MB"), "Yes", "No",
                                                          NativeMethods.GetSmallIcon(file.FullName).ToBitmap(), BetterDialog.ImageStyle.Icon
                                                          );

            if (result == DialogResult.OK)
            {
                file.Delete();
            }
        }
Exemple #15
0
        public void load_data(string sel)
        {
            gvDisc.Rows.Clear();
            try
            {
                DataTable temp = DB_Handle.GetDataTable(string.Format(
                                                            @"Select 
                        disc_contents.location_id, 
                        disc_contents.disc_id, 
                        discs.page_number,
                        discs.slot_number, 
                        contents.season, 
                        contents.rangeStart,
                        contents.rangeEnd 
                    FROM contents 
                    INNER JOIN disc_contents ON contents.content_id = disc_contents.content_id
                    INNER JOIN discs ON discs.disc_id = disc_contents.disc_id 
                    WHERE contents.title_id={0} AND discs.location_id=disc_contents.location_id",
                                                            "\"" + sel + "\""));

                if (temp.Rows.Count > 0)
                {
                    for (int i = 0; i <= temp.Rows.Count - 1; i++)
                    {
                        for (int k = 0; k <= temp.Columns.Count - 1; k++)
                        {
                            Console.WriteLine(temp.Rows[i][k].ToString());
                        }
                        gvDisc.Rows.Add(temp.Rows[i][0],
                                        temp.Rows[i][1], temp.Rows[i][2], temp.Rows[i][3],
                                        temp.Rows[i][4], temp.Rows[i][5], temp.Rows[i][6]);
                    }
                }
            }
            catch (Exception ex)
            {
                BetterDialog.ShowDialog("DB Error", ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
        }
Exemple #16
0
 /// <summary>
 /// Create a special dialog in the style of Windows XP or Vista. A dialog has a custom icon, an optional large
 /// title in the form, body text, window text, and one or two custom-labeled buttons.
 /// </summary>
 /// <param name="titleString">This string will be displayed in the system window frame.</param>
 /// <param name="bigString">This is the first string to appear in the dialog. It will be most prominent.</param>
 /// <param name="smallString">This string appears either under the big string, or is null, which means it is
 /// not displayed at all.</param>
 /// <param name="leftButton">This is the left button, typically the "accept" button--label it with an
 /// action verb (or "OK").</param>
 /// <param name="rightButton">The right button--typically "Cancel", but could be "No".</param>
 /// <param name="iconSet">An image to be displayed on the left side of the dialog. Should be 32 x 32 pixels.</param>
 public static DialogResult ShowDialog(string title, string largeHeading, string smallExplanation,
     string leftButton, string rightButton, Image iconSet, ImageStyle iconDock)
 {
     BetterDialog dlg = new BetterDialog(title, largeHeading, smallExplanation, leftButton,
         rightButton, iconSet, iconDock);
     dlg.Owner = MainForm.Main;
     return dlg.ShowDialog();
 }
Exemple #17
0
        /// <summary>
        /// Attempts to save selected disc and each of its content rows.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveClick(object sender, EventArgs e)
        {
            bool rollbackpos = false;

            if (txtDisc.Text.Length < 1)
            {
                Error_Handle.TipError("Disc required\n", toolTip, txtDisc);
            }
            else if (txtPage.Text.Length < 1)
            {
                Error_Handle.TipError("Page required\n", toolTip, txtPage);
            }
            else if (txtSlot.Text.Length < 1)
            {
                Error_Handle.TipError("Slot required\n", toolTip, txtSlot);
            }
            else if (ddLocation.Text.Length < 1)
            {
                Error_Handle.TipError("Location required\n", toolTip, ddLocation);
            }
            else if (gvContents.Rows.Count < 1)
            {
                Error_Handle.TipError("Content required\n", toolTip, gvContents);
            }
            else
            {
                try
                {
                    DB_Handle.UpdateTable(string.Format(
                                              @"INSERT OR REPLACE INTO DISCS 
                        VALUES ('{0}','{1}','{2}','{3}');",
                                              txtDisc.Text, txtPage.Text, txtSlot.Text, ddLocation.Text));

                    if (isNewRecord)
                    {
                        rollbackpos = true;
                    }
                    DB_Handle.OpenConnection();
                    for (int i = 0; i <= gvContents.Rows.Count - 1; i++)
                    {
                        DB_Handle.ScalarUpdate(string.Format(
                                                   @"INSERT OR REPLACE INTO CONTENTS 
                            (content_id, title_id, season, rangeStart, rangeEnd)
                            VALUES ({0},{1},'{2}','{3}','{4}');",
                                                   gvContents.Rows[i].Cells[4].Value,
                                                   "\"" + gvContents.Rows[i].Cells[0].Value + "\"",
                                                   gvContents.Rows[i].Cells[1].Value,
                                                   gvContents.Rows[i].Cells[2].Value,
                                                   gvContents.Rows[i].Cells[3].Value));


                        DB_Handle.ScalarUpdate(string.Format(
                                                   @"INSERT OR REPLACE INTO DISC_CONTENTS
                            (content_id, disc_id, location_id)
                            VALUES (last_insert_rowid(),'{0}','{1}');",
                                                   txtDisc.Text,
                                                   ddLocation.Text));
                    }
                    BetterDialog.ShowDialog("Disc Save", "Success", "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                catch (Exception ex)
                {
                    if (rollbackpos)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"DELETE FROM DISCS WHERE
                            disc_id = '{0}' AND location_id = '{1}'",
                                                  txtDisc.Text, ddLocation.Text));
                    }
                    BetterDialog.ShowDialog("Disc Save", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                finally
                {
                    DB_Handle.CloseConnection();
                    DButton.SelBtn.DButton_Click(null, null);
                    loadPage();
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Attempts to update title and information.
        /// Validates information.
        /// Renames image if exists.
        /// </summary>
        /// <remarks>'Insert into' for new records only.</remarks>
        /// <returns>Pass or fail coniditon.</returns>
        public bool saveData()
        {
            bool status = false;

            try
            {
                if (txtTitle.Text.Trim().Length == 0)
                {
                    Error_Handle.TipError("Title required\n", toolTip, txtTitle);
                }
                else if (isnewrecord && SearchExistingTitles())
                {
                    Error_Handle.TipError("Title already exists\n", toolTip, txtTitle);
                }
                else if (ddCategory.Text.Length == 0)
                {
                    Error_Handle.TipError("Category required\n", toolTip, ddCategory);
                }
                else if (ddStatus.Text.Length < 1)
                {
                    Error_Handle.TipError("Status required\n", toolTip, ddStatus);
                }
                else if (ddLanguage.Text.Length < 1)
                {
                    Error_Handle.TipError("Language required\n", toolTip, ddLanguage);
                }
                else if (txtYear.Text.Length != 4)
                {
                    Error_Handle.TipError("Year required\n", toolTip, txtYear);
                }
                else if (txtEpisode.Text.Length < 1)
                {
                    Error_Handle.TipError("Episode required\n", toolTip, txtEpisode);
                }
                else
                {
                    if (isnewrecord)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"INSERT INTO TITLES VALUES ({0},'{1}','{2}','{3}','{4}','{5}');",
                                                  "\"" + txtTitle.Text.Trim() + "\"", txtEpisode.Text.Replace(" ", ""), ddCategory.Text,
                                                  txtYear.Text, ddStatus.Text, ddLanguage.Text, currentTitle));
                    }
                    else
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"UPDATE TITLES SET
                            title_id={0}, 
                            episodes='{1}', 
                            category='{2}', 
                            year='{3}', 
                            status='{4}', 
                            language='{5}'
                            WHERE title_id={6};",
                                                  "\"" + txtTitle.Text.Trim() + "\"", txtEpisode.Text.Replace(" ", ""), ddCategory.Text,
                                                  txtYear.Text, ddStatus.Text, ddLanguage.Text, "\"" + currentTitle + "\""));

                        DB_Handle.UpdateTable(string.Format(
                                                  @"UPDATE CONTENTS SET
                            title_id={0}
                            WHERE title_id={1};",
                                                  "\"" + txtTitle.Text.Trim() + "\"", "\"" + currentTitle + "\""));
                        Image_IO.rename_Image(currentTitle, txtTitle.Text.Trim());
                    }

                    BetterDialog.ShowDialog("Saved", "Success", string.Empty, string.Empty, "OK", null, BetterDialog.ImageStyle.Icon);
                    status = true;
                    populateDropDownTitles();
                }
            }
            catch (Exception ex)
            {
                Error_Handle.TipError(ex.Message, toolTip, imgError);
            }
            return(status);
        }
Exemple #19
0
        /// <summary>
        /// Renames a file with a prefix, title, episode, and suffix into a standard format.
        /// </summary>
        /// <param name="filename">The fullpath filename.</param>
        /// <param name="prefix">The prefix for the front.</param>
        /// <param name="title">The title.</param>
        /// <param name="episode">The episode.</param>
        /// <param name="suffix">The suffix for the end.</param>
        /// <param name="newfilename">Just the filename.</param>
        /// <param name="skipped">A skipped message.</param>
        /// <returns>The fullpath filename.</returns>
        public static string RenameFile(string filename,
                                        string prefix, string title, string season, string episode, string suffix, EPFORMAT format,
                                        out string newfilename, out bool skipped)
        {
            FileInfo file         = new FileInfo(filename);
            string   destfilename = string.Empty;

            skipped = false;
            int outIgnore;

            try
            {
                if (prefix.Trim().Length >= 1)
                {
                    destfilename = '[' + prefix + ']' + ' ';
                }
                destfilename += title;

                if (episode.Trim().Length < 1)
                {
                    skipped = true;
                }
                else if (!int.TryParse(episode, out outIgnore))
                {
                    skipped = true;
                }
                else if (season.Trim().Length >= 1 && !int.TryParse(season, out outIgnore))
                {
                    skipped = true;
                }
                else
                {
                    destfilename += FileNameFormat.ToFormat(episode, season, format);
                }

                if (suffix.Trim().Length >= 1)
                {
                    destfilename += " [" + suffix + "]";
                }
                destfilename = destfilename.Replace(' ', '_');
                FixExtension(file);
                file.Refresh();
                if (!skipped)
                {
                    file.MoveTo(file.FullName.Replace(file.Name, destfilename) + file.Extension);
                }
                file.Refresh();
            }
            catch (IOException)
            {
                skipped = true;
                BetterDialog.ShowDialog("Rename Error",
                                        string.Format("Cannot Rename File: {0}\nFile Already Exists As: {1}", file.Name, destfilename),
                                        "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
            finally
            {
                newfilename = Path.GetFileName(file.Name);
            }
            return(file.FullName);
        }
Exemple #20
0
        /// <summary>
        /// Update filenames from selected or all files using gridview row data and txtTitle.
        /// </summary>
        /// <remarks>
        /// Updated fields are saved to the filter table.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRunFormats_Click(object sender, EventArgs e)
        {
            if (txtTitle.Text.Length < 1)
            {
                BetterDialog.ShowDialog("Rename Function", "Error : Title Required.", "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
            else
            {
                if (radCheckAll.Checked)
                {
                    fileWatcher.EnableRaisingEvents = false;
                    for (int i = 0; i < gvFiles.Rows.Count; i++)
                    {
                        string newfilename = string.Empty;
                        bool   skipped     = false;
                        if (!Directory.Exists(gvFiles.Rows[i].Cells[3].Value.ToString()))
                        {
                            gvFiles.Rows[i].Cells[3].Value =
                                Folder_IO.RenameFile(gvFiles.Rows[i].Cells[3].Value.ToString(),
                                                     gvFiles.Rows[i].Cells[4].Value.ToString(),
                                                     txtTitle.Text,
                                                     gvFiles.Rows[i].Cells[5].Value.ToString(),
                                                     gvFiles.Rows[i].Cells[6].Value.ToString(),
                                                     gvFiles.Rows[i].Cells[7].Value.ToString(),
                                                     (EPFORMAT)ddFormat_Use.SelectedValue,
                                                     out newfilename, out skipped);
                            gvFiles.Rows[i].Cells[2].Value = newfilename;
                            Copy_Cells(Convert.ToInt32(gvFiles.Rows[i].Cells[8].Value), i);

                            if (skipped)
                            {
                                gvFiles.Rows[i].Cells[0].Value = LFI.Properties.Resources.Warning;
                            }
                        }
                    }
                    fileWatcher.EnableRaisingEvents = true;
                    LoadFormatFields();
                }
                else
                {
                    string newfilename = string.Empty;
                    bool   skipped     = false;
                    if (!Directory.Exists(gvFiles.SelectedCells[3].Value.ToString()))
                    {
                        gvFiles.SelectedCells[3].Value =
                            Folder_IO.RenameFile(gvFiles.SelectedCells[3].Value.ToString(),
                                                 gvFiles.SelectedCells[4].Value.ToString(),
                                                 txtTitle.Text,
                                                 gvFiles.SelectedCells[5].Value.ToString(),
                                                 gvFiles.SelectedCells[6].Value.ToString(),
                                                 gvFiles.SelectedCells[7].Value.ToString(),
                                                 (EPFORMAT)ddFormat_Use.SelectedValue,
                                                 out newfilename, out skipped);
                        gvFiles.SelectedCells[2].Value = newfilename;
                        Copy_Cells(Convert.ToInt32(gvFiles.SelectedCells[8].Value), gvFiles.SelectedCells[0].RowIndex);

                        if (skipped)
                        {
                            gvFiles.SelectedCells[0].Value = LFI.Properties.Resources.Warning;
                        }
                    }
                }
            }
        }