예제 #1
0
        private void ApplyEyedropperTextElement(BaseTextElement textElement)
        {
            PropertyManager   propertyManager   = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform          = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata  = (IPlatformMetadata)platform.Metadata;
            Artboard          artboard          = this.ActiveView.Artboard;
            Matrix            matrix            = artboard.CalculateTransformFromArtboardToContent().Value;
            Matrix            transformFromRoot = this.ActiveView.GetComputedTransformFromRoot((SceneElement)textElement);
            Point             position          = this.MouseDevice.GetPosition((IInputElement)artboard);
            Point             point1            = matrix.Transform(position);
            Point             point2            = transformFromRoot.Transform(point1);

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)textElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object textValueAtPoint = textElement.GetTextValueAtPoint(point2, true, propertyReference2);
                        propertyManager.SetValue(propertyReference2, textValueAtPoint);
                    }
                }
            }
            this.UpdateEditTransaction();
        }
예제 #2
0
        private void ApplyEyedropper(SceneElement hitElement)
        {
            BaseTextElement textElement = hitElement as BaseTextElement;

            if (textElement != null)
            {
                this.ApplyEyedropperTextElement(textElement);
            }
            else
            {
                this.ApplyEyedropperSceneElement(hitElement);
            }
        }
예제 #3
0
        private void DrawProperties()
        {
            EditorGUILayout.LabelField(UIElementsDebugger.Styles.elementStylesContent, UIElementsDebugger.Styles.KInspectorTitle, new GUILayoutOption[0]);
            this.m_SelectedElement.name = EditorGUILayout.TextField("Name", this.m_SelectedElement.name, new GUILayoutOption[0]);
            BaseTextElement baseTextElement = this.m_SelectedElement as BaseTextElement;

            if (baseTextElement != null)
            {
                baseTextElement.text = EditorGUILayout.TextField("Text", baseTextElement.text, new GUILayoutOption[0]);
            }
            this.m_SelectedElement.clippingOptions = (VisualElement.ClippingOptions)EditorGUILayout.EnumPopup("Clipping Option", this.m_SelectedElement.clippingOptions, new GUILayoutOption[0]);
            this.m_SelectedElement.visible         = EditorGUILayout.Toggle("Visible", this.m_SelectedElement.visible, new GUILayoutOption[0]);
            EditorGUILayout.LabelField("Layout", this.m_SelectedElement.layout.ToString(), new GUILayoutOption[0]);
            EditorGUILayout.LabelField("World Bound", this.m_SelectedElement.worldBound.ToString(), new GUILayoutOption[0]);
            if (this.m_ClassList == null)
            {
                this.InitClassList();
            }
            this.m_ClassList.DoLayoutList();
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            this.m_DetailFilter = EditorGUILayout.ToolbarSearchField(this.m_DetailFilter, new GUILayoutOption[0]);
            this.m_ShowDefaults = GUILayout.Toggle(this.m_ShowDefaults, UIElementsDebugger.Styles.showDefaultsContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_Sort         = GUILayout.Toggle(this.m_Sort, UIElementsDebugger.Styles.sortContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUILayout.EndHorizontal();
            VisualElementStylesData effectiveStyle = this.m_SelectedElement.effectiveStyle;
            bool flag = false;

            PropertyInfo[] array = (!this.m_Sort) ? UIElementsDebugger.k_FieldInfos : UIElementsDebugger.k_SortedFieldInfos;
            for (int i = 0; i < array.Length; i++)
            {
                PropertyInfo propertyInfo = array[i];
                if (string.IsNullOrEmpty(this.m_DetailFilter) || propertyInfo.Name.IndexOf(this.m_DetailFilter, StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    if (propertyInfo.PropertyType.IsGenericType && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(StyleValue <>))
                    {
                        object obj = propertyInfo.GetValue(this.m_SelectedElement, null);
                        EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        EditorGUI.BeginChangeCheck();
                        int num;
                        if (obj is StyleValue <float> )
                        {
                            StyleValue <float> styleValue = (StyleValue <float>)obj;
                            num = UIElementsDebugger.GetSpecificity <float>(styleValue);
                            if (this.m_ShowDefaults || num > 0)
                            {
                                styleValue.specificity = 2147483647;
                                styleValue.value       = EditorGUILayout.FloatField(propertyInfo.Name, ((StyleValue <float>)obj).value, new GUILayoutOption[0]);
                                obj = styleValue;
                            }
                        }
                        else if (obj is StyleValue <int> )
                        {
                            StyleValue <int> styleValue2 = (StyleValue <int>)obj;
                            num = UIElementsDebugger.GetSpecificity <int>(styleValue2);
                            if (this.m_ShowDefaults || num > 0)
                            {
                                styleValue2.specificity = 2147483647;
                                styleValue2.value       = EditorGUILayout.IntField(propertyInfo.Name, ((StyleValue <int>)obj).value, new GUILayoutOption[0]);
                                obj = styleValue2;
                            }
                        }
                        else if (obj is StyleValue <bool> )
                        {
                            StyleValue <bool> styleValue3 = (StyleValue <bool>)obj;
                            num = UIElementsDebugger.GetSpecificity <bool>(styleValue3);
                            if (this.m_ShowDefaults || num > 0)
                            {
                                styleValue3.specificity = 2147483647;
                                styleValue3.value       = EditorGUILayout.Toggle(propertyInfo.Name, ((StyleValue <bool>)obj).value, new GUILayoutOption[0]);
                                obj = styleValue3;
                            }
                        }
                        else if (obj is StyleValue <Color> )
                        {
                            StyleValue <Color> styleValue4 = (StyleValue <Color>)obj;
                            num = UIElementsDebugger.GetSpecificity <Color>(styleValue4);
                            if (this.m_ShowDefaults || num > 0)
                            {
                                styleValue4.specificity = 2147483647;
                                styleValue4.value       = EditorGUILayout.ColorField(propertyInfo.Name, ((StyleValue <Color>)obj).value, new GUILayoutOption[0]);
                                obj = styleValue4;
                            }
                        }
                        else if (obj is StyleValue <Font> )
                        {
                            num = this.HandleReferenceProperty <Font>(propertyInfo, ref obj);
                        }
                        else if (obj is StyleValue <Texture2D> )
                        {
                            num = this.HandleReferenceProperty <Texture2D>(propertyInfo, ref obj);
                        }
                        else
                        {
                            Type type = obj.GetType();
                            if (type.GetGenericArguments()[0].IsEnum)
                            {
                                num = (int)type.GetField("specificity", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
                                if (this.m_ShowDefaults || num > 0)
                                {
                                    FieldInfo field = type.GetField("value");
                                    Enum      @enum = field.GetValue(obj) as Enum;
                                    Enum      enum2 = EditorGUILayout.EnumPopup(propertyInfo.Name, @enum, new GUILayoutOption[0]);
                                    if (!object.Equals(@enum, enum2))
                                    {
                                        field.SetValue(obj, enum2);
                                    }
                                }
                            }
                            else
                            {
                                EditorGUILayout.LabelField(propertyInfo.Name, (obj != null) ? obj.ToString() : "null", new GUILayoutOption[0]);
                                num = -1;
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            flag = true;
                            propertyInfo.SetValue(this.m_SelectedElement, obj, null);
                        }
                        if (num > 0)
                        {
                            GUILayout.Label((num != 2147483647) ? num.ToString() : "inline", new GUILayoutOption[0]);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            if (flag)
            {
                this.m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Transform);
                this.m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Styles);
                this.m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Layout);
                this.m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Repaint);
                this.m_CurPanel.Value.View.RepaintImmediately();
            }
        }