private void UpdateSelectedItem()
        {
            ++_updating;
            try
            {
                _depItems.OnGet();

                if (base.DropDownStyle != ComboBoxStyle.DropDownList)
                {
                    // If the control allows typing, then the text
                    // determines the selected item.
                    _depText.OnGet();
                    _selectedIndex = IndexOfText(base.Text);
                }
                else if (GetSelectedItem != null)
                {
                    // If the event is defined, use it to get the selected item.
                    _selectedIndex     = IndexOfTag(GetSelectedItem());
                    base.SelectedIndex = _selectedIndex;
                }
                else
                {
                    _dynSelectedItem.OnGet();
                }
            }
            finally
            {
                --_updating;
            }
        }
Beispiel #2
0
 protected override object GetValue()
 {
     if (_depProperty.IsNotUpdating)
     {
         _depProperty.OnGet();
     }
     return(_value);
 }
Beispiel #3
0
 private void UpdateItemValue()
 {
     _depItems.OnGet();
     foreach (DependentDataRow dependentDataRow in _rows)
     {
         dependentDataRow.OnGetValue();
     }
 }
Beispiel #4
0
        private void UpdateSelectedItem()
        {
            ++_updating;
            try
            {
                _depItems.OnGet();

                if (base.SelectionMode == SelectionMode.One)
                {
                    // Honor single selection.
                    if (GetSelectedItem != null)
                    {
                        // If the event is defined, use it to get the selected item.
                        base.SelectedIndex = IndexOfTag(GetSelectedItem());
                    }
                    else
                    {
                        _dynSelectedItem.OnGet();
                    }
                }
                else if (base.SelectionMode == SelectionMode.MultiSimple ||
                         base.SelectionMode == SelectionMode.MultiExtended)
                {
                    // Honor multiple selection.
                    if (GetItemSelected != null)
                    {
                        // If the event is defined, use it to get the selected items.
                        base.BeginUpdate();
                        try
                        {
                            int       index = 0;
                            ArrayList items = new ArrayList(base.Items);
                            foreach (ListBoxItem item in items)
                            {
                                bool selected = item.Selected;
                                if (base.GetSelected(index) != selected)
                                {
                                    base.SetSelected(index, selected);
                                }
                                ++index;
                            }
                        }
                        finally
                        {
                            base.EndUpdate();
                        }
                    }
                    else
                    {
                        _dynSelectedItem.OnGet();
                    }
                }
            }
            finally
            {
                --_updating;
            }
        }
 private void UpdateRecursive()
 {
     _depNodes.OnGet();
     base.BeginUpdate();
     foreach (DependentTreeNode item in base.Nodes)
     {
         item.OnGetRecursive();
     }
     base.EndUpdate();
 }
        public void UpdateNow()
        {
            if (_provider.IsCollection)
            {
                _depValue.OnGet();

                // Create a list of new items.
                List <CollectionItem> items = new List <CollectionItem>();

                // Dump all previous items into a recycle bin.
                using (RecycleBin <CollectionItem> bin = new RecycleBin <CollectionItem>())
                {
                    foreach (object oldItem in _collection)
                    {
                        bin.AddObject(new CollectionItem(_collection, oldItem, true));
                    }
                    // Add new objects to the list.
                    if (_sourceCollection != null)
                    {
                        foreach (object obj in _sourceCollection)
                        {
                            items.Add(bin.Extract(new CollectionItem(_collection, WrapValue(obj), false)));
                        }
                    }
                    _sourceCollection = null;
                    // All deleted items are removed from the collection at this point.
                }
                // Ensure that all items are added to the list.
                int index = 0;
                foreach (CollectionItem item in items)
                {
                    item.EnsureInCollection(index);
                    ++index;
                }
            }
            else
            {
                object oldValue = _value;
                _depValue.OnGet();
                object newValue = _value;

                if (_initialized)
                {
                    if ((!Object.Equals(newValue, oldValue)))
                    {
                        _wrapper.FirePropertyChanged(_propertyInfo.Name);
                    }
                }
                else
                {
                    _initialized = true;
                }
            }
        }
 public void Defer(Dependent dependent)
 {
     if (UnitTestDispatcher.On)
     {
         UnitTestDispatcher.Defer(delegate { dependent.OnGet(); });
     }
     else
     {
         Dispatcher.BeginInvoke(delegate { dependent.OnGet(); });
     }
 }
        public Point GetCenterByThought(Thought thought)
        {
            _depCenterByThought.OnGet();
            InertialProperty x;
            InertialProperty y;

            if (_inertialXByThought.TryGetValue(thought, out x) &&
                _inertialYByThought.TryGetValue(thought, out y))
            {
                return(new Point(x.Value, y.Value));
            }
            else
            {
                return(new Point(0.0, 0.0));
            }
        }
Beispiel #9
0
 public void UpdateNow()
 {
     using (NotificationGate.BeginOutbound())
     {
         _depProperty.OnGet();
     }
 }
 public void DoesNotGainDependentOnSecondUse()
 {
     _dependent.OnGet();
     _gained = false;
     _secondDependent.OnGet();
     Assert.IsFalse(_gained, "The independent should not have gained a dependent.");
 }
 private void Application_Idle(object sender, EventArgs e)
 {
     // Update all dependent sentries.
     _depEnabled.OnGet();
     _depItems.OnGet();
     _depItemCheckState.OnGet();
 }
Beispiel #12
0
 public override void UpdateNodes()
 {
     _depCollection.OnGet();
     foreach (IObjectInstance child in _children)
     {
         child.UpdateNodes();
     }
 }
Beispiel #13
0
 public void Go()
 {
     _depQueue.OnGet();
     foreach (T item in _queue)
     {
         _automaton.Process(item);
     }
 }
Beispiel #14
0
        public static Dependent UpdateWhenNecessary(this DependencyObject dependencyObject, Action update)
        {
            Dependent dependent = new Dependent(update);

            dependent.Invalidated += () => dependencyObject.Dispatcher.BeginInvoke(() => dependent.OnGet());
            dependent.OnGet();
            return(dependent);
        }
 private void Application_Idle(object sender, EventArgs e)
 {
     // Update all dependent sentries.
     _depText.OnGet();
     _depEnabled.OnGet();
     _depItems.OnGet();
     _depSelectedItem.OnGet();
 }
Beispiel #16
0
 private void Application_Idle(object sender, EventArgs e)
 {
     // Update all dependent sentries.
     _depEnabled.OnGet();
     _depSelection.OnGet();
     _depAnnuallyBoldedDates.OnGet();
     _depMonthlyBoldedDates.OnGet();
     _depBoldedDates.OnGet();
 }
Beispiel #17
0
 private void Application_Idle(object sender, EventArgs e)
 {
     // Update all dependent sentries.
     if (!this.Capture)
     {
         _depEnabled.OnGet();
         _depItems.OnGet();
         _depSelectedItem.OnGet();
     }
 }
 private void Application_Idle(object sender, EventArgs e)
 {
     if (!this.Capture)
     {
         // Update all dependent sentries.
         _depEnabled.OnGet();
         _depNodes.OnGet();
         _depRecursive.OnGet();
     }
 }
Beispiel #19
0
 public Relay(Actuator actuator, IAutomaton <T> automaton)
 {
     _automaton             = automaton;
     _depQueue              = new Dependent(UpdateQueue);
     _depQueue.Invalidated += delegate
     {
         actuator.RequestTrigger(this);
     };
     _depQueue.OnGet();
 }
 public override void UpdateNodes()
 {
     using (NotificationGate.BeginOutbound())
     {
         _depProperty.OnGet();
     }
     if (_child != null)
     {
         _child.UpdateNodes();
     }
 }
 private void UpdateNow()
 {
     _depCollection.OnGet();
     if (_delay != null)
     {
         // Update the observable collection outside of the update method
         // so we don't take a dependency on item template properties.
         _delay();
         _delay = null;
     }
 }
Beispiel #22
0
        public static Dependent WhenNecessary(Action updateMethod)
        {
            var    dependent = new Dependent(updateMethod);
            Update update    = new Update(dependent);

            dependent.Invalidated += delegate
            {
                UpdateScheduler.ScheduleUpdate(update);
            };
            dependent.OnGet();
            return(dependent);
        }
        private void UpdateItemCheckState()
        {
            ++_updating;
            try
            {
                _depItems.OnGet();

                if (GetItemChecked != null || GetItemCheckState != null)
                {
                    // If the event is defined, use it to get the checked items.
                    base.BeginUpdate();
                    try
                    {
                        int       index = 0;
                        ArrayList items = new ArrayList(base.Items);
                        foreach (CheckedListBoxItem item in items)
                        {
                            CheckState checkState = item.CheckState;
                            if (base.GetItemCheckState(index) != checkState)
                            {
                                base.SetItemCheckState(index, checkState);
                            }
                            ++index;
                        }
                    }
                    finally
                    {
                        base.EndUpdate();
                    }
                }
                else
                {
                    _dynItemCheckState.OnGet();
                }
            }
            finally
            {
                --_updating;
            }
        }
 private void UpdateSelectedNode()
 {
     ++_updating;
     try
     {
         if (GetSelectedNode != null)
         {
             // Selection is dependent.
             base.SelectedNode = NodeFromTag(GetSelectedNode());
         }
         else
         {
             // Selection is dynamic.
             _depRecursive.OnGet();
             _dynSelectedNode.OnGet();
         }
     }
     finally
     {
         --_updating;
     }
 }
 private void UpdateRecursive()
 {
     _depText.OnGet();
     _depImageIndex.OnGet();
     _depNodes.OnGet();
     _dynWasExpanded.OnGet();
     if (_wasExpanded)
     {
         foreach (DependentTreeNode node in base.Nodes)
         {
             node.OnGetRecursive();
         }
     }
 }
Beispiel #26
0
        /// <summary>
        /// Turn on validation and determine whether any errors have been found.
        /// </summary>
        /// <returns>True if there are no errors.</returns>
        public bool Validate()
        {
            if (_containerControl != null)
            {
                // Turn on validation.
                _dynValidation.OnSet();
                _validation = true;

                // Update the error text.
                _visErrorText.OnGet();

                // Return false if any errors have been found.
                foreach (Control control in AllControls(_containerControl))
                {
                    if (!string.IsNullOrEmpty(errorProvider.GetError(control)))
                    {
                        return(false);
                    }
                }
            }

            // All controls have been validated.
            return(true);
        }
 private void Application_Idle(object sender, EventArgs e)
 {
     _depForms.OnGet();
 }
Beispiel #28
0
 public void UpdateNow()
 {
     _depCollection.OnGet();
 }
 public void UpdateNodes()
 {
     _depNodes.OnGet();
 }
Beispiel #30
0
        private void UpdateItems()
        {
            using (_updateController.BeginUpdating())
            {
                _depColumns.OnGet();
                if (GetItems != null)
                {
                    // Recycle the collection of items.
                    using (var recycleBin = _rows.Recycle())
                    {
                        int rowIndex = 0;
                        // Extract each item from the recycle bin.
                        foreach (object item in GetItems())
                        {
                            DependentDataRow dependentDataRow = recycleBin.Extract(
                                new DependentDataRow(this, _table, item, _updateController));
                            _rows.Add(dependentDataRow);
                            if (dependentDataRow.DataRow == null)
                            {
                                if (Object.Equals(dependentDataRow.Tag, _newTag))
                                {
                                    // The user just added this row.
                                    dependentDataRow.DataRow = _newRow;
                                    _newTag = null;
                                    _newRow = null;
                                }
                                else
                                {
                                    // Add the new row at this position.
                                    dependentDataRow.DataRow = _table.NewRow();
                                    _table.Rows.InsertAt(dependentDataRow.DataRow, rowIndex);
                                }
                            }
                            else if (_table.Rows[rowIndex] != dependentDataRow.DataRow)
                            {
                                int priorIndex = _table.Rows.IndexOf(dependentDataRow.DataRow);
                                if (priorIndex >= 0)
                                {
                                    // Save the data.
                                    object[] data = new object[_table.Columns.Count];
                                    for (int columnIndex = 0; columnIndex < _table.Columns.Count; ++columnIndex)
                                    {
                                        data[columnIndex] = dependentDataRow.DataRow[columnIndex];
                                    }

                                    // Move the existing row up to this position.
                                    _table.Rows.RemoveAt(priorIndex);
                                    dependentDataRow.DataRow = _table.NewRow();
                                    _table.Rows.InsertAt(dependentDataRow.DataRow, rowIndex);

                                    // Restore the data.
                                    for (int columnIndex = 0; columnIndex < _table.Columns.Count; ++columnIndex)
                                    {
                                        dependentDataRow.DataRow[columnIndex] = data[columnIndex];
                                    }
                                }
                            }
                            ++rowIndex;
                        }

                        // If we haven't seen the new row, then delete it.
                        if (_newTag != null)
                        {
                            _table.Rows.Remove(_newRow);
                            _newTag = null;
                            _newRow = null;
                        }
                    }
                }
            }
        }