Пример #1
0
 private void CheckResetCounters()
 {
     lock (_sync)
     {
         bool changed = false;
         var  now     = DateTime.Now;
         if (!(now.Year == _lastCall.Year && now.Month == _lastCall.Month))
         {
             _callsThisMonth  = 0;
             _callsToday      = 0;
             _callsThisMinute = 0;
         }
         else if (now.Date != _lastCall.Date)
         {
             _callsToday      = 0;
             _callsThisMinute = 0;
         }
         else if (now.Hour != _lastCall.Hour || now.Minute != _lastCall.Minute)
         {
             _callsThisMinute = 0;
         }
         if (changed)
         {
             saveActions.StartDelayedAction("save", Save, TimeSpan.FromSeconds(1));
         }
     }
 }
Пример #2
0
 void AliasDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
 {
     // There seems to be a bug in WPF where this is called before the final editing cell is committed!
     // For example, I change Alias type to Regex, hit ENTER and this is called before Alias.Type is changed to Regex!
     rowEdit = e.Row.DataContext as Alias;
     delayedActions.StartDelayedAction("FindConflicts", FindConflicts, TimeSpan.FromMilliseconds(30));
 }
Пример #3
0
 private void ContextMenu_ContextMenuClosing(object sender, ContextMenuEventArgs e)
 {
     // tooltips are too quick to restart and lock tooltip picks up the new location before it can lock the original.
     _delayedUpdates.StartDelayedAction("SlowRestoreTooltips", () =>
     {
         anyContextMenuOpen = false;
     }, TimeSpan.FromSeconds(1));
 }
Пример #4
0
        // There is a weird bug in DataGrid that blows if there is a sort in place when items are changed.
        //
        //System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: 'Sorting' is not allowed during an AddNew or EditItem transaction.
        //at System.Windows.Data.ListCollectionView.SortDescriptionsChanged(Object sender, NotifyCollectionChangedEventArgs e)
        //at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
        //at System.Windows.Controls.ItemCollection.CloneList(IList clone, IList master)
        //at System.Windows.Controls.ItemCollection.SynchronizeSortDescriptions(NotifyCollectionChangedEventArgs e, SortDescriptionCollection origin, SortDescriptionCollection clone)
        //at System.Windows.Controls.ItemCollection.SortDescriptionsChanged(Object sender, NotifyCollectionChangedEventArgs e)
        //at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
        //at System.Windows.Controls.DataGrid.ClearSortDescriptionsOnItemsSourceChange()
        //at System.Windows.Controls.DataGrid.OnCoerceItemsSourceProperty(DependencyObject d, Object baseValue)
        //at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
        //at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
        //at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
        //at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
        //at Walkabout.Views.Controls.TransactionsView.Display(IList data, TransactionViewName name, String caption, Int64 selectedRowId)
        public void SetItemsSource(IEnumerable items)
        {
            ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;

            if (view != null)
            {
                if (view.IsAddingNew || view.IsEditingItem)
                {
                    if (view.IsAddingNew)
                    {
                        try
                        {
                            view.CancelNew();
                        }
                        catch
                        {
                        }
                    }
                    else if (view.IsEditingItem)
                    {
                        try
                        {
                            view.CancelEdit();
                        }
                        catch
                        {
                            // sometimes this throws but also removes IsEditing...
                        }
                    }
                }
            }

            var sorted = RemoveSort();

            if (sorted != null)
            {
                this.sorted = sorted;
            }
            try
            {
                // sometimes we get a weird exception saying
                // 'DeferRefresh' is not allowed during an AddNew or EditItem transaction
                this.ItemsSource = items;
            }
            catch (Exception ex)
            {
                // I want to see these errors
                if (MessageBoxEx.Show(ex.ToString() + "\n\nDo you want to try again?", "Debug Error", MessageBoxButton.OKCancel, MessageBoxImage.Error) == MessageBoxResult.OK)
                {
                    // and try again later...at low priority so that the UI has a chance to settle down...
                    delayedActions.StartDelayedAction("SetItemsSource", () =>
                    {
                        SetItemsSource(items);
                    }, TimeSpan.FromMilliseconds(10));
                }
            }
        }
 private void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.port != null && this.Tabs.SelectedItem == LogTab && !logTabSelected)
     {
         logList.Clear();
         delayedActions.StartDelayedAction("GetList", OnGetList, TimeSpan.FromMilliseconds(100));
     }
     logTabSelected = (this.Tabs.SelectedItem == LogTab);
 }
Пример #6
0
 private void DelayedSave()
 {
     if (!string.IsNullOrEmpty(_logFolder))
     {
         delayedActions.StartDelayedAction("save", new Action(() => { Save(_logFolder); }), TimeSpan.FromSeconds(1));
     }
 }
Пример #7
0
        void TrendGraph_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta != 0)
            {
                int spinIndex = e.Delta / 120;
                int direction = spinIndex < 0 ? -1 : 1;
                spinIndex = Math.Abs(spinIndex);

                if (spinIndex >= mouseWheelDateSteps.Length)
                {
                    spinIndex = mouseWheelDateSteps.Length - 1;
                }
                CalendarRange scrollAmount = mouseWheelDateSteps[spinIndex];

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    // pan
                    this.start      = Step(this.start, scrollAmount, 1, direction);
                    this.end        = Step(this.end, scrollAmount, 1, direction);
                    this.yearToDate = false;
                    this.showAll    = false;
                }
                else
                {
                    // zoom.
                    this.start      = Step(this.start, scrollAmount, 1, direction);
                    this.yearToDate = false;
                    this.showAll    = false;
                }

                Pin();
                delayedActions.StartDelayedAction("update_graph", GenerateGraph, TimeSpan.FromMilliseconds(100));
            }
        }
Пример #8
0
 private void Settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     saveActions.StartDelayedAction("Save Settings", new Action(async() =>
     {
         await settings.SaveAsync();
     }), TimeSpan.FromSeconds(1));
 }
Пример #9
0
 void CheckState()
 {
     EnableButtons();
     if (!string.IsNullOrWhiteSpace(this.textBox1.Text))
     {
         delayedActions.StartDelayedAction("CheckConflicts", CheckConflicts, TimeSpan.FromMilliseconds(50));
     }
 }
Пример #10
0
 public override void WriteLine(string message)
 {
     if (message == null)
     {
         return;
     }
     lock (pending)
     {
         pending.Add(message);
     }
     if (!actionPending)
     {
         actionPending = true;
         delayedActions.StartDelayedAction("Update", OnUpdate, TimeSpan.FromMilliseconds(30)); // 30fps is plenty
     }
 }
Пример #11
0
 private void OnWindowLocationChanged(object sender, EventArgs e)
 {
     delayedActions.StartDelayedAction("SaveWindowLocation", SavePosition, TimeSpan.FromMilliseconds(1000));
 }
Пример #12
0
 void DelayedUpdate()
 {
     delayedActions.StartDelayedAction("update", UpdateChart, TimeSpan.FromMilliseconds(1));
 }
Пример #13
0
 void DelayedSaveSettings()
 {
     Settings.Instance.Model.EnsureNewItem();
     delayedActions.StartDelayedAction("SaveSettings", OnSaveSettings, TimeSpan.FromSeconds(1));
 }
 void DelayedUpdate()
 {
     _delayedUpdates.StartDelayedAction("Update", UpdateChart, TimeSpan.FromMilliseconds(30));
 }
Пример #15
0
 private void OnDelayedUpdate()
 {
     actions.StartDelayedAction("update", UpdateLegend, TimeSpan.FromMilliseconds(10));
 }
Пример #16
0
 void OnBalanceChanged(object sender, ChangeEventArgs args)
 {
     delayedActions.StartDelayedAction("rebind", Rebind, TimeSpan.FromMilliseconds(30));
 }
Пример #17
0
 private void OnSeriesColorChanged()
 {
     delayedActions.StartDelayedAction("update", Relayout, TimeSpan.FromMilliseconds(10));
 }