예제 #1
0
        private async void Button_Update_Click(object sender, RoutedEventArgs e)
        {
            if (Button_Update.Content.ToString() == "检查更新")
            {
                Button_Update.Content = "检查中"; Button_Update.IsEnabled = false;
                try
                {
                    if (await UpdateServices.Check())
                    {
                        Text_Describe.Text = $"最新版本:{UpdateServices.RemoteVersion}({UpdateServices.RemoteUpdated.ToString("yyyy.MM.dd")})";
                        var logStr = await UpdateServices.GetUpdateLog();

                        TextBox_Log.Visibility = Visibility.Visible;
                        TextBox_Log.Text       = logStr;
                        Button_Update.Content  = "下载中";
                        await UpdateServices.Download();

                        Button_Update.Content = "立即更新"; Button_Update.IsEnabled = true;
                    }
                    else
                    {
                        Text_Describe.Text    = "当前已经是最新版本";
                        Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                    }
                }
                catch (Exception ex)
                {
                    MainWindow.ShowMessageDialog("错误", ex.Message);
                    Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                }
                return;
            }
            if (Button_Update.Content.ToString() == "立即更新")
            {
                try
                {
                    string exeFile = Path.Combine(UserSettings.AppDataDir, "AutoUpdate.exe");
                    File.WriteAllBytes(exeFile, CommonServices.GetCompressResBytes("SimpleRemote.Lib.AutoUpdate.exe.Compress"));
                    string updateFile = Path.Combine(UserSettings.AppDataDir, "Update.zip");
                    string unzipPath  = AppDomain.CurrentDomain.BaseDirectory;
                    Process.Start(exeFile, $"{updateFile} {unzipPath} {Assembly.GetEntryAssembly().Location}");
                    Application.Current.MainWindow.Close();
                }
                catch (Exception ex)
                {
                    MainWindow.ShowMessageDialog("错误", ex.Message);
                    Button_Update.Content = "检查更新"; Button_Update.IsEnabled = true;
                }
            }
        }
예제 #2
0
파일: Putty.cs 프로젝트: zjamt/SimpleRemote
        public Putty()
        {
            string libFileName = Environment.Is64BitProcess ? "SimpleRemote.Lib.putty64.dll.Compress" : "SimpleRemote.Lib.putty.dll.Compress";

            _memoryModule = MemoryModule.Create(CommonServices.GetCompressResBytes(libFileName));
            Init          = _memoryModule.GetProcDelegate <Putty_Init>("Putty_Init");
            Create        = _memoryModule.GetProcDelegate <Putty_Create>("Putty_Create");
            GetError      = _memoryModule.GetProcDelegate <Putty_GetError>("Putty_GetError");
            SetCallback   = _memoryModule.GetProcDelegate <Putty_SetCallback>("Putty_SetCallback");
            Move          = _memoryModule.GetProcDelegate <Putty_Move>("Putty_Move");
            GetHwnd       = _memoryModule.GetProcDelegate <Putty_GetHwnd>("Putty_GetHwnd");
            Exit          = _memoryModule.GetProcDelegate <Putty_Exit>("Putty_Exit");
            Show          = _memoryModule.GetProcDelegate <Putty_Show>("Putty_Show");
        }