Exemplo n.º 1
0
 protected override void OnClosing(CancelEventArgs e)
 {
     using (var loading = new LoadingHelper(LoadingType.Progress))
     {
         Thread.Sleep(100);
         loading.SetPosition(1, "正在保存标签页".GetL());
         Thread.Sleep(100);
         var files = new List <UncloseFileModel>();
         foreach (TabItemClose item in tabcontol.Items)
         {
             var npage = FindNewPage.GetPage(item);
             if (npage is null)
             {
                 continue;
             }
             var m = new UncloseFileModel
             {
                 FileName = (string)item.Header,
                 FilePath = npage.FilePath,
                 FileText = npage.tb.Text
             };
             files.Add(m);
         }
         Strings.Write(JsonConvert.SerializeObject(files), "Models/unclosefileconfig.json");
         loading.SetPosition(50, "正在保存数据链接".GetL());
         Thread.Sleep(100);
         vm.Idb?.CloseAllTable(vm.TreeSource);
         Strings.Write(JsonConvert.SerializeObject(vm.TreeSource), "Models/dbconfig.json");
         loading.SetPosition(100, "保存完成".GetL());
         Thread.Sleep(500);
     }
 }
Exemplo n.º 2
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            using (var loading = new LoadingHelper(LoadingType.Progress, this))
            {
                loading.SetPosition(20, "正在加载页面".GetL());
                MakeDataItem  = MakeData_item;
                OutputConsole = new OutputConsole(this);
                foreach (TabItemClose item in tabcontol.Items)
                {
                    item.Visibility = Visibility.Collapsed;
                }

                #region 激活校验

                /*
                 * 不启用激活校验
                 */
                //if (Common.Key() != Common.SetConfig("Password"))
                //{
                //    JiHuo ji = new JiHuo();
                //    ji.ShowDialog();
                //    if (Common.Key() != Common.SetConfig("Password"))
                //        this.Close();
                //}

                //if (Common.SetConfig("Date") == "0")
                //{
                //    this.Close();
                //}
                //else
                //{
                //    Common.SetConfig("Date", (Convert.ToInt32(Common.SetConfig("Date")) - 1).ToString());
                //}
                #endregion


                loading.SetPosition(50, "正在加载模型".GetL());
                LoadMode();

                //打开更新日志界面
                if (Common.SetConfig("Update") == "0")
                {
                    UpdateDesc u = new UpdateDesc();
                    u.ShowDialog();
                    if (u.IsChecked())
                    {
                        Common.SetConfig("Update", "1");
                    }
                }

                loading.SetPosition(80, "正在加载未保存的页面".GetL());
                InitUncloseFile();
                //RunNotifyBox();
                consolecc.Content = new Frame()
                {
                    Content = OutputConsole
                };
                loading.SetPosition(100, "加载完成".GetL());
                System.Threading.Thread.Sleep(200);
            }
        }