Example #1
0
        private void gvFiles_KeyDown(object sender, KeyEventArgs e)
        {
            if (!gvFiles.IsCurrentCellInEditMode)
            {
                if (e.KeyCode == Keys.Back)
                {
                    btnBack_Click(null, null);
                }
                if (e.KeyCode == Keys.F5)
                {
                    refresh_Folder();
                }
                if (e.KeyCode == Keys.Delete)
                {
                    Folder_IO.DeleteFile(gvFiles.SelectedCells[3].Value.ToString());
                }

                //Prevent fullrow copy and use only the filename.
                if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
                {
                    Clipboard.SetText(gvFiles.SelectedCells[2].Value.ToString(), TextDataFormat.Text);
                    e.Handled = true;
                }
            }
        }
Example #2
0
 /// <summary>
 /// Remove checksum from selected or all files.
 /// </summary>
 /// <remarks>
 /// Updated fields are saved to the filter table.
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRemoveCRC_Click(object sender, EventArgs e)
 {
     if (radCheckAll.Checked)
     {
         fileWatcher.EnableRaisingEvents = false;
         for (int i = 0; i < gvFiles.Rows.Count; i++)
         {
             string newfilename = string.Empty;
             gvFiles.Rows[i].Cells[3].Value =
                 Folder_IO.RemoveCRC(gvFiles.Rows[i].Cells[3].Value.ToString(),
                                     out newfilename);
             dtFilter.Rows[i][0]            = newfilename;
             dtFilter.Rows[i][1]            = gvFiles.Rows[i].Cells[3].Value;
             gvFiles.Rows[i].Cells[2].Value = newfilename;
             Copy_Cells(Convert.ToInt32(gvFiles.Rows[i].Cells[8].Value), i);
         }
         fileWatcher.EnableRaisingEvents = true;
         LoadFormatFields();
     }
     else
     {
         string newfilename = string.Empty;
         gvFiles.SelectedCells[3].Value =
             Folder_IO.RemoveCRC(gvFiles.SelectedCells[3].Value.ToString(),
                                 out newfilename);
         //
         gvFiles.SelectedCells[2].Value = newfilename;
         Copy_Cells(Convert.ToInt32(gvFiles.SelectedCells[8].Value), gvFiles.SelectedCells[0].RowIndex);
     }
 }
Example #3
0
        /// <summary>
        /// Show dialog for saving image with title as file name.
        /// </summary>
        /// <remarks>saves jpeg format.</remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImg_Click(object sender, EventArgs e)
        {
            if (txtTitle.Text.Trim().Length < 1)
            {
                toolTip.Show("Title Required!", imgError);
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() != DialogResult.Cancel)
            {
                try
                {
                    FileStream fs  = new FileStream(dlg.FileName, 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(), txtTitle.Text.Trim()),
                             System.Drawing.Imaging.ImageFormat.Jpeg);
                    imgTitle.Image = img;
                }
                catch (Exception ex)
                {
                    toolTip.Show(ex.Message, imgError);
                }
            }
        }
Example #4
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;
                    }
                }
            }
        }
Example #5
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();
        }
Example #6
0
        /// <summary>
        /// Create a merged image using the list of titles.
        /// Default image is used when an image cannot be found.
        /// </summary>
        /// <param name="titleStrs">list of string titles.</param>
        /// <param name="btn">control to resize to.</param>
        /// <returns>the final image.</returns>
        public static Image createMergedImage(List <string> titleStrs, Control btn)
        {
            List <Image>  imgLst   = new List <Image>();
            List <string> titleLst = new List <string>();
            string        path     = Folder_IO.GetUserImagePath();

            for (int i = 0; i <= titleStrs.Count - 1; i++)
            {
                if (!titleLst.Contains(titleStrs[i]))
                {
                    titleLst.Add(titleStrs[i]);
                    if (System.IO.File.Exists(path + string.Format("\\{0}.jpg", titleStrs[i])))
                    {
                        FileStream fs  = new FileStream(path + string.Format("\\{0}.jpg", titleStrs[i]), FileMode.Open);
                        Image      img = Image.FromStream(fs);
                        fs.Close();
                        imgLst.Add(resize_Image(img, 245, 345));
                    }
                    else
                    {
                        imgLst.Add(resize_Image(LFI.Properties.Resources.notavailable,
                                                245, 345));
                    }
                }
            }
            Image finalImage = merge_Images(imgLst, btn.Width, btn.Height, titleLst.Count);

            return(finalImage);
        }
Example #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);
     }
 }
