-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from cwensley/add-zoom-options
Add more zoom levels and zoom in/out/reset commands
- Loading branch information
Showing
8 changed files
with
193 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Linq; | ||
using Eto.Forms; | ||
|
||
namespace Pablo.Actions | ||
{ | ||
public class ZoomIn : Command | ||
{ | ||
public const string ActionID = "zoomIn"; | ||
|
||
public ViewerPane ViewerPane { get; private set; } | ||
|
||
public ZoomIn(ViewerPane viewerPane) | ||
{ | ||
this.ViewerPane = viewerPane; | ||
this.ID = ActionID; | ||
this.MenuText = "Zoom &In"; | ||
this.ToolTip = "Make things bigger"; | ||
this.Shortcut = Application.Instance.CommonModifier | Keys.Equal; | ||
} | ||
|
||
protected override void OnExecuted(EventArgs e) | ||
{ | ||
base.OnExecuted(e); | ||
var zoomInfo = ViewerPane.ZoomInfo; | ||
var nextZoom = Pablo.ViewerPane.ZOOM_LEVELS.Where(r => r > zoomInfo.Zoom).OrderBy(r => r).FirstOrDefault(); | ||
if (nextZoom == 0) | ||
nextZoom = ViewerPane.Zoom + 0.5f; | ||
zoomInfo.Zoom = nextZoom; | ||
ViewerPane.UpdateMenuItems(); | ||
ViewerPane.UpdateSizes(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Linq; | ||
using Eto.Forms; | ||
|
||
namespace Pablo.Actions | ||
{ | ||
public class ZoomLevel : RadioCommand, IUpdatableCommand | ||
{ | ||
public ZoomLevel(RadioCommand controller, ViewerPane viewerPane, float zoomLevel) | ||
{ | ||
ViewerPane = viewerPane; | ||
Zoom = zoomLevel; | ||
Controller = controller; | ||
ID = "zoom" + zoomLevel; | ||
MenuText = string.Format("{0}%", zoomLevel * 100); | ||
} | ||
|
||
public ViewerPane ViewerPane { get; set; } | ||
public float Zoom { get; set; } | ||
public void UpdateState() | ||
{ | ||
Checked = Math.Abs(ViewerPane.ZoomInfo.Zoom - Zoom) < 0.0001f; | ||
} | ||
|
||
protected override void OnExecuted(EventArgs e) | ||
{ | ||
base.OnExecuted(e); | ||
ViewerPane.ZoomInfo.Zoom = Zoom; | ||
ViewerPane.UpdateSizes(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Linq; | ||
using Eto.Forms; | ||
|
||
namespace Pablo.Actions | ||
{ | ||
public class ZoomOut : Command | ||
{ | ||
public const string ActionID = "zoomOut"; | ||
|
||
public ViewerPane ViewerPane { get; private set; } | ||
|
||
public ZoomOut(ViewerPane viewerPane) | ||
{ | ||
this.ViewerPane = viewerPane; | ||
this.ID = ActionID; | ||
this.MenuText = "Zoom &Out"; | ||
this.ToolTip = "Make things smaller"; | ||
this.Shortcut = Application.Instance.CommonModifier | Keys.Minus; | ||
} | ||
|
||
protected override void OnExecuted(EventArgs e) | ||
{ | ||
base.OnExecuted(e); | ||
var zoomInfo = ViewerPane.ZoomInfo; | ||
var nextZoom = Pablo.ViewerPane.ZOOM_LEVELS.Where(r => r < zoomInfo.Zoom).OrderByDescending(r => r).FirstOrDefault(); | ||
if (nextZoom == 0) | ||
nextZoom = ViewerPane.Zoom * 0.5f; | ||
if (nextZoom > 0.02) | ||
{ | ||
zoomInfo.Zoom = nextZoom; | ||
ViewerPane.UpdateMenuItems(); | ||
ViewerPane.UpdateSizes(); | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Linq; | ||
using Eto.Forms; | ||
|
||
namespace Pablo.Actions | ||
{ | ||
public class ZoomReset : Command | ||
{ | ||
public const string ActionID = "zoomReset"; | ||
|
||
public ViewerPane ViewerPane { get; private set; } | ||
|
||
public ZoomReset(ViewerPane viewerPane) | ||
{ | ||
this.ViewerPane = viewerPane; | ||
this.ID = ActionID; | ||
this.MenuText = "Reset Zoom"; | ||
this.ToolTip = "Get back to normal"; | ||
this.Shortcut = Application.Instance.CommonModifier | Keys.D0; | ||
} | ||
|
||
protected override void OnExecuted(EventArgs e) | ||
{ | ||
base.OnExecuted(e); | ||
ViewerPane.ZoomInfo.Zoom = 1; | ||
ViewerPane.UpdateMenuItems(); | ||
ViewerPane.UpdateSizes(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters