示例#1
0
        private static void Fucksssss(object abc)
        {
            try
            {
                var args = abc as Tuple <string, object, object[]>;
                if (args == null)
                {
                    return;
                }
                bool bolNavOnLoad    = false;
                var  userControlMvvm = args.Item2 as ContentControl;
                if (userControlMvvm != null)
                {
                    var mvvm = userControlMvvm.DataContext as IINavOnLoad; //导航页面必须实现此接口方可使用此函数进行页面导航数据初始化,否则需要自设定导航初始化
                    if (mvvm != null)
                    {
                        var dt = DateTime.Now.Ticks;
                        mvvm.NavOnLoad(args.Item3);
                        var ds = DateTime.Now.Ticks - dt;
                        RegionManageExtend.CalInitTime(args.Item1, ds);

                        //   mvvm.NavOnLoad(args.Item3);
                        bolNavOnLoad = true;
                    }
                }

                if (!bolNavOnLoad)
                {
                    WriteLog.WriteLogInfo("ShowViewByIdAttachRegion  Can not  be  NavOnLoaded,viewid is " + args.Item1);
                }
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error while NavOnLoad:" + ex);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argu"></param>
        private static void DoTaskB(params object[] argu)
        {
            // int viewId, string viewAttachRegionName, bool show


            try
            {
                if (argu.Length < 2)
                {
                    return;
                }
                if (argu[0] == null)
                {
                    return;
                }

                string viewId           = argu[0].ToString();
                string viewAttachRegion = ViewComponentHolding.GetViewAttachRegionById(viewId);
                //   string viewAttachRegion = argu[1].ToString();
                object[] arus = new object[argu.Length - 1];
                for (int i = 1; i < argu.Length; i++)
                {
                    arus[i - 1] = argu[i];
                }

                if (viewAttachRegion.Equals("DocumentRegion") && IsNewViewInDocumentRegionPopup)
                {
                    RegionManageExtend.DoTaskB(argu);
                    return;
                }

                if (!RegionManagerInstances.Regions.ContainsRegionWithName(viewAttachRegion))
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion Can not find Region :" + viewAttachRegion);
                    return;
                }
                var view = ViewComponentHolding.GetViewById(viewId);
                if (view == null)
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion Can not find View IN ViewComponentHolding By id :" + viewId);
                    return;
                }


                try
                {
                    var userControlMvvm = view as ContentControl;
                    if (userControlMvvm != null)
                    {
                        var mvvm = userControlMvvm.DataContext as IINavInitBeforShow;
                        //导航页面必须实现此接口方可使用此函数进行页面导航数据初始化,否则需要自设定导航初始化
                        if (mvvm != null)
                        {
                            //mvvm.NavInitBeforShow(arus);

                            var dt = DateTime.Now.Ticks;
                            mvvm.NavInitBeforShow(arus);
                            var ds = DateTime.Now.Ticks - dt;
                            RegionManageExtend.CalInitTime(viewId, ds);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion NavInitBeforShow Error IN ViewComponentHolding By id :" + viewId);
                }

                if (!RegionManagerInstances.Regions[viewAttachRegion].Views.Contains(view))
                {
                    RegionManagerInstances.Regions[viewAttachRegion].Add(view);
                }
                RegionManagerInstances.Regions[viewAttachRegion].Activate(view);


                //bool bolNavOnLoad = false;
                //var userControlMvvm = view as ContentControl;
                //if (userControlMvvm != null)
                //{
                //    var mvvm = userControlMvvm.DataContext as IINavOnLoad; //导航页面必须实现此接口方可使用此函数进行页面导航数据初始化,否则需要自设定导航初始化
                //    if (mvvm != null)
                //    {
                //        mvvm.NavOnLoad(arus);
                //        bolNavOnLoad = true;
                //    }
                //}

                //if (!bolNavOnLoad)
                //{
                //    WriteLog.WriteLogInfo("ShowViewByIdAttachRegion  viewId :" + viewId +
                //                          " Can not find Mvvm and can not be  NavOnLoaded");
                //}


                Task t = new Task(() =>
                {
                    Thread.Sleep(500);
                    try
                    {
                        Application.Current.Dispatcher.Invoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new DoTaskFuck(Fucksssss),
                            new Tuple <string, object, object[]>(viewId, view, arus));
                    }
                    catch (Exception e)
                    {
                        WriteLog.WriteLogError(
                            "Core ShowViewByIdAttachRegion Error in Invoke Task:" + e);
                    }
                });
                t.Start();
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error:" + ex);
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tuple"></param>
        private static void DoTaskA(Tuple <string, bool> tuple)
        {
            // int viewId, string viewAttachRegionName, bool show


            try
            {
                var attachRegion = ViewComponentHolding.GetViewAttachRegionById(tuple.Item1);

                if (attachRegion.Equals("DocumentRegion") && IsNewViewInDocumentRegionPopup)
                {
                    RegionManageExtend.DoTaskA(tuple);
                    return;
                }

                if (!RegionManagerInstances.Regions.ContainsRegionWithName(attachRegion))
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion Can not find Region :" + attachRegion);
                    return;
                }
                var view = ViewComponentHolding.GetViewById(tuple.Item1);
                if (view == null)
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion Can not find View IN ViewComponentHolding By id :" + tuple.Item1);
                    return;
                }


                if (tuple.Item2)
                {
                    if (!RegionManagerInstances.Regions[attachRegion].Views.Contains(view))
                    {
                        try
                        {
                            var userControlMvvm = view as ContentControl;
                            if (userControlMvvm != null)
                            {
                                var mvvm = userControlMvvm.DataContext as IINavInitBeforShow;
                                //导航页面必须实现此接口方可使用此函数进行页面导航数据初始化,否则需要自设定导航初始化
                                if (mvvm != null)
                                {
                                    // mvvm.NavInitBeforShow();

                                    var dt = DateTime.Now.Ticks;
                                    mvvm.NavInitBeforShow();
                                    var ds = DateTime.Now.Ticks - dt;
                                    RegionManageExtend.CalInitTime(tuple.Item1, ds);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            WriteLog.WriteLogInfo(
                                "Core ShowViewByIdAttachRegion NavInitBeforShow Error IN ViewComponentHolding By id :" + tuple.Item1);
                        }

                        RegionManagerInstances.Regions[attachRegion].
                        Add(view);
                    }
                    RegionManagerInstances.Regions[attachRegion].Activate(view);
                }
                else
                {
                    if (RegionManagerInstances.Regions[attachRegion].Views.Contains(view))
                    {
                        RegionManagerInstances.Regions[attachRegion].Remove(view);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error:" + ex);
            }
        }