Example #8
0
        /// <summary>
        /// Save dragged image with selected gridview row title.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void imgTitle_DragDrop(object sender, DragEventArgs e)
        {
            if (gvContents.Rows.Count > 0)
            {
                try
                {
                    int x = this.PointToClient(new Point(e.X, e.Y)).X;

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

                    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, IMG_SIZE.Width, IMG_SIZE.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;
                }
                catch (Exception ex)
                {
                    toolTip.Show(ex.Message, imgTitle);
                }
            }
            Enable();
            ParentForm.Activate();
            DButton.SelBtn.DButton_Click(null, null);
        }
Example #9
0
        /// <summary>
        /// Load initial form location from SystemInformation and
        /// create image folder in appdata if not already exists.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            BorderWidth = SystemInformation.FrameBorderSize.Width - 1;

            StartPosition = FormStartPosition.Manual;
            Location      = Properties.Settings.Default.location;
            Folder_IO.GetUserImagePath();
            this.Size          = vertical;
            this.ActiveControl = mv.GetInitialControl();
        }
Example #10
0
        /// <summary>
        /// Delete a specific image file.
        /// </summary>
        /// <param name="str">the filename.</param>
        public static void delete_Image(string str)
        {
            string path = Folder_IO.GetUserImagePath();
            string file = string.Format("\\{0}.jpg", str);

            if (System.IO.File.Exists(path + file))
            {
                File.Delete(path + file);
            }
        }
Example #11
0
        public static Image getImage(string str)
        {
            string path       = Folder_IO.GetUserImagePath() + string.Format("\\{0}.jpg", str);
            Image  foundImage = null;

            if (System.IO.File.Exists(path))
            {
                FileStream fs = new FileStream(path, FileMode.Open);
                foundImage = Image.FromStream(fs);
                fs.Close();
            }
            return(foundImage);
        }
Example #12
0
        /// <summary>
        /// Rename an image file to a new string.
        /// </summary>
        /// <param name="str">original filename.</param>
        /// <param name="newstr">new filename.</param>
        public static void rename_Image(string str, string newstr)
        {
            if (str == newstr)
            {
                return;
            }
            string path    = Folder_IO.GetUserImagePath();
            string file    = string.Format("\\{0}.jpg", str);
            string newfile = string.Format("\\{0}.jpg", newstr);

            if (System.IO.File.Exists(path + file))
            {
                File.Move(path + file, path + newfile);
            }
        }
Example #13
0
        /// <summary>
        /// Load image file to stream and place it into control property.
        /// </summary>
        /// <param name="str">filename.</param>
        /// <param name="bx">picturebox control.</param>
        public static void setImage(string str, PictureBox bx)
        {
            string path = Folder_IO.GetUserImagePath() + string.Format("\\{0}.jpg", str);

            if (System.IO.File.Exists(path))
            {
                FileStream fs  = new FileStream(path, FileMode.Open);
                Image      img = Image.FromStream(fs);
                fs.Close();
                bx.Image = img;
            }
            else
            {
                bx.Image = null;
            }
        }
Example #14
0
        /// <summary>
        /// Checks for existing image and loads it from stream to imgTitle.
        /// </summary>
        /// <param name="str">title_id</param>
        private void setImage(string str)
        {
            string path = Folder_IO.GetUserImagePath() + string.Format("\\{0}.jpg", str);

            if (System.IO.File.Exists(path))
            {
                FileStream fs  = new FileStream(path, FileMode.Open);
                Image      img = Image.FromStream(fs);
                fs.Close();
                imgTitle.Image = img;
            }
            else
            {
                imgTitle.Image = LFI.Properties.Resources.notavailable;
            }
        }
Example #15
0
        private void gvFiles_DragDrop(object sender, DragEventArgs e)
        {
            if (dragRow == -1)
            {
                return;
            }
            string files = (string)e.Data.GetData(DataFormats.Text);

            Console.WriteLine(files);
            Point p   = gvFiles.PointToClient(new Point(e.X, e.Y));
            int   row = gvFiles.HitTest(p.X, p.Y).RowIndex;

            gvFiles.AllowDrop = false;
            gvFiles.Rows[dragRow].Selected = true;
            Folder_IO.MoveFileTo(files, gvFiles.Rows[dragRow].Cells[3].Value.ToString());
        }
