Esempio n. 1
0
 private void ButtonClearAll_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "Note: This will remove all of your bookmarked files. You can't undo this. Continue?", "Clear Bookmarks", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         UserBookmarks.ClearBookmarks();
         LoadBookmarks();
     }
 }
Esempio n. 2
0
        private void LoadBookmarks()
        {
            try
            {
                Program.log.Info("Loading users bookmarks");
                LabelStatus.Text = "Loading bookmarks...";

                BackGroundWorker.RunWorkAsync <List <WebFile> >(() => Query.Search(UserBookmarks.BookmarkedFiles(), TextBoxSearchQuery.Text, SelectedFilesSort), (data) =>
                {
                    if (this.InvokeRequired)
                    {
                        var b = new LoadBookmarksCallBack(LoadBookmarks);
                        Invoke(b, new object[] { });
                    }
                    else
                    {
                        DataGridFiles.Rows.Clear();
                        ComboBoxHost.Items.Clear(); ComboBoxHost.Items.Add("Any");

                        foreach (var webFile in data)
                        {
                            if (SelectedFilesType.Contains(webFile.Type) && webFile.Host.Contains(SelectedFilesHost))
                            {
                                DataGridFiles.Rows.Add(webFile.Type, webFile.Name, StringExtensions.BytesToPrefix(webFile.Size), StringExtensions.TimeSpanAge(webFile.DateUploaded), webFile.Host, webFile.URL);
                                if (!(ComboBoxHost.Items.Contains(webFile.Host)))
                                {
                                    ComboBoxHost.Items.Add(webFile.Host);
                                }
                            }
                        }

                        LabelStatus.Text = "Loaded";

                        if (DataGridFiles.Rows.Count == 0)
                        {
                            labelNoResultsFound.Visible = true;
                        }
                        else
                        {
                            labelNoResultsFound.Visible = false;
                        }

                        // Sets selected item to host
                        if (SelectedFilesHost == "")
                        {
                            ComboBoxHost.SelectedIndex = 0;
                        }
                        else
                        {
                            ComboBoxHost.SelectedItem = SelectedFilesHost;
                        }

                        Program.log.Info("Successfully loaded users bookmarks");
                    }
                });
            }
            catch (Exception ex) { Program.log.Error("Error getting users bookmarks", ex); }
        }
