Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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;
                }
            }
        }