Example #1
0
 void TimeValuesChanged(object sender, FunctionValuesChangingEventArgs e)
 {
     if (TimesChanged != null)
     {
         TimesChanged();
     }
 }
Example #2
0
 protected virtual void FireFunctionValuesChanged(object sender, FunctionValuesChangingEventArgs e)
 {
     if (FunctionValuesChanged != null)
     {
         FunctionValuesChanged(sender, e);
     }
 }
Example #3
0
        protected virtual void OnFunctionValuesAdd(FunctionValuesChangingEventArgs e)
        {
            if (function == null || function.IsEditing)
            {
                return;
            }

            if (!function.Arguments.Contains((IVariable)e.Function))
            {
                return;
            }

            // do nothing if at least 1 of arguments is empty
            if (function.Arguments.Any(a => a.Values.Count == 0))
            {
                return;
            }

            var shape        = function.Components[0].Values.Shape;
            var valuesPerRow = MultiDimensionalArrayHelper.GetTotalLength(shape.Skip(1).ToArray());
            var numRowsAdded = e.Items.Count;
            var rowsToAdd    = numRowsAdded * valuesPerRow;

            if (rowsToAdd > 0)
            {
                InsertRows(shape, rowsToAdd, e.Index);
            }
        }
Example #4
0
        private void OnFunctionValuesRemoved(FunctionValuesChangingEventArgs e)
        {
            var function = e.Function;

            if (!function.Arguments.Contains((IVariable)e.Function))
            {
                return;
            }

            // 1d case, faster implementation
            if (function.Arguments.Count == 1)
            {
                RemoveAt(e.Index);
                return;
            }

            var argumentIndex = function.Arguments.IndexOf((IVariable)e.Function);

            for (var i = Count - 1; i >= 0; i--)
            {
                if (this[i].Index[argumentIndex] == e.Index)
                {
                    AllowRemove = true;
                    RemoveAt(i);
                    AllowRemove = false;
                }
            }
        }
Example #5
0
        private void OnFunctionValuesAdded(FunctionValuesChangingEventArgs e)
        {
            var function = e.Function;

            if (!function.Arguments.Contains((IVariable)e.Function))
            {
                return;
            }

            // do nothing if at least 1 of arguments is empty
            if (function.Arguments.Any(a => a.Values.Count == 0))
            {
                return;
            }

            // get number of rows to insert
            var shape        = function.Components[0].Values.Shape;
            var valuesPerRow = MultiDimensionalArrayHelper.GetTotalLength(shape.Skip(1).ToArray());
            var numRowsAdded = e.Items.Count;
            var rowsToAdd    = numRowsAdded * valuesPerRow;

            var index = new int[shape.Length];

            for (var i = 0; i < rowsToAdd; i++)
            {
                Insert(e.Index, new MultipleFunctionBindingListRow(this));
                //rowIndices.Insert(e.Index, index);
                MultiDimensionalArrayHelper.IncrementIndex(index, shape, 0);
            }
        }
Example #6
0
        private void OnFunctionValuesChanged(object sender, FunctionValuesChangingEventArgs e)
        {
            if (function == null || function.IsEditing)
            {
                return;
            }

            //should not a delayedEventHandler be used?
            if (!DelayedEventHandlerController.FireEvents)
            {
                return;
            }

            if (changingFromGui)
            {
                return;
            }

            while (changing)
            {
                Wait();
            }

            changing = true;

            //find out the property descriptor for this function and raise event.
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Reset:
                Clear();
                changing = false;
                Fill();
                changing = true;
                break;

            case NotifyCollectionChangeAction.Replace:
                OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, e.Index));
                break;

            case NotifyCollectionChangeAction.Add:
                OnFunctionValuesAdd(e);
                break;

            case NotifyCollectionChangeAction.Remove:
                OnFunctionValuesRemoved(e);
                break;

            default:
                changing = false;
                throw new NotImplementedException(e.ToString());
            }

            if (FunctionValuesChanged != null)
            {
                FunctionValuesChanged(sender, e);
            }

            changing = false;
        }
Example #7
0
        protected virtual void LocationsValuesChanged(object sender, FunctionValuesChangingEventArgs e)
        {
            if (SegmentGenerationMethod != SegmentGenerationMethod.None)
            {
                segmentsInitialized = false;
            }

            initialized = false;
            return;
        }
Example #8
0
        protected virtual void OnFunctionValuesChanged(object sender, FunctionValuesChangingEventArgs e)
        {
            if (changingFromGui)
            {
                return;
            }

            while (changing)
            {
                Thread.Sleep(0); // wait until other change has been processed
            }

            changing = true;

            //find out the property descriptor for this function and raise event.
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Reset:
                Clear();
                changing = false;
                Fill();
                changing = true;
                break;

            case NotifyCollectionChangeAction.Replace:
                OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, e.Index));
                break;

            case NotifyCollectionChangeAction.Add:
                OnFunctionValuesAdded(e);
                break;

            case NotifyCollectionChangeAction.Remove:
                OnFunctionValuesRemoved(e);
                break;

            default:
                changing = false;
                throw new NotImplementedException(e.ToString());
            }

            FireFunctionValuesChanged(sender, e);

            changing = false;
        }
