fixed surface prepare error

This commit is contained in:
Jaex 2014-11-26 19:48:25 +02:00
parent 4fc9c13dd4
commit d8a803f9ce
11 changed files with 11 additions and 41 deletions

View file

@ -31,11 +31,6 @@ namespace ScreenCaptureLib
{ {
public class DiamondRegion : RectangleRegion public class DiamondRegion : RectangleRegion
{ {
public DiamondRegion(Image backgroundImage = null)
: base(backgroundImage)
{
}
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect) protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect)
{ {
graphicsPath.AddDiamond(rect); graphicsPath.AddDiamond(rect);

View file

@ -30,11 +30,6 @@ namespace ScreenCaptureLib
{ {
public class EllipseRegion : RectangleRegion public class EllipseRegion : RectangleRegion
{ {
public EllipseRegion(Image backgroundImage = null)
: base(backgroundImage)
{
}
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect) protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect)
{ {
graphicsPath.AddEllipse(rect); graphicsPath.AddEllipse(rect);

View file

@ -38,12 +38,10 @@ public class FreeHandRegion : Surface
private bool isAreaCreated; private bool isAreaCreated;
private Rectangle currentArea; private Rectangle currentArea;
public FreeHandRegion(Image backgroundImage = null) public FreeHandRegion()
: base(backgroundImage)
{ {
points = new List<Point>(128); points = new List<Point>(128);
regionFillPath = new GraphicsPath(); regionFillPath = new GraphicsPath();
lastNode = new NodeObject() { Shape = NodeShape.Circle }; lastNode = new NodeObject() { Shape = NodeShape.Circle };
DrawableObjects.Add(lastNode); DrawableObjects.Add(lastNode);
} }

View file

@ -38,11 +38,9 @@ public class PolygonRegion : Surface
private bool isAreaCreated; private bool isAreaCreated;
private Rectangle currentArea; private Rectangle currentArea;
public PolygonRegion(Image backgroundImage = null) public PolygonRegion()
: base(backgroundImage)
{ {
nodes = new List<NodeObject>(); nodes = new List<NodeObject>();
MouseDown += PolygonRegionSurface_MouseDown; MouseDown += PolygonRegionSurface_MouseDown;
} }

View file

@ -44,8 +44,7 @@ public class RectangleRegion : Surface
// For screen ruler // For screen ruler
public bool RulerMode { get; set; } public bool RulerMode { get; set; }
public RectangleRegion(Image backgroundImage = null) public RectangleRegion()
: base(backgroundImage)
{ {
AreaManager = new AreaManager(this); AreaManager = new AreaManager(this);
KeyDown += RectangleRegion_KeyDown; KeyDown += RectangleRegion_KeyDown;

View file

@ -36,12 +36,10 @@ public class RoundedRectangleRegion : RectangleRegion
public float Radius { get; set; } public float Radius { get; set; }
public int RadiusIncrement { get; set; } public int RadiusIncrement { get; set; }
public RoundedRectangleRegion(Image backgroundImage = null) public RoundedRectangleRegion()
: base(backgroundImage)
{ {
Radius = 25; Radius = 25;
RadiusIncrement = 3; RadiusIncrement = 3;
KeyDown += RoundedRectangleRegion_KeyDown; KeyDown += RoundedRectangleRegion_KeyDown;
} }

View file

@ -58,7 +58,7 @@ public class Surface : Form
public static GraphicsPath LastRegionFillPath, LastRegionDrawPath; public static GraphicsPath LastRegionFillPath, LastRegionDrawPath;
public Surface(Image backgroundImage = null) public Surface()
{ {
ScreenRectangle = CaptureHelpers.GetScreenBounds(); ScreenRectangle = CaptureHelpers.GetScreenBounds();
ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle); ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle);
@ -70,12 +70,6 @@ public Surface(Image backgroundImage = null)
Cursor = new Cursor(cursorStream); Cursor = new Cursor(cursorStream);
} }
if (backgroundImage != null)
{
SurfaceImage = backgroundImage;
Prepare();
}
DrawableObjects = new List<DrawableObject>(); DrawableObjects = new List<DrawableObject>();
Config = new SurfaceOptions(); Config = new SurfaceOptions();
timer = new Stopwatch(); timer = new Stopwatch();

View file

@ -34,11 +34,9 @@ public class TriangleRegion : RectangleRegion
{ {
public TriangleAngle Angle { get; set; } public TriangleAngle Angle { get; set; }
public TriangleRegion(Image backgroundImage = null) public TriangleRegion()
: base(backgroundImage)
{ {
Angle = TriangleAngle.Top; Angle = TriangleAngle.Top;
KeyDown += TriangleRegion_KeyDown; KeyDown += TriangleRegion_KeyDown;
} }

View file

@ -1478,7 +1478,7 @@
</data> </data>
<data name="niTray.Text" xml:space="preserve"> <data name="niTray.Text" xml:space="preserve">
<value>ShareX</value> <value>ShareX</value>
</data> <comment>@Invariant</comment></data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@ -1499,7 +1499,7 @@
</data> </data>
<data name="$this.Text" xml:space="preserve"> <data name="$this.Text" xml:space="preserve">
<value>ShareX</value> <value>ShareX</value>
</data> <comment>@Invariant</comment></data>
<data name="&gt;&gt;chFilename.Name" xml:space="preserve"> <data name="&gt;&gt;chFilename.Name" xml:space="preserve">
<value>chFilename</value> <value>chFilename</value>
</data> </data>

View file

@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="lblDragAndDropTip.Text" xml:space="preserve">
<value>Dosyaları bu pencereye sürükleyip bırakabilirsiniz</value>
</data>
<data name="chFilename.Text" xml:space="preserve"> <data name="chFilename.Text" xml:space="preserve">
<value>Dosya adı</value> <value>Dosya adı</value>
</data> </data>

View file

@ -348,8 +348,7 @@ public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null)
surfaceOptions = new SurfaceOptions(); surfaceOptions = new SurfaceOptions();
} }
using (Image fullscreen = Screenshot.CaptureFullscreen()) using (RectangleRegion surface = new RectangleRegion())
using (RectangleRegion surface = new RectangleRegion(fullscreen))
{ {
surface.Config = surfaceOptions; surface.Config = surfaceOptions;
surface.OneClickMode = true; surface.OneClickMode = true;
@ -360,7 +359,7 @@ public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null)
{ {
PointInfo pointInfo = new PointInfo(); PointInfo pointInfo = new PointInfo();
pointInfo.Position = CaptureHelpers.ClientToScreen(surface.OneClickPosition); pointInfo.Position = CaptureHelpers.ClientToScreen(surface.OneClickPosition);
pointInfo.Color = ((Bitmap)fullscreen).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y); pointInfo.Color = ((Bitmap)surface.SurfaceImage).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y);
return pointInfo; return pointInfo;
} }
} }
@ -512,8 +511,7 @@ public static void OpenScreenColorPicker()
public static void OpenRuler() public static void OpenRuler()
{ {
using (Image fullscreen = Screenshot.CaptureFullscreen()) using (RectangleRegion surface = new RectangleRegion())
using (RectangleRegion surface = new RectangleRegion(fullscreen))
{ {
surface.RulerMode = true; surface.RulerMode = true;
surface.Config.QuickCrop = false; surface.Config.QuickCrop = false;