本文整理汇总了C#中ContentAlignment类的典型用法代码示例。如果您正苦于以下问题:C# ContentAlignment类的具体用法?C# ContentAlignment怎么用?C# ContentAlignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentAlignment类属于命名空间,在下文中一共展示了ContentAlignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseTextItem
public BaseTextItem():base() {
this.dataType = "System.String";
this.stringFormat = StringFormat.GenericTypographic;
this.contentAlignment = ContentAlignment.TopLeft;
this.stringTrimming = StringTrimming.None;
VisibleInReport = true;
}
示例2: Resize
public static void Resize(this Image source, String newFilename, Size newSize, long quality, ContentAlignment contentAlignment, ThumbMode mode)
{
Image image = source.Resize(newSize, quality, contentAlignment, mode);
using (EncoderParameters encoderParams = new EncoderParameters(1))
{
using (EncoderParameter parameter = (encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality)))
{
ImageCodecInfo encoder = null;
//取得擴展名
string ext = Path.GetExtension(newFilename);
if (string.IsNullOrEmpty(ext))
ext = ".jpg";
//根據擴展名得到解碼、編碼器
foreach (ImageCodecInfo codecInfo in ImageCodecInfo.GetImageEncoders())
{
if (Regex.IsMatch(codecInfo.FilenameExtension, string.Format(@"(;|^)\*\{0}(;|$)", ext), RegexOptions.IgnoreCase))
{
encoder = codecInfo;
break;
}
}
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(newFilename));
if(dir.Exists == false) dir.Create();
image.Save(newFilename, encoder, encoderParams);
}
}
}
示例3: BaseTextItem
public BaseTextItem(){
DefaultSize = GlobalValues.PreferedSize;
Size = GlobalValues.PreferedSize;
BackColor = Color.White;
contentAlignment = ContentAlignment.TopLeft;
TypeDescriptor.AddProvider(new TextItemTypeProvider(), typeof(BaseTextItem));
}
示例4: ImageWatermark
/// <summary>
/// 图片水印处理方法
/// </summary>
/// <param name="path">需要加载水印的图片路径(绝对路径)</param>
/// <param name="waterpath">水印图片(绝对路径)</param>
/// <param name="align">水印位置(传送正确的代码)</param>
public static string ImageWatermark(string path, string waterpath, ContentAlignment align)
{
string kz_name = Path.GetExtension(path);
if (kz_name == ".jpg" || kz_name == ".bmp" || kz_name == ".jpeg")
{
DateTime time = DateTime.Now;
string filename = "" + time.Year.ToString() + time.Month.ToString() + time.Day.ToString() + time.Hour.ToString() + time.Minute.ToString() + time.Second.ToString() + time.Millisecond.ToString();
Image img = Bitmap.FromFile(path);
Image waterimg = Image.FromFile(waterpath);
Graphics g = Graphics.FromImage(img);
ArrayList loca = GetLocation(align, img, waterimg);
g.DrawImage(waterimg, new Rectangle(int.Parse(loca[0].ToString()), int.Parse(loca[1].ToString()), waterimg.Width, waterimg.Height));
waterimg.Dispose();
g.Dispose();
string newpath = Path.GetDirectoryName(path) + filename + kz_name;
img.Save(newpath);
img.Dispose();
File.Copy(newpath, path, true);
if (File.Exists(newpath))
{
File.Delete(newpath);
}
}
return path;
}
示例5: Switcher
/// <summary>
/// Initializes a new instance of the <see cref="Switcher"/> class.
/// </summary>
/// <param name="serviceProvider"><para>Requires:</para>
/// <para><see cref="INuGenRadioButtonRenderer"/></para>
/// <para><see cref="INuGenRadioButtonLayoutManager"/></para>
/// <para><see cref="INuGenButtonStateService"/></para>
/// <para><see cref="INuGenControlStateService"/></para>
/// </param>
/// <param name="associatedAlignment"></param>
/// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception>
public Switcher(INuGenServiceProvider serviceProvider, ContentAlignment associatedAlignment)
: base(serviceProvider)
{
_assoicatedAlignment = associatedAlignment;
this.CheckAlign = ContentAlignment.MiddleCenter;
this.Dock = DockStyle.Fill;
}
示例6: CommonLayout
internal static LayoutOptions CommonLayout(Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
{
return new LayoutOptions {
client = LayoutUtils.DeflateRect(clientRectangle, padding), padding = padding, growBorderBy1PxWhenDefault = true, isDefault = isDefault, borderSize = 2, paddingSize = 0, maxFocus = true, focusOddEvenFixup = false, font = font, text = text, imageSize = Size.Empty, checkSize = 0, checkPaddingSize = 0, checkAlign = ContentAlignment.TopLeft, imageAlign = ContentAlignment.MiddleCenter, textAlign = textAlign,
hintTextUp = false, shadowedText = !enabled, layoutRTL = RightToLeft.Yes == rtl, textImageRelation = TextImageRelation.Overlay, useCompatibleTextRendering = false
};
}
示例7: GetSubImageBuffer
private byte[] GetSubImageBuffer(RunLengthTwoParts twoPartBuffer, NikseBitmap nbmp, Paragraph p, ContentAlignment alignment)
{
var ms = new MemoryStream();
// sup picture datasize
WriteEndianWord(twoPartBuffer.Length + 34, ms);
// first display control sequence table address
int startDisplayControlSequenceTableAddress = twoPartBuffer.Length + 4;
WriteEndianWord(startDisplayControlSequenceTableAddress, ms);
// Write image
const int imageTopFieldDataAddress = 4;
ms.Write(twoPartBuffer.Buffer1, 0, twoPartBuffer.Buffer1.Length);
int imageBottomFieldDataAddress = 4 + twoPartBuffer.Buffer1.Length;
ms.Write(twoPartBuffer.Buffer2, 0, twoPartBuffer.Buffer2.Length);
// Write zero delay
ms.WriteByte(0);
ms.WriteByte(0);
// next display control sequence table address (use current is last)
WriteEndianWord(startDisplayControlSequenceTableAddress + 24, ms); // start of display control sequence table address
// Control command start
if (p.Forced)
ms.WriteByte(0); // ForcedStartDisplay==0
else
ms.WriteByte(1); // StartDisplay==1
// Control command 3 = SetColor
WriteColors(ms); // 3 bytes
// Control command 4 = SetContrast
WriteContrast(ms); // 3 bytes
// Control command 5 = SetDisplayArea
WriteDisplayArea(ms, nbmp, alignment); // 7 bytes
// Control command 6 = SetPixelDataAddress
WritePixelDataAddress(ms, imageTopFieldDataAddress, imageBottomFieldDataAddress); // 5 bytes
// Control command exit
ms.WriteByte(255); // 1 byte
// Control Sequence Table
// Write delay - subtitle duration
WriteEndianWord(Convert.ToInt32(p.Duration.TotalMilliseconds * 90.0 - 1023) >> 10, ms);
// next display control sequence table address (use current is last)
WriteEndianWord(startDisplayControlSequenceTableAddress + 24, ms); // start of display control sequence table address
// Control command 2 = StopDisplay
ms.WriteByte(2);
// extra byte - for compatability with gpac/MP4BOX
ms.WriteByte(255); // 1 byte
return ms.ToArray();
}
示例8: ApplyWatermark
/// <summary>
/// Creates an instance of Watermarker class.
/// </summary>
public ApplyWatermark ()
{
Color = Color.Aquamarine;
Font = new Font(FontFamily.GenericSansSerif, 16);
WatermarkText = "(c) ESRI Inc.";
TextAlignment = ContentAlignment.BottomLeft;
}
示例9: NotificationForm
public NotificationForm(int duration, ContentAlignment placement, Size size, NotificationFormConfig config)
{
InitializeComponent();
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
ToastConfig = config;
textFont = new Font("Arial", 10);
if (config.Image != null)
{
config.Image = ImageHelpers.ResizeImageLimit(config.Image, size);
config.Image = ImageHelpers.DrawCheckers(config.Image);
size = new Size(config.Image.Width + 2, config.Image.Height + 2);
}
else if (!string.IsNullOrEmpty(config.Text))
{
textRenderSize = Helpers.MeasureText(config.Text, textFont, size.Width - textPadding * 2);
size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2);
}
Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, size);
NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, position.X + Screen.PrimaryScreen.WorkingArea.X,
position.Y + Screen.PrimaryScreen.WorkingArea.Y, size.Width, size.Height, SetWindowPosFlags.SWP_NOACTIVATE);
if (duration <= 0)
{
DurationEnd();
}
else
{
tDuration.Interval = duration;
tDuration.Start();
}
}
示例10: GetAlignedRectangle
/// <summary>
/// calculates the position of an element depending on the desired alignment within a RectangleF
/// </summary>
/// <param name="currentRect">the bounds of the element to be aligned</param>
/// <param name="targetRect">the rectangle reference for aligment of the element</param>
/// <param name="alignment">the System.Drawing.ContentAlignment value indicating how the element is to be aligned should the width or height differ from targetSize</param>
/// <returns>a new RectangleF object with Location aligned aligned to targetRect</returns>
public static RectangleF GetAlignedRectangle(RectangleF currentRect, RectangleF targetRect, ContentAlignment alignment)
{
RectangleF newRect = new RectangleF(targetRect.Location, currentRect.Size);
switch(alignment) {
case ContentAlignment.TopCenter:
newRect.X = (targetRect.Width - currentRect.Width) / 2;
break;
case ContentAlignment.TopRight:
newRect.X = (targetRect.Width - currentRect.Width);
break;
case ContentAlignment.MiddleLeft:
newRect.Y = (targetRect.Height - currentRect.Height) / 2;
break;
case ContentAlignment.MiddleCenter:
newRect.Y = (targetRect.Height - currentRect.Height) / 2;
newRect.X = (targetRect.Width - currentRect.Width) / 2;
break;
case ContentAlignment.MiddleRight:
newRect.Y = (targetRect.Height - currentRect.Height) / 2;
newRect.X = (targetRect.Width - currentRect.Width);
break;
case ContentAlignment.BottomLeft:
newRect.Y = (targetRect.Height - currentRect.Height);
break;
case ContentAlignment.BottomCenter:
newRect.Y = (targetRect.Height - currentRect.Height);
newRect.X = (targetRect.Width - currentRect.Width) / 2;
break;
case ContentAlignment.BottomRight:
newRect.Y = (targetRect.Height - currentRect.Height);
newRect.X = (targetRect.Width - currentRect.Width);
break;
}
return newRect;
}
示例11: Separator
public Separator()
{
SetStyle(ControlStyles.ResizeRedraw, true);
m_orientation = Orientation.Horizontal;
m_alignment = ContentAlignment.MiddleCenter;
OnResize(EventArgs.Empty);
}
示例12: GetContentPosition
public static PointF GetContentPosition(ContentAlignment alignment, SizeF size, SizeF containerSize)
{
return new PointF(
GetContentPositionX(alignment, size, containerSize),
GetContentPositionY(alignment, size, containerSize)
);
}
示例13: ButtonBase
protected ButtonBase() : base()
{
flat_style = FlatStyle.Standard;
flat_button_appearance = new FlatButtonAppearance (this);
this.image_key = string.Empty;
this.text_image_relation = TextImageRelation.Overlay;
this.use_mnemonic = true;
use_visual_style_back_color = true;
image_index = -1;
image = null;
image_list = null;
image_alignment = ContentAlignment.MiddleCenter;
ImeMode = ImeMode.Disable;
text_alignment = ContentAlignment.MiddleCenter;
is_default = false;
is_pressed = false;
text_format = new StringFormat();
text_format.Alignment = StringAlignment.Center;
text_format.LineAlignment = StringAlignment.Center;
text_format.HotkeyPrefix = HotkeyPrefix.Show;
text_format.FormatFlags |= StringFormatFlags.LineLimit;
text_format_flags = TextFormatFlags.HorizontalCenter;
text_format_flags |= TextFormatFlags.VerticalCenter;
text_format_flags |= TextFormatFlags.TextBoxControl;
SetStyle (ControlStyles.ResizeRedraw |
ControlStyles.Opaque |
ControlStyles.UserMouse |
ControlStyles.SupportsTransparentBackColor |
ControlStyles.CacheText |
ControlStyles.OptimizedDoubleBuffer, true);
SetStyle (ControlStyles.StandardClick, false);
}
示例14: reset
protected void reset()
{
_alignment = ContentAlignment.MiddleLeft;
setColor(SystemColors.WindowText);
setBackground(SystemColors.Window);
setFont(SystemFonts.DefaultFont);
}
示例15: CombineImage
/// <summary>
/// 合并图像
/// </summary>
/// <param name="imageBackground"></param>
/// <param name="imageForeground"></param>
/// <param name="alignment"></param>
/// <returns></returns>
public static Image CombineImage(Image imageBackground, Image imageForeground, ContentAlignment alignment)
{
Image imageBk = imageBackground.Clone() as Image;
Graphics g = Graphics.FromImage(imageBk);
Point point;
switch (alignment)
{
case ContentAlignment.TopLeft:
point = new Point(0, 0);
break;
case ContentAlignment.TopRight:
point = new Point(imageBackground.Width - imageForeground.Width, 0);
break;
case ContentAlignment.BottomLeft:
point = new Point(0, imageBackground.Height - imageForeground.Height);
break;
case ContentAlignment.BottomRight:
point = new Point(imageBackground.Width - imageForeground.Width, imageBackground.Height - imageForeground.Height);
break;
case ContentAlignment.TopCenter:
point = new Point(imageBackground.Width / 2 - imageForeground.Width / 2, 0);
break;
case ContentAlignment.BottomCenter:
point = new Point(imageBackground.Width / 2 - imageForeground.Width / 2, imageBackground.Height - imageForeground.Height);
break;
default:
throw new NotSupportedException("Not supported alignment");
}
g.DrawImage(imageForeground, point);
return imageBk;
}