本文整理汇总了C#中System.Drawing.Size.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Size.Equals方法的具体用法?C# Size.Equals怎么用?C# Size.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Size
的用法示例。
在下文中一共展示了Size.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitControls
private void InitControls()
{
using(new LayoutSuspender(this))
{
var tablePanel = new TableLayoutPanel
{
AutoSizeMode = AutoSizeMode.GrowAndShrink,
Margin = Padding.Empty,
Padding = Padding.Empty,
Size = ClientSize
};
tablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f));
tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
tablePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50f));
Controls.Add(tablePanel);
GroupingEvent sizeEvent = Environment.Threading.GroupingEvents[Rgc.Invariant].CreateEvent(
_lifetime,
Pid + ".SizeChanged",
TimeSpan.FromMilliseconds(300.0), () =>
{
var clientSize = new Size(ClientSize.Width - _margin, ClientSize.Height - _margin);
if(!clientSize.Equals(tablePanel.Size))
{
using(new LayoutSuspender(this))
{
tablePanel.Size = clientSize;
}
}
});
EventHandler handler = (sender, args) => sizeEvent.FireIncoming();
_lifetime.AddBracket(() => SizeChanged += handler, () => SizeChanged -= handler);
string titleCaption = "Specify external file and directory paths to include in the code inspection. " +
"Relative paths are relative to the directory containing the project. " +
"Exclusions specified in the Generated Code settings apply." +
System.Environment.NewLine +
"NOTE: Changes do not take affect until project is loaded." +
System.Environment.NewLine;
var titleLabel = new Controls.Label(titleCaption) {AutoSize = true, Dock = DockStyle.Top};
tablePanel.Controls.Add(titleLabel);
string[] externalCodePaths = _settings.EnumIndexedValues(ExternalCodeSettingsAccessor.Paths).ToArray();
_externalCodePathsCollectionEdit = new StringCollectionEdit(Environment, "External files and directories:", null, _mainWindow, _windowsHookManager, _formValidators)
{
Dock = DockStyle.Fill
};
_externalCodePathsCollectionEdit.Items.Value = externalCodePaths;
tablePanel.Controls.Add(_externalCodePathsCollectionEdit, 0, 1);
}
}
示例2: AddMarker
/// <summary>
/// Adds a marker with its configurations and image to layout manager.
/// </summary>
/// <param name="markerID">The ID of the marker (specified by the ARTag)</param>
/// <param name="upperLeftCorner">The upper left corner (in pixels) of this marker in the entire
/// marker array.</param>
/// <param name="size">The size of this marker to be printed on the marker array. If different
/// from the original image size, the marker image will be resized to fit this size.</param>
/// <param name="cropArea">The area to be retained after cropping other parts outside of
/// this area</param>
/// <param name="imagefile">The file name of the marker image (must have an extension that
/// indicates the image format)</param>
/// <param name="additionalInfos">Additional information that should be added to the config file</param>
/// <exception cref="ArgumentException">If the given marker ID is already added</exception>
/// <exception cref="InvalidOperationException"></exception>
public void AddMarker(int markerID, Point upperLeftCorner, Size size, Rectangle cropArea, String imagefile,
List<KeyValuePair<string, string>> additionalInfos)
{
if (configs.ContainsKey(markerID))
throw new ArgumentException("You can't add same marker ID in one config file");
MarkerConfig config = new MarkerConfig();
config.ID = markerID;
config.Position = upperLeftCorner;
int width = 0, height = 0;
config.Image = ImageReader.Load(imagefile, ref width, ref height);
config.ImageWidth = width;
config.ImageHeight = height;
config.CropArea = cropArea;
config.AdditionalInfo = additionalInfos;
config.ImageFilename = imagefile;
if (size.Equals(Size.Empty))
{
if (!cropArea.Equals(Rectangle.Empty))
config.Size = cropArea.Size;
else
config.Size = new Size(width, height);
}
else
config.Size = size;
// if crop area is not empty, then make sure that the crop area is within the marker size
if (!cropArea.Equals(Rectangle.Empty))
{
if (cropArea.X < 0 || cropArea.X > width)
throw new ArgumentException("Your crop area's X position is outside of the marker size");
if (cropArea.Y < 0 || cropArea.Y > height)
throw new ArgumentException("Your crop area's Y position is outside of the marker size");
if ((cropArea.X + cropArea.Width) > width)
throw new ArgumentException("Your crop area's X dimension exceeds the marker width");
if ((cropArea.Y + cropArea.Height) > height)
throw new ArgumentException("Your crop area's Y dimension exceeds the marker height");
}
configs.Add(markerID, config);
markerIDs.Add(markerID);
}
示例3: AdjustImageSizeForNewBaseSize
internal static Size AdjustImageSizeForNewBaseSize(bool allowEnlargement, IResizeDecoratorSettings s, Size newBaseSize, RotateFlipType rotation, ImageDecoratorContext context)
{
Size rotatedBaseSize = ImageUtils.IsRotated90(rotation)
? new Size(newBaseSize.Height, newBaseSize.Width)
: newBaseSize;
if (s.ImageSizeName != ImageSizeName.Custom)
{
// If a standard image size is being used, fit to that
Size sizeBounds = ImageSizeHelper.GetSizeConstraints(s.ImageSizeName);
if (!allowEnlargement)
{
sizeBounds.Width = Math.Min(rotatedBaseSize.Width, sizeBounds.Width);
sizeBounds.Height = Math.Min(rotatedBaseSize.Height, sizeBounds.Height);
}
return ImageUtils.GetScaledImageSize(sizeBounds.Width, sizeBounds.Height, rotatedBaseSize);
}
else
{
// If custom size, but we know the base size, preserve
// the aspect ratio "skew" (difference in x and y DPI)
// and pixel area
Size imageSize = s.ImageSize;
// Need to get the image size to the non-rotated angle,
// because s.BaseSize dimensions are always pre-rotation.
// Although ImageSize has not been fully updated for this
// decorator yet (that's what we're trying to do here),
// the width/height gets flipped immediately when a
// rotation is applied, so rotation is already taken
// into account.
if (ImageUtils.IsRotated90(rotation))
imageSize = new Size(imageSize.Height, imageSize.Width);
// If the base size has not been set yet, we have to guess.
// This basically means the image was inserted using an older
// build of Writer that did not have the crop feature. Ideally
// we would use the original image size, but this is expensive
// to get from here. It just so happens that newBaseSize works
// for now because the crop dialog defaults to the same aspect
// ratio as the original image, but if that ever changes this
// will break.
#if DEBUG
if (s.BaseSize == null)
{
using (Bitmap bitmap = (Bitmap)Bitmap.FromFile(context.SourceImageUri.LocalPath))
{
Size size = new Size(Math.Max(1, bitmap.Width / 2),
Math.Max(1, bitmap.Height / 2));
Debug.Assert(size.Equals(newBaseSize) || bitmap.Size.Equals(newBaseSize), "Check base size assumptions. Can't use 's.BaseSize ?? newBaseSize', instead must calculate original image size (context.SourceImageUri.LocalPath).");
}
}
#endif
Size baseSize = s.BaseSize ?? newBaseSize;
double xFactor = imageSize.Width / (double)baseSize.Width;
double yFactor = imageSize.Height / (double)baseSize.Height;
newBaseSize = new Size(
(int)Math.Round(xFactor * newBaseSize.Width),
(int)Math.Round(yFactor * newBaseSize.Height)
);
// Need to re-apply the rotation if necessary.
if (ImageUtils.IsRotated90(rotation))
newBaseSize = new Size(newBaseSize.Height, newBaseSize.Width);
// At this point, newBaseSize has the right aspect ratio; we now
// need to scale it so it uses about the same number of pixels
// as it did before.
double factor = (imageSize.Width * imageSize.Height) / (double)(newBaseSize.Width * newBaseSize.Height);
factor = Math.Sqrt(factor);
newBaseSize.Width = (int)Math.Round(newBaseSize.Width * factor);
newBaseSize.Height = (int)Math.Round(newBaseSize.Height * factor);
if (!allowEnlargement)
{
if (newBaseSize.Width > rotatedBaseSize.Width || newBaseSize.Height > rotatedBaseSize.Height)
newBaseSize = ImageUtils.GetScaledImageSize(rotatedBaseSize.Width, rotatedBaseSize.Height, newBaseSize);
}
return newBaseSize;
}
}
示例4: setText
public void setText(string text, int tooltipID, int data, Form parent, bool force)
{
if ((tooltipID == 0x2710) || (tooltipID == 0x2775))
{
this.createCardTooltip(tooltipID, data, parent, force);
}
else if (tooltipID == 0x8d)
{
this.createVillagePeasant(tooltipID, data, parent, force);
}
else if ((this.lastText != text) || force)
{
this.lastText = text;
this.lastTooltip = tooltipID;
base.clearControls();
this.tooltipLabel.Text = text;
this.tooltipLabel.Color = ARGBColors.Black;
this.tooltipLabel.Position = new Point(2, 2);
this.tooltipLabel.Font = FontManager.GetFont("Arial", 10f, FontStyle.Regular);
Graphics graphics = base.CreateGraphics();
Size size = graphics.MeasureString(text, this.tooltipLabel.Font, 350).ToSize();
graphics.Dispose();
this.tooltipLabel.Size = new Size(size.Width + 1, size.Height + 1);
Size size2 = new Size((size.Width + 4) + 1, (size.Height + 4) + 1);
if (!size2.Equals(parent.Size))
{
parent.Size = size2;
}
this.tooltipLabel.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_LEFT;
this.background.Size = size2;
this.background.Position = new Point(0, 0);
base.addControl(this.background);
this.background.Create((Image) GFXLibrary.cardpanel_grey_9slice_left_top, (Image) GFXLibrary.cardpanel_grey_9slice_middle_top, (Image) GFXLibrary.cardpanel_grey_9slice_right_top, (Image) GFXLibrary.cardpanel_grey_9slice_left_middle, (Image) GFXLibrary.cardpanel_grey_9slice_middle_middle, (Image) GFXLibrary.cardpanel_grey_9slice_right_middle, (Image) GFXLibrary.cardpanel_grey_9slice_left_bottom, (Image) GFXLibrary.cardpanel_grey_9slice_middle_bottom, (Image) GFXLibrary.cardpanel_grey_9slice_right_bottom);
this.background.addControl(this.tooltipLabel);
base.Invalidate();
parent.Invalidate();
}
}
示例5: PixelsFromSize
public int PixelsFromSize( Size size )
{
foreach ( var item in Sizes.Keys ) {
var itemSize = Sizes[item];
if ( size.Equals ( itemSize ) ) {
Console.WriteLine ( "Size: {0}", itemSize.ToString ( ) );
return item;
}
}
throw new IndexOutOfRangeException ( );
}
示例6: ComputeForDesiredMapSize
private void ComputeForDesiredMapSize(Size desiredMapSize)
{
Bitmap mapImage = new Bitmap(mapLocation);
if (!desiredMapSize.Equals(Size.Empty))
{
Bitmap oldMapImage = mapImage;
mapImage = ResizeMap(oldMapImage, desiredMapSize);
oldMapImage.Dispose();
}
AnaliseMap(mapImage);
SameSizeCheck(colorMap.GetSameSizeActions(), 1);
mapImage.Dispose();
}
示例7: Test
public static bool Test()
{
bool ok = true;
string s = string.Empty;
// DecodePoint
Point p1 = new Point(5, 104);
s = DecodePointInverse(p1);
Point p2 = DecodePoint(s);
if (!p1.Equals(p2))
ok = false;
// DecodeSize
Size s1 = new Size(1254, 67);
s = DecodeSizeInverse(s1);
Size s2 = DecodeSize(s);
if (!s1.Equals(s2))
ok = false;
// DecodeFont
Font f1 = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
s = DecodeFontInverse(f1);
Font f2 = DecodeFont(s);
if (!f1.Equals(f2))
ok = false;
// DecodeDateTime
DateTime t1 = DateTime.Today;
s = DecodeDateTimeInverse(t1);
DateTime t2 = DecodeDateTime(s);
if (!t1.Equals(t2))
ok = false;
// DecodeAppearance
Appearance a1 = Appearance.Button;
s = DecodeAppearanceInverse(a1);
Appearance a2 = DecodeAppearance(s);
if (!t1.Equals(t2))
ok = false;
// DecodeScrollBars
ScrollBars sb1 = ScrollBars.Both;
s = DecodeScrollBarsInverse(sb1);
ScrollBars sb2 = DecodeScrollBars(s);
if (!sb1.Equals(sb2))
ok = false;
// DecodeSelectionMode
SelectionMode sm1 = SelectionMode.MultiSimple;
s = DecodeSelectionModeInverse(sm1);
SelectionMode sm2 = DecodeSelectionMode(s);
if (!sm1.Equals(sm2))
ok = false;
// DecodeView
View v1 = View.LargeIcon;
s = DecodeViewInverse(v1);
View v2 = DecodeView(s);
if (!v1.Equals(v2))
ok = false;
// DecodeOrientation
Orientation o1 = Orientation.Vertical;
s = DecodeOrientationInverse(o1);
Orientation o2 = DecodeOrientation(s);
if (!o1.Equals(o2))
ok = false;
// DecodeTickStyle
TickStyle ts1 = TickStyle.BottomRight;
s = DecodeTickStyleInverse(ts1);
TickStyle ts2 = DecodeTickStyle(s);
if (!ts1.Equals(ts2))
ok = false;
// DecodeTabAlignment
TabAlignment ta1 = TabAlignment.Right;
s = DecodeTabAlignmentInverse(ta1);
TabAlignment ta2 = DecodeTabAlignment(s);
if (!ta1.Equals(ta2))
ok = false;
// DecodeListViewItem (single)
ListViewItem lv1 = new ListViewItem("John Doe");
s = DecodeListViewItemInverse(lv1);
ListViewItem lv2 = DecodeListViewItem(s);
/* not comparable (only by reference)
if (!lv1.Equals(lv2))
//.........这里部分代码省略.........
示例8: GetImg
public static Bitmap GetImg(bool[,] cells)
{
int w = cells.GetLength(0);
int h = cells.GetLength(1);
Size s = new Size(w,h);
if (!s.Equals(Config.Conf.worldSize))
throw new ArgumentException("Размеры массива несоответствуют размерам в файле конфигурации");
Bitmap img = new Bitmap(w*PixToCell, h*PixToCell);
using (Graphics g = Graphics.FromImage(img))
{
for (int i = 0; i < w; i++)
{
for (int j = 0; j < h; j++)
{
if (cells[i, j])
{
g.FillRectangle(new SolidBrush(Config.Conf.AliveColor), i * PixToCell, j * PixToCell, PixToCell, PixToCell);
}
else
{
g.FillRectangle(new SolidBrush(Config.Conf.DeadColor), i * PixToCell, j * PixToCell, PixToCell, PixToCell);
}
}
}
}
return img;
}