private void FormSync_Load(object sender, EventArgs e)
        {
            listViewSyncUp.View          = View.Details;
            listViewSyncUp.FullRowSelect = true;
            listViewSyncUp.Sorting       = SortOrder.Ascending;
            listViewSyncUp.HideSelection = false; // keep selection highlighted (grey) on blur

            listViewSyncUp.Columns.Clear();
            listViewSyncUp.Columns.Add("Name", nameWidth, HorizontalAlignment.Left);
            listViewSyncUp.Columns.Add("Qty", qtyWidth, HorizontalAlignment.Center);
            listViewSyncUp.Columns.Add("Size", sizeWidth, HorizontalAlignment.Right);


            // meh .. seems have to use resizing events
            // listViewSyncUp.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);

            ResizeColumns();

            ListVideoInfo.Save();

            Sync.Load();
            if (Sync.syncSettings.syncUp == DateTime.MinValue)
            {
                MyFormField.SetLabelText(labelLastSyncUp, "Not yet");
            }
            else
            {
                MyFormField.SetLabelText(labelLastSyncUp, Sync.syncSettings.syncUp);
            }

            SetList();
        }
        private void FormOptions_Load(object sender, EventArgs e)
        {
            comboBoxWatchedAfter.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBoxWatchedAfter.Items.Clear();
            comboBoxWatchedAfter.Items.Add(1);
            comboBoxWatchedAfter.Items.Add(5);
            comboBoxWatchedAfter.Items.Add(10);
            comboBoxWatchedAfter.Items.Add(15);

            int watchedAfter;

            if (Config.settings.watchedAfter == 0)
            {
                watchedAfter = 1;
            }
            else
            {
                watchedAfter = (int)Math.Floor((decimal)Config.settings.watchedAfter / 60);
                switch (watchedAfter)
                {
                case 1:
                case 5:
                case 10:
                case 15:
                    break;

                default:
                    watchedAfter = 1;
                    break;
                }
            }


            try
            {
                // update
                MyFormField.SetCheckBoxChecked(checkBoxCreateMB, Config.settings.createMB);
                MyFormField.SetCheckBoxChecked(checkBoxCreateMVE, Config.settings.createMVE);
                MyFormField.SetCheckBoxChecked(checkBoxCreateXBMC, Config.settings.createXBMC);
                MyFormField.SetCheckBoxChecked(checkBoxUpdateMB, Config.settings.updateMB);
                MyFormField.SetCheckBoxChecked(checkBoxUpdateXBMC, Config.settings.updateXBMC);
                MyFormField.SetCheckBoxChecked(checkBoxMarkWatched, Config.settings.markWatched);
                MyFormField.SetComboBoxValue(comboBoxWatchedAfter, watchedAfter);
                ValidateMarkWatched();


                // gallery
                MyFormField.SetCheckBoxChecked(checkBoxEnableGallery, Config.settings.gallery.enable);
                ToggleGalleryEnabled();
                labelGalleryBackColor.Text      = "";
                labelGalleryBackColor.BackColor = Config.settings.gallery.backColor;
                MyFormField.SetCheckBoxChecked(checkBoxEnableGalleryCache, Config.settings.gallery.cachePosterThumbnails);
            }
            catch (Exception ex2)
            {
                MyLog.Add(ex2.ToString());
            }
        }
        private void listViewSource_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (scanning)
            {
                // revert to scanning source
                if (currentSource != null)
                {
                    ListViewItem listViewItem = listViewSource.FindItemWithText(currentSource.alias);
                    if (listViewItem != null)
                    {
                        listViewItem.Selected = true;
                    }
                }
                return;
            }

            if (listViewSource.SelectedItems.Count == 0)
            {
                ClearSourceForm();

                buttonRemoveSource.Enabled = false;
                buttonScanSource.Enabled   = false;
                buttonAddSource.Enabled    = true;
            }
            else
            {
                ListViewItem selectedItem = listViewSource.SelectedItems[0];
                string       alias        = selectedItem.SubItems[0].Text;

                ConfigSettings.Source source = Config.GetSourceByAlias(alias);
                if (source == null)
                {
                    return;
                }

                currentSource = source;

                MyFormField.SetTextBoxText(textBoxAlias, source.alias);
                MyFormField.SetComboBoxValue(comboBoxType, source.type);
                MyFormField.SetLabelText(labelLastScanned, source.lastScanned);
                MyFormField.SetTextBoxText(textBoxDirectory, source.directory);

                CalcStatsForSource(source);

                textBoxAlias.Enabled     = false;
                textBoxDirectory.Enabled = false;
                comboBoxType.Enabled     = false;

                buttonAddSource.Enabled       = true;
                buttonSourceDirectory.Enabled = false;
                buttonRemoveSource.Enabled    = true;
                buttonSaveSource.Enabled      = false;
                buttonScanSource.Enabled      = true;
                subFormProgressOptions.Text("Ready");
            }
        }
        private void buttonRemoveSource_Click(object sender, EventArgs e)
        {
            MyFormField.DelayButtonClick(buttonRemoveSource);

            if (currentSource == null)
            {
                return;
            }

            string message = "Are you sure you want to remove this Video Source?" + Environment.NewLine;

            message += "Alias: " + currentSource.alias + Environment.NewLine;
            message += "Type: " + currentSource.type + Environment.NewLine;
            message += "Directory: " + currentSource.directory + Environment.NewLine;
            string lastScanned = currentSource.lastScanned.ToLocalTime().ToString();

            if (currentSource.lastScanned == DateTime.MinValue)
            {
                lastScanned = "Not yet";
            }
            message += "Last Scanned: " + lastScanned + Environment.NewLine;

            if (MessageBox.Show(message, "Confirm Removal",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
            {
                listViewSource.SelectedItems[0].Remove();


                // remove entry from settings
                Config.settings.sources.Remove(currentSource);

                List <VideoInfo> currentVideoInfos = ListVideoInfo.GetList();
                int nbrOrigVideoInfos = currentVideoInfos.Count();
                currentVideoInfos.RemoveAll(s => s.sourceAlias == currentSource.alias);
                int nbrRemovedVideoInfos = nbrOrigVideoInfos - currentVideoInfos.Count();
                ListVideoInfo.SetList(currentVideoInfos);

                // meh, but works
                FormMain        formMain        = (FormMain)this.Owner;
                SubFormListView subFormListView = formMain.GetSubFormListView();
                subFormListView.SetListViewInfos(ListVideoInfo.GetList());

                MyLog.Add("Removed " + currentSource.alias + " and it's " + nbrRemovedVideoInfos + " VideoItems");

                // datatable xml will be updated on main form close
                // settings xml will be updated on main form close

                currentSource = null;
                buttonRemoveSource.Enabled = false;
            }
        }
Exemple #5
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            button.Enabled = false;
            button.Text    = "Saving..";



            SaveForm();

            MyFormField.DelayButtonClick(button, "Save");
        }
        private void FormSources_Shown(object sender, EventArgs e)
        {
            MyFormField.HighlightTextBoxesOnFocus(this);

            ClearSourceForm();

            ResizeColumns();

            if (Config.settings.sources.Count == 0)
            {
                buttonAddSource_Click(sender, e);
                return;
            }
        }
        private void ClearSourceForm()
        {
            MyFormField.SetTextBoxText(textBoxAlias, "");
            MyFormField.SetComboBoxValue(comboBoxType, VideoFileEnums.sourceType.defaultValue);
            comboBoxType.SelectedIndex = 0;
            MyFormField.SetTextBoxText(textBoxDirectory, "");
            MyFormField.SetLabelText(labelLastScanned, "-");

            MyFormField.SetLabelText(labelVideoFileQty, "-");
            MyFormField.SetLabelText(labelOtherFilesQty, "-");

            subFormProgressOptions.Text("Select a Source");
            subFormProgressOptions.Value(0);

            buttonRemoveSource.Enabled = false;
            buttonScanSource.Enabled   = false;
        }
Exemple #8
0
        private void SetLinkLabelFromTitle(LinkLabel linkLabel, string link)
        {
            string search = "";

            if (textBoxTitle.Text != null && textBoxTitle.Text.Length > 0)
            {
                search = textBoxTitle.Text;
                if (comboBoxYear.Text != null && comboBoxYear.Text.Length == 4)
                {
                    search += " " + comboBoxYear.Text;
                }
                search = Uri.EscapeUriString(search);
                MyFormField.SetLinkLabel(linkLabel, link, search);
            }
            else
            {
                MyFormField.SetLinkLabel(linkLabel, link, null);
            }
        }
        // after form loaded
        private void FormMain_Shown(object sender, EventArgs e)
        {
            MyFormField.HighlightFormFieldsOnFocus(this);

            loadVideos.AddAccessToSubForms(subFormListView, subFormGallery, subFormVideoForm, subFormFilterForm, subFormProgressMain);


            Application.DoEvents(); // meh



            // ensure required app dirs exist
            MyFile.EnsureDirectoryExists(@"cache");
            MyFile.EnsureDirectoryExists(@"cache\gallery");
            MyFile.EnsureDirectoryExists(@"config");
            MyFile.EnsureDirectoryExists(@"data");
            MyFile.EnsureDirectoryExists(@"filters");
            MyFile.EnsureDirectoryExists(@"libs");
            MyFile.EnsureDirectoryExists(@"libs\ffmpeg\bin");
            MyFile.EnsureDirectoryExists(@"logs");
            MyFile.EnsureDirectoryExists(@"stats");
            MyFile.EnsureDirectoryExists(@"sync");



            if (Config.settings.sources.Count == 0)
            {
                MessageBox.Show("No Video Sources found. Add some and Scan..");
                ShowFormSources();
                return;
            }

            if (ListVideoInfo.Load())
            {
                loadVideos.FilterListView();
            }
            else
            {
                loadVideos.LoadFromDisk();
            }
        }
Exemple #10
0
        public void SetWatched()
        {
            // set watched
            try
            {
                selectedVideoInfo.videoItem.watched = "YES";
                MyFormField.SetCheckBoxChecked(checkBoxWatched, true);
            }
            catch (Exception e)
            {
                MyLog.Add(e.ToString());
            }

            // set last played
            try
            {
                selectedVideoInfo.videoItem.lastPlayed = DateTime.UtcNow;
                MyFormField.SetLabelText(labelLastPlayed, selectedVideoInfo.videoItem.lastPlayed);
            }
            catch (Exception e)
            {
                MyLog.Add(e.ToString());
            }

            // increment play count
            try
            {
                if (comboBoxPlayCount.Text == "")
                {
                    comboBoxPlayCount.Text = "0";
                }
                int playCount = Convert.ToInt32(comboBoxPlayCount.Text) + 1;
                selectedVideoInfo.videoItem.playCount = playCount;
                MyFormField.SetComboBoxValue(comboBoxPlayCount, selectedVideoInfo.videoItem.playCount);
            }
            catch (Exception e)
            {
                MyLog.Add(e.ToString());
            }
        }
        private void buttonSourceBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (textBoxDirectory.Text != "" && textBoxDirectory.Text.Length > 2)
            {
                folderBrowserDialog.SelectedPath = textBoxDirectory.Text;
            }

            if (folderBrowserDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                textBoxDirectory.Text = folderBrowserDialog.SelectedPath;
                if (textBoxAlias.Text == "")
                {
                    string alias = folderBrowserDialog.SelectedPath.Substring(folderBrowserDialog.SelectedPath.LastIndexOf(@"\") + 1);
                    MyFormField.SetTextBoxText(textBoxAlias, MyFile.SafeFileName(alias));
                }
            }
        }
        private void buttonSyncUp_Click(object sender, EventArgs e)
        {
            if (listViewSyncUp.SelectedItems.Count == 0)
            {
                MessageBox.Show("Select a Video Source to Sync Up");
                return;
            }

            ListViewItem selectedItem     = listViewSyncUp.SelectedItems[0];
            FileInfo     selectedFileInfo = (FileInfo)selectedItem.Tag;

            if (selectedFileInfo == null)
            {
                return;
            }

            SyncUpVideoSource(selectedFileInfo);


            Sync.syncSettings.syncUp = DateTime.UtcNow;
            MyFormField.SetLabelText(labelLastSyncUp, Sync.syncSettings.syncUp);

            Sync.Save();
        }
        protected void LoadVideos_Completed(object sender, EventArgs e)
        {
            currentSource.lastScanned = DateTime.UtcNow;
            MyFormField.SetLabelText(labelLastScanned, currentSource.lastScanned);
            ListViewItem listViewItem = listViewSource.FindItemWithText(currentSource.alias);

            if (listViewItem != null)
            {
                listViewItem.SubItems[2].Text = currentSource.lastScanned.ToLocalTime().ToString();
            }

            CalcStatsForSource(currentSource);

            int sourceIndex = Config.settings.sources.FindIndex(x => x.alias == currentSource.alias);

            Config.settings.sources[sourceIndex] = currentSource;


            buttonSourceDirectory.Enabled = true;
            buttonScanSource.Enabled      = true;
            buttonRemoveSource.Enabled    = true;
            buttonAddSource.Enabled       = true;
            scanning = false;
        }
Exemple #14
0
        private void buttonScan_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (selectedVideoInfo != null && selectedVideoInfo.videoItem != null)
            {
                button.Enabled = false;
                button.Text    = "Scanning..";

                string directory = selectedVideoInfo.videoDirectory;
                MyLog.Add("Scanning: " + directory);

                ParseVideo parseVideo = new ParseVideo();
                selectedVideoInfo = parseVideo.ReadDirectory(directory);


                subFormFileList.SetList(selectedVideoInfo);
                SetForm(selectedVideoInfo);
                ListVideoInfo.UpdateVideoInfoList(selectedVideoInfo);


                MyFormField.DelayButtonClick(button, "Scan");
            }
        }
Exemple #15
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (selectedVideoInfo != null && selectedVideoInfo.files != null && selectedVideoInfo.files.video != null)
            {
                button.Enabled = false;
                button.Text    = "Playing..";

                PlayFile playFile = new PlayFile();
                playFile.playFile_Completed += (senderPlay, eventPlay) => PlayFile_Completed(senderPlay, eventPlay, selectedVideoInfo);
                playFile.AddAccessToSubForms(this, subFormProgress);
                string   videoFullName = selectedVideoInfo.GetFullName(selectedVideoInfo.files.video);
                FileInfo fileInfo      = MyFile.FileInfo(videoFullName);
                if (fileInfo == null)
                {
                    MessageBox.Show("Error trying to play video [" + selectedVideoInfo.files.video.Name + "]");
                    return;
                }
                playFile.Play(selectedVideoInfo, selectedVideoInfo.files.video);

                MyFormField.DelayButtonClick(button, "Play");
            }
        }
