Exemplo n.º 1
0
        /// <summary>
        /// Updates the viewmodel with the curent value from the view.
        /// </summary>
        protected override void UpdateViewModel()
        {
            base.UpdateViewModel();
            var viewModel = BindingManager.GetViewModelFor <TViewModel>(View);

            var valueToSet = ViewPropertyInfo.GetValue(Control, null);

            ViewModelPropertyInfo.SetValue(viewModel, valueToSet, null);
        }
Exemplo n.º 2
0
        private static void DoViewModelProperty(Type type, ViewModelPropertyInfo property)
        {
            if (property.IsCollectionProperty)
            {
                if (property.Property != null && property.Property.ObjectValue != null)
                {
                    EditorGUILayout.LabelField(property.Property.PropertyName, ((IList)property.Property.ObjectValue).Count.ToString());
                }
                return;
            }
            if (property.IsComputed)
            {
                if (property.Property != null && property.Property.ObjectValue != null)
                {
                    EditorGUILayout.LabelField(property.Property.PropertyName, property.Property.ObjectValue.ToString());
                }
                return;
            }
            else if (property.Property.ValueType == typeof(State))
            {
                EditorGUILayout.LabelField(property.Property.PropertyName, property.Property.ObjectValue.ToString());
                var _designerWidnow = InvertGraphEditor.DesignerWindow;
                if (_designerWidnow != null && _designerWidnow.DiagramDrawer != null)
                {
                    var items = _designerWidnow.DiagramDrawer.DiagramViewModel.GraphItems;

                    var objectValue = property.Property.ObjectValue as State;
                    if (objectValue != null)
                    {
                        var stateMachine = objectValue.StateMachine;

                        foreach (var item in items)
                        {
                            var stateNode = item as StateNodeViewModel;
                            if (stateNode != null)
                            {
                                stateNode.IsCurrentState = item.Name == objectValue.Name;
                            }
                            else if (stateMachine.LastTransition != null)
                            {
                                var connectionNode = item as ConnectionViewModel;
                                if (connectionNode != null)
                                {
                                    connectionNode.IsActive = stateMachine.LastTransition.Name ==
                                                              connectionNode.ConnectorA.ConnectorFor.Name;
                                }
                            }
                        }
                    }

                    //EditorWindow.GetWindow<ElementsDesigner>().Repaint();
                }

                return;
            }
            EditorGUI.BeginChangeCheck();
            object newValue     = null;
            object currentValue = property.Property.ObjectValue;
            var    propertyName = property.Property.PropertyName;
            var    isEnum       = property.IsEnum;

            newValue = DoTypeInspector(type, propertyName, currentValue, isEnum);

            if (EditorGUI.EndChangeCheck())
            {
                property.Property.ObjectValue = newValue;
            }
        }
Exemplo n.º 3
0
    private static void DoViewModelProperty(Type type, ViewModelPropertyInfo property)
    {
        if (property.IsCollectionProperty)
        {
            if (property.Property != null && property.Property.ObjectValue != null)
            EditorGUILayout.LabelField(property.Property.PropertyName, ((IList)property.Property.ObjectValue).Count.ToString());
            return;
        }
        if (property.IsComputed)
        {
            if (property.Property != null && property.Property.ObjectValue != null)
            EditorGUILayout.LabelField(property.Property.PropertyName, property.Property.ObjectValue.ToString());
            return;
        }
        else if (property.Property.ValueType == typeof(State))
        {
            EditorGUILayout.LabelField(property.Property.PropertyName, property.Property.ObjectValue.ToString());
            var _designerWidnow = uFrameEditor.DesignerWindow;
            if (_designerWidnow != null && _designerWidnow.DiagramDrawer != null)
            {
                var items = _designerWidnow.DiagramDrawer.DiagramViewModel.GraphItems;

                var objectValue = property.Property.ObjectValue as State;
                if (objectValue != null)
                {
                    var stateMachine = objectValue.StateMachine;

                    foreach (var item in items)
                    {
                        var stateNode = item as StateMachineStateNodeViewModel;
                        if (stateNode != null)
                        {
                            stateNode.IsCurrentState = item.Name == objectValue.Name;
                        }
                        else if (stateMachine.LastTransition != null)
                        {
                            var connectionNode = item as ConnectionViewModel;
                            if (connectionNode != null)
                            {

                                connectionNode.IsActive = stateMachine.LastTransition.Name ==
                                                          connectionNode.ConnectorA.ConnectorFor.Name;
                            }
                        }

                    }
                }

                _designerWidnow.Repaint();
            }

            return;
        }
        EditorGUI.BeginChangeCheck();
        object newValue = null;
        object currentValue = property.Property.ObjectValue;
        var propertyName = property.Property.PropertyName;
        var isEnum = property.IsEnum;
        newValue = DoTypeInspector(type,  propertyName, currentValue, isEnum);

        if (EditorGUI.EndChangeCheck())
        {

            property.Property.ObjectValue = newValue;
        }
    }