當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。