Exemplo n.º 1
0
        public override void Initialize()
        {
            this.settings = new Settings(AddonPath + "/settings.txt");

              FacebookClient.DefaultVersion = "v2.1";
              this.facebookClient = new FacebookClient() {
            IsSecureConnection = true
              };

              LoadSettings();

              if (this.facebookClient.AccessToken != "") {
            // don't block the main thread by loading the user's facebook name in a new thread
            new Thread(new ThreadStart(delegate
            {
              try {
            this.facebookName = (this.facebookClient.Get("/me") as dynamic).name;
              } catch {
            // If it crashes here, then the user probably doesn't have a working internet connection.
            // Not sure what else to do here besides turning off the addon itself...
            this.facebookClient.AccessToken = "";
              }
            })).Start();
              }
        }
Exemplo n.º 2
0
 public PostHttp()
 {
     this.settings = new Settings(AddonPath + "/settings.txt");
       Icon icon = new Icon(AddonPath + "/Icon.ico");
       this.bmpIcon = icon.ToBitmap();
       this.bmpIcon16 = new Icon(icon, new Size(16, 16)).ToBitmap();
 }
Exemplo n.º 3
0
        public void Initialize(NotifyIcon Tray)
        {
            this.Tray = Tray;
            this.settings = new Settings("Addons/Imgur/settings.txt");
            this.bmpIcon = new Icon("Addons/Imgur/Icon.ico").ToBitmap();

            LoadSettings();
        }
Exemplo n.º 4
0
        public void Initialize(NotifyIcon Tray)
        {
            this.Tray = Tray;

            this.settings = new Settings("Addons/Pastebin/settings.txt");

            LoadSettings();
        }
Exemplo n.º 5
0
        public FormDrag(Addon addon)
        {
            InitializeComponent();

              this.addon = addon;
              Addon.SetShortcuts(false);

              ScreenBox.BackColor = Color.FromArgb(128, Color.SkyBlue);
              picWidth.BackColor = Color.FromArgb(0, Color.Black);
              picHeight.BackColor = Color.FromArgb(0, Color.Black);

              this.settings = new Settings("settings.txt");

              this.Screens = new Rectangle[Screen.AllScreens.Length];

              for (int i = 0; i < this.Screens.Length; i++)
            this.Screens[i] = Screen.AllScreens[i].Bounds;

              this.Width = this.Screens[0].Width;
              this.Height = this.Screens[0].Height;

              //TODO: Fix the whole multi-monitor issue. D:
              //      Maybe we could make some kind of "perfect" class for every kind of use? (GetFullScreenRectangle?) Shouldn't be /too/ hard.. right?

              // This works because WinForms has an internal way of setting the maximum width/height of a Control (Form)
              // Check it with ILSpy, System.Windows.Forms.Control.Width (set)
              for (int i = 0; i < Screen.AllScreens.Length; i++) {
            if (Screen.AllScreens[i].Bounds.Left < this.Left) {
              this.Width += this.Left - Screen.AllScreens[i].Bounds.Left;
              this.Left = Screen.AllScreens[i].Bounds.Left;
            } else
              this.Width += Screen.AllScreens[i].Bounds.Width;

            if (Screen.AllScreens[i].Bounds.Top < this.Top) {
              this.Height += this.Top - Screen.AllScreens[i].Bounds.Top;
              this.Top = Screen.AllScreens[i].Bounds.Top;
            } else
              this.Height += Screen.AllScreens[i].Bounds.Height;
              }

              this.Opacity = 0.5f;
              this.TopMost = true;

              this.beginImage = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppRgb);
              Graphics beginGfx = Graphics.FromImage(this.beginImage);
              beginGfx.CopyFromScreen(this.Location, Point.Empty, this.Size);
              beginGfx.Dispose();

              this.bgForm = new Form();
              //TODO: Fix me, doesn't work too well on weird multi-monitor setups for some reason. :(
              /*this.bgForm.Left = this.Left;
              this.bgForm.Top = this.Top;
              this.bgForm.Width = this.Width;
              this.bgForm.Height = this.Height;
              this.bgForm.BackgroundImage = this.beginImage;
              this.bgForm.FormBorderStyle = FormBorderStyle.None;
              this.bgForm.Show();*/
        }
Exemplo n.º 6
0
        public void Initialize(NotifyIcon Tray)
        {
            this.Tray = Tray;
            this.DropboxInstalled = File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Dropbox\\config.db");
            this.bmpIcon = new Icon("Addons/Dropbox/Icon.ico").ToBitmap();
            this.settings = new Settings("Addons/Dropbox/settings.txt");

            LoadSettings();
        }
Exemplo n.º 7
0
        public FormProgressBar(Settings settings)
        {
            InitializeComponent();

            if (settings.GetBool("PortableProgressBar")) {
                this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            }

            Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;

            if (this.DwmEnabled) {
                this.Left = workingArea.Width - this.Width - 4;
                this.Top = workingArea.Height - this.Height - 4;
            } else {
                this.Left = workingArea.Width - this.Width;
                this.Top = workingArea.Height - this.Height;
            }
        }
