本文整理汇总了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;
}
示例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;
}
示例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);
//.........这里部分代码省略.........