コード例 #1
0
ファイル: MessageBoxCard.cs プロジェクト: goensin/rubyer-wpf
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ButtonBase closeButton = GetTemplateChild(CloseButtonPartName) as ButtonBase;

            closeButton.Click += (sender, args) =>
            {
                CloseMessageBoxCardAnimaton();
                MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.No, this);
                this.RaiseEvent(eventArgs);
            };

            if (IsShowOk)
            {
                ButtonBase okButton = GetTemplateChild(OkButtonPartName) as ButtonBase;
                okButton.Click += (sender, args) =>
                {
                    CloseMessageBoxCardAnimaton();
                    MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.OK, this);
                    this.RaiseEvent(eventArgs);
                };
            }

            if (IsShowCancel)
            {
                ButtonBase cancelButton = GetTemplateChild(CancelButtonPartName) as ButtonBase;
                cancelButton.Click += (sender, args) =>
                {
                    CloseMessageBoxCardAnimaton();
                    MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.Cancel, this);
                    this.RaiseEvent(eventArgs);
                };
            }

            if (IsShowYes)
            {
                ButtonBase yesButton = GetTemplateChild(YesButtonPartName) as ButtonBase;
                yesButton.Click += (sender, args) =>
                {
                    CloseMessageBoxCardAnimaton();
                    MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.Yes, this);
                    this.RaiseEvent(eventArgs);
                };
            }

            if (IsShowNo)
            {
                ButtonBase noButton = GetTemplateChild(NoButtonPartName) as ButtonBase;
                noButton.Click += (sender, args) =>
                {
                    CloseMessageBoxCardAnimaton();
                    MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.No, this);
                    this.RaiseEvent(eventArgs);
                };
            }
        }
コード例 #2
0
        private void Card_ReturnResult(object sender, MessageBoxResultRoutedEventArge e)
        {
            Storyboard unloadStoryboard = (Storyboard)this.Resources["UnLoadFadeUp"];

            unloadStoryboard.Completed += (a, b) => {
                messageBoxPanel.Children.Remove(e.Card);
                DialogResult = true;
            };

            rootGrid.BeginStoryboard(unloadStoryboard);
            MessageBoxResult = e.Result;
        }