Esempio n. 1
0
        public void PointMutatorCreationWithMapControlTest()
        {
            IMapControl mapControl = new MapControl {
                Map = { Size = new Size(1000, 1000) }
            };
            ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl);
            PointEditor          pointMutator        = new PointEditor(coordinateConverter, null,
                                                                       sampleFeature, GetStyle(Pens.Red), null);

            Assert.AreEqual(null, pointMutator.TargetFeature);
            Assert.AreNotEqual(null, pointMutator.SourceFeature);

            ITrackerFeature tracker = pointMutator.GetTrackerAtCoordinate(new Coordinate(0, 0));

            Assert.AreNotEqual(null, tracker);

            pointMutator.Start();
            pointMutator.MoveTracker(tracker, 5.0, 5.0, null);
            pointMutator.Stop();

            Assert.AreEqual(5.0, tracker.Geometry.Coordinates[0].X);
            Assert.AreEqual(5.0, tracker.Geometry.Coordinates[0].Y);
            Assert.AreEqual(5.0, sampleFeature.Geometry.Coordinates[0].X);
            Assert.AreEqual(5.0, sampleFeature.Geometry.Coordinates[0].Y);
        }
Esempio n. 2
0
        public void SelectionTest()
        {
            PointEditor     pointMutator = new PointEditor(null, null, sampleFeature, GetStyle(Pens.Red), null);
            ITrackerFeature tracker      = pointMutator.GetTrackerByIndex(0);

            // The tracker has focus by default; is this ok
            Assert.AreEqual(true, tracker.Selected);
            pointMutator.Select(tracker, false);
            Assert.AreEqual(false, tracker.Selected);
        }
Esempio n. 3
0
        public void PointMutatorCreationWithoutMapControlTest()
        {
            PointEditor pointMutator = new PointEditor(null, null, sampleFeature, GetStyle(Pens.Red), null);

            Assert.AreEqual(null, pointMutator.TargetFeature);
            Assert.AreNotEqual(null, pointMutator.SourceFeature);
            // The tracker has focus by default; is this ok
            IList <ITrackerFeature> trackers = pointMutator.GetFocusedTrackers();

            Assert.AreEqual(1, trackers.Count);

            ITrackerFeature tracker = pointMutator.GetTrackerByIndex(0);

            Assert.AreNotEqual(null, tracker);

            pointMutator.Start();
            Assert.AreNotEqual(null, pointMutator.TargetFeature);
            Assert.AreNotEqual(pointMutator.SourceFeature, pointMutator.TargetFeature);
        }
        public bool OnSceneGUI(Transform transform)
        {
            if (!m_Group.enabled)
            {
                return(m_Editing);
            }

            if (Event.current.type == EventType.Layout)
            {
                //If the group has moved / scaled since last frame need to retetra);)
                if (m_LastPosition != m_Group.transform.position ||
                    m_LastRotation != m_Group.transform.rotation ||
                    m_LastScale != m_Group.transform.localScale)
                {
                    MarkMeshDirty();
                }

                m_LastPosition = m_Group.transform.position;
                m_LastRotation = m_Group.transform.rotation;
                m_LastScale    = m_Group.transform.localScale;
            }

            //See if we should enter edit mode!
            bool firstSelect = false;

            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                //We have no probes selected and have clicked the mouse... Did we click a probe
                if (SelectedCount == 0)
                {
                    var selected     = PointEditor.FindNearest(Event.current.mousePosition, transform, this);
                    var clickedProbe = selected != -1;

                    if (clickedProbe && !m_Editing)
                    {
                        m_Inspector.StartEditMode();
                        m_Editing   = true;
                        firstSelect = true;
                    }
                }
            }

            //Need to cache this as select points will use it!
            var mouseUpEvent = Event.current.type == EventType.MouseUp;

            if (m_Editing)
            {
                if (PointEditor.SelectPoints(this, transform, ref m_Selection, firstSelect))
                {
                    Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[] { m_Group, m_SerializedSelectedProbes }, "Select Probes");
                    m_Inspector.Repaint();
                }
                if (SelectedCount > 0)
                {
                    Transform trans       = m_Group.transform;
                    Vector3   pos         = trans.TransformPoint(SelectedCount > 0 ? GetSelectedPositions()[0] : Vector3.zero);
                    Vector3   newPosition = Handles.DoPositionHandle(pos, Quaternion.identity);

                    if (mouseUpEvent)
                    {
                        have_saved = false;
                    }
                    if (newPosition != pos)
                    {
                        newPosition = trans.InverseTransformPoint(newPosition);
                        pos         = trans.InverseTransformPoint(pos);
                        if (!have_saved)
                        {
                            Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[] { m_Group, m_SerializedSelectedProbes }, "Move Probes");
                            have_saved = true;
                        }
                        Vector3[] selectedPositions = GetSelectedPositions();
                        Vector3   delta             = newPosition - pos;
                        for (int i = 0; i < selectedPositions.Length; i++)
                        {
                            UpdateSelectedPosition(i, selectedPositions[i] + delta);
                        }
                        MarkMeshDirty();
                    }
                }
            }

            //Special handling for paste (want to be able to paste when not in edit mode!)

            if ((Event.current.type == EventType.ValidateCommand || Event.current.type == EventType.ExecuteCommand) &&
                Event.current.commandName == EventCommandNames.Paste)
            {
                if (Event.current.type == EventType.ValidateCommand)
                {
                    if (CanPasteProbes())
                    {
                        Event.current.Use();
                    }
                }
                if (Event.current.type == EventType.ExecuteCommand)
                {
                    if (PasteProbes())
                    {
                        Event.current.Use();
                        m_Editing = true;
                    }
                }
            }

            PointEditor.Draw(this, transform, m_Selection, true);


            //volume size
            {
                var color = Handles.color;

                Handles.color = Color.yellow;

                var  trans    = m_Group.transform;
                var  cellSize = m_Group.cellSize / 2;
                bool changed  = false;


                Vector3 half_size = m_Group.volumeSize / 2;

                {
                    var   handle_pos = trans.TransformPoint(Vector3.right * half_size.x);
                    var   poss       = Handles.Slider(handle_pos, trans.right, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = trans.InverseTransformPoint(poss).x;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.x)
                    {
                        changed = true; half_size.x = new_v;
                    }
                }
                {
                    var   handle_pos = trans.TransformPoint(Vector3.left * half_size.x);
                    var   poss       = Handles.Slider(handle_pos, -trans.right, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = -trans.InverseTransformPoint(poss).x;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.x)
                    {
                        changed = true; half_size.x = new_v;
                    }
                }
                {
                    var   handle_pos = trans.TransformPoint(Vector3.up * half_size.y);
                    var   poss       = Handles.Slider(handle_pos, trans.up, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = trans.InverseTransformPoint(poss).y;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.y)
                    {
                        changed = true; half_size.y = new_v;
                    }
                }
                {
                    var   handle_pos = trans.TransformPoint(Vector3.down * half_size.y);
                    var   poss       = Handles.Slider(handle_pos, -trans.up, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = -trans.InverseTransformPoint(poss).y;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.y)
                    {
                        changed = true; half_size.y = new_v;
                    }
                }
                {
                    var   handle_pos = trans.TransformPoint(Vector3.forward * half_size.z);
                    var   poss       = Handles.Slider(handle_pos, trans.forward, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = trans.InverseTransformPoint(poss).z;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.z)
                    {
                        changed = true; half_size.z = new_v;
                    }
                }
                {
                    var   handle_pos = trans.TransformPoint(Vector3.back * half_size.z);
                    var   poss       = Handles.Slider(handle_pos, -trans.forward, 0.1f, Handles.CubeHandleCap, 0);
                    float new_v      = -trans.InverseTransformPoint(poss).z;
                    new_v = new_v < cellSize ? cellSize : new_v;
                    if (new_v != half_size.z)
                    {
                        changed = true; half_size.z = new_v;
                    }
                }

                if (mouseUpEvent)
                {
                    have_saved = false;
                }
                if (changed)
                {
                    if (!have_saved)
                    {
                        Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[] { m_Group }, "Change probe volume size");
                        have_saved = true;
                    }
                    m_Group.volumeSize = half_size * 2;
                }

                Handles.color = color;
            }


            if (!m_Editing)
            {
                return(m_Editing);
            }

            HandleEditMenuHotKeyCommands();

            return(m_Editing);
        }
Esempio n. 5
0
        private void actBZCurve_Execute(object sender, ExecuteEventArgs e)
        {
            var cadView = this.CadView;

            if (cadView == null)
            {
                return;
            }
            var surfaceLayer = SurfaceLayer.GetSurfaceLayer(cadView);

            if (surfaceLayer == null)
            {
                return;
            }
            var surface = surfaceLayer.Surface;

            if (surface == null)
            {
                return;
            }

            cadView.SelectionSet.Clear();
            surface.BeginUpdate("Сглаживание структурной линии");

            try
            {
                var line = surfaceLayer.SelectOneStructureLine(null, "Выберите структурную линию") as StructureLine;
                if (line == null)
                {
                    return;
                }

                double         step      = 10.0;
                GetPointResult gpr_delta = Topomatic.Cad.View.Hints.CadCursors.GetDoubleWithDefault(cadView, ref step, "Укажите укажите размер сегмента после сглаживания, м <10>:");
                if (gpr_delta != GetPointResult.Accept)
                {
                    return;
                }

                int            Nb       = 3;
                GetPointResult gpr_code = Topomatic.Cad.View.Hints.CadCursors.GetIntegerWithDefault(cadView, ref Nb, "Укажите количество сегментов для разбиения коротких участков <3>:");
                if (gpr_code != GetPointResult.Accept)
                {
                    return;
                }

                var editor = new PointEditor(surface);

                var newline = new Topomatic.Sfc.StructureLine();

                newline.CopyProperty(line);

                SurfacePoint[,] segments = new SurfacePoint[(line.Count - 1), 4];

                var node  = line[0];
                var point = surface.Points[node.Index];
                segments[0, 0] = point.Clone();


                double coef = 0.341, raznicaS = 1.0, raznicaF = 1.0;

                for (int i = 0; i < line.Count - 2; i++)
                {
                    double LS = 0, LF = 0;

                    var nodeS  = line[i];
                    var pointS = surface.Points[nodeS.Index].Clone();
                    var nodeF  = line[i + 1];
                    var pointF = surface.Points[nodeF.Index].Clone();
                    var nodeN  = line[i + 2];
                    var pointN = surface.Points[nodeN.Index].Clone();

                    LS = Math.Sqrt(Math.Pow(pointF.Vertex.X - pointS.Vertex.X, 2) + Math.Pow(pointF.Vertex.Y - pointS.Vertex.Y, 2) + Math.Pow(pointF.Vertex.Z - pointS.Vertex.Z, 2));
                    LF = Math.Sqrt(Math.Pow(pointN.Vertex.X - pointF.Vertex.X, 2) + Math.Pow(pointN.Vertex.Y - pointF.Vertex.Y, 2) + Math.Pow(pointN.Vertex.Z - pointF.Vertex.Z, 2));

                    double D1 = DirAngle(pointS, pointF);
                    double D2 = DirAngle(pointF, pointN);
                    double gamma = 0, C1, C2;

                    //if (D1 > D2)
                    //{
                    //    gamma = Math.PI + D2 - D1;
                    //}
                    //else if (D2 < D1)
                    //{
                    //    gamma = Math.PI + D1 - D2;
                    //}
                    //else { gamma = Math.PI; }

                    gamma = D2 - D1 + 2 * 3.1415926535897932384626433832795;


                    if (gamma < Math.PI)
                    {
                        C1 = D2 + ((Math.PI - gamma) / 2) + Math.PI * 1.5;
                        C2 = C1 + Math.PI;
                    }
                    else
                    {
                        if (D1 > D2)
                        {
                            C1 = D2 + ((Math.PI - gamma) / 2) + Math.PI * 1.5;
                            C2 = C1 + Math.PI;
                        }
                        else
                        {
                            C1 = D2 - gamma + ((gamma - Math.PI) / 2) + Math.PI * 0.5;
                            C2 = C1 + Math.PI;
                        }
                    }


                    //if(D1>D2)
                    //{
                    //    double temp = C2;
                    //    C2 = C1;
                    //    C1 = temp;
                    //}

                    if (LS / LF > 10)
                    {
                        LS = LF;
                    }

                    if (LF / LS > 10)
                    {
                        LF = LS;
                    }


                    double dy = LS * coef * Math.Cos(C1) * raznicaS;
                    double dx = LS * coef * Math.Sin(C1) * raznicaS;

                    var vectorFC1 = new Vector3D(pointF.Vertex.X + dx, pointF.Vertex.Y + dy, pointF.Vertex.Z);

                    dy = LF * coef * Math.Cos(C2) * raznicaF;
                    dx = LF * coef * Math.Sin(C2) * raznicaF;
                    var vectorFC2 = new Vector3D(pointF.Vertex.X + dx, pointF.Vertex.Y + dy, pointF.Vertex.Z);

                    SurfacePoint pointFC1 = new SurfacePoint(vectorFC1);
                    SurfacePoint pointFC2 = new SurfacePoint(vectorFC2);

                    segments[i, 3]     = pointF.Clone();
                    segments[i + 1, 0] = pointF.Clone();

                    if (i == 0)
                    {
                        //double C0 = D1 - ((Math.PI - gamma) / 2);
                        double C0 = C1 - 3.14 - gamma;
                        dy = LS * coef * Math.Cos(C0);
                        dx = LS * coef * Math.Sin(C0);
                        var          vectorSC0 = new Vector3D(pointS.Vertex.X + dx, pointS.Vertex.Y + dy, pointS.Vertex.Z);
                        SurfacePoint pointSC1  = new SurfacePoint(vectorSC0);
                        segments[0, 1] = pointSC1;
                    }

                    if (i == line.Count - 3)
                    {
                        //double C3 = Math.PI + D2 + ((Math.PI - gamma) / 2);
                        double C3 = C2 + 3.14 + gamma;
                        dy = LF * coef * Math.Cos(C3);
                        dx = LF * coef * Math.Sin(C3);
                        var          vectorNC3 = new Vector3D(pointN.Vertex.X + dx, pointN.Vertex.Y + dy, pointN.Vertex.Z);
                        SurfacePoint pointNC3  = new SurfacePoint(vectorNC3);
                        segments[i + 1, 2] = pointNC3;
                        segments[i + 1, 3] = pointN.Clone();
                    }

                    segments[i, 2]     = pointFC1;
                    segments[i + 1, 1] = pointFC2;
                }

                var drawingLayer = DrawingLayer.GetDrawingLayer(cadView);
                if (drawingLayer == null)
                {
                    return;
                }
                var drawing = drawingLayer.Drawing;
                if (drawing == null)
                {
                    return;
                }


                drawing.ActiveSpace.BeginUpdate();

                try
                {
                    /*for (int i = 0; i < segments.GetLength(0); i++)
                     * {
                     *  var cLineS = new Topomatic.Dwg.Entities.DwgPolyline();
                     *  var cLineF = new Topomatic.Dwg.Entities.DwgPolyline();
                     *
                     *  var posS1 = new Topomatic.Cad.Foundation.Vector2D(segments[i, 0].Vertex.X, segments[i, 0].Vertex.Y);
                     *  cLineS.Add(new Topomatic.Cad.Foundation.BugleVector2D(posS1, 0));
                     *  var posF1 = new Topomatic.Cad.Foundation.Vector2D(segments[i, 1].Vertex.X, segments[i, 1].Vertex.Y);
                     *  cLineS.Add(new Topomatic.Cad.Foundation.BugleVector2D(posF1, 0));
                     *  var posS2 = new Topomatic.Cad.Foundation.Vector2D(segments[i, 2].Vertex.X, segments[i, 2].Vertex.Y);
                     *  cLineF.Add(new Topomatic.Cad.Foundation.BugleVector2D(posS2, 0));
                     *  var posF2 = new Topomatic.Cad.Foundation.Vector2D(segments[i, 3].Vertex.X, segments[i, 3].Vertex.Y);
                     *  cLineF.Add(new Topomatic.Cad.Foundation.BugleVector2D(posF2, 0));
                     *
                     *  drawing.ActiveSpace.Add(cLineS);
                     *  drawing.ActiveSpace.Add(cLineF);
                     * }*/
                }
                finally
                {
                    drawing.ActiveSpace.EndUpdate();
                }

                for (int i = 0; i < segments.GetLength(0); i++)
                {
                    double t = 0.0;
                    //int step = 100;
                    double L1 = Math.Sqrt(Math.Pow(segments[i, 3].Vertex.X - segments[i, 0].Vertex.X, 2) + //длина исходного сегмента
                                          Math.Pow(segments[i, 3].Vertex.Y - segments[i, 0].Vertex.Y, 2) +
                                          Math.Pow(segments[i, 3].Vertex.Z - segments[i, 0].Vertex.Z, 2));

                    double L3 = Math.Sqrt(Math.Pow(segments[i, 1].Vertex.X - segments[i, 0].Vertex.X, 2) +//длина полилинии, проходящей через начальную, две контрольные и конечную точки
                                          Math.Pow(segments[i, 1].Vertex.Y - segments[i, 0].Vertex.Y, 2) +
                                          Math.Pow(segments[i, 1].Vertex.Z - segments[i, 0].Vertex.Z, 2)) +

                                Math.Sqrt(Math.Pow(segments[i, 2].Vertex.X - segments[i, 1].Vertex.X, 2) +
                                          Math.Pow(segments[i, 2].Vertex.Y - segments[i, 1].Vertex.Y, 2) +
                                          Math.Pow(segments[i, 2].Vertex.Z - segments[i, 1].Vertex.Z, 2)) +

                                Math.Sqrt(Math.Pow(segments[i, 3].Vertex.X - segments[i, 2].Vertex.X, 2) +
                                          Math.Pow(segments[i, 3].Vertex.Y - segments[i, 2].Vertex.Y, 2) +
                                          Math.Pow(segments[i, 3].Vertex.Z - segments[i, 2].Vertex.Z, 2));

                    double L2 = 1.01 * (L3 + L1) / 2;
                    int    N  = (Int32)Math.Round(L2 / step);//количество шагов кривой

                    if (N < Nb)
                    {
                        N = Nb;
                    }

                    double         d = 1.0 / N; //шаг дельта t
                    SurfacePoint[] p = new SurfacePoint[4];

                    for (int j = 0; j < 4; j++)
                    {
                        p[j] = segments[i, j];
                    }

                    SurfacePoint q = new SurfacePoint();
                    //SurfacePoint r = CastR(p, t, 3, 0).Clone();
                    SurfacePoint r = segments[i, 0].Clone();

                    var index = new Topomatic.Sfc.PointEditor(surface).Add(r);
                    newline.Add(index);

                    for (int k = 0; k < N - 1; k++)
                    {
                        t           += d;
                        q            = CastR(p, t, 3, 0).Clone();
                        r            = q.Clone();
                        r.IsExtended = true;
                        r.IsDynamic  = true;
                        index        = new Topomatic.Sfc.PointEditor(surface).Add(r);
                        newline.Add(index);
                    }
                }
                var ind = new Topomatic.Sfc.PointEditor(surface).Add(segments[segments.GetLength(0) - 1, 3]);
                newline.Add(ind);

                surface.StructureLines.Add(newline);

                for (int l = 0; l < line.Count; l++)
                {
                    var delpoint = new StructureLineNode(line[l].Index);
                    line.Remove(delpoint);
                    editor.Remove(delpoint.Index);
                }
                surface.StructureLines.Remove(line);
            }
            finally
            {
                surface.EndUpdate();
            }
        }
Esempio n. 6
0
        public GraphNode(IFilter filter)
        {
            InitializeComponent();

            _filter = filter;
            _filter.OnPinsChanged += OnPinsChanged;
            _filter.OnProcessingProgressChanged += OnProcessingProgressChanged;
            _filter.OnProcessingStateChanged    += OnProcessingStateChanged;

            UpdateSize(_filter);

            var table = new TableLayoutPanel
            {
                Size     = new Size(Width - 2, _filter.Properties.Count * PropertyHeight),
                Location = new Point(1, HeaderHeight + 2)
            };

            table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));

            for (int i = 0; i < _filter.Properties.Count; i++)
            {
                IFilterProperty    property = _filter.Properties.Skip(i).First().Value;
                BasePropertyEditor editor;
                switch (property.Type)
                {
                case FilterPropertyType.String:
                    editor = new PathEditor {
                        Value = property.Value
                    };
                    break;

                case FilterPropertyType.Float:
                case FilterPropertyType.Integer:
                    editor = new NumericEditor((INumericProperty)property)
                    {
                        Value = Convert.ToDecimal(property.Value)
                    };
                    break;

                case FilterPropertyType.Size:
                case FilterPropertyType.Point:
                    editor = new PointEditor((IPointProperty)property)
                    {
                        Value = property.Value
                    };
                    break;

                case FilterPropertyType.Enum:
                    editor = new EnumEditor((IEnumProperty)property)
                    {
                        Value = property.Value
                    };
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                editor.Dock            = DockStyle.Fill;
                editor.Margin          = new Padding(0);
                editor.OnValueChanged += newValue => { property.Value = newValue; };

                table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                table.SetRow(editor, i);
                table.SetColumn(editor, 1);

                var label = new Label
                {
                    Text     = property.Name,
                    Margin   = new Padding(0),
                    Dock     = DockStyle.Right,
                    AutoSize = true,
                    Anchor   = AnchorStyles.Right
                };
                table.SetRow(label, i);
                table.SetColumn(label, 0);
                table.Controls.Add(label);
                table.Controls.Add(editor);
            }
            Controls.Add(table);
        }
Esempio n. 7
0
        private async Task <DependencyObject> GetEditorForType(object originalObject, object value, Type memberType, string propertyPath, string memberName, Type declaringTypeToIgnore)
        {
            DependencyObject result = null;

            if (memberType.IsEnum)
            {
                var editor = new EnumEditor {
                    EnumType     = memberType,
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <object> >(e => this.UpdateProperty(e.PropertyName, value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(string))
            {
                var editor = new StringEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (string)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <string> >(e => this.UpdateProperty(e.PropertyName, (string)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(int))
            {
                var editor = new IntEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (int)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <int> >(e => this.UpdateProperty(e.PropertyName, (int)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(float))
            {
                var editor = new FloatEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (float)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <float> >(e => this.UpdateProperty(e.PropertyName, (float)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(bool))
            {
                var editor = new BoolEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (bool)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <bool> >(e => this.UpdateProperty(e.PropertyName, (bool)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(Vector2))
            {
                var editor = new VectorEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (Vector2)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Vector2> >(e => this.UpdateProperty(e.PropertyName, (Vector2)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(Microsoft.Xna.Framework.Point))
            {
                var editor = new PointEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (Microsoft.Xna.Framework.Point)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Microsoft.Xna.Framework.Point> >(e => this.UpdateProperty(e.PropertyName, (Microsoft.Xna.Framework.Point)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(Microsoft.Xna.Framework.Color))
            {
                var editor = new ColorEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (Microsoft.Xna.Framework.Color)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Microsoft.Xna.Framework.Color> >(e => this.UpdateProperty(e.PropertyName, (Microsoft.Xna.Framework.Color)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(Sprite))
            {
                var editor = new SpriteEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = value as Sprite
                };

                if (value is Sprite sprite)
                {
                    var spriteWrappers = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <SpriteWrapper>();
                    editor.SpriteWrapper = spriteWrappers.FirstOrDefault(x => x.Sprite.Id == sprite.Id);
                }

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Sprite> >(e => this.UpdateProperty(e.PropertyName, value as Sprite, e.Value, originalObject, editor), true);
                editor.SelectSpriteCommand = new RelayCommand(() => {
                    var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Image | AssetType.Sprite, AssetType.Sprite);
                    if (asset is SpriteWrapper spriteWrapper)
                    {
                        editor.SpriteWrapper = spriteWrapper;
                    }
                }, true);

                result = editor;
            }
            else if (memberType == typeof(AudioClip))
            {
                var editor = new AudioClipEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = value as AudioClip
                };

                editor.ValueChangedCommand    = new RelayCommand <EditableValueChangedEventArgs <AudioClip> >(e => this.UpdateProperty(e.PropertyName, value as AudioClip, e.Value, originalObject, editor), true);
                editor.SelectAudioClipCommand = new RelayCommand(() => {
                    var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Audio, AssetType.Audio);
                    if (asset is AudioAsset audioAsset)
                    {
                        editor.Value = audioAsset.AudioClip;
                    }
                }, true);

                result = editor;
            }
            else if (memberType == typeof(SpriteAnimation))
            {
                var editor = new SpriteAnimationEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = value as SpriteAnimation
                };

                if (value is SpriteAnimation animation)
                {
                    var spriteAnimationAssets = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <SpriteAnimationAsset>();
                    editor.Asset = spriteAnimationAssets.FirstOrDefault(x => x.SavableValue.Id == animation.Id);
                }

                editor.ValueChangedCommand          = new RelayCommand <EditableValueChangedEventArgs <SpriteAnimation> >(e => this.UpdateProperty(e.PropertyName, value as SpriteAnimation, e.Value, originalObject, editor), true);
                editor.SelectSpriteAnimationCommand = new RelayCommand(() => {
                    var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.SpriteAnimation, AssetType.SpriteAnimation);
                    if (asset is SpriteAnimationAsset spriteAnimationAsset)
                    {
                        editor.Asset = spriteAnimationAsset;
                        editor.Value = spriteAnimationAsset.SavableValue;
                    }
                }, true);

                result = editor;
            }
            else if (memberType == typeof(Font))
            {
                var editor = new FontEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = value as Font
                };

                if (value is Font font)
                {
                    var fontAssets = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <FontAsset>();
                    editor.Asset = fontAssets.FirstOrDefault(x => x.SavableValue.Id == font.Id);
                }

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Font> >(e => this.UpdateProperty(e.PropertyName, value as Font, e.Value, originalObject, editor), true);
                editor.SelectFontCommand   = new RelayCommand(() => {
                    var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Font, AssetType.Font);
                    if (asset is FontAsset fontAsset)
                    {
                        editor.Asset = fontAsset;
                        editor.Value = fontAsset.SavableValue;
                    }
                }, true);

                result = editor;
            }
            else if (memberType == typeof(Collider))
            {
                var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider));

                colliderTypes.Remove(typeof(PolygonCollider)); // TODO: Eventually allow PolygonCollider.
                var editor = new ColliderEditor {
                    ColliderTypes = colliderTypes,
                    PropertyName  = propertyPath,
                    Title         = memberName,
                    Value         = (Collider)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Collider> >(e => this.UpdateProperty(e.PropertyName, (Collider)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(LineCollider))
            {
                var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider));

                var editor = new LineColliderEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (LineCollider)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <LineCollider> >(e => this.UpdateProperty(e.PropertyName, (LineCollider)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType == typeof(RectangleCollider))
            {
                var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider));

                var editor = new RectangleColliderEditor {
                    PropertyName = propertyPath,
                    Title        = memberName,
                    Value        = (RectangleCollider)value
                };

                editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <RectangleCollider> >(e => this.UpdateProperty(e.PropertyName, (RectangleCollider)value, e.Value, originalObject, editor), true);
                result = editor;
            }
            else if (memberType.IsSubclassOf(typeof(BaseComponent)))
            {
                // TODO: Allow user to select a component.
            }
            else
            {
                // TODO: I don't know, this should probably work when value is null
                if (value != null)
                {
                    var editor = new GenericValueEditor {
                        DeclaringType = declaringTypeToIgnore,
                        PropertyName  = propertyPath,
                        Title         = memberName,
                        Value         = value
                    };

                    editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <object> >(e => this.UpdateProperty(e.PropertyName, value, e.Value, originalObject, editor), true);
                    result = editor;
                }
            }

            return(result);
        }