Fixed file handling, fixed wrong order in the title of the editor, changed left-click handling of the context menu. Added a boolean in the ProcessCmdKey of the surface.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2327 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-11-28 18:59:01 +00:00
commit 2a26be0a37
4 changed files with 56 additions and 8 deletions

View file

@ -1556,10 +1556,11 @@ namespace Greenshot.Drawing {
}
/// <summary>
/// Process key
/// Process key presses on the surface, this is called from the editor (and NOT an override from the Control)
/// </summary>
/// <param name="k"></param>
public void ProcessCmdKey(Keys k) {
/// <param name="k">Keys</param>
/// <returns>false if no keys were processed</returns>
public bool ProcessCmdKey(Keys k) {
if (selectedElements.Count > 0) {
bool shiftModifier = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
int px = shiftModifier ? 10 : 1;
@ -1604,13 +1605,15 @@ namespace Greenshot.Drawing {
RemoveSelectedElements();
break;*/
default:
return;
return false;
}
if (!Point.Empty.Equals(moveBy)) {
selectedElements.MakeBoundsChangeUndoable(true);
selectedElements.MoveBy(moveBy.X, moveBy.Y);
}
return true;
}
return false;
}
/// <summary>

View file

@ -384,7 +384,7 @@ namespace Greenshot {
return;
}
updateStatusLabel(Language.GetFormattedString(LangKey.editor_imagesaved, fullpath), fileSavedStatusContextMenu);
this.Text = Language.GetString(LangKey.editor_title) + " - " + Path.GetFileName(fullpath);
this.Text = Path.GetFileName(fullpath) + " - " + Language.GetString(LangKey.editor_title);
}
void surface_DrawingModeChanged(object source, DrawingModes drawingMode) {

View file

@ -1087,10 +1087,43 @@ namespace Greenshot {
new BugReportForm(exceptionText).ShowDialog();
}
/// <summary>
/// Handle the notify icon click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NotifyIconClick(object sender, MouseEventArgs e) {
// The right button will automatically be handled with the context menu, here we only check the left.
if (e.Button == MouseButtons.Left) {
MethodInfo oMethodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
oMethodInfo.Invoke(notifyIcon, null);
switch (conf.LeftClickAction) {
case LeftClickActions.OPEN_LAST_IN_EXPLORER:
string path = null;
string configPath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath);
if (Directory.Exists(lastFilePath)) {
path = lastFilePath;
} else if (Directory.Exists(configPath)) {
path = configPath;
}
try {
System.Diagnostics.Process.Start(path);
} catch (Exception ex) {
// Make sure we show what we tried to open in the exception
ex.Data.Add("path", path);
throw ex;
}
break;
case LeftClickActions.OPEN_LAST_IN_EDITOR:
if (File.Exists(conf.OutputFileAsFullpath)) {
CaptureHelper.CaptureFile(conf.OutputFileAsFullpath, DestinationHelper.GetDestination(EditorDestination.DESIGNATION));
}
break;
default:
MethodInfo oMethodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
oMethodInfo.Invoke(notifyIcon, null);
break;
}
}
}

View file

@ -86,24 +86,36 @@ namespace Greenshot.Helpers {
public static void CaptureWindow(bool captureMouse) {
new CaptureHelper(CaptureMode.ActiveWindow, captureMouse).MakeCapture();
}
public static void CaptureWindow(WindowDetails windowToCapture) {
CaptureHelper captureHelper = new CaptureHelper(CaptureMode.ActiveWindow);
captureHelper.SelectedCaptureWindow = windowToCapture;
captureHelper.MakeCapture();
}
public static void CaptureWindowInteractive(bool captureMouse) {
new CaptureHelper(CaptureMode.Window, captureMouse).MakeCapture();
}
public static void CaptureFile(string filename) {
new CaptureHelper(CaptureMode.File).MakeCapture(filename);
}
public static void CaptureFile(string filename, IDestination destination) {
new CaptureHelper(CaptureMode.File).AddDestination(destination).MakeCapture(filename);
}
public static void ImportCapture(ICapture captureToImport) {
CaptureHelper captureHelper = new CaptureHelper(CaptureMode.File);
captureHelper.capture = captureToImport;
captureHelper.HandleCapture();
}
public CaptureHelper AddDestination(IDestination destination) {
capture.CaptureDetails.AddDestination(destination);
return this;
}
public CaptureHelper(CaptureMode captureMode) {
this.captureMode = captureMode;
capture = new Capture();