Example #9
0
        //TODO : split out some logic here. We do a unique values administration AND determine insertion index. Split.
        protected override void OnFunctionValuesChanging(FunctionValuesChangingEventArgs e)
        {
            if (!IsIndependent)
            {
                return;
            }

            var values = (IList <T>)Values;

            // check if we're replacing the same value
            if (e.Action == NotifyCollectionChangeAction.Replace && e.Items.Count == 1 &&
                (e.Items[0].Equals(values[e.Index])))
            {
                return;
            }

            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Replace:
            case NotifyCollectionChangeAction.Add:
                //objects need to be sorted as wel. Look at networklocations in a coverage.
                if (GenerateUniqueValueForDefaultValue)
                {
                    MakeItemValuesUnique(e, values);
                }

                if (e.Items.Cast <object>().Any(i => values.Contains((T)(i))))
                {
                    var message =
                        string.Format(
                            "Values added to independent variable must be unique, adding {0}index {1}",
                            e.Items.Cast <object>().Aggregate("", (current, item) => current + item + ", "),
                            e.Index);
                    throw new InvalidOperationException(message);
                }
                break;

            case NotifyCollectionChangeAction.Remove:
                break;

            default:
                break;
            }
        }
Example #10
0
        protected virtual void OnFunctionValuesRemoved(FunctionValuesChangingEventArgs e)
        {
            if (function == null || function.IsEditing)
            {
                return;
            }

            int argumentIndex = function.Arguments.IndexOf((IVariable)e.Function);

            if (!function.Arguments.Contains((IVariable)e.Function))
            {
                return;
            }

            var indicesToRemove = new List <int>();

            // 1d case, faster implementation
            if (function.Arguments.Count == 1)
            {
                var index = e.Index;
                for (var i = e.Items.Count - 1; i >= 0; i--)
                {
                    indicesToRemove.Add(index + i);
                }
            }
            else
            {
                for (var i = Count - 1; i >= 0; i--)
                {
                    if (this[i].Index[argumentIndex] == e.Index)
                    {
                        indicesToRemove.Add(i);
                    }
                }
            }

            if (indicesToRemove.Count > 0)
            {
                RemoveRows(indicesToRemove);
            }
        }
Example #11
0
        private void MakeItemValuesUnique(FunctionValuesChangingEventArgs e, IList <T> values)
        {
            var  previousValue        = default(T);
            bool previousValueDefined = false;

            if (values.Count != 0 && e.Index > 0)
            {
                previousValue        = values[e.Index - 1];
                previousValueDefined = true;
            }

            for (int i = 0; i < e.Items.Count; i++)
            {
                bool currentAndDefaultNull = false;

                var item = e.Items[i];

                if (item == null && DefaultValue == null)
                {
                    currentAndDefaultNull = true;
                }

                if (currentAndDefaultNull || item != null && item.Equals(DefaultValue))
                {
                    if (i > 0)
                    {
                        previousValue        = (T)e.Items[i - 1];
                        previousValueDefined = true;
                    }

                    if (previousValueDefined || currentAndDefaultNull)
                    {
                        e.Items[i] = GetNextValue(previousValue);
                        // add a new value using current DefaultStep (generate series)
                    }
                }
            }
        }
Example #12
0
 private void ValuesChanged(object sender, FunctionValuesChangingEventArgs e)
 {
     themeIsDirty        = true;
     base.RenderRequired = true;
 }
 private void RegularGridCoverage_ValuesChanged(object sender, FunctionValuesChangingEventArgs e)
 {
     isDirty = true;
 }
 private void Grid_ValuesChanged(object sender, FunctionValuesChangingEventArgs e)
 {
     RenderRequired = true;
 }
Example #15
0
        private void function_ValuesChanged(object sender, FunctionValuesChangingEventArgs e)
        {
            if (changingFromGui)
            {
                return;
            }

            while (changing)
            {
                Thread.Sleep(0); // wait until other change has been processed
            }

            changing = true;

            IFunction function = e.Function;

            //find out the property descriptor for this function and raise event.
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Reset:
                Clear();
                ResetBindings();
                changing = false;
                Fill();
                changing = true;
                break;

            case NotifyCollectionChangeAction.Replace:
                OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, e.Index));
                //                     log.DebugFormat("Function[{0}] value replaced {1}, number of rows: {2}", args.Function, e.Index, Count);
                break;

            case NotifyCollectionChangeAction.Add:
                // react only on chainges in arguments
                if (!function.Arguments.Contains((IVariable)e.Function))
                {
                    break;
                }

                // do nothing if at least 1 of arguments is empty
                if (function.Arguments.Any(a => a.Values.Count == 0))
                {
                    break;
                }

                // get number of rows to insert
                var shape = function.Components[0].Values.Shape;
                //TODO : this would be wrong if not the dimensions is added.
                var countValuesToInsert = MultiDimensionalArrayHelper.GetTotalLength(shape.Skip(1).ToArray());

                var index = new int[shape.Length];
                for (var i = 0; i < countValuesToInsert; i++)
                {
                    Insert(e.Index, new MultipleFunctionBindingListRow(this));
                    //rowIndices.Insert(e.Index, index);
                    MultiDimensionalArrayHelper.IncrementIndex(index, shape, 0);
                }


                //                    log.DebugFormat("Function[{0}] value added {1}, number of rows: {2}", args.Function, e.Index, Count);
                break;

            case NotifyCollectionChangeAction.Remove:
                // react only on chainges in arguments
                if (!function.Arguments.Contains((IVariable)e.Function))
                {
                    break;
                }

                // 1d case, faster implementation
                if (function.Arguments.Count == 1)
                {
                    RemoveAt(e.Index);
                    break;
                }

                var argumentIndex = function.Arguments.IndexOf((IVariable)e.Function);

                for (var i = Count - 1; i >= 0; i--)
                {
                    if (this[i].Index[argumentIndex] == e.Index)
                    {
                        AllowRemove = true;
                        RemoveAt(i);
                        AllowRemove = false;
                    }
                }

                //                    log.DebugFormat("Function[{0}] value removed {1}, number of rows: {2}", args.Function, e.Index, Count);
                break;

            default:
                changing = false;
                throw new NotImplementedException(e.ToString());
            }

            changing = false;
        }