Пример #1
0
        /// <summary>
        /// Sends current dbutton info to Disc View and creates an upscaled
        /// split image of the disc contents.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DButton_Click(object sender, EventArgs e)
        {
            Caller.popContentPane();
            SetClick();
            DataTable temp = DB_Handle.GetDataTable(string.Format(
                                                        @"SELECT * FROM contents JOIN disc_contents on contents.content_id =
                disc_contents.content_id WHERE disc_id='{0}' and location_id='{1}';",
                                                        Disc, Location_ID));

            if (temp.Rows.Count > 0)
            {
                Caller.isNewRecord = false;
                Caller.setData(Disc, Page, Slot);
                for (int i = 0; i <= temp.Rows.Count - 1; i++)
                {
                    Caller.getContentsGrid().Rows.Add(temp.Rows[i][1], temp.Rows[i][2],
                                                      temp.Rows[i][3], temp.Rows[i][4], temp.Rows[i][0]);
                }
            }
            else
            {
                Caller.isNewRecord = true;
                Caller.setData(string.Empty, Page, Slot);
            }
            Caller.setImagebox(Image_IO.generateDiscImage(Disc, Location_ID, Caller.getImagebox()));
        }
Пример #2
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();
        }
Пример #3
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);
         }
     }
 }
Пример #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;
                    }
                }
            }
        }
Пример #5
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);
        }
Пример #6
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);
                }
            }
        }
Пример #7
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();
            }
        }
Пример #8
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);
        }
Пример #9
0
        public discView()
        {
            InitializeComponent();
            DoubleBuffered = true;
            gvContents.AlternatingRowsDefaultCellStyle = null;
            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = true;
            worker.DoWork             += new DoWorkEventHandler(worker_DoWork);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_Completed);
            imgTitle.Image             = Image_IO.generateDiscImage("", "", imgTitle);

            for (int i = 0, slot = 1; i <= (PAGES_PER_VIEW * DISCS_PER_PAGE) - 1; i++, slot++)
            {
                if (slot > DISCS_PER_PAGE)
                {
                    slot = 1;
                }
                dbuttons.Add(new DButton(slot, copyLabel,
                                         Controls["btn" + (i + 1)].Location, this));
                Controls.Add(dbuttons[i]);
                Controls.Add(dbuttons[i].vlbl);
            }

            DataTable locations = DB_Handle.GetDataTable(string.Format(
                                                             @"Select location_id from locations order by location_id"));

            ddLocation.DisplayMember = "location_id";
            ddLocation.DataSource    = locations;

            DataTable titles = DB_Handle.GetDataTable(string.Format(
                                                          @"Select title_id from titles order by title_id"));

            ddInsTitle.DataSource    = titles;
            ddInsTitle.DisplayMember = "title_id";

            this.DoubleBuffered = true;
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            UpdateStyles();

            txtDisc.ReadOnly = AllowDiscEdit;
            loadView();
            foreach (Control c in panel1.Controls)
            {
                c.Enter += new EventHandler(c_Enter);
            }
            foreach (Control c in gbContents.Controls)
            {
                c.Enter += new EventHandler(c_Enter);
            }
        }
Пример #10
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;
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Get contents of a disc_id and generate a merged image for it.
        /// </summary>
        /// <param name="discid"></param>
        /// <param name="locationid"></param>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static Image generateDiscImage(string discid, string locationid, Control btn)
        {
            Image     img  = resize_Image(LFI.Properties.Resources.border, 245, 345);
            DataTable temp = DB_Handle.GetDataTable(string.Format(
                                                        @"SELECT * FROM contents JOIN disc_contents on contents.content_id =
                disc_contents.content_id WHERE disc_id='{0}' and location_id='{1}';",
                                                        discid, locationid));

            if (temp.Rows.Count > 0)
            {
                List <string> disc_titles = new List <string>();
                if (temp.Rows.Count > 0)
                {
                    for (int i = 0; i <= temp.Rows.Count - 1; i++)
                    {
                        disc_titles.Add(temp.Rows[i][1].ToString());
                    }
                }
                img = Image_IO.createMergedImage(disc_titles, btn);
            }
            return(img);
        }
Пример #12
0
        /// <summary>
        /// Load dbutton information based on Location, Page, Slot.
        /// Set selection data if currently selected.
        /// </summary>
        /// <param name="page">page_number.</param>
        public void load(int page)
        {
            DataTable dt = DB_Handle.GetDataTable(string.Format(@"select * from discs
                where location_id='{0}' and page_number='{1}' and slot_number='{2}'",
                                                                Location_ID, page, Slot));

            if (dt.Rows.Count != 0)
            {
                setData(dt.Rows[0][0], dt.Rows[0][1]);
            }
            else
            {
                setData(string.Empty, page);
            }
            Image = Image_IO.generateDiscImage(Disc, Location_ID, this);
            if (selDisc != string.Empty)
            {
                if (selSlot == Slot && selPage == Page)
                {
                    SetClick();
                }
            }
        }
Пример #13
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);
        }