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


C# Action.Dispatch方法代码示例

本文整理汇总了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);
 }
开发者ID:strongloop,项目名称:loopback-example-xamarin,代码行数:9,代码来源:SWTableViewCell.cs

示例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);
        }
开发者ID:strongloop,项目名称:loopback-example-xamarin,代码行数:101,代码来源:TaskPopup.cs


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