Inheritance: AddonHelper.Addon
Example #1
0
        public FormSettings(Pastebin mainClass)
        {
            InitializeComponent();

              this.mainClass = mainClass;

              labelStatus.Text = mainClass.UserLoggedIn ? "Logged in as " + mainClass.UserName + "." : "Not logged in.";
              buttonSignout.Enabled = mainClass.UserLoggedIn;
              checkShowPrivate.Checked = mainClass.ShowPrivate;
        }
Example #2
0
        public FormSettings(Pastebin mainClass)
        {
            InitializeComponent();

            this.mainClass = mainClass;

            labelStatus.Text         = mainClass.UserLoggedIn ? "Logged in as " + mainClass.UserName + "." : "Not logged in.";
            buttonSignout.Enabled    = mainClass.UserLoggedIn;
            checkShowPrivate.Checked = mainClass.ShowPrivate;
        }
Example #3
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string    text  = string.Empty;
            ITextItem titem = null;

            foreach (Item item in items)
            {
                if (item is IFileItem)
                {
                    titem = new TextItem(File.ReadAllText((item as IFileItem).Path));
                }
                else
                {
                    titem = new TextItem((item as ITextItem).Text);
                }
                text += titem.Text;
            }

            if (string.IsNullOrEmpty(text))
            {
                Services.Notifications.Notify("Pastebin", "No text provided for pasting.");
                yield break;
            }

            IPastebinProvider pastebinProvider = null;

            if (modifierItems.Any())
            {
                pastebinProvider = PastebinProviderFactory.GetProviderFromPreferences(text, (modifierItems.First() as ITextSyntaxItem).Syntax);
            }
            else
            {
                pastebinProvider = PastebinProviderFactory.GetProviderFromPreferences(text);
            }

            string url = Pastebin.PostUsing(pastebinProvider);

            if (!string.IsNullOrEmpty(url))
            {
                yield return(new TextItem(url));
            }
        }
Example #4
0
 /// <summary>
 /// Creates a new paste under the current user.
 /// </summary>
 /// <param name="title">The title of the paste as it will appear on the page.</param>
 /// <param name="languageId">The the language ID of the paste's content. A full list of language IDs can be found at http://pastebin.com/api#5 </param>
 /// <param name="code">The contents of the paste.</param>
 /// <param name="exposure">The visibility of the paste (private, public, or unlisted).</param>
 /// <param name="expiration">The duration of time the paste will be available before expiring.</param>
 /// <returns>The URL for the newly created paste.</returns>
 /// <exception cref="System.Net.WebException">Thrown when the underlying HTTP client encounters an error.</exception>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="code"/> is null.</exception>
 /// <exception cref="PastebinException">Thrown when a bad API request is made.</exception>
 public string CreatePaste(string title, string languageId, string code, PasteExposure exposure = PasteExposure.Public, PasteExpiration expiration = PasteExpiration.Never)
 {
     return(Pastebin.CreatePasteImpl(this.agent, true, title, languageId, code, exposure, expiration));
 }