Beispiel #1
0
        internal void SetEvaluation(VariableViewModel wrapper)
        {
            VsAppShell.Current.AssertIsOnMainThread();

            // Is the variable gone?
            if (wrapper.TypeName == null)
            {
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, wrapper.Expression));
                _evaluation = null;
                return;
            }

            ClearError();

            // Does it have the same size and shape? If so, can update in-place (without losing scrolling etc).
            if (_evaluation?.Dimensions.SequenceEqual(wrapper.Dimensions) == true)
            {
                VariableGrid.Refresh();
                return;
            }

            // Otherwise, need to refresh the whole thing from scratch.
            VariableGrid.Initialize(new GridDataProvider(wrapper));
            _evaluation = wrapper;
        }
Beispiel #2
0
        internal void SetEvaluation(IRSessionDataObject dataObject)
        {
            _services.MainThread().Assert();

            // Is the variable gone?
            if (dataObject.TypeName == null)
            {
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, dataObject.Expression));
                _evaluation = null;
                return;
            }

            ClearError();

            // Does it have the same size and shape? If so, can update in-place (without losing scrolling etc).
            if (_evaluation?.Dimensions.SequenceEqual(dataObject.Dimensions) == true)
            {
                VariableGrid.Refresh();
                return;
            }

            // Otherwise, need to refresh the whole thing from scratch.
            var session = _services.GetService <IRInteractiveWorkflowProvider>().GetOrCreate().RSession;

            VariableGrid.Initialize(new GridDataProvider(session, dataObject));
            _evaluation = dataObject;
        }
Beispiel #3
0
        internal void SetEvaluation(EvaluationWrapper evaluation)
        {
            ClearError();

            VariableGrid.Initialize(new GridDataProvider(evaluation));

            _evaluation = evaluation;

            if (_subscription != null)
            {
                _variableProvider.Unsubscribe(_subscription);
                _subscription = null;
            }

            _subscription = _variableProvider.Subscribe(
                evaluation.FrameIndex,
                evaluation.Expression,
                SubscribeAction);
        }
Beispiel #4
0
        internal void SetEvaluation(EvaluationWrapper wrapper)
        {
            if (wrapper.TypeName == "NULL" && wrapper.Value == "NULL")
            {
                // the variable should have been removed
                SetError(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Package.Resources.VariableGrid_Missing,
                        wrapper.Expression));
            }
            else if (wrapper.Dimensions.Count != 2)
            {
                // the same evaluation changed to non-matrix
                SetError(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Package.Resources.VariableGrid_NotTwoDimension,
                        wrapper.Expression));
            }
            else if (_evaluation == null ||
                     (wrapper.Dimensions[0] != _evaluation.Dimensions[0] || wrapper.Dimensions[1] != _evaluation.Dimensions[1]))
            {
                // matrix size changed. Reset the evaluation
                ClearError();

                VariableGrid.Initialize(new GridDataProvider(wrapper));

                _evaluation = wrapper;
            }
            else
            {
                ClearError();

                // size stays same. Refresh
                VariableGrid.Refresh();
            }
        }
        internal void SetEvaluation(VariableViewModel wrapper)
        {
            VsAppShell.Current.AssertIsOnMainThread();

            if (wrapper.TypeName == "NULL" && wrapper.Value == "NULL")
            {
                // the variable should have been removed
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, wrapper.Expression));
            }
            else if (_evaluation == null ||
                     (wrapper.Dimensions.Count == 2 && (wrapper.Dimensions[0] != _evaluation.Dimensions[0] || wrapper.Dimensions[1] != _evaluation.Dimensions[1])))
            {
                // matrix size changed. Reset the evaluation
                ClearError();
                VariableGrid.Initialize(new GridDataProvider(wrapper));
                _evaluation = wrapper;
            }
            else
            {
                ClearError();
                // size stays same. Refresh
                VariableGrid.Refresh();
            }
        }