public EditorHelper() : base()
 {
     if (!CustomEditorHelper.Loaded)
     {
         CustomEditorHelper.Reload();
     }
 }
Exemplo n.º 2
0
        //4. SET COMBO DATA SOURCE AND VALUE

        //Listing 19-10. ComboBox Code File

        //        private void SetContentDataBinding()
        //        {
        //            if (!String.IsNullOrEmpty(ComboDisplayItem))
        //            {
        //                string str = @"<DataTemplate
        //            xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
        //            <TextBlock Text=""{Binding " + ComboDisplayItem + @"}"" />
        //              </DataTemplate>";

        //                Combo.ItemTemplate = (DataTemplate)XamlReader.Load(str);

        //                Binding selectedBinding = new Binding("Value");
        //                selectedBinding.Mode = BindingMode.TwoWay;
        //                Combo.SetBinding(
        //                  System.Windows.Controls.ComboBox.SelectedValueProperty,
        //                  selectedBinding);
        //            }
        //        }


        //Listing 19-12. ComboBox Control Code
        private void SetContentDataBinding()
        {
            if (ContentItem != null)
            {
                IEntityType entityType = ContentItem.ResultingDataType as IEntityType;
                if (ContentItem != null)
                {
                    string displayProperty = ComboDisplayItem;
                    if (string.IsNullOrEmpty(displayProperty))
                    {
                        displayProperty =
                            CustomEditorHelper.GetSummaryProperty(entityType).Name;
                    }

                    if (!string.IsNullOrEmpty(displayProperty))
                    {
                        string str = @"<DataTemplate
              xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
                   <TextBlock Text=""{Binding " +
                                     displayProperty + @"}"" /> </DataTemplate>";

                        Combo.ItemTemplate = (DataTemplate)XamlReader.Load(str);

                        Binding selectedBinding = new Binding("Value");
                        selectedBinding.Mode = BindingMode.TwoWay;
                        Combo.SetBinding(
                            System.Windows.Controls.ComboBox.SelectedValueProperty,
                            selectedBinding);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public object Convert(object value, System.Type targetType,
                              object parameter, System.Globalization.CultureInfo culture)
        {
            List <string> textProperties = new List <string>();

            textProperties.Add(string.Empty);

            IContentItemDefinition contentItemDefinition =
                value as IContentItemDefinition;

            if (contentItemDefinition != null)
            {
                IEntityType entityType =
                    contentItemDefinition.DataType as IEntityType;
                if (entityType != null)
                {
                    foreach (IPropertyDefinition p in
                             CustomEditorHelper.GetTextPropertiesForEntity(entityType))
                    {
                        textProperties.Add(p.Name);
                    }
                }
            }
            return(textProperties);
        }
Exemplo n.º 4
0
 GetTextPropertiesForEntity(IDataType dataType)
 {
     if (dataType != null)
     {
         return(dataType.Properties.Where(
                    p => CustomEditorHelper.IsTextProperty(p)
                    ).Cast <IPropertyDefinition>());
     }
     return(Enumerable.Empty <IPropertyDefinition>());
 }
Exemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            Rect levelCamerasRect = EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            EditorGUILayout.LabelField("Level Cameras", EditorStyles.boldLabel);
            CustomEditorHelper.DrawProperty(isStuntTriggerProperty);

            if (isStuntTriggerProperty.boolValue)
            {
                CustomEditorHelper.DrawProperty(linkedStuntProperty);
            }
            else
            {
                EditorGUI.indentLevel++;
                CustomEditorHelper.DrawProperty(linkedCamerasProperty);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Shot Determination", EditorStyles.boldLabel);
            if (isStuntTriggerProperty.boolValue)
            {
                CustomEditorHelper.DrawProperty(levelShotWeightProperty, "stuntShotWeight");
            }
            else
            {
                CustomEditorHelper.DrawProperty(levelShotWeightProperty);
            }
            CustomEditorHelper.DrawProperty(mountedShotWeightProperty);

            if (!isStuntTriggerProperty.boolValue && levelShotWeightProperty.floatValue > 0 && linkedCamerasProperty.arraySize == 0)
            {
                EditorGUILayout.HelpBox("WARNING: Level shot weight is above 0, but there are no linked cameras set!", MessageType.Warning);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Track Values (Read Only)", EditorStyles.boldLabel);
            CustomEditorHelper.DrawPropertyReadOnlyLabel(distanceAlongTrackProperty, distanceAlongTrackProperty.floatValue.ToString());
            CustomEditorHelper.DrawPropertyReadOnlyLabel(percentageAlongTrackProperty, percentageAlongTrackProperty.floatValue.ToString("##0.0") + "%");
            CustomEditorHelper.DrawPropertyReadOnlyLabel(closestPointOnTrackProperty, closestPointOnTrackProperty.vector3Value.ToString());
            CustomEditorHelper.DrawPropertyReadOnlyLabel(trackDirectionProperty, trackDirectionProperty.vector3Value.ToString());
            CustomEditorHelper.DrawPropertyReadOnlyLabel(trackPerpendicularProperty, trackPerpendicularProperty.vector3Value.ToString());
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Snap To Track"))
            {
                SnapToTrack();
            }
            EditorGUILayout.HelpBox("NOTE: The trigger's automatic snapping feature doesn't work if an inspector is in debug mode.", MessageType.Info);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 6
0
    private static IEntityPropertyDefinition GetFirstEntityProperty(
        IEntityType entityType)
    {
        // Simple types are non business types/ non navigation properties
        IEnumerable <IEntityPropertyDefinition> simpleTypeProperties =
            entityType.Properties.Where(p => p.PropertyType is ISimpleType);

        // Find the first string property, or the first one that can
        // be represented as a string
        IEntityPropertyDefinition defaultSummaryProperty =
            simpleTypeProperties.FirstOrDefault(
                p => CustomEditorHelper.GetBaseSystemType(
                    (ISimpleType)p.PropertyType) == typeof(string)) ??
            simpleTypeProperties.FirstOrDefault(
                p => CustomEditorHelper.IsTextProperty(p));

        return(defaultSummaryProperty);
    }
Exemplo n.º 7
0
    protected virtual void ApplyConnect()
    {
        if (currentNode != null)
        {
            CustomEditorHelper.DrawConnection(currentNode.BezierStartPosition, Event.current.mousePosition);
            if (Event.current.type != EventType.MouseDown)
            {
                return;
            }
            switch (Event.current.button)
            {
            case 0:
                var isConnected = false;
                foreach (var node in nodes)
                {
                    if (!node.FullRect.Contains(Event.current.mousePosition))
                    {
                        continue;
                    }
                    currentNode.CurrentJointPoint.Connect(node);
                    isConnected = true;
                    break;
                }
                if (!isConnected)
                {
                    currentNode.CurrentJointPoint.Connect(null);
                }
                CurrentState = WindowState.None;
                break;

            case 1:
                CurrentState = WindowState.ContextMenu;
                break;
            }
        }
        else
        {
            CurrentState = WindowState.None;
        }
    }
Exemplo n.º 8
0
 public virtual void DrawConnections()
 {
     foreach (var child in Children)
     {
         //Debug.Log(string.Format("Length of {0}'s joints:{1}", child.ElementName, child.joints.Count));
         foreach (var point in child.joints)
         {
             if (point.TargetId == NothingId)
             {
                 continue;
             }
             var startPoint      = Position + child.Position + point.Offset + new Vector2(0, Size.y);
             var destinationNode = point.Target.Parent;
             if (destinationNode == null)
             {
                 continue;
             }
             var endPoint = point.Target.Parent.Position + destinationNode.joints [0].Offset;
             CustomEditorHelper.DrawConnection(startPoint, endPoint);
         }
     }
 }
Exemplo n.º 9
0
        public override void OnInspectorGUI()
        {
            CustomEditorHelper.DrawPropertyWithTooltip(overrideWorldUpProperty, "Overriding the world up allows this camera's vertical axis to be freely oriented in space.");

            EditorGUILayout.HelpBox("NOTE: The green gizmo line indicates the world up for this camera. The blue gizmo line indicates the forward relative to world up.", MessageType.Info);

            if (overrideWorldUpProperty.boolValue)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Snapping Camera Rotation", EditorStyles.boldLabel);
                if (GUILayout.Button(CinematicCamera.ALIGN_ROTATION_FUNCTION_NAME))
                {
                    Script.AlignCameraRotationWithTrack();
                }

                if (GUILayout.Button(CinematicCamera.ALIGN_UP_FUNCTION_NAME))
                {
                    Script.AlignCameraUpWithTrack();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }