mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
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:
parent
b7cfe23605
commit
57e4a8dd73
9 changed files with 89 additions and 33 deletions
2
Greenshot/Forms/AboutForm.Designer.cs
generated
2
Greenshot/Forms/AboutForm.Designer.cs
generated
|
@ -211,7 +211,7 @@ namespace Greenshot {
|
|||
this.Controls.Add(this.lblHost);
|
||||
this.Controls.Add(this.lblLicense);
|
||||
this.Controls.Add(this.lblTitle);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.LanguageKey = "about_title";
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
|
|
|
@ -30,7 +30,7 @@ using Greenshot.IniFile;
|
|||
|
||||
namespace Greenshot {
|
||||
/// <summary>
|
||||
/// Description of AboutForm.
|
||||
/// The about form
|
||||
/// </summary>
|
||||
public partial class AboutForm : BaseForm {
|
||||
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.
|
||||
//
|
||||
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();
|
||||
Version v = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
// 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)");
|
||||
}
|
||||
|
||||
/// <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) {
|
||||
openLink((LinkLabel)sender);
|
||||
}
|
||||
|
||||
private void openLink(LinkLabel link) {
|
||||
try {
|
||||
link.LinkVisited = true;
|
||||
System.Diagnostics.Process.Start(link.Text);
|
||||
} catch (Exception) {
|
||||
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, link.Text), Language.GetString(LangKey.error));
|
||||
LinkLabel linkLabel = sender as LinkLabel;
|
||||
if (linkLabel != null) {
|
||||
try {
|
||||
linkLabel.LinkVisited = true;
|
||||
System.Diagnostics.Process.Start(linkLabel.Text);
|
||||
} catch (Exception) {
|
||||
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, linkLabel.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) {
|
||||
try {
|
||||
switch (keyData) {
|
||||
case Keys.Escape:
|
||||
DialogResult = DialogResult.Cancel;
|
||||
DialogResult = DialogResult.Cancel;
|
||||
break;
|
||||
case Keys.E:
|
||||
MessageBox.Show(EnvironmentInfo.EnvironmentToString(true));
|
||||
|
|
|
@ -127,6 +127,9 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
currentForm = this;
|
||||
|
||||
// Enable the AnimatingForm
|
||||
EnableAnimation = true;
|
||||
|
||||
// Using 32bppPArgb speeds up the drawing.
|
||||
//capturedImage = ImageHelper.Clone(capture.Image, PixelFormat.Format32bppPArgb);
|
||||
// comment the clone, uncomment the assignment and the original bitmap is used.
|
||||
|
|
|
@ -47,10 +47,8 @@ namespace Greenshot {
|
|||
/// Description of ImageEditorForm.
|
||||
/// </summary>
|
||||
public partial class ImageEditorForm : BaseForm, IImageEditor {
|
||||
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm));
|
||||
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<IImageEditor> editorList = new List<IImageEditor>();
|
||||
|
||||
|
@ -161,10 +159,10 @@ namespace Greenshot {
|
|||
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
||||
|
||||
// Disable access to the settings, for feature #3521446
|
||||
preferencesToolStripMenuItem.Visible = !coreConf.DisableSettings;
|
||||
toolStripSeparator12.Visible = !coreConf.DisableSettings;
|
||||
toolStripSeparator11.Visible = !coreConf.DisableSettings;
|
||||
btnSettings.Visible = !coreConf.DisableSettings;
|
||||
preferencesToolStripMenuItem.Visible = !coreConfiguration.DisableSettings;
|
||||
toolStripSeparator12.Visible = !coreConfiguration.DisableSettings;
|
||||
toolStripSeparator11.Visible = !coreConfiguration.DisableSettings;
|
||||
btnSettings.Visible = !coreConfiguration.DisableSettings;
|
||||
|
||||
// Make sure Double-buffer is enabled
|
||||
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
|
||||
|
@ -655,7 +653,7 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
void AboutToolStripMenuItemClick(object sender, System.EventArgs e) {
|
||||
new AboutForm().Show();
|
||||
new AboutForm().ShowDialog(this);
|
||||
}
|
||||
|
||||
void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) {
|
||||
|
@ -1096,7 +1094,7 @@ namespace Greenshot {
|
|||
void SaveElementsToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
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();
|
||||
if(dialogResult.Equals(DialogResult.OK)) {
|
||||
using (Stream streamWrite = File.OpenWrite(saveFileDialog.FileName)) {
|
||||
|
@ -1173,7 +1171,7 @@ namespace Greenshot {
|
|||
}
|
||||
windowToCapture = CaptureHelper.SelectCaptureWindow(windowToCapture);
|
||||
if (windowToCapture != null) {
|
||||
capture = CaptureHelper.CaptureWindow(windowToCapture, capture, coreConf.WindowCaptureMode);
|
||||
capture = CaptureHelper.CaptureWindow(windowToCapture, capture, coreConfiguration.WindowCaptureMode);
|
||||
this.Activate();
|
||||
WindowDetails.ToForeground(this.Handle);
|
||||
if (capture!= null && capture.Image != null) {
|
||||
|
|
|
@ -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) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
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) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
ShowSetting();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called indirectly from the context menu "Preferences"
|
||||
/// </summary>
|
||||
public void ShowSetting() {
|
||||
if (settingsForm != null) {
|
||||
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) {
|
||||
if (aboutForm != null) {
|
||||
WindowDetails.ToForeground(aboutForm.Handle);
|
||||
} else {
|
||||
try {
|
||||
using (aboutForm = new AboutForm()) {
|
||||
aboutForm.ShowDialog();
|
||||
aboutForm.ShowDialog(this);
|
||||
}
|
||||
} finally {
|
||||
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) {
|
||||
HelpFileLoader.LoadHelp();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "Exit" entry is clicked
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_exitClick(object sender, EventArgs e) {
|
||||
Exit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This needs to be called to initialize the quick settings menu entries
|
||||
/// </summary>
|
||||
private void InitializeQuickSettingsMenu() {
|
||||
this.contextmenu_quicksettings.DropDownItems.Clear();
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace Greenshot.Forms {
|
|||
/// Description of PrintOptionsDialog.
|
||||
/// </summary>
|
||||
public partial class PrintOptionsDialog : BaseForm {
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
|
||||
public PrintOptionsDialog() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
|
@ -43,7 +41,7 @@ namespace Greenshot.Forms {
|
|||
|
||||
void Button_okClick(object sender, EventArgs e) {
|
||||
// update config
|
||||
conf.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked;
|
||||
coreConfiguration.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked;
|
||||
IniConfig.Save();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
public partial class SettingsForm : BaseForm {
|
||||
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 ToolTip toolTip = new ToolTip();
|
||||
private bool inHotkey = false;
|
||||
|
|
|
@ -33,6 +33,14 @@ namespace GreenshotPlugin.Controls {
|
|||
private int vRefresh = 0;
|
||||
private Timer timer = null;
|
||||
|
||||
/// <summary>
|
||||
/// This flag specifies if any animation is used
|
||||
/// </summary>
|
||||
protected bool EnableAnimation {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Refresh Rate
|
||||
/// </summary>
|
||||
|
@ -74,12 +82,13 @@ namespace GreenshotPlugin.Controls {
|
|||
/// Initialize the animation
|
||||
/// </summary>
|
||||
protected AnimatingForm() {
|
||||
timer = new Timer();
|
||||
timer.Interval = 1000 / VRefresh;
|
||||
timer.Tick += new EventHandler(timer_Tick);
|
||||
|
||||
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
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.ComponentModel.Design;
|
|||
using System.IO;
|
||||
|
||||
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 IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>();
|
||||
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>
|
||||
/// Code to initialize the language etc during design time
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue