public bool Initialize(IGreenshotHost host, PluginAttribute pluginAttribute) { this.host = host; this.pluginAttribute = pluginAttribute; config = IniConfig.GetIniSection <DemoConfiguration>(); return(true); }
// Initialize Log4J public static string InitializeLog4NET() { // Setup log4j, currently the file is called log4net.xml if (System.Diagnostics.Debugger.IsAttached || CoreConfiguration.IsInDesignMode) { CoreConfiguration config = IniConfig.GetIniSection <CoreConfiguration>(); config.LogLevel = LogLevel.INFO; LogManager.Configure(); } else if (CoreConfiguration.IsPortableApp) { string logfile = Path.Combine(CoreConfiguration.PortableAppPath, @"Greenshot\Greenshot.log"); LogManager.Configure( //where to put the logs : folders will be automatically created logfile, // limit the file sizes to 500kb, 0 = no limiting 500 ); return(logfile); } else { string logfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Greenshot\Greenshot.log"); LogManager.Configure( //where to put the logs : folders will be automatically created logfile, // limit the file sizes to 500kb, 0 = no limiting 500 ); return(logfile); } return(null); }
static GreenshotForm() { if (!IsInDesignMode) { coreConfiguration = IniConfig.GetIniSection <CoreConfiguration>(); } }
/// <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); }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="greenshotHost">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 greenshotHost, PluginAttribute myAttributes) { Log.Debug("Initialize called of " + myAttributes.Name); _myAttributes = myAttributes; var ocrDirectory = Path.GetDirectoryName(myAttributes.DllFile); if (ocrDirectory == null) { return(false); } _ocrCommand = Path.Combine(ocrDirectory, "greenshotocrcommand.exe"); if (!HasModi()) { Log.Warn("No MODI found!"); return(false); } // Load configuration config = IniConfig.GetIniSection <OCRConfiguration>(); if (config.Language != null) { config.Language = config.Language.Replace("miLANG_", "").Replace("_", " "); } return(true); }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="host">Use the IGreenshotPluginHost interface to register events</param> /// <param name="pluginAttribute">My own attributes</param> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { this.host = (IGreenshotHost)pluginHost; Attributes = myAttributes; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <FlickrConfiguration>(); resources = new ComponentResourceManager(typeof(FlickrPlugin)); ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem(); itemPlugInRoot.Text = "Flickr"; itemPlugInRoot.Tag = host; itemPlugInRoot.Image = (Image)resources.GetObject("flickr"); ToolStripMenuItem itemPlugInHistory = new ToolStripMenuItem(); itemPlugInHistory.Text = lang.GetString(LangKey.History); itemPlugInHistory.Tag = host; itemPlugInHistory.Click += new System.EventHandler(HistoryMenuClick); itemPlugInRoot.DropDownItems.Add(itemPlugInHistory); ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(); itemPlugInConfig.Text = lang.GetString(LangKey.Configure); itemPlugInConfig.Tag = host; itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick); itemPlugInRoot.DropDownItems.Add(itemPlugInConfig); PluginUtils.AddToContextMenu(host, itemPlugInRoot); return(true); }
/// <summary> /// Store all GreenshotControl values to the configuration /// </summary> protected void StoreFields() { bool iniDirty = false; foreach (FieldInfo field in GetCachedFields(GetType())) { Object controlObject = field.GetValue(this); if (controlObject == null) { continue; } IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (configBindable == null) { continue; } if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { IniValue iniValue = null; if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) { continue; } CheckBox checkBox = controlObject as CheckBox; if (checkBox != null) { iniValue.Value = checkBox.Checked; iniDirty = true; continue; } RadioButton radioButton = controlObject as RadioButton; if (radioButton != null) { iniValue.Value = radioButton.Checked; iniDirty = true; continue; } GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; if (comboxBox != null) { iniValue.Value = comboxBox.GetSelectedEnum(); iniDirty = true; continue; } } } } if (iniDirty) { //IniConfig.Save(); } }
/// <summary> /// Static initializer for the language code /// </summary> static Language() { if (!LogHelper.isInitialized) { LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)"); LogHelper.InitializeLog4NET(); } if (!IniConfig.IsInited) { LOG.Warn("IniConfig hasn't been initialized yet! (Design mode?)"); IniConfig.Init("greenshot", "greenshot"); } string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // PAF Path AddPath(Path.Combine(applicationFolder, @"App\Greenshot\Languages")); // Application data path AddPath(Path.Combine(applicationDataFolder, @"Greenshot\Languages\")); // Startup path AddPath(Path.Combine(applicationFolder, @"Languages")); try { using (RegistryKey languageGroupsKey = Registry.LocalMachine.OpenSubKey(LANGUAGE_GROUPS_KEY, false)) { if (languageGroupsKey != null) { string [] groups = languageGroupsKey.GetValueNames(); foreach (string group in groups) { string groupValue = (string)languageGroupsKey.GetValue(group); bool isGroupNotInstalled = "0".Equals(groupValue); if (isGroupNotInstalled) { unsupportedLanguageGroups.Add(group.ToLower()); } } } } } catch (Exception e) { LOG.Warn("Couldn't read the installed language groups.", e); } coreConfig = IniConfig.GetIniSection <CoreConfiguration>(); ScanFiles(); if (!string.IsNullOrEmpty(coreConfig.Language)) { CurrentLanguage = coreConfig.Language; } else { CurrentLanguage = DEFAULT_LANGUAGE; } LOG.Error("Couldn't set language, installation problem?"); }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="host">Use the IGreenshotPluginHost interface to register events</param> /// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param> /// <param name="pluginAttribute">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) { this.host = (IGreenshotHost)pluginHost; jiraPluginAttributes = myAttributes; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <JiraConfiguration>(); resources = new ComponentResourceManager(typeof(JiraPlugin)); return(true); }
/// <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; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <JiraConfiguration>(); // Register our configuration SettingsWindow.RegisterSettingsPage <JiraSettingsPage>("settings_plugins,jira.settings_title"); return(true); }
public override void Log(LogLevel level, string typename, string msg, params object[] objs) { if (coreConfig == null && IniConfig.isInitialized) { coreConfig = IniConfig.GetIniSection <CoreConfiguration>(false); } if (coreConfig == null || level >= coreConfig.LogLevel) { _que.Enqueue(FormatLog(level, typename, msg, objs)); } }
/// <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 = (IGreenshotHost)pluginHost; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <BoxConfiguration>(); resources = new ComponentResourceManager(typeof(BoxPlugin)); // Register our configuration SettingsWindow.RegisterSettingsPage <BoxSettingsPage>("settings_plugins,box.settings_title"); return(true); }
/// <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 <PicasaConfiguration>(); resources = new ComponentResourceManager(typeof(PicasaPlugin)); // Register our configuration SettingsWindow.RegisterSettingsPage <PicasaSettingsPage>("settings_plugins,picasa.settings_title"); return(true); }
/// <summary> /// Fill all GreenshotControls with the values from the configuration /// </summary> protected void FillFields() { foreach (FieldInfo field in GetCachedFields(GetType())) { Object controlObject = field.GetValue(this); if (controlObject == null) { continue; } IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (configBindable == null) { continue; } if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { IniValue iniValue = null; if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) { LOG.DebugFormat("Wrong property '{0}' configured for field '{1}'", configBindable.PropertyName, field.Name); continue; } CheckBox checkBox = controlObject as CheckBox; if (checkBox != null) { checkBox.Checked = (bool)iniValue.Value; checkBox.Enabled = !iniValue.IsFixed; continue; } RadioButton radÃoButton = controlObject as RadioButton; if (radÃoButton != null) { radÃoButton.Checked = (bool)iniValue.Value; radÃoButton.Enabled = !iniValue.IsFixed; continue; } GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; if (comboxBox != null) { comboxBox.Populate(iniValue.ValueType); comboxBox.SetValue((Enum)iniValue.Value); comboxBox.Enabled = !iniValue.IsFixed; continue; } } } } OnFieldsFilled(); }
public static string BuildReport(Exception exception) { StringBuilder exceptionText = new StringBuilder(); exceptionText.AppendLine(EnvironmentInfo.EnvironmentToString(true)); exceptionText.AppendLine(EnvironmentInfo.ExceptionToString(exception)); exceptionText.AppendLine("Configuration dump:"); using (TextWriter writer = new StringWriter(exceptionText)) { IniConfig.SaveIniSectionToWriter(writer, IniConfig.GetIniSection <CoreConfiguration>(), true); } return(exceptionText.ToString()); }
/// <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) { host = pluginHost; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <ConfluenceConfiguration>(); if (config.IsDirty) { IniConfig.Save(); } // Register our configuration SettingsWindow.RegisterSettingsPage <ConfluenceSettingsPage>("settings_plugins,confluence.plugin_settings"); return(true); }
/// <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) { // Register configuration (don't need the configuration itself) _config = IniConfig.GetIniSection <JiraConfiguration>(); // Make sure the loggin is enable for the corect level. if (Log.IsDebugEnabled) { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Verbose); } else if (Log.IsInfoEnabled) { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Info); } else if (Log.IsWarnEnabled) { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Warn); } else if (Log.IsErrorEnabled) { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Error); } else if (Log.IsErrorEnabled) { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Error); } else { LogSettings.RegisterDefaultLogger <Log4NetLogger>(LogLevels.Fatal); } // Add a SVG converter, although it doesn't fit to the Jira plugin there is currently no other way ImageHelper.StreamConverters["svg"] = (stream, s) => { stream.Position = 0; try { return(SvgImage.FromStream(stream).Image); } catch (Exception ex) { Log.Error("Can't load SVG", ex); } return(null); }; return(true); }
/// <summary> /// Store all GreenshotControl values to the configuration /// </summary> protected void StoreFields() { bool iniDirty = false; foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if (!field.FieldType.IsSubclassOf(typeof(Control))) { continue; } if (!typeof(IGreenshotConfigBindable).IsAssignableFrom(field.FieldType)) { continue; } Object controlObject = field.GetValue(this); IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { if (typeof(CheckBox).IsAssignableFrom(field.FieldType)) { CheckBox checkBox = controlObject as CheckBox; section.Values[configBindable.PropertyName].Value = checkBox.Checked; iniDirty = true; } else if (typeof(TextBox).IsAssignableFrom(field.FieldType)) { TextBox textBox = controlObject as TextBox; section.Values[configBindable.PropertyName].Value = textBox.Text; iniDirty = true; } else if (typeof(GreenshotComboBox).IsAssignableFrom(field.FieldType)) { GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; section.Values[configBindable.PropertyName].Value = comboxBox.GetSelectedEnum(); } } } } if (iniDirty) { IniConfig.Save(); } }
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description); CoreConfiguration config = IniConfig.GetIniSection <CoreConfiguration>(); SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(); string file = FilenameHelper.GetFilename(OutputFormat.png, null); string filePath = Path.Combine(config.OutputFilePath, file); using (FileStream stream = new FileStream(filePath, FileMode.Create)) { ImageOutput.SaveToStream(surface, stream, outputSettings); } exportInformation.Filepath = filePath; exportInformation.ExportMade = true; ProcessExport(exportInformation, surface); return(exportInformation); }
public void Reset() { var coreConfiguration = IniConfig.GetIniSection <CoreConfiguration>(); if (null == coreConfiguration || string.IsNullOrEmpty(coreConfiguration.DestinationDefaultBorderEffect?.Trim())) { return; } var defaultBorderEffect = Newtonsoft.Json.JsonConvert.DeserializeObject <DefaultBorderEffect>(coreConfiguration.DestinationDefaultBorderEffect); if (null == defaultBorderEffect) { return; } this.Color = defaultBorderEffect.Color; this.Width = defaultBorderEffect.Width; }
/// <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> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { // Register configuration (don't need the configuration itself) _config = IniConfig.GetIniSection <ConfluenceConfiguration>(); if (_config.IsDirty) { IniConfig.Save(); } try { TranslationManager.Instance.TranslationProvider = new LanguageXMLTranslationProvider(); //resources = new ComponentResourceManager(typeof(ConfluencePlugin)); } catch (Exception ex) { LOG.ErrorFormat("Problem in ConfluencePlugin.Initialize: {0}", ex.Message); return(false); } return(true); }
/// <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); }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="host">Use the IGreenshotPluginHost interface to register events</param> /// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param> /// <param name="pluginAttribute">My own attributes</param> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { this.host = (IGreenshotHost)pluginHost; Attributes = myAttributes; // Get configuration config = IniConfig.GetIniSection <PicasaConfiguration>(); resources = new ComponentResourceManager(typeof(PicasaPlugin)); itemPlugInRoot = new ToolStripMenuItem(); itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure); itemPlugInRoot.Tag = host; itemPlugInRoot.Image = (Image)resources.GetObject("Picasa"); itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick); PluginUtils.AddToContextMenu(host, itemPlugInRoot); Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return(true); }
/// <summary> /// Fill all GreenshotControls with the values from the configuration /// </summary> protected void FillFields() { foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if (!field.FieldType.IsSubclassOf(typeof(Control))) { continue; } Object controlObject = field.GetValue(this); if (typeof(IGreenshotConfigBindable).IsAssignableFrom(field.FieldType)) { IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { if (!section.Values.ContainsKey(configBindable.PropertyName)) { LOG.WarnFormat("Wrong property '{0}' configured for field '{1}'", configBindable.PropertyName, field.Name); continue; } if (typeof(CheckBox).IsAssignableFrom(field.FieldType)) { CheckBox checkBox = controlObject as CheckBox; checkBox.Checked = (bool)section.Values[configBindable.PropertyName].Value; } else if (typeof(TextBox).IsAssignableFrom(field.FieldType)) { TextBox textBox = controlObject as TextBox; textBox.Text = (string)section.Values[configBindable.PropertyName].Value; } else if (typeof(GreenshotComboBox).IsAssignableFrom(field.FieldType)) { GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; comboxBox.Populate(section.Values[configBindable.PropertyName].ValueType); comboxBox.SetValue((Enum)section.Values[configBindable.PropertyName].Value); } } } } } }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param> /// <param name="pluginAttribute">My own attributes</param> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute pluginAttribute) { _host = pluginHost; Attributes = pluginAttribute; // Register configuration (don't need the configuration itself) _config = IniConfig.GetIniSection <BoxConfiguration>(); _resources = new ComponentResourceManager(typeof(BoxPlugin)); _itemPlugInConfig = new ToolStripMenuItem { Image = (Image)_resources.GetObject("Box"), Text = Language.GetString("box", LangKey.Configure) }; _itemPlugInConfig.Click += ConfigMenuClick; PluginUtils.AddToContextMenu(_host, _itemPlugInConfig); Language.LanguageChanged += OnLanguageChanged; return(true); }
protected void ApplyLanguage(Control applyTo) { IGreenshotLanguageBindable languageBindable = applyTo as IGreenshotLanguageBindable; if (languageBindable == null) { // check if it's a menu! if (applyTo is ToolStrip) { ToolStrip toolStrip = applyTo as ToolStrip; foreach (ToolStripItem item in toolStrip.Items) { ApplyLanguage(item); } } return; } string languageKey = languageBindable.LanguageKey; // Apply language text to the control ApplyLanguage(applyTo, languageKey); // Repopulate the combox boxes if (typeof(IGreenshotConfigBindable).IsAssignableFrom(applyTo.GetType())) { if (typeof(GreenshotComboBox).IsAssignableFrom(applyTo.GetType())) { IGreenshotConfigBindable configBindable = applyTo as IGreenshotConfigBindable; if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { GreenshotComboBox comboxBox = applyTo as GreenshotComboBox; // Only update the language, so get the actual value and than repopulate Enum currentValue = (Enum)comboxBox.GetSelectedEnum(); comboxBox.Populate(section.Values[configBindable.PropertyName].ValueType); comboxBox.SetValue(currentValue); } } } } }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="host">Use the IGreenshotPluginHost interface to register events</param> /// <param name="pluginAttribute">My own attributes</param> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { this.host = (IGreenshotHost)pluginHost; Attributes = myAttributes; // Register configuration (don't need the configuration itself) config = IniConfig.GetIniSection <DropboxPluginConfiguration>(); resources = new ComponentResourceManager(typeof(DropboxPlugin)); itemPlugInConfig = new ToolStripMenuItem(); itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure); itemPlugInConfig.Tag = host; itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick); itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox"); PluginUtils.AddToContextMenu(host, itemPlugInConfig); Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return(true); }
public static ILanguage GetInstance() { if (uniqueInstance == null) { uniqueInstance = new LanguageContainer(); uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN; uniqueInstance.Load(); CoreConfiguration conf = IniConfig.GetIniSection <CoreConfiguration>(); if (string.IsNullOrEmpty(conf.Language)) { uniqueInstance.SynchronizeLanguageToCulture(); } else { uniqueInstance.SetLanguage(conf.Language); } } return(uniqueInstance); }
/// <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> public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { _host = pluginHost; Attributes = myAttributes; // Get configuration _config = IniConfig.GetIniSection <PicasaConfiguration>(); _resources = new ComponentResourceManager(typeof(PicasaPlugin)); _itemPlugInRoot = new ToolStripMenuItem { Text = Language.GetString("picasa", LangKey.Configure), Tag = _host, Image = (Image)_resources.GetObject("Picasa") }; _itemPlugInRoot.Click += ConfigMenuClick; PluginUtils.AddToContextMenu(_host, _itemPlugInRoot); Language.LanguageChanged += OnLanguageChanged; return(true); }
/// <summary> /// Implementation of the IGreenshotPlugin.Initialize /// </summary> /// <param name="host">Use the IGreenshotPluginHost interface to register events</param> /// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param> /// <param name="pluginAttribute">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) { this.host = (IGreenshotHost)pluginHost; Attributes = myAttributes; // Get configuration config = IniConfig.GetIniSection <FogBugzConfiguration>(); resources = new ComponentResourceManager(typeof(FogBugzPlugin)); itemPlugInRoot = new ToolStripMenuItem(Language.GetString("fogbugz", LangKey.fogbugz_configure)); itemPlugInRoot.Image = (Image)resources.GetObject("FogBugz"); itemPlugInRoot.Tag = host; itemPlugInRoot.Click += delegate { config.ShowConfigDialog(); }; PluginUtils.AddToContextMenu(host, itemPlugInRoot); Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return(true); }