Пример #1
0
        /// <summary>
        /// Implementation of the IGreenshotPlugin.Initialize
        /// </summary>
        /// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
        /// <param name="metadata">IDictionary<string, object></param>
        /// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
        public override bool Initialize(IGreenshotHost pluginHost, IDictionary <string, object> metadata)
        {
            this.host = pluginHost;

            // Get configuration
            config    = IniConfig.GetIniSection <ImgurConfiguration>();
            resources = new ComponentResourceManager(typeof(ImgurPlugin));

            ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur");

            itemPlugInRoot.Image = (Image)resources.GetObject("Imgur");

            historyMenuItem        = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history));
            historyMenuItem.Tag    = host;
            historyMenuItem.Click += delegate {
                ImgurHistory.ShowHistory();
            };
            itemPlugInRoot.DropDownItems.Add(historyMenuItem);

            PluginUtils.AddToContextMenu(host, itemPlugInRoot);
            Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);

            // retrieve history in the background
            Thread backgroundTask = new Thread(new ThreadStart(CheckHistory));

            backgroundTask.Name         = "Imgur History";
            backgroundTask.IsBackground = true;
            backgroundTask.SetApartmentState(ApartmentState.STA);
            backgroundTask.Start();

            // Register our configuration
            SettingsWindow.RegisterSettingsPage <ImgurSettingsPage>("settings_plugins,imgur.settings_title");
            return(true);
        }
Пример #2
0
		public static void ShowHistory() {
			// Make sure the history is loaded, will be done only once
			ImgurUtils.LoadHistory();
			if (instance == null) {
				instance = new ImgurHistory();
			}
			instance.Show();
			instance.redraw();
		}
Пример #3
0
 public static void ShowHistory()
 {
     // Make sure the history is loaded, will be done only once
     ImgurUtils.LoadHistory();
     if (instance == null)
     {
         instance = new ImgurHistory();
     }
     instance.Show();
     instance.redraw();
 }
Пример #4
0
        /// <summary>
        /// Implementation of the IGreenshotPlugin.Initialize
        /// </summary>
        /// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
        /// <param name="myAttributes">My own attributes</param>
        /// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
        public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes)
        {
            _host      = pluginHost;
            Attributes = myAttributes;

            // Get configuration
            _config    = IniConfig.GetIniSection <ImgurConfiguration>();
            _resources = new ComponentResourceManager(typeof(ImgurPlugin));

            ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur")
            {
                Image = (Image)_resources.GetObject("Imgur")
            };

            _historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history))
            {
                Tag = _host
            };
            _historyMenuItem.Click += delegate {
                ImgurHistory.ShowHistory();
            };
            itemPlugInRoot.DropDownItems.Add(_historyMenuItem);

            _itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure))
            {
                Tag = _host
            };
            _itemPlugInConfig.Click += delegate {
                _config.ShowConfigDialog();
            };
            itemPlugInRoot.DropDownItems.Add(_itemPlugInConfig);

            PluginUtils.AddToContextMenu(_host, itemPlugInRoot);
            Language.LanguageChanged += OnLanguageChanged;

            // retrieve history in the background
            Thread backgroundTask = new Thread(CheckHistory)
            {
                Name         = "Imgur History",
                IsBackground = true
            };

            backgroundTask.SetApartmentState(ApartmentState.STA);
            backgroundTask.Start();
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Implementation of the IGreenshotPlugin.Initialize
        /// </summary>
        /// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
        /// <param name="myAttributes">My own attributes</param>
        /// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
        public bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes)
        {
            _host      = pluginHost;
            Attributes = myAttributes;

            // Get configuration
            _config    = IniConfig.GetIniSection <ImgurConfiguration>();
            _resources = new ComponentResourceManager(typeof(ImgurPlugin));

            ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur")
            {
                Image = (Image)_resources.GetObject("Imgur")
            };

            _historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history))
            {
                Tag = _host
            };
            _historyMenuItem.Click += delegate {
                ImgurHistory.ShowHistory();
            };
            itemPlugInRoot.DropDownItems.Add(_historyMenuItem);

            _itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure))
            {
                Tag = _host
            };
            _itemPlugInConfig.Click += delegate {
                _config.ShowConfigDialog();
            };
            itemPlugInRoot.DropDownItems.Add(_itemPlugInConfig);

            PluginUtils.AddToContextMenu(_host, itemPlugInRoot);
            Language.LanguageChanged += OnLanguageChanged;

            // Enable history if there are items available
            UpdateHistoryMenuItem();
            return(true);
        }
Пример #6
0
        public static void ShowHistory()
        {
            lock (Lock)
            {
                if (ImgurUtils.IsHistoryLoadingNeeded())
                {
                    // Run upload in the background
                    new PleaseWaitForm().ShowAndWait("Imgur " + Language.GetString("imgur", LangKey.history), Language.GetString("imgur", LangKey.communication_wait),
                                                     ImgurUtils.LoadHistory
                                                     );
                }

                // Make sure the history is loaded, will be done only once
                if (_instance == null)
                {
                    _instance = new ImgurHistory();
                }
                if (!_instance.Visible)
                {
                    _instance.Show();
                }
                _instance.Redraw();
            }
        }
Пример #7
0
 void ButtonHistoryClick(object sender, EventArgs e)
 {
     ImgurHistory.ShowHistory();
 }
Пример #8
0
 void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e)
 {
     instance = null;
 }
Пример #9
0
 private void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e)
 {
     _instance = null;
 }