Cleanup of the AboutForm, changed the Style to a "FixedToolWindow", I find this more professional. Changed the AnimatingForm to have a flag, EnableAnimation, which is false by default and makes it possible to make the Form the base form of all GreenshotForm forms. Renamed the conf -> coreConfiguration, as this is already in the base class. Also added some comments.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2367 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-07 16:31:20 +00:00
commit 57e4a8dd73
9 changed files with 89 additions and 33 deletions

View file

@ -211,7 +211,7 @@ namespace Greenshot {
this.Controls.Add(this.lblHost); this.Controls.Add(this.lblHost);
this.Controls.Add(this.lblLicense); this.Controls.Add(this.lblLicense);
this.Controls.Add(this.lblTitle); this.Controls.Add(this.lblTitle);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.LanguageKey = "about_title"; this.LanguageKey = "about_title";
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;

View file

@ -30,7 +30,7 @@ using Greenshot.IniFile;
namespace Greenshot { namespace Greenshot {
/// <summary> /// <summary>
/// Description of AboutForm. /// The about form
/// </summary> /// </summary>
public partial class AboutForm : BaseForm { public partial class AboutForm : BaseForm {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm)); private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
@ -39,31 +39,42 @@ namespace Greenshot {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); // Not needed for a Tool Window:
//this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.pictureBox1.Image = GreenshotPlugin.Core.GreenshotResources.getGreenshotImage(); this.pictureBox1.Image = GreenshotPlugin.Core.GreenshotResources.getGreenshotImage();
Version v = Assembly.GetExecutingAssembly().GetName().Version; Version v = Assembly.GetExecutingAssembly().GetName().Version;
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")] // Format is like this: AssemblyVersion("Major.Minor.Build.Revision")]
lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable?" Portable":"") + (" (" + OSInfo.Bits +" bit)"); lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable?" Portable":"") + (" (" + OSInfo.Bits +" bit)");
} }
/// <summary>
/// This is called when a link is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void LinkLabelClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { void LinkLabelClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) {
openLink((LinkLabel)sender); LinkLabel linkLabel = sender as LinkLabel;
} if (linkLabel != null) {
try {
private void openLink(LinkLabel link) { linkLabel.LinkVisited = true;
try { System.Diagnostics.Process.Start(linkLabel.Text);
link.LinkVisited = true; } catch (Exception) {
System.Diagnostics.Process.Start(link.Text); MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, linkLabel.Text), Language.GetString(LangKey.error));
} catch (Exception) { }
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, link.Text), Language.GetString(LangKey.error));
} }
} }
/// <summary>
/// CmdKey handler
/// </summary>
/// <param name="msg"></param>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
try { try {
switch (keyData) { switch (keyData) {
case Keys.Escape: case Keys.Escape:
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
break; break;
case Keys.E: case Keys.E:
MessageBox.Show(EnvironmentInfo.EnvironmentToString(true)); MessageBox.Show(EnvironmentInfo.EnvironmentToString(true));

View file

@ -127,6 +127,9 @@ namespace Greenshot.Forms {
} }
currentForm = this; currentForm = this;
// Enable the AnimatingForm
EnableAnimation = true;
// Using 32bppPArgb speeds up the drawing. // Using 32bppPArgb speeds up the drawing.
//capturedImage = ImageHelper.Clone(capture.Image, PixelFormat.Format32bppPArgb); //capturedImage = ImageHelper.Clone(capture.Image, PixelFormat.Format32bppPArgb);
// comment the clone, uncomment the assignment and the original bitmap is used. // comment the clone, uncomment the assignment and the original bitmap is used.

View file

@ -47,10 +47,8 @@ namespace Greenshot {
/// Description of ImageEditorForm. /// Description of ImageEditorForm.
/// </summary> /// </summary>
public partial class ImageEditorForm : BaseForm, IImageEditor { public partial class ImageEditorForm : BaseForm, IImageEditor {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm)); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>(); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
private static CoreConfiguration coreConf = IniConfig.GetIniSection<CoreConfiguration>();
private static List<string> ignoreDestinations = new List<string>() {PickerDestination.DESIGNATION, EditorDestination.DESIGNATION}; private static List<string> ignoreDestinations = new List<string>() {PickerDestination.DESIGNATION, EditorDestination.DESIGNATION};
private static List<IImageEditor> editorList = new List<IImageEditor>(); private static List<IImageEditor> editorList = new List<IImageEditor>();
@ -161,10 +159,10 @@ namespace Greenshot {
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
// Disable access to the settings, for feature #3521446 // Disable access to the settings, for feature #3521446
preferencesToolStripMenuItem.Visible = !coreConf.DisableSettings; preferencesToolStripMenuItem.Visible = !coreConfiguration.DisableSettings;
toolStripSeparator12.Visible = !coreConf.DisableSettings; toolStripSeparator12.Visible = !coreConfiguration.DisableSettings;
toolStripSeparator11.Visible = !coreConf.DisableSettings; toolStripSeparator11.Visible = !coreConfiguration.DisableSettings;
btnSettings.Visible = !coreConf.DisableSettings; btnSettings.Visible = !coreConfiguration.DisableSettings;
// Make sure Double-buffer is enabled // Make sure Double-buffer is enabled
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
@ -655,7 +653,7 @@ namespace Greenshot {
} }
void AboutToolStripMenuItemClick(object sender, System.EventArgs e) { void AboutToolStripMenuItemClick(object sender, System.EventArgs e) {
new AboutForm().Show(); new AboutForm().ShowDialog(this);
} }
void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) { void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) {
@ -1096,7 +1094,7 @@ namespace Greenshot {
void SaveElementsToolStripMenuItemClick(object sender, EventArgs e) { void SaveElementsToolStripMenuItemClick(object sender, EventArgs e) {
SaveFileDialog saveFileDialog = new SaveFileDialog(); SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Greenshot templates (*.gst)|*.gst"; saveFileDialog.Filter = "Greenshot templates (*.gst)|*.gst";
saveFileDialog.FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConf.OutputFileFilenamePattern, surface.CaptureDetails); saveFileDialog.FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConfiguration.OutputFileFilenamePattern, surface.CaptureDetails);
DialogResult dialogResult = saveFileDialog.ShowDialog(); DialogResult dialogResult = saveFileDialog.ShowDialog();
if(dialogResult.Equals(DialogResult.OK)) { if(dialogResult.Equals(DialogResult.OK)) {
using (Stream streamWrite = File.OpenWrite(saveFileDialog.FileName)) { using (Stream streamWrite = File.OpenWrite(saveFileDialog.FileName)) {
@ -1173,7 +1171,7 @@ namespace Greenshot {
} }
windowToCapture = CaptureHelper.SelectCaptureWindow(windowToCapture); windowToCapture = CaptureHelper.SelectCaptureWindow(windowToCapture);
if (windowToCapture != null) { if (windowToCapture != null) {
capture = CaptureHelper.CaptureWindow(windowToCapture, capture, coreConf.WindowCaptureMode); capture = CaptureHelper.CaptureWindow(windowToCapture, capture, coreConfiguration.WindowCaptureMode);
this.Activate(); this.Activate();
WindowDetails.ToForeground(this.Handle); WindowDetails.ToForeground(this.Handle);
if (capture!= null && capture.Image != null) { if (capture!= null && capture.Image != null) {

View file

@ -897,18 +897,31 @@ namespace Greenshot {
}); });
} }
/// <summary>
/// Context menu entry "Support Greenshot"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Contextmenu_donateClick(object sender, EventArgs e) { void Contextmenu_donateClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
Process.Start("http://getgreenshot.org/support/"); Process.Start("http://getgreenshot.org/support/");
}); });
} }
/// <summary>
/// Context menu entry "Preferences"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Contextmenu_settingsClick(object sender, EventArgs e) { void Contextmenu_settingsClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
ShowSetting(); ShowSetting();
}); });
} }
/// <summary>
/// This is called indirectly from the context menu "Preferences"
/// </summary>
public void ShowSetting() { public void ShowSetting() {
if (settingsForm != null) { if (settingsForm != null) {
WindowDetails.ToForeground(settingsForm.Handle); WindowDetails.ToForeground(settingsForm.Handle);
@ -925,13 +938,18 @@ namespace Greenshot {
} }
} }
/// <summary>
/// The "About Greenshot" entry is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Contextmenu_aboutClick(object sender, EventArgs e) { void Contextmenu_aboutClick(object sender, EventArgs e) {
if (aboutForm != null) { if (aboutForm != null) {
WindowDetails.ToForeground(aboutForm.Handle); WindowDetails.ToForeground(aboutForm.Handle);
} else { } else {
try { try {
using (aboutForm = new AboutForm()) { using (aboutForm = new AboutForm()) {
aboutForm.ShowDialog(); aboutForm.ShowDialog(this);
} }
} finally { } finally {
aboutForm = null; aboutForm = null;
@ -939,14 +957,27 @@ namespace Greenshot {
} }
} }
/// <summary>
/// The "Help" entry is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Contextmenu_helpClick(object sender, EventArgs e) { void Contextmenu_helpClick(object sender, EventArgs e) {
HelpFileLoader.LoadHelp(); HelpFileLoader.LoadHelp();
} }
/// <summary>
/// The "Exit" entry is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Contextmenu_exitClick(object sender, EventArgs e) { void Contextmenu_exitClick(object sender, EventArgs e) {
Exit(); Exit();
} }
/// <summary>
/// This needs to be called to initialize the quick settings menu entries
/// </summary>
private void InitializeQuickSettingsMenu() { private void InitializeQuickSettingsMenu() {
this.contextmenu_quicksettings.DropDownItems.Clear(); this.contextmenu_quicksettings.DropDownItems.Clear();

View file

@ -29,8 +29,6 @@ namespace Greenshot.Forms {
/// Description of PrintOptionsDialog. /// Description of PrintOptionsDialog.
/// </summary> /// </summary>
public partial class PrintOptionsDialog : BaseForm { public partial class PrintOptionsDialog : BaseForm {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
public PrintOptionsDialog() { public PrintOptionsDialog() {
// //
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
@ -43,7 +41,7 @@ namespace Greenshot.Forms {
void Button_okClick(object sender, EventArgs e) { void Button_okClick(object sender, EventArgs e) {
// update config // update config
conf.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked; coreConfiguration.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked;
IniConfig.Save(); IniConfig.Save();
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} }

View file

@ -41,7 +41,6 @@ namespace Greenshot {
/// </summary> /// </summary>
public partial class SettingsForm : BaseForm { public partial class SettingsForm : BaseForm {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm)); private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
private static CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>(); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
private ToolTip toolTip = new ToolTip(); private ToolTip toolTip = new ToolTip();
private bool inHotkey = false; private bool inHotkey = false;

View file

@ -33,6 +33,14 @@ namespace GreenshotPlugin.Controls {
private int vRefresh = 0; private int vRefresh = 0;
private Timer timer = null; private Timer timer = null;
/// <summary>
/// This flag specifies if any animation is used
/// </summary>
protected bool EnableAnimation {
get;
set;
}
/// <summary> /// <summary>
/// Vertical Refresh Rate /// Vertical Refresh Rate
/// </summary> /// </summary>
@ -74,12 +82,13 @@ namespace GreenshotPlugin.Controls {
/// Initialize the animation /// Initialize the animation
/// </summary> /// </summary>
protected AnimatingForm() { protected AnimatingForm() {
timer = new Timer();
timer.Interval = 1000 / VRefresh;
timer.Tick += new EventHandler(timer_Tick);
this.Load += delegate { this.Load += delegate {
timer.Start(); if (EnableAnimation) {
timer = new Timer();
timer.Interval = 1000 / VRefresh;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
}; };
// Unregister at close // Unregister at close

View file

@ -30,7 +30,7 @@ using System.ComponentModel.Design;
using System.IO; using System.IO;
namespace GreenshotPlugin.Controls { namespace GreenshotPlugin.Controls {
public abstract class GreenshotForm : Form, IGreenshotLanguageBindable { public abstract class GreenshotForm : AnimatingForm, IGreenshotLanguageBindable {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm)); private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm));
private static IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>(); private static IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>();
private IComponentChangeService m_changeService; private IComponentChangeService m_changeService;
@ -64,6 +64,13 @@ namespace GreenshotPlugin.Controls {
} }
} }
/// <summary>
/// Normally a Greenshot form doesn't animate
/// </summary>
protected override void Animate() {
throw new NotImplementedException();
}
/// <summary> /// <summary>
/// Code to initialize the language etc during design time /// Code to initialize the language etc during design time
/// </summary> /// </summary>