Exemplo n.º 1
0
        public void nsfwCheckChange(string sub)
        {
            RedditSub redditSub = subsToSave.Where(s => s.subName == sub).First();

            subsToSave.Remove(redditSub);
            redditSub.nsfw = _login.subNSFW.Checked;
            subsToSave.Add(redditSub);
        }
Exemplo n.º 2
0
 private void subComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (subComboBox.SelectedItem != null)
     {
         RedditSub redditSub = helper.subsToSave.Where(s => s.subName == subComboBox.SelectedItem.ToString()).FirstOrDefault();
         subNSFW.Checked          = redditSub.nsfw;
         subDirectoryTextbox.Text = redditSub.directory;
     }
 }
Exemplo n.º 3
0
 private void changeCustomDirectoryButton_Click(object sender, EventArgs e)
 {
     if (subComboBox.SelectedItem != null && folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         subDirectoryTextbox.Text = folderBrowserDialog1.SelectedPath;
         RedditSub redditSub = helper.subsToSave.Where(s => s.subName == subComboBox.SelectedItem.ToString()).First();
         helper.subsToSave.Remove(redditSub);
         redditSub.directory = folderBrowserDialog1.SelectedPath;
         helper.subsToSave.Add(redditSub);
     }
     folderBrowserDialog1.Dispose();
 }
Exemplo n.º 4
0
        private void addSubButton_Click(object sender, EventArgs e)
        {
            AddSub AS = new AddSub(this);

            if (AS.ShowDialog() == DialogResult.OK)
            {
                string    subName      = AS.subTextbox.Text;
                bool      nsfw         = AS.nsfwCheckBox.Checked;
                string    subDirectory = AS.subDirectoryTextbox.Text;
                RedditSub sub          = new RedditSub()
                {
                    subName = AS.subTextbox.Text, nsfw = AS.nsfwCheckBox.Checked, directory = AS.subDirectoryTextbox.Text
                };
                helper.subsToSave.Add(sub);
            }
            AS.Dispose();
        }
Exemplo n.º 5
0
        public void downloadSaved()
        {
            Listing <VotableThing> savedPosts = user.GetSaved();

            foreach (VotableThing savedPost in savedPosts)
            {
                Post post = (Post)savedPost;
                if (subsToSave.Where(s => s.subName == post.SubredditName).Count() == 1)
                {
                    RedditSub subToSave = subsToSave.Where(s => s.subName == post.SubredditName).First();
                    if (!post.IsSelfPost && ID.isImageUrl(post.Url.ToString()))
                    {
                        string savePath;
                        if (string.IsNullOrEmpty(subToSave.directory))
                        {
                            savePath = Path.Combine(_login.rootDirectoryTextbox.Text, ID.removeIllegalChars(post.SubredditName));
                        }
                        else
                        {
                            savePath = Path.Combine(subToSave.directory, ID.removeIllegalChars(post.SubredditName));
                        }
                        createFolder(savePath, subToSave.nsfw);
                        string name = Path.Combine(savePath, ID.removeIllegalChars(post.Title) + ID.imageType(post.Url.ToString()));
                        ID.saveImage(name, post.Url.ToString(), subToSave.nsfw);
                    }
                    else if (!post.IsSelfPost && ID.isImgurAlbumLink(post.Url.ToString()))
                    {
                        string savePath;
                        if (string.IsNullOrEmpty(subToSave.directory))
                        {
                            createFolder(Path.Combine(_login.rootDirectoryTextbox.Text, ID.removeIllegalChars(post.SubredditName)), subToSave.nsfw);
                            savePath = Path.Combine(_login.rootDirectoryTextbox.Text, ID.removeIllegalChars(post.SubredditName), ID.removeIllegalChars(post.Title));
                        }
                        else
                        {
                            createFolder(Path.Combine(subToSave.directory, ID.removeIllegalChars(post.SubredditName)), subToSave.nsfw);
                            savePath = Path.Combine(subToSave.directory, ID.removeIllegalChars(post.SubredditName), ID.removeIllegalChars(post.Title));
                        }
                        createFolder(savePath, subToSave.nsfw);
                        ID.downloadImgurAlbum(savePath, post.Url.ToString(), subToSave.nsfw);
                    }
                }
            }
        }