本文整理汇总了C#中System.Action.Dispatch方法的典型用法代码示例。如果您正苦于以下问题:C# Action.Dispatch方法的具体用法?C# Action.Dispatch怎么用?C# Action.Dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Action
的用法示例。
在下文中一共展示了Action.Dispatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUtilityButton
public static void AddUtilityButton(this List<UIButton> list, UIImage image, Action onClickAction = null)
{
var button = new UIButton(UIButtonType.Custom) {
BackgroundColor = UIColor.Gray
};
button.TouchDown += (sender, args) => onClickAction.Dispatch ();
button.SetImage(image, UIControlState.Normal);
list.Add(button);
}
示例2: TaskPopup
//.........这里部分代码省略.........
datePicker.DateChanged += (sender, e) => {
SelectedDate = datePicker.SelectedDate;
};
popupFragment.Content = datePicker.DefaultView;
var categoryIcon = new Image {HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 12, Source = task.GetCategory().IconSource};
categoryPicker = new CategoryPicker();
categoryPicker.SelectedIndex = 0;
foreach (Category category in CategoryHelper.AllCategories) {
categoryPicker.Items.Add (category.Name);
if (task.category == category.Name) {
categoryPicker.SelectedIndex = categoryPicker.Items.Count - 1;
}
}
categoryPicker.SelectedIndexChanged += ( sender, args ) => categoryIcon.Source = CategoryHelper.AllCategories[categoryPicker.SelectedIndex].IconSource;
var selectCategoryArrow = new Image { HorizontalOptions = LayoutOptions.End, Source = "select.png", HeightRequest = 10 };
selectCategoryArrow.GestureRecognizers.Add(new TapGestureRecognizer {
Command = new Command(() => categoryPicker.Focus ())
});
var categoryLayout = new StackLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = {
new DefaultLabel {Text = "Category", TextColor = StyleManager.MainColor},
categoryIcon,
categoryPicker,
selectCategoryArrow
}
};
isFavorite = task.isFavorite;
var starResource = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;
var favoriteLabel = new DefaultLabel { Text = "Mark as favorite", TextColor = StyleManager.MainColor };
var favoriteImage = new Image {
HorizontalOptions = LayoutOptions.EndAndExpand,
Source = starResource,
HeightRequest = 15
};
var favoriteLayout = new StackLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = { favoriteLabel, favoriteImage}
};
favoriteImage.GestureRecognizers.Add(new TapGestureRecognizer {
Command = new Command(() => Device.BeginInvokeOnMainThread (() => {
isFavorite = !isFavorite;
favoriteImage.Source = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;
}))
});
var actionText = "Create";
if (!string.IsNullOrWhiteSpace (task.title))
actionText = "Update";
var buttons = new StackLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Spacing = 0,
Children = {
new DefaultButton {
Text = "Cancel",
TextColor = Color.White,
BackgroundColor = Color.Silver,
HorizontalOptions = LayoutOptions.FillAndExpand,
Command = new Command (onCancel.Dispatch)
},
new DefaultButton {
Text = actionText,
TextColor = Color.White,
BackgroundColor = StyleManager.MainColor,
HorizontalOptions = LayoutOptions.FillAndExpand,
Command = new Command (() => Device.BeginInvokeOnMainThread (() => {
UpdateTask (task);
onSubmit.Dispatch ();
}))
}
}
};
var mainLayout = new StackLayout {
Padding = 15,
BackgroundColor = StyleManager.AccentColor,
Spacing = 20,
Children = { // TODO time picker, pass time
timePicker, categoryLayout, favoriteLayout, buttons
}
};
Children.Add(topPanel);
Children.Add(datePicker);
Children.Add(popupFragment);
Children.Add(mainLayout);
}