• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ContentAlignment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ContentAlignment的典型用法代码示例。如果您正苦于以下问题:C# ContentAlignment类的具体用法?C# ContentAlignment怎么用?C# ContentAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentAlignment类属于命名空间,在下文中一共展示了ContentAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: DefaultBaselineOffset

 private int DefaultBaselineOffset(ContentAlignment alignment, FlatStyle flatStyle)
 {
     if ((alignment & DesignerUtils.anyMiddleAlignment) != ((ContentAlignment) 0))
     {
         return 0;
     }
     if ((flatStyle == FlatStyle.Standard) || (flatStyle == FlatStyle.Popup))
     {
         if ((alignment & DesignerUtils.anyTopAlignment) == ((ContentAlignment) 0))
         {
             return -4;
         }
         return 4;
     }
     if (flatStyle == FlatStyle.System)
     {
         if ((alignment & DesignerUtils.anyTopAlignment) == ((ContentAlignment) 0))
         {
             return -3;
         }
         return 3;
     }
     if (flatStyle != FlatStyle.Flat)
     {
         return 0;
     }
     if ((alignment & DesignerUtils.anyTopAlignment) == ((ContentAlignment) 0))
     {
         return -5;
     }
     return 5;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:ButtonBaseDesigner.cs


示例17: TextAlignToFormatFlags

 private TextFormatFlags TextAlignToFormatFlags(ContentAlignment align)
 {
     switch (align)
     {
         case ContentAlignment.MiddleCenter:
             return TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter;
         case ContentAlignment.BottomCenter:
             return TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom;
         case ContentAlignment.BottomLeft:
             return TextFormatFlags.Left | TextFormatFlags.Bottom;
         case ContentAlignment.BottomRight:
             return TextFormatFlags.Right | TextFormatFlags.Bottom;
         case ContentAlignment.MiddleLeft:
             return TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
         case ContentAlignment.MiddleRight:
             return TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
         case ContentAlignment.TopCenter:
             return TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
         case ContentAlignment.TopLeft:
             return TextFormatFlags.Top | TextFormatFlags.Left;
         case ContentAlignment.TopRight:
             return TextFormatFlags.Top | TextFormatFlags.Right;
     }
     return TextFormatFlags.HorizontalCenter | TextFormatFlags.Top;
 }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:25,代码来源:GlowLabel.cs


示例18: NotificationForm

        public NotificationForm(int duration, ContentAlignment placement, Size size, NotificationFormConfig config)
        {
            InitializeComponent();
            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);
            }

            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            Size = size;
            Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, Size);
            Location = new Point(Screen.PrimaryScreen.WorkingArea.X + position.X, Screen.PrimaryScreen.WorkingArea.Y + position.Y);

            tDuration.Interval = duration;
            tDuration.Start();
        }
开发者ID:barsv,项目名称:ShareX,代码行数:26,代码来源:NotificationForm.cs


示例19: DrawText

        public void DrawText(Point p, string font, int size, FontStyle fontStyle, Color fill, ContentAlignment alignment, object text)
        {
            Dictionary<ContentAlignment, XAttribute> alignmentTransform = new Dictionary<ContentAlignment, XAttribute>
            {
                { ContentAlignment.MiddleLeft, new XAttribute("text-anchor", "start")},
                { ContentAlignment.MiddleCenter, new XAttribute("text-anchor", "middle")},
                { ContentAlignment.MiddleRight, new XAttribute("text-anchor", "end")}
            };

            Dictionary<FontStyle, XAttribute> fontWeightTransform = new Dictionary<FontStyle, XAttribute>
            {
                { FontStyle.Regular, new XAttribute("font-weight", "normal")},
                { FontStyle.Bold, new XAttribute("font-weight", "bold")},
            };

            root.Add(new XElement(@namespace + "text",            
                new XAttribute("x", p.X ),
                new XAttribute("y", p.Y ),
                new XAttribute("fill", ColorTranslator.ToHtml(fill)),
                new XAttribute("stroke", ColorTranslator.ToHtml(fill)),
                new XAttribute("font-size", size),
                new XAttribute("font-family", font),
                new XAttribute("stroke-width", 0),
                alignmentTransform[alignment],
                fontWeightTransform[fontStyle],
                text
            ));
        }
开发者ID:modulexcite,项目名称:BuildAnalyzer,代码行数:28,代码来源:SvgDocument.cs


示例20: FromContentAlignment

 public static StringAlignments FromContentAlignment(ContentAlignment ca)
 {
     Int32 lNum = (Int32)Math.Log((Double)ca, 2);
     StringAlignments sa = new StringAlignments();
     sa.LineAlignment = (StringAlignment)(lNum / 4);
     sa.Alignment = (StringAlignment)(lNum % 4);
     return sa;
 }
开发者ID:rraguso,项目名称:protone-suite,代码行数:8,代码来源:GuiHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ContentControl类代码示例发布时间:2022-05-24
下一篇:
C# ContentActivator类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap