Example #1
0
        private void RefreshConfigs()
        {
            checkerFileInfos = CheckerUtility.ReadCheckerFileInfos();

            selectedCheckerFileInfo = null;
            checkerDrawer           = null;

            if (configListView != null)
            {
                configListView.Clear();
            }
            else
            {
                configListView = new EasyListView();
                configListView.HeaderContent    = "Checker File List";
                configListView.OnSelectedChange = (selected) =>
                {
                    SetSelected((CheckerFileInfo)selected);
                };
            }
            foreach (var cfi in checkerFileInfos)
            {
                configListView.AddItem(Path.GetFileNameWithoutExtension(cfi.filePath), cfi);
            }
        }
Example #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(color);
            ObjectDrawer.Draw(spriteBatch, positionRepository);

            base.Draw(gameTime);
        }
        public override void DrawFields(FieldInfo fieldInfo)
        {
            if (fieldInfo.Name == "anim")
            {
                GUIContent lable     = new GUIContent(fieldInfo.Name);
                float      tmpHeight = GUIExtension.GetHeight(fieldInfo.FieldType, lable);

                UnityObjectAsset oldObj       = (UnityObjectAsset)fieldInfo.GetValue(Target);
                ObjectDrawer     objectDrawer = ObjectDrawer.CreateEditor(oldObj);
                objectDrawer.OnGUI(EditorGUILayout.GetControlRect(true, tmpHeight), lable);
                if (GUILayout.Button("设置为动画时长"))
                {
                    AnimationClip clip = (AnimationClip)oldObj.GetObj();
                    if (clip != null)
                    {
                        ClipModel clipModel = Target as ClipModel;
                        clipModel.SetEnd(clipModel.StartTime + clip.length);
                    }
                }
            }
            else
            {
                base.DrawFields(fieldInfo);
            }
        }
Example #4
0
 static StratusSerializedEditorObject()
 {
     foreach (Type drawerType in customObjectDrawers)
     {
         ObjectDrawer drawer     = (ObjectDrawer)StratusReflection.Instantiate(drawerType);
         Type         objectType = drawer.type;
         objectDrawers.Add(objectType, drawer);
     }
 }
Example #5
0
 static SerializedSystemObject()
 {
     foreach (var drawerType in customObjectDrawers)
     {
         ObjectDrawer drawer     = (ObjectDrawer)Reflection.Instantiate(drawerType);
         Type         objectType = drawer.type;
         objectDrawers.Add(objectType, drawer);
     }
 }
Example #6
0
        private void pictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            var location = e.Location;

            ObjectDrawer = new ObjectDrawer();
            ObjectDrawer.FloodFill(Bitmap, location, Color.Black);

            pictureBox.Refresh();
        }
Example #7
0
        private void polygonButton_Click(object sender, EventArgs e)
        {
            ObjectDrawer = new ObjectDrawer();

            var g = Graphics.FromImage(Bitmap);

            ObjectDrawer.DrawPolygon(g, pictureBox.Width, pictureBox.Height);

            pictureBox.Image = Bitmap;
        }
Example #8
0
        public static ObjectDrawer GetObjectDrawer(Type elementType)
        {
            if (!objectDrawers.ContainsKey(elementType))
            {
                objectDrawers.Add(elementType, new SerializedSystemObject.DefaultObjectDrawer(elementType));
            }
            ObjectDrawer drawer = objectDrawers[elementType];

            return(drawer);
        }
Example #9
0
        private void SmallLineRotation()
        {
            ObjectDrawer = new ObjectDrawer();

            var smallLinePointCoordinates = ObjectDrawer.Rotation(_x3, _y3, _x2, _y2, 10);

            _x3 = smallLinePointCoordinates.Item1;
            _y3 = smallLinePointCoordinates.Item2;

            ObjectDrawer.DrawLine(Graphics, Color.Black, _x2, _y2, _x3, _y3);
        }
Example #10
0
 private void SetSelected(CheckerFileInfo fileInfo)
 {
     selectedCheckerFileInfo = fileInfo;
     checkerDrawer           = null;
     if (selectedCheckerFileInfo != null)
     {
         checkerDrawer              = new ObjectDrawer(selectedCheckerFileInfo.checker);
         checkerDrawer.IsShowBox    = true;
         checkerDrawer.IsShowScroll = true;
     }
 }
Example #11
0
        /// <summary>
        /// Gets the object drawer for the given type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ObjectDrawer GetDrawer(FieldInfo field)
        {
            Type type = field.FieldType;

            if (!objectDrawers.ContainsKey(type))
            {
                objectDrawers.Add(type, new DefaultObjectDrawer(field, type));
            }
            ObjectDrawer drawer = objectDrawers[type];

            //drawer.SetDisplayName(field.Name);
            return(drawer);
        }
Example #12
0
        //------------------------------------------------------------------------/
        // Static Methods
        //------------------------------------------------------------------------/
        public static ObjectDrawer GetObjectDrawer(object element)
        {
            Type elementType = element.GetType();

            if (!objectDrawers.ContainsKey(elementType))
            {
                objectDrawers.Add(elementType, new StratusSerializedEditorObject.DefaultObjectDrawer(elementType));
            }

            ObjectDrawer drawer = objectDrawers[elementType];

            return(drawer);
        }
Example #13
0
        private void LineButton_Click(object sender, EventArgs e)
        {
            ObjectDrawer = new ObjectDrawer();

            var random = new Random();

            _x1 = random.Next(pictureBox.Width);
            _x2 = random.Next(pictureBox.Width);
            _y1 = random.Next(pictureBox.Height);
            _y2 = random.Next(pictureBox.Height);

            ObjectDrawer.DrawLine(pictureBox.CreateGraphics(), Color.Black, _x1, _y1, _x2, _y2);
        }
Example #14
0
        public void SetData(ActionData actionData)
        {
            m_ActionData = actionData;
            if (m_ActionData.GetType().IsSubclassOf(typeof(DurationActionData)))
            {
                m_DurationActionData = (DurationActionData)m_ActionData;
            }
            m_DataDrawer = new ObjectDrawer("Action Data", m_ActionData);

            m_ActionBriefName = string.Empty;
            var nameAttrs = m_ActionData.GetType().GetCustomAttributes(typeof(ActionBriefName), false);

            if (nameAttrs != null && nameAttrs.Length > 0)
            {
                m_ActionBriefName = ((ActionBriefName)nameAttrs[0]).Name;
            }
        }
        private void OnEnable()
        {
            NativeData nData = new NativeData();

            // nData.iBaseValue = new TDValue();

            nativeObject = new ObjectDrawer(nData)
            {
                IsShowInherit = true,
                IsShowScroll  = true,
                IsShowBox     = true,
                Header        = "Test For NativeData"
            };

            Type enumType = typeof(NativeEnum);

            Debug.Log(GetTypeInfo(enumType));
        }
Example #16
0
        private void TimerForRotation_Tick(object sender, EventArgs e)
        {
            ObjectDrawer = new ObjectDrawer();

            Graphics.FillRectangle(new SolidBrush(Color.Gray), 0, 0, pictureBox.Width, pictureBox.Height);

            var firstPointCoordinates  = ObjectDrawer.Rotation(_x4, _y4, pictureBox.Width / 2, pictureBox.Height / 2, 15);
            var secondPointCoordinates = ObjectDrawer.Rotation(_x2, _y2, pictureBox.Width / 2, pictureBox.Height / 2, 15);

            _x4 = firstPointCoordinates.Item1;
            _y4 = firstPointCoordinates.Item2;

            _x2 = secondPointCoordinates.Item1;
            _y2 = secondPointCoordinates.Item2;

            ObjectDrawer.DrawLine(Graphics, Color.Black, _x4, _y4, _x2, _y2);

            SmallLineRotation();
            ObjectDrawer.DrawLine(Graphics, Color.Black, pictureBox.Width / 2, pictureBox.Height / 2, _x2, _y2);
        }
Example #17
0
        private void LineRotationButton_Click(object sender, EventArgs e)
        {
            ObjectDrawer = new ObjectDrawer();

            Graphics = Graphics.FromHwnd(pictureBox.Handle);

            _x2 = pictureBox.Width / 2;
            _y2 = (pictureBox.Height / 2) - 100;

            _x4 = pictureBox.Width / 2;
            _y4 = (pictureBox.Height / 2) + 100;

            //ObjectDrawer.DrawLine(Graphics, Color.Black, _x4, _y4, _x2, _y2);

            ObjectDrawer.DrawLine(Graphics, Color.Black, _x2, _y2, _x3, _y3);
            ObjectDrawer.DrawLine(Graphics, Color.Black, pictureBox.Width / 2, pictureBox.Height / 2, _x2, _y2);
            _x3 = _x2;
            _y3 = _y2 - 50;

            Graphics.FillRectangle(new SolidBrush(Color.Gray), 0, 0, pictureBox.Width, pictureBox.Height);

            timerForRotation.Enabled = true;
        }
Example #18
0
 //------------------------------------------------------------------------/
 // CTOR
 //------------------------------------------------------------------------/
 public StratusSerializedEditorObject(object target) : base(target)
 {
     this.drawer = GetDrawer(target.GetType());
 }
Example #19
0
 /// <summary>
 /// 获得类型绘制高度
 /// </summary>
 /// <param name="type"></param>
 /// <param name="label"></param>
 /// <returns></returns>
 public static float GetHeight(Type type, GUIContent label)
 {
     if (type.Equals(typeof(bool)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Boolean, label));
     }
     if (type.Equals(typeof(byte)) || type.Equals(typeof(sbyte)) ||
         type.Equals(typeof(short)) || type.Equals(typeof(ushort)) ||
         type.Equals(typeof(int)) || type.Equals(typeof(uint)) ||
         type.Equals(typeof(long)) || type.Equals(typeof(ulong)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Integer, label));
     }
     if (type.Equals(typeof(float)) || type.Equals(typeof(double)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Float, label));
     }
     if (type.Equals(typeof(char)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Character, label));
     }
     if (type.Equals(typeof(string)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.String, label));
     }
     if (type.Equals(typeof(Color)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Color, label));
     }
     if (type.Equals(typeof(LayerMask)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.LayerMask, label));
     }
     if (type.Equals(typeof(Vector2)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector2, label));
     }
     if (type.Equals(typeof(Vector2Int)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector2Int, label));
     }
     if (type.Equals(typeof(Vector3)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector3, label));
     }
     if (type.Equals(typeof(Vector3Int)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector3Int, label));
     }
     if (type.Equals(typeof(Vector4)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector4, label));
     }
     if (type.Equals(typeof(Quaternion)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Quaternion, label));
     }
     if (type.Equals(typeof(Rect)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Rect, label));
     }
     if (type.Equals(typeof(RectInt)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.RectInt, label));
     }
     if (type.Equals(typeof(Bounds)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Bounds, label));
     }
     if (type.Equals(typeof(BoundsInt)))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.BoundsInt, label));
     }
     if (type.IsEnum)
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Enum, label));
     }
     if (typeof(Gradient).IsAssignableFrom(type))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.Gradient, label));
     }
     if (typeof(AnimationCurve).IsAssignableFrom(type))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.AnimationCurve, label));
     }
     if (typeof(UnityObject).IsAssignableFrom(type))
     {
         return(EditorGUI.GetPropertyHeight(SerializedPropertyType.ObjectReference, label));
     }
     if (ObjectDrawer.CheckHasCustomDrawer(type))
     {
         return(ObjectDrawer.GetHeight(type));
     }
     return(0);
 }
Example #20
0
        /// <summary>
        /// 绘制字段
        /// </summary>
        /// <param name="rect">区域</param>
        /// <param name="type">类型</param>
        /// <param name="value">值</param>
        /// <param name="label">名</param>
        /// <returns></returns>
        public static object DrawField(Rect rect, Type type, object value, GUIContent label)
        {
            if (value == null)
            {
                if (!typeof(UnityObject).IsAssignableFrom(type))
                {
                    value = CreateInstance(type);
                }
            }
            if (!IsSupport(type))
            {
                return(null);
            }
            if (type.IsEnum)
            {
                return(EditorGUI.EnumPopup(rect, label, (Enum)value));
            }
            if (type.Equals(typeof(bool)))
            {
                return(EditorGUI.Toggle(rect, label, value == null ? false : (bool)value));
            }
            if (type.Equals(typeof(short)) || type.Equals(typeof(ushort)) ||
                type.Equals(typeof(int)) || type.Equals(typeof(uint)))
            {
                return(EditorGUI.IntField(rect, label, value == null ? 0 : (int)value));
            }
            if (type.Equals(typeof(long)) || type.Equals(typeof(ulong)))
            {
                return(EditorGUI.LongField(rect, label, value == null ? 0 : (long)value));
            }
            if (type.Equals(typeof(float)))
            {
                return(EditorGUI.FloatField(rect, label, value == null ? 0 : (float)value));
            }
            if (type.Equals(typeof(double)))
            {
                return(EditorGUI.DoubleField(rect, label, value == null ? 0 : (double)value));
            }
            if (type.Equals(typeof(string)))
            {
                return(EditorGUI.TextField(rect, label, value == null ? "" : (string)value));
            }
            if (type.Equals(typeof(Vector2)))
            {
                return(EditorGUI.Vector2Field(rect, label, value == null ? Vector2.zero : (Vector2)value));
            }
            if (type.Equals(typeof(Vector2Int)))
            {
                return(EditorGUI.Vector2IntField(rect, label, value == null ? Vector2Int.zero : (Vector2Int)value));
            }
            if (type.Equals(typeof(Vector3)))
            {
                return(EditorGUI.Vector3Field(rect, label, value == null ? Vector3.zero : (Vector3)value));
            }
            if (type.Equals(typeof(Vector3Int)))
            {
                return(EditorGUI.Vector3IntField(rect, label, value == null ? Vector3Int.zero : (Vector3Int)value));
            }
            if (type.Equals(typeof(Vector4)))
            {
                return(EditorGUI.Vector4Field(rect, label, value == null ? Vector4.zero : (Vector4)value));
            }
            if (type.Equals(typeof(Quaternion)))
            {
                Quaternion quaternion = value == null ? Quaternion.identity : (Quaternion)value;
                Vector4    vector     = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
                vector = EditorGUI.Vector4Field(rect, label, vector);
                quaternion.Set(vector.x, vector.y, vector.z, vector.w);
                return(quaternion);
            }
            if (type.Equals(typeof(Color)))
            {
                return(EditorGUI.ColorField(rect, label, value == null ? Color.black : (Color)value));
            }
            if (type.Equals(typeof(Rect)))
            {
                return(EditorGUI.RectField(rect, label, value == null ? Rect.zero : (Rect)value));
            }
            if (type.Equals(typeof(AnimationCurve)))
            {
                return(EditorGUI.CurveField(rect, label, value == null ? AnimationCurve.EaseInOut(0f, 0f, 1f, 1f) : (AnimationCurve)value));
            }
            if (type.Equals(typeof(LayerMask)))
            {
                return((LayerMask)EditorGUI.LayerField(rect, label, (LayerMask)(value == null ? (-1) : value)));
            }
            if (typeof(UnityObject).IsAssignableFrom(type))
            {
                return(EditorGUI.ObjectField(rect, label, (UnityObject)value, type, true));
            }
            if (ObjectDrawer.CheckHasCustomDrawer(type))
            {
                ObjectDrawer objectDrawer = ObjectDrawer.CreateEditor(value);
                return(objectDrawer.OnGUI(rect, label));
            }

            return(null);
        }
        /// <summary>
        /// This method performs a translation and rotation to drawn an object in the world.
        /// </summary>
        /// <param name="e">PaintEventArgs to access the graphics (for drawing)</param>
        /// <param name="o">The object to draw</param>
        /// <param name="worldSize">The size of one edge of the world (assuming the world is square)</param>
        /// <param name="worldX">The X coordinate of the object in world space</param>
        /// <param name="worldY">The Y coordinate of the object in world space</param>
        /// <param name="angle">The orientation of the objec, measured in degrees clockwise from "up"</param>
        /// <param name="drawer">The drawer delegate. After the transformation is applied, the delegate is invoked to draw whatever it wants</param>
        public static void DrawObjectWithTransform(PaintEventArgs e, object o, int worldSize, double worldX, double worldY, double angle, ObjectDrawer drawer)
        {
            // "push" the current transform
            System.Drawing.Drawing2D.Matrix oldMatrix = e.Graphics.Transform.Clone();
            int x = WorldSpaceToImageSpace(worldSize, worldX);
            int y = WorldSpaceToImageSpace(worldSize, worldY);

            e.Graphics.TranslateTransform(x, y);
            e.Graphics.RotateTransform((float)angle);
            drawer(o, e);
            // "pop" the transform
            e.Graphics.Transform = oldMatrix;
        }
Example #22
0
 /// <summary>
 /// 是否是基元类型
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static bool IsBasicType(Type type)
 {
     if (type.Equals(typeof(bool)))
     {
         return(true);
     }
     if (type.Equals(typeof(byte)))
     {
         return(true);
     }
     if (type.Equals(typeof(sbyte)))
     {
         return(true);
     }
     if (type.Equals(typeof(short)))
     {
         return(true);
     }
     if (type.Equals(typeof(ushort)))
     {
         return(true);
     }
     if (type.Equals(typeof(int)))
     {
         return(true);
     }
     if (type.Equals(typeof(uint)))
     {
         return(true);
     }
     if (type.Equals(typeof(float)))
     {
         return(true);
     }
     if (type.Equals(typeof(double)))
     {
         return(true);
     }
     if (type.Equals(typeof(long)))
     {
         return(true);
     }
     if (type.Equals(typeof(ulong)))
     {
         return(true);
     }
     if (type.Equals(typeof(string)))
     {
         return(true);
     }
     if (type.Equals(typeof(char)))
     {
         return(true);
     }
     if (type.Equals(typeof(Vector2)))
     {
         return(true);
     }
     if (type.Equals(typeof(Vector2Int)))
     {
         return(true);
     }
     if (type.Equals(typeof(Vector3)))
     {
         return(true);
     }
     if (type.Equals(typeof(Vector3Int)))
     {
         return(true);
     }
     if (type.Equals(typeof(Vector4)))
     {
         return(true);
     }
     if (type.Equals(typeof(Quaternion)))
     {
         return(true);
     }
     if (type.Equals(typeof(Color)))
     {
         return(true);
     }
     if (type.Equals(typeof(Rect)))
     {
         return(true);
     }
     if (type.Equals(typeof(RectInt)))
     {
         return(true);
     }
     if (type.Equals(typeof(Bounds)))
     {
         return(true);
     }
     if (type.Equals(typeof(BoundsInt)))
     {
         return(true);
     }
     if (type.Equals(typeof(LayerMask)))
     {
         return(true);
     }
     if (type.IsEnum)
     {
         return(true);
     }
     if (typeof(Gradient).IsAssignableFrom(type))
     {
         return(true);
     }
     if (typeof(AnimationCurve).IsAssignableFrom(type))
     {
         return(true);
     }
     if (typeof(UnityObject).IsAssignableFrom(type))
     {
         return(true);
     }
     if (ObjectDrawer.CheckHasCustomDrawer(type))
     {
         return(true);
     }
     return(false);
 }
 public void SetData(object data)
 {
     m_BaseData   = (SkillBaseData)data;
     m_DataDrawer = new ObjectDrawer("Base Data", m_BaseData);
 }
Example #24
0
        /// <summary>
        /// This method performs a translation and rotation to drawn an object in the world.
        /// </summary>
        /// <param name="e">PaintEventArgs to access the graphics (for drawing)</param>
        /// <param name="o">The object to draw</param>
        /// <param name="worldSize">The size of one edge of the world (assuming the world is square)</param>
        /// <param name="worldX">The X coordinate of the object in world space</param>
        /// <param name="worldY">The Y coordinate of the object in world space</param>
        /// <param name="angle">The orientation of the objec, measured in degrees clockwise from "up"</param>
        /// <param name="drawer">The drawer delegate. After the transformation is applied, the delegate is invoked to draw whatever it wants</param>
        private void DrawObjectWithTransform(PaintEventArgs e, object o, int worldSize, double worldX, double worldY, double angle, ObjectDrawer drawer)
        {
            // Perform the transformation
            int x = WorldSpaceToImageSpace(worldSize, worldX);
            int y = WorldSpaceToImageSpace(worldSize, worldY);

            e.Graphics.TranslateTransform(x, y);
            e.Graphics.RotateTransform((float)angle);
            // Draw the object
            drawer(o, e);
            // Then undo the transformation
            e.Graphics.ResetTransform();
        }