当前位置: 首页>>代码示例>>C#>>正文


C# ContentAlignment类代码示例

本文整理汇总了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;
		}
开发者ID:OmerRaviv,项目名称:SharpDevelop,代码行数:7,代码来源:BaseTextItem.cs

示例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);
                }
            }
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:29,代码来源:DrawingExtension.cs

示例3: BaseTextItem

		public BaseTextItem(){
			DefaultSize = GlobalValues.PreferedSize;
			Size = GlobalValues.PreferedSize;
			BackColor = Color.White;
			contentAlignment = ContentAlignment.TopLeft;
			TypeDescriptor.AddProvider(new TextItemTypeProvider(), typeof(BaseTextItem));
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:7,代码来源:BaseTextItem.cs

示例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;
 }
开发者ID:liujunhua,项目名称:Smart,代码行数:31,代码来源:ImageUtility.cs

示例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;
			}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:18,代码来源:NuGenAlignSelector.Switcher.cs

示例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
      };
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ButtonBaseAdapter.cs

示例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();
        }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:60,代码来源:VobSubWriter.cs

示例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;
 }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:10,代码来源:ApplyWatermark.cs

示例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();
            }
        }
开发者ID:noscripter,项目名称:ShareX,代码行数:35,代码来源:NotificationForm.cs

示例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;
 }
开发者ID:eservicepartner,项目名称:espUrl,代码行数:42,代码来源:ScaleHelper.cs

示例11: Separator

 public Separator()
 {
     SetStyle(ControlStyles.ResizeRedraw, true);
     m_orientation = Orientation.Horizontal;
     m_alignment = ContentAlignment.MiddleCenter;
     OnResize(EventArgs.Empty);
 }
开发者ID:bobsummerwill,项目名称:ZXMAK2,代码行数:7,代码来源:Separator.cs

示例12: GetContentPosition

 public static PointF GetContentPosition(ContentAlignment alignment, SizeF size, SizeF containerSize)
 {
     return new PointF(
         GetContentPositionX(alignment, size, containerSize),
         GetContentPositionY(alignment, size, containerSize)
     );
 }
开发者ID:anirnet,项目名称:raf-manager,代码行数:7,代码来源:wGUI.cs

示例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);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:34,代码来源:ButtonBase.cs

示例14: reset

 protected void reset()
 {
     _alignment = ContentAlignment.MiddleLeft;
     setColor(SystemColors.WindowText);
     setBackground(SystemColors.Window);
     setFont(SystemFonts.DefaultFont);
 }
开发者ID:verebes,项目名称:xml_form_editor,代码行数:7,代码来源:StaticLabelPropertyControl.cs

示例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;
        }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:40,代码来源:ImageHelper.cs


注:本文中的ContentAlignment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。