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


C# ImageDescription.WithDefaultSize方法代码示例

本文整理汇总了C#中Xwt.Backends.ImageDescription.WithDefaultSize方法的典型用法代码示例。如果您正苦于以下问题:C# ImageDescription.WithDefaultSize方法的具体用法?C# ImageDescription.WithDefaultSize怎么用?C# ImageDescription.WithDefaultSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xwt.Backends.ImageDescription的用法示例。


在下文中一共展示了ImageDescription.WithDefaultSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetContent

        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image = image;

            if (label != null && label.Length == 0)
                label = null;

            Button b = (Button) Frontend;
            if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure) {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll ();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
                imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

            labelWidget = null;

            if (label != null && imageWidget == null) {
                contentWidget = labelWidget = new Gtk.Label (label);
            }
            else if (label == null && imageWidget != null) {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null) {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
                labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };

                if (position == ContentPosition.Left || position == ContentPosition.Top) {
                    box.PackStart (imageWidget, false, false, 0);
                    box.PackStart (labelWidget, false, false, 0);
                } else {
                    box.PackStart (labelWidget, false, false, 0);
                    box.PackStart (imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            var expandButtonContent = false;
            if (b.Type == ButtonType.DropDown) {
                if (contentWidget != null) {
                    Gtk.HBox box = new Gtk.HBox (false, 3);
                    box.PackStart (contentWidget, true, true, 3);
                    box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                    expandButtonContent = true;
                } else
                    contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
            }
            if (contentWidget != null) {
                contentWidget.ShowAll ();
                Widget.Label = null;
                Widget.Image = contentWidget;
                var alignment = Widget.Child as Gtk.Alignment;
                if (alignment != null) {
                    if (expandButtonContent) {
                        var box = alignment.Child as Gtk.Box;
                        if (box != null) {
                            alignment.Xscale = 1;
                            box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start);
                            if (labelWidget != null)
                                labelWidget.Xalign = 0;
                        }
                    } else if (position == ContentPosition.Left && (contentWidget is Gtk.Box)) {
                        // in case the button is wider than its natural size and has text and an image on the left,
                        // optimize its alignment to make the text more centered.
                        // FIXME: more sophisticated size calculation
                        alignment.Xalign = 0.475f;
                    }
                }
                if (labelWidget != null) {
                    labelWidget.UseUnderline = useMnemonic;
                    if (customFont != null)
                        labelWidget.ModifyFont (customFont);
                    if (customLabelColor.HasValue) {
                        labelWidget.SetForegroundColor (customLabelColor.Value);
                        labelWidget.SetForegroundColor (Gtk.StateType.Prelight, customLabelColor.Value);
                    }
                }
            } else
                Widget.Label = null;
        }
开发者ID:mono,项目名称:xwt,代码行数:93,代码来源:ButtonBackend.cs

示例2: SetImage

		public void SetImage (ImageDescription image) 
		{
			image = image.WithDefaultSize (Gtk.IconSize.Menu);
			statusItem.Pixbuf = ((GtkImage)image.Backend).GetBestFrame (context, Util.GetDefaultScaleFactor (), image.Size.Width, image.Size.Height, true);
		}
开发者ID:m13253,项目名称:xwt,代码行数:5,代码来源:StatusIconBackend.cs

示例3: SetContent

        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image = image;

            if (label != null && label.Length == 0)
                label = null;

            Button b = (Button) Frontend;
            if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure) {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll ();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
                imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

            if (label != null && imageWidget == null) {
                contentWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };
            }
            else if (label == null && imageWidget != null) {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null) {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
                var lab = new Gtk.Label (label) { UseUnderline = useMnemonic };

                if (position == ContentPosition.Left || position == ContentPosition.Top) {
                    box.PackStart (imageWidget, false, false, 0);
                    box.PackStart (lab, false, false, 0);
                } else {
                    box.PackStart (lab, false, false, 0);
                    box.PackStart (imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            if (b.Type == ButtonType.DropDown) {
                if (contentWidget != null) {
                    Gtk.HBox box = new Gtk.HBox (false, 3);
                    box.PackStart (contentWidget, true, true, 3);
                    box.PackStart (new Gtk.VSeparator (), true, true, 0);
                    box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                } else
                    contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
            }
            if (contentWidget != null) {
                contentWidget.ShowAll ();
                Widget.Label = null;
                Widget.Image = contentWidget;
            } else
                Widget.Label = null;
        }
开发者ID:nite2006,项目名称:xwt,代码行数:64,代码来源:ButtonBackend.cs

示例4: SetContent

		public void SetContent (string label, bool useMnemonic, ImageDescription image, ContentPosition position)
		{			
			Widget.UseUnderline = useMnemonic;
			this.image = image;

			if (label != null && label.Length == 0)
				label = null;
			
			Button b = (Button) Frontend;
			if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
				Widget.Label = label;
				return;
			}
			
			if (b.Type == ButtonType.Disclosure) {
				Widget.Label = null;
				Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
				Widget.Image.ShowAll ();
				return;
			}
			
			Gtk.Widget contentWidget = null;
			
			Gtk.Widget imageWidget = null;
			if (image.Backend != null)
				imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

			Gtk.Label labelWidget = null;

			if (label != null && imageWidget == null) {
				contentWidget = labelWidget = new Gtk.Label (label);
			}
			else if (label == null && imageWidget != null) {
				contentWidget = imageWidget;
			}
			else if (label != null && imageWidget != null) {
				Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
				labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };
				
				if (position == ContentPosition.Left || position == ContentPosition.Top) {
					box.PackStart (imageWidget, false, false, 0);
					box.PackStart (labelWidget, false, false, 0);
				} else {
					box.PackStart (labelWidget, false, false, 0);
					box.PackStart (imageWidget, false, false, 0);
				}
				
				contentWidget = box;
			}
			var expandButtonContent = false;
			if (b.Type == ButtonType.DropDown) {
				if (contentWidget != null) {
					Gtk.HBox box = new Gtk.HBox (false, 3);
					box.PackStart (contentWidget, true, true, 3);
					box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
					contentWidget = box;
					expandButtonContent = true;
				} else
					contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
			}
			if (contentWidget != null) {
				contentWidget.ShowAll ();
				Widget.Label = null;
				Widget.Image = contentWidget;
				if (expandButtonContent) {
					var alignment = Widget.Child as Gtk.Alignment;
					if (alignment != null) {
						var box = alignment.Child as Gtk.Box;
						if (box != null) {
							alignment.Xscale = 1;
							box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start);
							if (labelWidget != null)
								labelWidget.Xalign = 0;
						}
					}
				}
				if (labelWidget != null) {
					labelWidget.UseUnderline = useMnemonic;
					if (customFont != null)
						labelWidget.ModifyFont (customFont);
				}
			} else
				Widget.Label = null;
		}
开发者ID:m13253,项目名称:xwt,代码行数:84,代码来源:ButtonBackend.cs


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