Exemple #16
0
        public void SetForm(VideoInfo videoInfo)
        {
            this.selectedVideoInfo = videoInfo;
            VideoItem videoItem = videoInfo.videoItem;

            try
            {
                // set search title
                MyFormField.SetTextBoxText(textBoxTitle, videoItem.title);

                // set movie set
                MyFormField.SetTextBoxText(textBoxMovieSet, videoItem.movieset);

                // set plot
                MyFormField.SetRichTextBoxText(richTextBoxPlot, videoItem.plot);

                // set runtime
                MyFormField.SetTextBoxText(textBoxRunTime, videoItem.runtime.ToString());

                // set tagline
                // MyFormField.SetTextBoxText(textBoxTagLine, videoItem.tagline); // not yet

                // set notes
                MyFormField.SetRichTextBoxText(richTextBoxNotes, videoItem.notes);

                if (videoItem.encoding != null)
                {
                    // set width
                    if (videoItem.encoding.width > 0)
                    {
                        MyFormField.SetTextBoxText(textBoxWidth, videoItem.encoding.width.ToString());
                    }
                    else
                    {
                        MyFormField.SetTextBoxText(textBoxWidth, "");
                    }

                    // set height
                    if (videoItem.encoding.height > 0)
                    {
                        MyFormField.SetTextBoxText(textBoxHeight, videoItem.encoding.height.ToString());
                    }
                    else
                    {
                        MyFormField.SetTextBoxText(textBoxHeight, "");
                    }

                    // set bitrate
                    if (videoItem.encoding.bitrate > 0)
                    {
                        MyFormField.SetTextBoxText(textBoxBitrate, videoItem.encoding.bitrate.ToString());
                        string bitrateFormatted = MyFile.FormatSize(videoItem.encoding.bitrate, 2);
                        bitrateFormatted = bitrateFormatted.Replace(" ", "\n");
                        MyFormField.SetLabelText(labelForBitrateFormatted, bitrateFormatted);
                    }
                    else
                    {
                        MyFormField.SetTextBoxText(textBoxBitrate, "");
                        MyFormField.SetLabelText(labelForBitrateFormatted, "");
                    }

                    // set codec
                    if (!String.IsNullOrEmpty(videoItem.encoding.codec))
                    {
                        MyFormField.SetComboBoxValue(comboBoxCodec, videoItem.encoding.codec);
                    }
                    else
                    {
                        MyFormField.SetComboBoxValue(comboBoxCodec, "");
                    }
                }


                // set tag
                for (int index = dataGridViewTags.Rows.Count - 1; index >= 0; index--)
                {
                    if (dataGridViewTags.Rows[index].IsNewRow)
                    {
                        continue;
                    }
                    dataGridViewTags.Rows.RemoveAt(index);
                }
                if (videoItem.tags != null)
                {
                    IComparer <VideoItemTag <string> > sortVideoItemTag = new SortVideoItemTag();
                    videoItem.tags.Sort(sortVideoItemTag);
                    foreach (VideoItemTag <string> tag in videoItem.tags)
                    {
                        dataGridViewTags.Rows.Add(new object[] { tag.name });
                    }
                    // prevent add row from being auto selected
                    if (dataGridViewTags.CurrentCell != null)
                    {
                        dataGridViewTags.CurrentCell.Selected = false;
                    }
                }

                // set genre
                for (int index = dataGridViewGenres.Rows.Count - 1; index >= 0; index--)
                {
                    if (dataGridViewGenres.Rows[index].IsNewRow)
                    {
                        continue;
                    }
                    dataGridViewGenres.Rows.RemoveAt(index);
                }
                if (videoItem.genres != null)
                {
                    IComparer <VideoItemGenre <string> > sortVideoItemGenre = new SortVideoItemGenre();
                    videoItem.genres.Sort(sortVideoItemGenre);
                    foreach (VideoItemGenre <string> genre in videoItem.genres)
                    {
                        dataGridViewGenres.Rows.Add(new object[] { genre.name });
                    }
                    // prevent add row from being auto selected
                    if (dataGridViewGenres.CurrentCell != null)
                    {
                        dataGridViewGenres.CurrentCell.Selected = false;
                    }
                }

                // set bing link
                SetLinkLabelFromTitle(linkLabelBing, "https://www.bing.com/search?q=");

                // set google link
                SetLinkLabelFromTitle(linkLabelGoogle, "https://www.google.com/search?q=");

                // set google link
                SetLinkLabelFromTitle(linkLabelRT, "https://www.rottentomatoes.com/search/?search=");

                // set upc
                MyFormField.SetTextBoxText(textBoxUPC, videoItem.upc);

                // set tmdbId link
                MyFormField.SetTextBoxText(textBoxTMDB, videoItem.tmdbId);
                MyFormField.SetLinkLabel(linkLabelTMDB, "http://www.themoviedb.org/movie/", videoItem.tmdbId);

                // set imdbId link
                MyFormField.SetTextBoxText(textBoxIMDB, videoItem.imdbId);
                MyFormField.SetLinkLabel(linkLabelIMDB, "http://www.imdb.com/title/", videoItem.imdbId);


                // set year
                MyFormField.SetComboBoxValue(comboBoxYear, videoItem.year);

                // set imdbRating
                MyFormField.SetComboBoxValue(comboBoxIMDBRating, Convert.ToInt32(videoItem.imdbRating));

                // set mpaa
                MyFormField.SetComboBoxValue(comboBoxMPAA, videoItem.mpaa);

                // set playCount
                MyFormField.SetComboBoxValue(comboBoxPlayCount, videoItem.playCount);

                // set rating
                MyFormField.SetComboBoxValue(comboBoxRating, videoItem.rating);

                // set source
                MyFormField.SetComboBoxValue(comboBoxSource, videoItem.source);

                // set version
                MyFormField.SetComboBoxValue(comboBoxVersion, videoItem.version);

                // set lastPlayed
                MyFormField.SetLabelText(labelLastPlayed, videoItem.lastPlayed);

                // set labelUpdated
                MyFormField.SetLabelText(labelUpdated, videoInfo.updated);


                // set watched
                MyFormField.SetCheckBoxChecked(checkBoxWatched, ((videoItem.watched != "NO") ? true : false));

                // set actor/director
                for (int index = dataGridViewActors.Rows.Count - 1; index >= 0; index--)
                {
                    if (dataGridViewActors.Rows[index].IsNewRow)
                    {
                        continue;
                    }
                    dataGridViewActors.Rows.RemoveAt(index);
                }
                if (videoItem.directors != null)
                {
                    IComparer <VideoItemDirector <string> > sortVideoItemDirector = new SortVideoItemDirector();
                    videoItem.directors.Sort(sortVideoItemDirector);
                    foreach (VideoItemDirector <string> director in videoItem.directors)
                    {
                        dataGridViewActors.Rows.Add(new object[] { director.name, "Director" });
                    }
                }
                if (videoItem.actors != null)
                {
                    IComparer <VideoItemActor <string, string> > sortVideoItemActor = new SortVideoItemActor();
                    videoItem.actors.Sort(sortVideoItemActor);
                    foreach (VideoItemActor <string, string> actor in videoItem.actors)
                    {
                        dataGridViewActors.Rows.Add(new object[] { actor.name, actor.role });
                    }
                }
                // prevent add row from being auto selected
                if (dataGridViewActors.CurrentCell != null)
                {
                    dataGridViewActors.CurrentCell.Selected = false;
                }
            }
            catch (Exception e)
            {
                MyLog.Add(e.ToString());
            }

            this.Parent.Focus();
        }
Exemple #17
0
 private void textBoxIMDB_TextChanged(object sender, EventArgs e)
 {
     // set imdbId link
     MyFormField.SetLinkLabel(linkLabelIMDB, "http://www.imdb.com/title/", textBoxIMDB.Text);
 }
 private void FormOptions_Shown(object sender, EventArgs e)
 {
     MyFormField.HighlightTextBoxesOnFocus(this);
 }
Exemple #19
0
 private void textBoxTMDB_TextChanged(object sender, EventArgs e)
 {
     // set tmdbId link
     MyFormField.SetLinkLabel(linkLabelTMDB, "http://www.themoviedb.org/movie/", textBoxTMDB.Text);
 }