示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argu"></param>
        internal 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];
                }


                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;
                            CalInitTime(viewId, ds);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogInfo(
                        "Core ShowViewByIdAttachRegion NavInitBeforShow Error IN ViewComponentHolding By id :" + viewId);
                }

                int vid = Convert.ToInt32(viewId);
                if (item.ContainsKey(vid))
                {
                    item[vid].Show();
                    item[vid].Focus();
                    item[vid].WindowState = WindowState.Normal;


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

                            var dt = DateTime.Now.Ticks;

                            mvvm.NavOnLoad(arus);
                            var ds = DateTime.Now.Ticks - dt;
                            CalInitTime(vid, ds);
                        }
                    }
                    return;
                }



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

                            mvvm.NavOnLoad(arus);
                            bolNavOnLoad = true;
                            var ds = DateTime.Now.Ticks - dt;
                            CalInitTime(vid, ds);
                        }
                        var mv = userControlMvvm.DataContext as IITab;
                        if (mv != null)
                        {
                            title = mv.Title;
                        }
                    }
                    AddAndShowView(title, vid, userControlMvvm);
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error while NavOnLoad:" + ex);
                }
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error:" + 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
        internal static void DoTaskA(Tuple <string, bool> tuple)
        {
            string viewId  = tuple.Item1;
            bool   show    = tuple.Item2;
            int    viewIdx = Convert.ToInt32(viewId);

            try
            {
                var attachRegion = ViewComponentHolding.GetViewAttachRegionById(viewId);


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


                if (show)
                {
                    if (item.ContainsKey(viewIdx))
                    {
                        item[viewIdx].Show();
                        item[viewIdx].Focus();
                        item[viewIdx].WindowState = WindowState.Normal;
                        return;
                    }

                    try
                    {
                        var    userControlMvvm = view as ContentControl;
                        string title           = string.Empty;
                        if (userControlMvvm != null)
                        {
                            userControlMvvm.HorizontalAlignment = HorizontalAlignment.Center;
                            userControlMvvm.VerticalAlignment   = VerticalAlignment.Center;
                            //userControlMvvm.HorizontalContentAlignment = HorizontalAlignment.Center;
                            //userControlMvvm.VerticalContentAlignment  = VerticalAlignment.Center;
                            var mvvm = userControlMvvm.DataContext as IINavInitBeforShow;
                            //导航页面必须实现此接口方可使用此函数进行页面导航数据初始化,否则需要自设定导航初始化
                            if (mvvm != null)
                            {
                                var dt = DateTime.Now.Ticks;
                                mvvm.NavInitBeforShow();
                                var ds = DateTime.Now.Ticks - dt;
                                CalInitTime(viewIdx, ds);

                                // mvvm.NavInitBeforShow();
                            }

                            var mv = userControlMvvm.DataContext as IITab;
                            if (mv != null)
                            {
                                title = mv.Title;
                            }
                        }
                        AddAndShowView(title, viewIdx, userControlMvvm);

                        //Window win = new Window();
                        //win.Title = title;
                        //win.Closing += new System.ComponentModel.CancelEventHandler(win_Closing);

                        //win.Content = userControlMvvm;
                        //win.Show();
                        //if (item.ContainsKey(viewIdx) == false) item.Add(viewIdx, win);
                    }
                    catch (Exception ex)
                    {
                        WriteLog.WriteLogInfo(
                            "Core ShowViewByIdAttachRegion NavInitBeforShow Error IN ViewComponentHolding By id :" +
                            view);
                    }
                }
                //else
                //{
                //    if (RegionManagerInstances.Regions[attachRegion].Views.Contains(view))
                //    {
                //        RegionManagerInstances.Regions[attachRegion].Remove(view);
                //    }
                //}
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError("Core ShowViewByIdAttachRegion Error:" + ex);
            }
        }
示例#4
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);
            }
        }