Exemplo n.º 1
0
 public void Show(NoticeWindowViewModel viewModel)
 {
     if (MessageBox.Show(viewModel.Message, LanguagesManager.Instance.ConfirmWindow_Title, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK) == MessageBoxResult.OK)
     {
         viewModel.Ok();
     }
 }
Exemplo n.º 2
0
        private void Setting_CheckDiskSpace()
        {
            bool watchFlag = true;

            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                if (!watchFlag)
                {
                    return;
                }

                try
                {
                    var paths = new List <string>();
                    paths.Add(AmoebaEnvironment.Config.Cache.BlocksPath);

                    bool flag = false;

                    foreach (string path in paths)
                    {
                        var drive = new DriveInfo(Path.GetFullPath(path));

                        if (drive.AvailableFreeSpace < NetworkConverter.FromSizeString("256MB"))
                        {
                            flag |= true;
                            break;
                        }
                    }

                    if (_serviceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("10GB"))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_serviceManager.State == ManagerState.Stop)
                        {
                            _serviceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_serviceManager.State == ManagerState.Start)
                        {
                            _serviceManager.Stop();
                            Log.Information("Stop");

                            watchFlag = false;

                            App.Current.Dispatcher.InvokeAsync(() =>
                            {
                                var viewModel       = new NoticeWindowViewModel(LanguagesManager.Instance.MainWindow_SpaceNotFound_Message);
                                viewModel.Callback += () => watchFlag = true;

                                _dialogService.Show(viewModel);
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 3, 0));
        }