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


C# Button.Bind方法代码示例

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


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

示例1: ImageButton

		Control ImageButton(Image image)
		{
			var control = new Button { Image = image };
			control.Bind(r => r.ImagePosition, this, r => r.ImagePosition);
			var defaultMinimiumSize = control.MinimumSize;
            control.Bind(r => r.MinimumSize, Binding.Property(this, r => r.ClearMinimumSize).Convert(r => r ? Size.Empty : defaultMinimiumSize));
			LogEvents(control);
			return control;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:9,代码来源:ButtonSection.cs

示例2: ImageButton

		Control ImageButton(Image image)
		{
			var control = new Button { Image = image };
			control.Bind(r => r.ImagePosition, this, r => r.ImagePosition);
			LogEvents(control);
			return control;
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:7,代码来源:ButtonSection.cs

示例3: RichTextAreaSection

		public RichTextAreaSection()
		{
			var richText = new RichTextArea();
			richText.Size = new Size(-1, 300);
			richText.Text = LoremText;

			var range = new Range<int>(6, 10);
			var buffer = richText.Buffer;
			buffer.SetFont(range, Fonts.Cursive(20, FontStyle.Bold, FontDecoration.Underline));
			buffer.SetForeground(range, Colors.Blue);
			buffer.SetBackground(range, Colors.Yellow);

			buffer.SetBold(new Range<int>(11, 16), true);
			buffer.SetItalic(new Range<int>(18, 20), true);
			buffer.SetUnderline(new Range<int>(22, 25), true);
			buffer.SetStrikethrough(new Range<int>(28, 38), true);

			richText.CaretIndex = LoremText.Length - 1;

			richText.SelectionChanged += (sender, e) =>
			{
				UpdateBindings(BindingUpdateMode.Destination);
				Log.Write(sender, "SelectionChanged: {0}", richText.Selection);
			};

			var boldButton = new CheckBox { Text = "Bold" };
			boldButton.CheckedBinding.Bind(richText, r => r.SelectionBold);
			boldButton.CheckedChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var italicButton = new CheckBox { Text = "Italic" };
			italicButton.CheckedBinding.Bind(richText, r => r.SelectionItalic);
			italicButton.CheckedChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var underlineButton = new CheckBox { Text = "Underline" };
			underlineButton.CheckedBinding.Bind(richText, r => r.SelectionUnderline);
			underlineButton.CheckedChanged += (sender, e) => richText.Focus();

			var strikethroughButton = new CheckBox { Text = "Strikethrough" };
			strikethroughButton.CheckedBinding.Bind(richText, r => r.SelectionStrikethrough);
			strikethroughButton.CheckedChanged += (sender, e) => richText.Focus();

			var backgroundButton = new ColorPicker { };
			backgroundButton.ValueBinding.Bind(() => richText.SelectionBackground, val => richText.SelectionBackground = val, h => Binding.AddPropertyEvent(richText, r => r.SelectionBackground, h), h => Binding.RemovePropertyEvent(richText, h));
			backgroundButton.ValueChanged += (sender, e) => richText.Focus();

			var foregroundButton = new ColorPicker { };
			foregroundButton.ValueBinding.Bind(richText, r => r.SelectionForeground);
			foregroundButton.ValueChanged += (sender, e) => richText.Focus();

			var fontButton = new Button();
			fontButton.Bind(c => c.Text, new DelegateBinding<string>(() =>
			{
				var font = richText.SelectionFont;
				if (font == null)
					return "<No Font>";
				return string.Format("{0}, {1}, {2:0.00}pt", font.FamilyName, font.Typeface.Name, font.Size);
			}));
			var fd = new FontDialog();
			fontButton.Click += (sender, e) =>
			{
				fd.Font = richText.SelectionFont;
				fd.FontChanged += (s, ee) =>
				{
					richText.SelectionFont = fd.Font;
					UpdateBindings(BindingUpdateMode.Destination);
				};
				if (fd.ShowDialog(this) == DialogResult.Ok)
					richText.Focus();
			};

			var familyDropDown = new DropDown();
			familyDropDown.DataStore = Fonts.AvailableFontFamilies.OrderBy(r => r.Name);
			familyDropDown.SelectedValueBinding.Bind(richText, r => r.SelectionFamily);
			familyDropDown.SelectedValueChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var formatEnum = new EnumDropDown<RichTextAreaFormat>();
			formatEnum.SelectedValue = RichTextAreaFormat.Rtf;

			var loadButton = new Button { Text = "Load" };
			loadButton.Enabled = buffer.SupportedFormats.Contains(formatEnum.SelectedValue);
			loadButton.Click += (sender, e) => buffer.Load(new MemoryStream(Encoding.UTF8.GetBytes(formatEnum.SelectedValue == RichTextAreaFormat.Rtf ? RtfString : LoremText)), formatEnum.SelectedValue);

			var saveButton = new Button { Text = "Save" };
			saveButton.Enabled = buffer.SupportedFormats.Contains(formatEnum.SelectedValue);
			saveButton.Click += (sender, e) =>
			{
				var stream = new MemoryStream();
				buffer.Save(stream, formatEnum.SelectedValue);
//.........这里部分代码省略.........
开发者ID:mhusen,项目名称:Eto,代码行数:101,代码来源:RichTextAreaSection.cs


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