Esempio n. 3
0
        public void CheckFileEvents()
        {
            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(currentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Shows 'Play Media' button if this file has a supported file extension
            if (videoFileTypes.Contains(currentFile.Type) || audioFileTypes.Contains(currentFile.Type))
            {
                // Support media players installed on users machine
                VLC2ToolStripMenuItem.Visible = true;
                WMPToolStripMenuItem.Visible  = true;
                VLCToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathVLC);
                MPCToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);
            }

            // Support download manangers installed on users machine, shown if this isn't a local file
            IDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathIDMAN64) || File.Exists(LocalExtensions.pathIDMAN86) && !currentFile.URL.StartsWith(LocalExtensions.userDownloadsDirectory);

            if (contextOpenFile.Items.Count != 0)
            {
                buttonOpenFile.Visible = true;
            }

            // Shows Request File Size button if size property returns 0
            if (currentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.HasExistingSubtitle(currentFile.URL) == true) // If users downloads folder contains a subtitle file matching web file name
            {
                infoFileSubtitles = LocalExtensions.userDownloadsDirectory + Path.GetFileNameWithoutExtension(currentFile.URL) + ".srt";
            }
            else
            {
                infoFileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Esempio n. 4
0
 private void BtnBookmarkFile_ClickButtonArea(object Sender, MouseEventArgs e)
 {
     if (UserBookmarks.IsBookmarked(currentFile.URL))
     {
         UserBookmarks.RemoveFile(currentFile.URL);
         ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
     }
     else
     {
         UserBookmarks.AddFile(currentFile.URL);
         ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
     }
 }
Esempio n. 5
0
 private void ButtonBookmark_Click(object sender, EventArgs e)
 {
     // Add/Remove file from users Bookmarks
     if (UserBookmarks.IsBookmarked(CurrentFile.URL))
     {
         UserBookmarks.RemoveFile(CurrentFile.URL);
         ControlExtensions.SetControlText(ButtonBookmark, "Add to Bookmarks");
     }
     else
     {
         UserBookmarks.AddFile(CurrentFile.URL);
         ControlExtensions.SetControlText(ButtonBookmark, "Remove from Bookmarks");
     }
 }
Esempio n. 6
0
        public void CheckFileEvents()
        {
            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(currentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Support media players installed on users machine
            VLCToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathVLC);
            MPCToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);

            // Shows 'Play Media' button if is valid file extension
            if (videoFileTypes.Contains(currentFile.Type) || audioFileTypes.Contains(currentFile.Type))
            {
                buttonPlayMedia.Visible = true;
            }
            else
            {
                buttonPlayMedia.Visible = false;
            }

            // Checks if file size isn't default
            if (currentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.HasExistingSubtitle(currentFile.URL) == true) // If users downloads folder contains a subtitle file matching web file name
            {
                infoFileSubtitles = LocalExtensions.userDownloadsDirectory + Path.GetFileNameWithoutExtension(currentFile.URL) + ".srt";
            }
            else
            {
                infoFileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Esempio n. 7
0
        public void CreateAndSaveBookmark(Guid userID, Guid bookmarkUserID)
        {
            var bookmark = new UserBookmarks
                                         {BookmarkedUserID = bookmarkUserID, UserId = userID, TimeStamp = DateTime.Now};

            Entities.UserBookmarks.AddObject(bookmark);

            try
            {
                Entities.SaveChanges();
            }
            catch
            {
                // could already be added
            }
        }
Esempio n. 8
0
        public void LoadStateFromIsoStorage()
        {
            if (!MainDataSource.Instance.IsActive)
            {
                UserDataSource        user      = CoreExtensions.LoadFromFile <UserDataSource>("user.xml");
                PinnedItemsCollection pins      = CoreExtensions.LoadFromFile <PinnedItemsCollection>("pins.xml");
                ForumCollection       forums    = CoreExtensions.LoadFromFile <ForumCollection>("forums.xml");
                UserBookmarks         bookmarks = CoreExtensions.LoadFromFile <UserBookmarks>("bookmarks.xml");
                ThreadTable           threads   = CoreExtensions.LoadFromFile <ThreadTable>("threads.xml");

                MainDataSource.Instance.CurrentUser = user;
                MainDataSource.Instance.Pins        = pins;
                MainDataSource.Instance.Forums      = forums;
                MainDataSource.Instance.Bookmarks   = bookmarks;
                MainDataSource.Instance.ThreadTable = threads;
            }
        }
Esempio n. 9
0
        public void CheckFileEvents()
        {
            // Hides all open file items
            foreach (ToolStripMenuItem item in contextOpenFile.Items)
            {
                item.Visible = false;
            }

            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(CurrentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Shows supported pdf readers installed on users machine
            if (BookFileTypes.Contains(CurrentFile.Type))
            {
                NitroReaderToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathNitroReader);
            }

            // Shows supported pdf readers installed on users machine
            if (TextFileTypes.Contains(CurrentFile.Type))
            {
            }

            // Shows supported media players installed on users machine
            if (VideoFileTypes.Contains(CurrentFile.Type) || AudioFileTypes.Contains(CurrentFile.Type))
            {
                VLC2ToolStripMenuItem.Visible      = true;
                WMPToolStripMenuItem.Visible       = true;
                VLCToolStripMenuItem.Visible       = File.Exists(LocalExtensions.pathVLC);
                MPCToolStripMenuItem.Visible       = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);
                KMPlayerToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathKMPlayer);
                PotPlayerToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathPotPlayer);
            }

            // Support download manangers installed on users machine, only shown if this isn't a local file
            if (!IsLocalFile)
            {
                IDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathIDM64) || File.Exists(LocalExtensions.pathIDM86) && !CurrentFile.URL.StartsWith(LocalExtensions.pathDownloadsDirectory);
                FDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathFDM) && !CurrentFile.URL.StartsWith(LocalExtensions.pathDownloadsDirectory);
            }

            // Shows Open File button if context menu has items
            if (contextOpenFile.Items.Count > 0)
            {
                buttonOpenWith.Visible = true;
            }

            // Shows Request File Size button if size property returns 0
            if (CurrentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Hides features that aren't needed for local files (Bookmark, Share & Report)
            if (IsLocalFile)
            {
                buttonBookmarkFile.Visible = false;
                panelShare.Visible         = false;
                panelReport.Visible        = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.IsSubtitlesAvailable(CurrentFile.URL)) // If users downloads folder contains a subtitle file matching web file name
            {
                FileSubtitles = LocalExtensions.pathDownloadsDirectory + Path.GetFileNameWithoutExtension(CurrentFile.URL) + ".srt";
            }
            else
            {
                FileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Esempio n. 10
0
 private void buttonFilesBookmarks_ClickButtonArea(object Sender, MouseEventArgs e)
 {
     SelectedFilesType = Types.All; ControlExtensions.SelectFilesTab(buttonFilesBookmarks); SelectedFiles = UserBookmarks.GetBookmarks(); ShowFiles(SelectedFiles);
 }
 public void Delete(UserBookmarks entity)
 {
     throw new NotImplementedException();
 }
 public void Add(UserBookmarks entity)
 {
     _entities
         .UserBookmarks
         .AddObject(entity);
 }