Example #16
0
 /// <summary>
 /// Remove part file extension from selected or all files.
 /// </summary>
 /// <remarks>
 /// Updated fields are saved to the filter table.
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPartFiles_Click(object sender, EventArgs e)
 {
     if (radCheckAll.Checked)
     {
         for (int i = 0; i < gvFiles.Rows.Count; i++)
         {
             FileInfo file = new FileInfo(gvFiles.Rows[i].Cells[3].Value.ToString());
             Folder_IO.FixExtension(file);
             Copy_Cells(Convert.ToInt32(gvFiles.Rows[i].Cells[8].Value), i);
         }
     }
     else
     {
         FileInfo file = new FileInfo(gvFiles.SelectedCells[3].Value.ToString());
         Folder_IO.FixExtension(file);
         Copy_Cells(Convert.ToInt32(gvFiles.SelectedCells[8].Value), gvFiles.SelectedCells[0].RowIndex);
     }
 }
Example #17
0
 /// <summary>
 /// Sets savedRow to selected rowindex of gridview.
 /// Sets LabelItemSize to selected row's item file size.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gvFiles_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (gvFiles.SelectedCells.Count > 0)
     {
         if (gvFiles.SelectedCells[2].Value != null && !multiRun)
         {
             if (!multiRun)
             {
                 savedRow = gvFiles.SelectedCells[2].RowIndex;
             }
             caller.SetLabelItemSize(Folder_IO.Get_Item_Size(gvFiles.SelectedCells[3].Value.ToString()));
             Console.WriteLine(savedRow);
         }
     }
     else
     {
         caller.SetLabelItemSize(" ");
     }
 }
Example #18
0
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Image img = Clipboard.GetImage();

            if (img != null)
            {
                if (txtTitle.Text.Trim().Length < 1)
                {
                    toolTip.Show("Title Required!", imgError);
                }
                else
                {
                    img = Image_IO.resize_Image(img, imgTitle.Width, imgTitle.Height);
                    img.Save(string.Format("{0}\\{1}.jpg", Folder_IO.GetUserImagePath(), txtTitle.Text.Trim()),
                             System.Drawing.Imaging.ImageFormat.Jpeg);
                    imgTitle.Image = img;
                }
            }
        }
Example #19
0
        private void AddCRC()
        {
            string fullfilename = gvFiles.Rows[workingRow].Cells[3].Value.ToString();

            if (!Folder_IO.IsCRC(fullfilename) && !Directory.Exists(fullfilename))
            {
                gvFiles.Rows[workingRow].Cells[0].Value = LFI.Properties.Resources.empty;
                animation.Show();
                Crc32.worker = new BackgroundWorker();
                Crc32.worker.WorkerReportsProgress      = true;
                Crc32.worker.WorkerSupportsCancellation = true;
                Crc32.worker.DoWork             += new DoWorkEventHandler(worker_ComputeCRC);
                Crc32.worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_AddCRCCompleted);
                EnableRunButtons();
                caller.start_progBar();
                Crc32.worker.RunWorkerAsync(gvFiles.Rows[workingRow].Cells[3].Value);
            }
            else
            {
                Add_MultiRunIncrement();
            }
        }
Example #20
0
        private void bw_AddCRCCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            animation.Hide();
            caller.stop_progBar();
            string newfilename = string.Empty;

            if (!cancel)
            {
                gvFiles.Rows[workingRow].Cells[3].Value =
                    Folder_IO.AddCRC(gvFiles.Rows[workingRow].Cells[3].Value.ToString(),
                                     checksum, out newfilename);
                gvFiles.Rows[workingRow].Cells[0].Value = LFI.Properties.Resources.check;
                gvFiles.Rows[workingRow].Cells[2].Value = newfilename;
            }
            else
            {
                gvFiles.Rows[workingRow].Cells[0].Value = null;
            }

            DisableRunButtons();
            Add_MultiRunIncrement();
        }
Example #21
0
        private void bw_CheckCRCCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            animation.Hide();
            caller.stop_progBar();

            if (!cancel)
            {
                if (checksum == Folder_IO.ScanCRC(gvFiles.Rows[workingRow].Cells[3].Value.ToString()))
                {
                    gvFiles.Rows[workingRow].Cells[0].Value = LFI.Properties.Resources.check;
                }
                else
                {
                    gvFiles.Rows[workingRow].Cells[0].Value = LFI.Properties.Resources.error;
                }
            }
            else
            {
                gvFiles.Rows[workingRow].Cells[0].Value = null;
            }

            DisableRunButtons();
            Check_MultiRunIncrement();
        }
Example #22
0
 public string EstimateCRC()
 {
     return(Folder_IO.ScanCRC(fileName));
 }
Example #23
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);
     }
 }
Example #24
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;
                        }
                    }
                }
            }
        }