Example #1
0
 private void UpdateMethodInfo()
 {
     this.methodDescriptors.Clear();
     if (this.Target != null && !string.IsNullOrEmpty(this.MethodName))
     {
         Type         type    = this.Target.GetType();
         MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
         for (int i = 0; i < methods.Length; i++)
         {
             MethodInfo methodInfo = methods[i];
             if (this.IsMethodValid(methodInfo))
             {
                 ParameterInfo[] parameters = methodInfo.GetParameters();
                 if (CallParameterizedMethodAction.AreMethodParamsValid(parameters))
                 {
                     this.methodDescriptors.Add(new CallParameterizedMethodAction.MethodDescriptor(methodInfo, parameters));
                 }
             }
         }
         //this.methodDescriptors = this.methodDescriptors.OrderByDescending(delegate(CallParameterizedMethodAction.MethodDescriptor methodDescriptor)
         //{
         //    int num = 0;
         //    if (methodDescriptor.HasParameters)
         //    {
         //        Type type2 = methodDescriptor.SecondParameterType;
         //        while (type2 != typeof(EventArgs))
         //        {
         //            num++;
         //            type2 = type2.BaseType;
         //        }
         //    }
         //    return methodDescriptor.ParameterCount + num;
         //}).ToList<CallParameterizedMethodAction.MethodDescriptor>();
     }
 }
Example #2
0
        /// <summary>
        /// 弹出窗口
        /// </summary>
        /// <typeparam name="TViewModel">传入的viewmodel</typeparam>
        /// <param name="owner">owner</param>
        /// <param name="title">窗口的title</param>
        /// <param name="view">窗口的内容</param>
        /// <param name="viewmodel">窗口的内容的viewmodel</param>
        /// <param name="onDialogCloseCallBack">窗口关闭后的回掉事件</param>
        /// <param name="option">窗口的一些属性设置(主要是动画)</param>
        /// <param name="winLoadAction">窗口加载完页面后执行的操作</param>
        /// <param name="request">InteractionRequest类,调用者可执行Requested,即可关闭弹出的窗口</param>
        public static void ShowDialog <TViewModel>(Window owner, string title, System.Windows.Controls.UserControl view, TViewModel viewmodel, Action <TViewModel> onDialogCloseCallBack, MyLayerOptions option, Action winLoadAction, InteractionRequest request)
        {
            view.DataContext = viewmodel;
            MyLayer messageBox = new MyLayer(owner, view, title, option, true, winLoadAction);

            if (onDialogCloseCallBack != null)
            {
                messageBox.Closed += (sender, e) => onDialogCloseCallBack(viewmodel);
            }
            if (request != null)
            {
                CallParameterizedMethodAction action = new CallParameterizedMethodAction();
                action.MethodName   = "Close";
                action.TargetObject = messageBox;
                InteractionRequestTrigger trigger = new InteractionRequestTrigger();
                trigger.Actions.Add(action);
                trigger.SourceObject = request;
                Interaction.GetTriggers(messageBox).Add(trigger);
            }
            messageBox.Show();
        }
Example #3
0
        private static void OnTargetObjectChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            CallParameterizedMethodAction callMethodAction = (CallParameterizedMethodAction)sender;

            callMethodAction.UpdateMethodInfo();
        }