本文整理汇总了C#中System.Drawing.Size.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Size.ToString方法的具体用法?C# Size.ToString怎么用?C# Size.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Size
的用法示例。
在下文中一共展示了Size.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPreferredSize
internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) {
#if DEBUG
if (CompModSwitches.FlowLayout.TraceInfo) {
Debug.WriteLine("FlowLayout::GetPreferredSize("
+ "container=" + container.ToString() + ", "
+ "proposedConstraints=" + proposedConstraints.ToString() + ")");
Debug.Indent();
}
#endif
Rectangle measureBounds = new Rectangle(new Point(0, 0), proposedConstraints);
Size prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);
if(prefSize.Width > proposedConstraints.Width || prefSize.Height> proposedConstraints.Height) {
// Controls measured earlier than a control which couldn't be fit to constraints may
// shift around with the new bounds. We need to make a 2nd pass through the
// controls using these bounds which are gauranteed to fit.
measureBounds.Size = prefSize;
prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);
}
#if DEBUG
if (CompModSwitches.FlowLayout.TraceInfo) {
Debug.Unindent();
Debug.WriteLine("GetPreferredSize returned " + prefSize);
}
#endif
return prefSize;
}
示例2: Run
public void Run()
{
String[] Input;
Console.WriteLine("Please specify the size of the Mars Plateu:");
Console.WriteLine("The first number is the width, and the second number is the height.");
Input = Console.ReadLine().Split(' ');
Size plateu = new Size(Convert.ToInt32(Input[0]), Convert.ToInt32(Input[1]));
Console.WriteLine("Initializing Plateau with size: {0}.", plateu.ToString());
Bus.Send<RequestSurfaceMessage>(m =>
{
m.MessageID = Guid.NewGuid();
m.Width = plateu.Width;
m.Height = plateu.Height;
});
while (true)
{
Console.WriteLine("");
Console.WriteLine("Please specify the starting position and direction of the rover:");
Console.WriteLine("The first number is the horizontal coordinate, the second number is the vertical coordinate");
Console.WriteLine("The third value is a single character representing a Cardinal Point (N, S, E, or W)");
Console.WriteLine("Please enter a blank line to indicate you have no more rovers to enter.");
Input = Console.ReadLine().Split(' ');
try
{
Point roverStartingPosition = new Point(Convert.ToInt32(Input[0]), Convert.ToInt32(Input[1]));
String roverDirection = Input[2].ToUpper();
Console.WriteLine("Please provide a string of directions for the rover to follow. No spaces are requred.");
Console.WriteLine("{ L = Turn Left; R = Turn Right; M = Move 1 unit forward }");
String roverCommands = Console.ReadLine().Replace(" ", "").ToUpper();
Console.WriteLine("Sending message to rover...");
Bus.Send<RequestRoverMessage>(m =>
{
m.MessageID = Guid.NewGuid();
m.StartingPositionX = roverStartingPosition.X;
m.StartingPositionY = roverStartingPosition.Y;
m.StartingDirection = roverDirection;
m.Commands = roverCommands;
});
}
catch
{
break;
}
}
}
示例3: GetImage
public Bitmap GetImage(Size size)
{
try
{
IEnumerable<XElement> images = artistElement.Elements().Where(e => e.Name.LocalName == "image");
string imageUrl = (from xElement in images
where xElement.Attributes().Where(a => a.Name.LocalName == "size").First().Value == size.ToString().ToLower()
select xElement.Value).FirstOrDefault();
WebRequest request = WebRequest.Create(imageUrl);
Stream responseStream = request.GetResponse().GetResponseStream();
return new Bitmap(responseStream);
}
catch (Exception)
{
//TODO: write to logger
return null;
}
}
示例4: ApplyBase
/// <summary>
/// Provides a default implementation for performing dst = F(dst, src) or F(src) over some rectangle
/// of interest. May be slightly faster than calling the other multi-parameter Apply method, as less
/// variables are used in the implementation, thus inducing less register pressure.
/// </summary>
/// <param name="dst">The Surface to write pixels to, and from which pixels are read and used as the lhs parameter for calling the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param>
/// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param>
/// <param name="src">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>b>.</param></param>
/// <param name="srcOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the src Surface.</param>
/// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param>
public void ApplyBase(Surface dst, Point dstOffset, Surface src, Point srcOffset, Size roiSize)
{
// Create bounding rectangles for each Surface
Rectangle dstRect = new Rectangle(dstOffset, roiSize);
if (dstRect.Width == 0 || dstRect.Height == 0)
{
return;
}
Rectangle srcRect = new Rectangle(srcOffset, roiSize);
if (srcRect.Width == 0 || srcRect.Height == 0)
{
return;
}
// Clip those rectangles to those Surface's bounding rectangles
Rectangle dstClip = Rectangle.Intersect(dstRect, dst.Bounds);
Rectangle srcClip = Rectangle.Intersect(srcRect, src.Bounds);
// If any of those Rectangles actually got clipped, then throw an exception
if (dstRect != dstClip)
{
throw new ArgumentOutOfRangeException
(
"roiSize",
"Destination roi out of bounds" +
", dst.Size=" + dst.Size.ToString() +
", dst.Bounds=" + dst.Bounds.ToString() +
", dstOffset=" + dstOffset.ToString() +
", src.Size=" + src.Size.ToString() +
", srcOffset=" + srcOffset.ToString() +
", roiSize=" + roiSize.ToString() +
", dstRect=" + dstRect.ToString() +
", dstClip=" + dstClip.ToString() +
", srcRect=" + srcRect.ToString() +
", srcClip=" + srcClip.ToString()
);
}
if (srcRect != srcClip)
{
throw new ArgumentOutOfRangeException("roiSize", "Source roi out of bounds");
}
// Cache the width and height properties
int width = roiSize.Width;
int height = roiSize.Height;
// Do the work.
unsafe
{
for (int row = 0; row < roiSize.Height; ++row)
{
ColorBgra *dstPtr = dst.GetPointAddress(dstOffset.X, dstOffset.Y + row);
ColorBgra *srcPtr = src.GetPointAddress(srcOffset.X, srcOffset.Y + row);
Apply(dstPtr, srcPtr, width);
}
}
}
示例5: FrameBufferResized
//static Random r = new Random();
public void FrameBufferResized()
{
// run this entire thing exactly twice, since the first resize may adjust the menu stacking
for (int i = 0; i < 2; i++)
{
var video = Global.Emulator.VideoProvider();
int zoom = Global.Config.TargetZoomFactor;
var area = Screen.FromControl(this).WorkingArea;
int borderWidth = Size.Width - PresentationPanel.Control.Size.Width;
int borderHeight = Size.Height - PresentationPanel.Control.Size.Height;
// start at target zoom and work way down until we find acceptable zoom
Size lastComputedSize = new Size(1, 1);
for (; zoom >= 1; zoom--)
{
lastComputedSize = GlobalWin.DisplayManager.CalculateClientSize(video, zoom);
if ((((lastComputedSize.Width) + borderWidth) < area.Width)
&& (((lastComputedSize.Height) + borderHeight) < area.Height))
{
break;
}
}
Console.WriteLine("Selecting display size " + lastComputedSize.ToString());
// Change size
Size = new Size((lastComputedSize.Width) + borderWidth, ((lastComputedSize.Height) + borderHeight));
PerformLayout();
PresentationPanel.Resized = true;
// Is window off the screen at this size?
if (area.Contains(Bounds) == false)
{
if (Bounds.Right > area.Right) // Window is off the right edge
{
Location = new Point(area.Right - Size.Width, Location.Y);
}
if (Bounds.Bottom > area.Bottom) // Window is off the bottom edge
{
Location = new Point(Location.X, area.Bottom - Size.Height);
}
}
}
}
示例6: Accumulate
public void Accumulate(Size size)
{
this.Accumulate(size.ToString());
}
示例7: Paint
/// <devdoc>
/// Called by the dataGrid when it needs the caption
/// to repaint.
/// </devdoc>
internal void Paint(Graphics g, Rectangle bounds, bool alignRight) {
Size textSize = new Size((int) g.MeasureString(text, this.Font).Width + 2, this.Font.Height + 2);
downButtonRect = GetDetailsButtonRect(bounds, alignRight);
int downButtonWidth = GetDetailsButtonWidth();
backButtonRect = GetBackButtonRect(bounds, alignRight, downButtonWidth);
int backButtonArea = backButtonVisible ? backButtonRect.Width + xOffset + buttonToText : 0;
int downButtonArea = downButtonVisible && !dataGrid.ParentRowsIsEmpty() ? downButtonWidth + xOffset + buttonToText : 0;
int textWidthLeft = bounds.Width - xOffset - backButtonArea - downButtonArea;
textRect = new Rectangle(
bounds.X,
bounds.Y + yOffset,
Math.Min(textWidthLeft, 2 * textPadding + textSize.Width),
2 * textPadding + textSize.Height);
// align the caption text box, downButton, and backButton
// if the RigthToLeft property is set to true
if (alignRight) {
textRect.X = bounds.Right - textRect.Width;
backButtonRect.X = bounds.X + xOffset * 4 + downButtonWidth;
downButtonRect.X = bounds.X + xOffset * 2;
}
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "text size = " + textSize.ToString());
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "downButtonWidth = " + downButtonWidth.ToString(CultureInfo.InvariantCulture));
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "textWidthLeft = " + textWidthLeft.ToString(CultureInfo.InvariantCulture));
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "backButtonRect " + backButtonRect.ToString());
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "textRect " + textRect.ToString());
Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "downButtonRect " + downButtonRect.ToString());
// we should use the code that is commented out
// with today's code, there are pixels on the backButtonRect and the downButtonRect
// that are getting painted twice
//
g.FillRectangle(backBrush, bounds);
if (backButtonVisible) {
PaintBackButton(g, backButtonRect, alignRight);
if (backActive) {
if (lastMouseLocation == CaptionLocation.BackButton) {
backButtonRect.Inflate(1,1);
ControlPaint.DrawBorder3D(g, backButtonRect,
backPressed ? Border3DStyle.SunkenInner : Border3DStyle.RaisedInner);
}
}
}
PaintText(g, textRect, alignRight);
if (downButtonVisible && !dataGrid.ParentRowsIsEmpty()) {
PaintDownButton(g, downButtonRect);
// the rules have changed, yet again.
// now: if we show the parent rows and the mouse is
// not on top of this icon, then let the icon be depressed.
// if the mouse is pressed over the icon, then show the icon pressed
// if the mouse is over the icon and not pressed, then show the icon SunkenInner;
//
if (lastMouseLocation == CaptionLocation.DownButton)
{
downButtonRect.Inflate(1,1);
ControlPaint.DrawBorder3D(g, downButtonRect,
downPressed ? Border3DStyle.SunkenInner : Border3DStyle.RaisedInner);
}
}
}
示例8: VideoResizer
// Idea from Gabest (http://www.gabest.org) and modify by me
public virtual void VideoResizer(VideoSizeMode videoZoomMode, bool keepAspectRatio, PointF offset, double zoom, double aspectRatioFactor)
{
Trace.WriteLineIf(trace.TraceInfo, "VideoResizer(...)");
int hr = 0;
Rectangle windowRect = this.hostingControl.ClientRectangle;
currentVideoTargetRectangle = windowRect;
currentVideoSourceSize = new Size();
FilterState filterState = GetGraphState();
if (filterState == FilterState.Paused || filterState == FilterState.Running)
{
if (videoZoomMode != VideoSizeMode.StretchToWindow)
{
int arX, arY;
int arX2 = 0, arY2 = 0;
if (useEVR)
{
Size videoSize = new Size(), arVideoSize = new Size();
hr = evrVideoDisplayControl.GetNativeVideoSize(out videoSize, out arVideoSize);
//IMFVideoDisplayControlEx evrVideoDisplayControlPlus = evrVideoDisplayControl as IMFVideoDisplayControlEx;
//hr = evrVideoDisplayControlPlus.GetNativeVideoSize(out videoSize, out arVideoSize);
//hr = evrVideoDisplayControlPlus.GetIdealVideoSize(videoSize, arVideoSize);
arX = videoSize.Width;
arY = videoSize.Height;
arX2 = arVideoSize.Width;
arY2 = arVideoSize.Height;
Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tvideoRenderer.GetNativeVideoSize({0}, {1})"), videoSize.ToString(), arVideoSize.ToString()));
}
else
hr = (this.videoRenderer as IVMRWindowlessControl9).GetNativeVideoSize(out arX, out arY, out arX2, out arY2);
if (hr >= 0 && arY > 0)
{
//DsError.ThrowExceptionForHR(hr);
//Trace.WriteLineIf(trace.TraceVerbose, string.Format("\tGetNativeVideoSize(width: {0}, height: {1}, arX {2}, arY: {3}", arX, arY, arX2, arY2));
if (arX2 > 0 && arY2 > 0)
{
arX = arX2;
arY = arY2;
}
currentVideoSourceSize.Width = arX;
currentVideoSourceSize.Height = arY;
Size windowSize = windowRect.Size;
double newAspectRation = aspectRatioFactor * (double)arX / (double)arY * (this.useVideo169Mode ? 3.0 / 4.0 : 1.0);
int height = windowSize.Height;
int width = (int)((double)height * newAspectRation);
if (videoZoomMode == VideoSizeMode.FromInside || videoZoomMode == VideoSizeMode.FromOutside)
{
if (videoZoomMode == VideoSizeMode.FromInside && width > windowSize.Width
|| videoZoomMode == VideoSizeMode.FromOutside && width < windowSize.Width)
{
width = windowSize.Width;
height = (int)((double)width / newAspectRation);
}
}
Size size = new Size((int)(zoom * width), (int)(zoom * height));
Point pos = new Point(
(int)(offset.X * (windowRect.Width * 3 - size.Width) - windowRect.Width),
(int)(offset.Y * (windowRect.Height * 3 - size.Height) - windowRect.Height));
//Point pos = new Point(
// (int)(offset.X * (windowRect.Width - size.Width)),
// (int)(offset.Y * (windowRect.Height - size.Height)));
currentVideoTargetRectangle = new Rectangle(pos, size);
}
}
if (useEVR)
{
//hr = evrVideoDisplayControl.SetVideoWindow(this.hostingControl.Handle);
MFVideoNormalizedRect pnrcSource = new MFVideoNormalizedRect(0.0f, 0.0f, 1.0f, 1.0f);
hr = this.evrVideoDisplayControl.SetVideoPosition(pnrcSource, (MediaFoundation.Misc.MFRect)currentVideoTargetRectangle);
this.hostingControl.ModifyBlackBands(GetBlackBands(), Settings.VideoBackgroundColor);
}
else
hr = (this.videoRenderer as IVMRWindowlessControl9).SetVideoPosition(null, DsRect.FromRectangle(currentVideoTargetRectangle));
//Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tPos {0:F2} {1:F2}, Zoom {2:F2}, ARF {4:F2}, AR {4:F2}"), offset.X, offset.Y, zoom, aspectRatioFactor, (float)videoTargetRect.Width / videoTargetRect.Height));
Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tvideoRenderer.SetVideoPosition({0})"), currentVideoTargetRectangle.ToString()));
}
}
示例9: ComputeCrop
private void ComputeCrop(Size videoSize)
{
Size mySize = ClientSize;
Debug.WriteLine("Video Sizes = " + videoSize.ToString() + ", " + mySize.ToString());
Debug.WriteLine("Crop = " + cropLeft.ToString() + ", " + cropTop.ToString()
+ ", " + cropRight.ToString() + ", " + cropBottom.ToString());
this.topBlocker.Visible = false;
this.bottomBlocker.Visible = false;
this.leftBlocker.Visible = false;
this.rightBlocker.Visible = false;
double myAspect = Convert.ToDouble(mySize.Width) / Convert.ToDouble(mySize.Height);
if ((this.cropTop == 0) && (this.cropBottom == 0) && (this.cropLeft == 0) && (this.cropRight == 0))
{
double vlcAspect = Convert.ToDouble(videoSize.Width) / Convert.ToDouble(videoSize.Height);
if (vlcAspect > myAspect)
{
// gray borders on the top and bottom
int perfectHeight = Convert.ToInt32(mySize.Width / vlcAspect);
this.innerVlc.Bounds = new Rectangle(new Point(0, (mySize.Height - perfectHeight) / 2),
new Size(mySize.Width, perfectHeight));
//Debug.WriteLine("vlcAspect > myAspect " + this.innerVlc.Bounds.ToString());
}
else
{
// gray borders on the left and right
int perfectWidth = Convert.ToInt32(mySize.Height * vlcAspect);
this.innerVlc.Bounds = new Rectangle(new Point((mySize.Width - perfectWidth) / 2, 0),
new Size(perfectWidth, mySize.Height));
//Debug.WriteLine("vlcAspect < myAspect " + this.innerVlc.Bounds.ToString());
}
}
else
{
double realVlcAspect = Convert.ToDouble(videoSize.Width - this.cropRight - this.cropLeft) /
Convert.ToDouble(videoSize.Height - this.cropTop - this.cropBottom);
if (realVlcAspect > myAspect)
{
// gray borders on the top and bottom, and possible blocking panels
// first, position and size the innerVlc as if there was no top or bottom cropping
int videoPixelWidth = videoSize.Width - this.cropRight - this.cropLeft;
double fakeVlcAspect = Convert.ToDouble(videoPixelWidth) / Convert.ToDouble(videoSize.Height);
int perfectHeight = Convert.ToInt32(mySize.Width / fakeVlcAspect);
Debug.WriteLine("perfectHeight = " + perfectHeight.ToString());
double scalingFactor = Convert.ToDouble(mySize.Width) / Convert.ToDouble(videoPixelWidth);
int innerVlcLeft = -Convert.ToInt32(Convert.ToDouble(this.cropLeft) * scalingFactor);
int innerVlcWidth = Convert.ToInt32(Convert.ToDouble(videoSize.Width) * scalingFactor);
int offTheTop = Convert.ToInt32(Convert.ToDouble(this.cropTop) * scalingFactor);
int offTheBottom = Convert.ToInt32(Convert.ToDouble(this.cropBottom) * scalingFactor);
int innerVlcTop = (mySize.Height - (perfectHeight - offTheTop - offTheBottom)) / 2;
innerVlcTop -= offTheTop;
this.innerVlc.Bounds = new Rectangle(new Point(innerVlcLeft, innerVlcTop),
new Size(innerVlcWidth, perfectHeight));
Debug.WriteLine("toowide innerVlc.Bounds = " + this.innerVlc.Bounds.ToString());
// then, add blocking panels if necessary for the top and bottom cropping
if (this.cropTop != 0)
{
if (offTheTop + innerVlcTop > 0)
{
this.topBlocker.Bounds = new Rectangle(
new Point(0, innerVlcTop),
new Size(mySize.Width, offTheTop));
this.topBlocker.Visible = true;
Debug.WriteLine("topBlocker.Bounds = " + this.topBlocker.Bounds.ToString());
}
}
if (this.cropBottom != 0)
{
if (innerVlcTop + perfectHeight - offTheBottom < mySize.Height)
{
this.bottomBlocker.Bounds = new Rectangle(
new Point(0, innerVlcTop + perfectHeight - offTheBottom),
new Size(mySize.Width, offTheBottom));
this.bottomBlocker.Visible = true;
Debug.WriteLine("bottomBlocker.Bounds = " + this.bottomBlocker.Bounds.ToString());
}
}
}
else
{
// gray borders on the left and right, and possible blocking panels
// first, position and size the innerVlc as if there was no left or right cropping
int videoPixelHeight = videoSize.Height - this.cropBottom - this.cropTop;
double fakeVlcAspect = Convert.ToDouble(videoSize.Width) / Convert.ToDouble(videoPixelHeight);
int perfectWidth = Convert.ToInt32(mySize.Height * fakeVlcAspect);
Debug.WriteLine("perfectWidth = " + perfectWidth.ToString());
double scalingFactor = Convert.ToDouble(mySize.Height) / Convert.ToDouble(videoPixelHeight);
int innerVlcTop = -Convert.ToInt32(Convert.ToDouble(this.cropTop) * scalingFactor);
int innerVlcHeight = Convert.ToInt32(Convert.ToDouble(videoSize.Height) * scalingFactor);
int offTheLeft = Convert.ToInt32(Convert.ToDouble(this.cropLeft) * scalingFactor);
int offTheRight = Convert.ToInt32(Convert.ToDouble(this.cropRight) * scalingFactor);
int innerVlcLeft = (mySize.Width - (perfectWidth - offTheLeft - offTheRight)) / 2;
innerVlcLeft -= offTheLeft;
//.........这里部分代码省略.........
示例10: SetWindowSize
public void SetWindowSize(Size size, ILogger log)
{
try
{
log?.INFO($"Resize window using size: {size.ToString()}");
_container.Value.Driver.Manage().Window.Size = size;
log?.INFO("Window resizing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during window resizing");
throw new CommandAbortException($"Error occurred during window resizing", ex);
}
}
示例11: GetFreeDimensionFromConstraint
static internal DataGridViewFreeDimension GetFreeDimensionFromConstraint(Size constraintSize)
{
if (constraintSize.Width < 0 || constraintSize.Height < 0)
{
throw new ArgumentException(SR.GetString(SR.InvalidArgument, "constraintSize", constraintSize.ToString()));
}
if (constraintSize.Width == 0)
{
if (constraintSize.Height == 0)
{
return DataGridViewFreeDimension.Both;
}
else
{
return DataGridViewFreeDimension.Width;
}
}
else
{
if (constraintSize.Height == 0)
{
return DataGridViewFreeDimension.Height;
}
else
{
throw new ArgumentException(SR.GetString(SR.InvalidArgument, "constraintSize", constraintSize.ToString()));
}
}
}
示例12: GetFreeDimensionFromConstraint
/// <summary>
/// Utility function that converts a constraintSize provided to GetPreferredSize into a
/// DataGridViewRadioButtonFreeDimension enum value.
/// </summary>
private static DataGridViewRadioButtonFreeDimension GetFreeDimensionFromConstraint(Size constraintSize)
{
if (constraintSize.Width < 0 || constraintSize.Height < 0)
{
throw new ArgumentException("InvalidArgument=Value of '" + constraintSize.ToString() + "' is not valid for 'constraintSize'.");
}
if (constraintSize.Width == 0)
{
if (constraintSize.Height == 0)
{
return DataGridViewRadioButtonFreeDimension.Both;
}
else
{
return DataGridViewRadioButtonFreeDimension.Width;
}
}
else
{
if (constraintSize.Height == 0)
{
return DataGridViewRadioButtonFreeDimension.Height;
}
else
{
throw new ArgumentException("InvalidArgument=Value of '" + constraintSize.ToString() + "' is not valid for 'constraintSize'.");
}
}
}
示例13: bug_82358
public void bug_82358 ()
{
//Console.WriteLine ("Starting bug_82358");
int sizeable_factor;
int title_bar;
int tool_bar;
int tool_border;
int d3;
int d2;
// WinXP, default theme
sizeable_factor = 2;
title_bar = 26;
tool_bar = 18;
tool_border = 6;
d3 = 10;
d2 = 6;
// WinXP, Win32 theme:
sizeable_factor = 2;
title_bar = 19;
tool_bar = 16;
tool_border = 6;
d3 = 10;
d2 = 6;
Size size = new Size (200, 200);
// Universal theme??
using (Form f = new Form ()) {
f.FormBorderStyle = FormBorderStyle.FixedSingle;
f.Visible = true;
d2 = f.Size.Width - f.ClientSize.Width;
title_bar = f.Size.Height - f.ClientSize.Height - d2;
}
using (Form f = new Form ()) {
f.FormBorderStyle = FormBorderStyle.Sizable;
f.Visible = true;
sizeable_factor = f.Size.Width - f.ClientSize.Width - d2;
}
using (Form f = new Form ()) {
f.ClientSize = size;
f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
//f.Visible = true;
tool_border = f.Size.Width - f.ClientSize.Width;
tool_bar = f.Size.Height - f.ClientSize.Height - tool_border;
}
using (Form f = new Form ()) {
f.FormBorderStyle = FormBorderStyle.Fixed3D;
f.Visible = true;
d3 = f.Size.Width - f.ClientSize.Width;
}
FormBorderStyle style;
//Console.WriteLine ("Universal theme says: d2={0}, d3={1}, title_bar={2}, sizeable_factor={3}, tool_border={4}, tool_bar={5}", d2, d3, title_bar, sizeable_factor, tool_border, tool_bar);
// Changing client size, then FormBorderStyle.
using (Form f = new Form ()) {
style = FormBorderStyle.FixedToolWindow;
//Console.WriteLine ("Created form, size: {0}, clientsize: {1}", f.Size, f.ClientSize);
f.ClientSize = size;
//Console.WriteLine ("Changed ClientSize, size: {0}, clientsize: {1}", f.Size, f.ClientSize);
f.FormBorderStyle = style;
//Console.WriteLine ("Changed FormBorderStyle, size: {0}, clientsize: {1}", f.Size, f.ClientSize);
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1");
Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-A2");
f.Visible = true;
//Console.WriteLine ("Made visible, size: {0}, clientsize: {1}", f.Size, f.ClientSize);
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3");
Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-A4");
}
using (Form f = new Form ()) {
style = FormBorderStyle.SizableToolWindow;
f.ClientSize = size;
f.FormBorderStyle = style;
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1");
Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A2");
f.Visible = true;
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3");
Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A4");
}
using (Form f = new Form ()) {
style = FormBorderStyle.Fixed3D;
f.ClientSize = size;
f.FormBorderStyle = style;
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1");
Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString () , f.Size.ToString (), style.ToString () + "-A2");
f.Visible = true;
Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3");
Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-A4");
}
using (Form f = new Form ()) {
style = FormBorderStyle.FixedDialog;
f.ClientSize = size;
//.........这里部分代码省略.........
示例14: StoreSize
//Size
/// <summary>
/// Stores the specified Size Objectas a setting in the current SettingsKey.
/// </summary>
///
/// <param name="settingName">
/// The name of the setting to store.
/// </param>
///
/// <param name="settingValue">
/// The Size to store for this setting.
/// </param>
///
/// <exception cref="UnauthorizedAccessException">
/// This current SettingsKey is the root SettingsKey or is read-only.
/// </exception>
///
/// <exception cref="ArgumentNullException">
/// The specified 'settingName'
/// is a null reference or an empty string or the specified
/// 'settingValue' is null.
/// </exception>
///
/// <remarks>
/// To retrieve a stored Size from the settings file use the <see cref="GetSize"/> method.
/// <para>
/// Since many settings can be stored in each SettingsKey,
/// the 'settingName' parameter specifies the particular setting you wish to manipulate.
/// </para>
///
/// <para>
/// The key that is opened with the setting being set must have been
/// opened with write access, and not be a read-only key.
/// Once you have been granted write-access to a key, you can change
/// the data associated with any of the settings in that key.
/// </para>
///
/// <para>
/// The parameter 'settingName' is case-sensitive.
/// </para>
///
/// <para>
/// If the specified setting name does not exist in the key,
/// it will be created, and the sepecified settingValue is stored.
/// </para>
/// </remarks>
public void StoreSize(string settingName, Size settingValue)
{
#region conditions
//Removed because a size of 0,0 should be valid.
// // is the settingValue parameter null
// if (settingValue == Size.Empty)
// {
// this.throwParameterNullException("setting");
// }
#endregion
StoreSetting(settingName,settingValue.ToString());
}
示例15: TaskMain
public static void TaskMain(string[] args)
{
if (args == null || args.Length != 4)
{
throw new Exception("Usage: ImageBlur.exe --Task <blobpath> <storageAccountName> <storageAccountKey>");
}
string blobName = args[1];
string storageAccountName = args[2];
string storageAccountKey = args[3];
string workingDirectory = Environment.GetEnvironmentVariable("AZ_BATCH_TASK_WORKING_DIR");
int numberToBlur = 3;
Console.WriteLine();
Console.WriteLine(" blobName: <{0}>", blobName);
Console.WriteLine(" storageAccountName: <{0}>", storageAccountName);
Console.WriteLine(" number to blur: <{0}>", numberToBlur);
Console.WriteLine();
// get source image from cloud blob
var storageCred = new StorageCredentials(storageAccountName, storageAccountKey);
CloudBlockBlob blob = new CloudBlockBlob(new Uri(blobName), storageCred);
using (MemoryStream inStream = new MemoryStream())
{
blob.DownloadToStream(inStream);
Image img = Image.FromStream(inStream);
int imgWidth = img.Width;
int imgHeight = img.Height;
Size size = new Size(imgWidth, imgHeight);
ISupportedImageFormat format = new JpegFormat { Quality = 70 };
// Print image properties to stdout
Console.WriteLine(" Image Properties:");
Console.WriteLine(" Format: {0}", FormatUtilities.GetFormat(inStream));
Console.WriteLine(" Size: {0}", size.ToString());
Console.WriteLine();
for (var i = 0; i < numberToBlur; i++)
{
using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
{
int blurIndex = (i * 5) + 10;
imageFactory.Load(inStream);
imageFactory.Resize(size)
.Format(format)
.GaussianBlur(blurIndex)
.Save(workingDirectory + "/resultimage" + i + ".Jpeg");
//.Save(@"C:/Users/jiata/Desktop/imageblur/results/resultimage" + i + ".Jpeg");
}
}
}
// TODO - not working
for (var i = 0; i < numberToBlur; i++)
{
blob.UploadFromFile(workingDirectory + "/resultimage" + i + ".Jpeg", FileMode.Open);
}
Environment.Exit(1);
}