public void Execute(object parameter)
        {
            if (Interlocked.Exchange(ref _canExecute, 0) != 1)
            {
                return;
            }
            CanExecuteChanged.NullSafeInvoke(this, new EventArgs());

            try
            {
                _action.Invoke();
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(null, ex);
            }

            Interlocked.Exchange(ref _canExecute, 1);
            CanExecuteChanged.NullSafeInvoke(this, new EventArgs());
        }
Esempio n. 2
0
        private void ClearContent()
        {
            try
            {
                if (CheckAccess())
                {
                    _treeView.ItemsSource = null;
                    _listView.ItemsSource = null;

                    IsEnabled = false;
                }
                else
                {
                    Dispatcher.Invoke(ClearContent);
                }
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(this, ex);
            }
        }
Esempio n. 3
0
        private async Task RefreshContent(GameLocationInfo obj)
        {
            try
            {
                if (CheckAccess())
                {
                    _treeNodes            = await obj.ArchivesTree;
                    _treeView.ItemsSource = _treeNodes;

                    SelectNode();

                    IsEnabled = true;
                }
                else
                {
                    await Dispatcher.Invoke(async() => await RefreshContent(obj));
                }
            }
            catch (Exception ex)
            {
                ClearContent();
                UiHelper.ShowError(this, ex);
            }
        }
Esempio n. 4
0
 private string FormatValue(long value)
 {
     return(_units == UiProgressUnits.Items ? value.ToString(CultureInfo.CurrentCulture) : UiHelper.FormatBytes(value));
 }