Exemplo n.º 8
0
        public void Initialize(NotifyIcon Tray)
        {
            this.Tray = Tray;
            this.settings = new Settings("Addons/Facebook/settings.txt");
            this.bmpIcon = Image.FromFile("Addons/Facebook/Icon.ico");

            this.facebookClient = new FacebookClient() { IsSecureConnection = true };

            LoadSettings();

            if (this.facebookClient.AccessToken != "") {
                try {
                    this.facebookName = (this.facebookClient.Get("/me") as dynamic).name;
                } catch {
                    // If it crashes here, then the user probably doesn't have a working internet connection.
                    // Not sure what else to do here besides turning off the addon itself...
                    this.facebookClient.AccessToken = "";
                }
            }
        }
Exemplo n.º 9
0
        public FormDrag(Addon addon)
        {
            InitializeComponent();

            this.addon = addon;
            Addon.SetShortcuts(false);

            this.settings = new Settings("settings.txt");

            this.Screens = new Rectangle[Screen.AllScreens.Length];

            for (int i = 0; i < this.Screens.Length; i++)
                this.Screens[i] = Screen.AllScreens[i].Bounds;

            this.Width = this.Screens[0].Width;
            this.Height = this.Screens[0].Height;

            // This works because WinForms has an internal way of setting the maximum width/height of a Control (Form)
            // Check it with ILSpy, System.Windows.Forms.Control.Width (set)
            for (int i = 0; i < Screen.AllScreens.Length; i++) {
                if (Screen.AllScreens[i].Bounds.Left < this.Left) {
                    this.Width += this.Left - Screen.AllScreens[i].Bounds.Left;
                    this.Left = Screen.AllScreens[i].Bounds.Left;
                } else
                    this.Width += Screen.AllScreens[i].Bounds.Width;

                if (Screen.AllScreens[i].Bounds.Top < this.Top) {
                    this.Height += this.Top - Screen.AllScreens[i].Bounds.Top;
                    this.Top = Screen.AllScreens[i].Bounds.Top;
                } else
                    this.Height += Screen.AllScreens[i].Bounds.Height;
            }

            this.Opacity = 0.5f;
            //this.TopMost = true;

            this.beginImage = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            Graphics beginGfx = Graphics.FromImage(this.beginImage);
            beginGfx.CopyFromScreen(this.Location, Point.Empty, this.Size);
            beginGfx.Dispose();
        }
Exemplo n.º 10
0
        public override void Initialize()
        {
            this.settings = new Settings(AddonPath + "/settings.txt");

              LoadSettings();
        }
Exemplo n.º 11
0
        public override void Initialize()
        {
            this.settings = new Settings(AddonPath + "/settings.txt");

              web_path = AddonPath + "/Files";

              if (!Directory.Exists(web_path)) {
            Directory.CreateDirectory(web_path);
            using (StreamWriter writer = File.CreateText(web_path + "/index.html")) {
              writer.WriteLine(
            @"<!DOCTYPE html>
            <html>
              <head>
            <title>ClipUpload Self-Hoster Addon</title>
            <style>
              body {
            font-family: Sans-serif;
            font-size: 12px;
            background: #ddd;
            color: #222;
              }
              #container {
            width: 900px;
            margin: 0 auto;
              }
              h1 {
            text-align: center;
              }
            </style>
              </head>
              <body>
            <div id=""container"">
              <h1>ClipUpload Self-Hoster Addon</h1>
              <p>This is the <i>index.html</i> file located in <i>" + web_path + @"/</i>. All files uploaded with the <i>Self Hoster</i> addon will be placed in this folder. Feel free
             to modify this index page or even delete it if you wish.</p>
              <p><a href=""http://clipupload.net/"">ClipUpload</a> is a program to easily take screenshots and text snippets and instantly upload them to a file host of one's choice such
             as Imgur or Dropbox, as well as allowing for custom addon support for users who's favorite host isn't supported by default.</p>
            </div>
              </body>
            </html>");
            }
              }

              LoadSettings();
        }
Exemplo n.º 12
0
        public override void Initialize()
        {
            this.DropboxInstalled = File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Dropbox\\host.db");
              this.settings = new Settings(AddonPath + "/settings.txt");

              LoadSettings();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Serialize settings to file from object
 /// </summary>
 /// <param name="obj">The object</param>
 /// <param name="filename">The filename (usually AddonPath + "/settings.txt")</param>
 public void SerializeSettings(object obj, string filename)
 {
     Type type = obj.GetType();
       Settings settings = new Settings(filename);
       FieldInfo[] fields = type.GetFields();
       foreach (FieldInfo field in fields) {
     settings.SetString(field.Name, field.GetValue(obj).ToString());
       }
       settings.Save();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Deserialize settings from file to object
 /// </summary>
 /// <param name="obj">The object</param>
 /// <param name="filename">The filename (usually AddonPath + "/settings.txt")</param>
 public void DeserializeSettings(object obj, string filename)
 {
     Type type = obj.GetType();
       Settings settings = new Settings(filename);
       FieldInfo[] fields = type.GetFields();
       foreach (FieldInfo field in fields) {
     if (settings.Contains(field.Name)) {
       if (field.FieldType == typeof(string)) {
     field.SetValue(obj, settings.GetString(field.Name));
       } else if (field.FieldType == typeof(bool)) {
     field.SetValue(obj, settings.GetBool(field.Name));
       } else if (field.FieldType == typeof(int)) {
     field.SetValue(obj, settings.GetInt(field.Name));
       } else if (field.FieldType == typeof(long)) {
     field.SetValue(obj, settings.GetLong(field.Name));
       } else if (field.FieldType == typeof(float)) {
     field.SetValue(obj, settings.GetFloat(field.Name));
       }
     }
       }
 }