Пример #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();
        }
Пример #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;
                    }
                }
            }
        }
Пример #3
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);
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        private void contextMenuImg_Opening(object sender, CancelEventArgs e)
        {
            Image img = Clipboard.GetImage();

            if (img == null)
            {
                e.Cancel = true;
                return;
            }

            pasteToolStripMenuItem.Image = Image_IO.resize_Image(img, imgTitle.Width, imgTitle.Height);
        }
Пример #6
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;
                }
            }
        }