public override void UpdateDisplayedProperties()
        {
            base.UpdateDisplayedProperties();

            if (mListDisplayWindow != null)
            {
                mListDisplayWindow.UpdateToList();

                if (SelectedObject != null)
                {
                    (SelectedObject as InstructionBlueprintList).InsertionSortAscendingTimeToExecute();
                }
            }

            if (SelectedObject != null && SelectedObject.Count > 0 && InputManager.ReceivingInput != mSetSelectedInstructionTimeUpDown.textBox)
            {
                if (mListDisplayWindow.FloatingChildren.Count == 0 && mListDisplayWindow.GetFirstHighlightedItem() != null)
                {
                    mSetSelectedInstructionTimeUpDown.CurrentValue = (float)(mListDisplayWindow.GetFirstHighlightedObject() as InstructionBlueprint).Time;
                }
                else if (mListDisplayWindow.FloatingChildren.Count == 0)
                {
                    mSetSelectedInstructionTimeUpDown.CurrentValue = (float)(SelectedObject as InstructionBlueprintList)[0].Time;
                }
                else
                {
                    mSetSelectedInstructionTimeUpDown.CurrentValue =
                        (float)((mListDisplayWindow.FloatingChildren[0] as InstructionBlueprintPropertyGrid <Sprite>).SelectedObject as InstructionBlueprint).Time;
                }
            }
        }
        private void HighlightAnimationSequenceListBox(Window callingWindow)
        {
            object highlightedObject = mAnimationSequenceListBox.GetFirstHighlightedObject();

            if (highlightedObject == null)
            {
            }
            else
            {
                if (highlightedObject is AnimationSequence)
                {
                    EditorData.EditorLogic.CurrentAnimationSequence = highlightedObject as AnimationSequence;
                }
                else if (highlightedObject is TimedKeyframeList)
                {
                    CollapseItem highlightedItem = mAnimationSequenceListBox.GetFirstHighlightedItem();

                    CollapseItem parentItem = highlightedItem.TopParent;

                    EditorData.EditorLogic.CurrentAnimationSequence =
                        parentItem.ReferenceObject as AnimationSequence;

                    EditorData.EditorLogic.CurrentTimedKeyframeList = highlightedObject as TimedKeyframeList;
                }
            }
        }
        internal IObjectDisplayer CreateObjectDisplayer(object displayedObject, Window requestingWindow, string memberName)
        {
            IObjectDisplayer objectToReturn = null;


            PropertyGrid      newGrid = null;
            ListDisplayWindow newListDisplayWindow = null;

            Type objectType = displayedObject.GetType();
            Type propertyGridType;

            ListDisplayWindow requestingListDisplayWindow = requestingWindow as ListDisplayWindow;
            PropertyGrid      requestingPropertyGrid      = requestingWindow as PropertyGrid;

            #region Get the cursor to use for the new Window

            Cursor cursor = GuiManager.Cursor;

            if (requestingWindow != null)
            {
                cursor = requestingWindow.mCursor;
            }

            #endregion


            #region Create the IDisplayWindow depending on the type of object passed

            #region If object is enum

            if (objectType.IsEnum)
            {
#if SILVERLIGHT
                throw new NotImplementedException();
#else
                propertyGridType = typeof(EnumPropertyGrid <>).MakeGenericType(objectType);

#if XBOX360
                throw new NotImplementedException("No PropertyGrid support in ObjectDisplayManager on 360 currently");
#else
                // handle enums specially
                newGrid = Activator.CreateInstance(propertyGridType, cursor, requestingWindow,
                                                   requestingListDisplayWindow.Items.IndexOf(requestingListDisplayWindow.GetFirstHighlightedItem())) as PropertyGrid;
#endif
#endif
            }

            #endregion

            #region Else if the object has an associated GUI element

            else if (PropertyGrid.sPropertyGridTypesForObjectType.ContainsKey(objectType))
            {
#if XBOX360
                throw new NotImplementedException("PropertyGrid creation not supported on 360.");
#else
                if (objectType.IsValueType || objectType == typeof(string))
                {
                    newGrid = Activator.CreateInstance(
                        PropertyGrid.sPropertyGridTypesForObjectType[objectType], cursor, requestingWindow,
                        requestingListDisplayWindow.Items.IndexOf(requestingListDisplayWindow.GetFirstHighlightedItem())) as PropertyGrid;
                }
                else
                {
                    Type objectDisplayerType = PropertyGrid.sPropertyGridTypesForObjectType[objectType];

                    ConstructorInfo ci = objectDisplayerType.GetConstructor(System.Type.EmptyTypes);

                    if (ci != null)
                    {
                        // The IObjectDisplayer has a no-argument constructor
                        objectToReturn = Activator.CreateInstance(objectDisplayerType) as IObjectDisplayer;
                    }
                    else
                    {
                        // The constructor requires arguments, meaning it's probabaly a Window, so let's pass a cursor
                        objectToReturn = Activator.CreateInstance(objectDisplayerType, cursor) as IObjectDisplayer;
                    }



                    if (objectToReturn is PropertyGrid)
                    {
                        newGrid = objectToReturn as PropertyGrid;
                    }
                    else if (objectToReturn is ListDisplayWindow)
                    {
                        newListDisplayWindow = objectToReturn as ListDisplayWindow;
                    }
                }
#endif
            }

            #endregion

            #region Else if the object is an IEnumerable

            else if (IsIEnumerable(objectType))
            {
                ListDisplayWindow listDisplayWindow = CreateListDisplayWindowForObject(displayedObject, cursor);

                newListDisplayWindow = listDisplayWindow;
            }

            #endregion

            #region Else if the object is a value type

            else if (objectType.IsValueType)
            {
#if SILVERLIGHT
                throw new NotImplementedException();
#else
                propertyGridType = typeof(StructReferencePropertyGrid <>).MakeGenericType(objectType);

#if XBOX360
                throw new NotImplementedException("No PropertyGrid support on 360");
#else
                if (requestingListDisplayWindow != null)
                {
                    newGrid = Activator.CreateInstance(propertyGridType, cursor, requestingListDisplayWindow,
                                                       requestingListDisplayWindow.Items.IndexOf(requestingListDisplayWindow.GetFirstHighlightedItem())) as PropertyGrid;
                }
                else
                {
                    newGrid = Activator.CreateInstance(
                        propertyGridType,
                        cursor,
                        requestingPropertyGrid,
                        memberName) as PropertyGrid;
                }
#endif
                newGrid.ExcludeStaticMembers();
#endif
            }

            #endregion

            #region Else, just create a regular PropertyGrid

            else
            {
#if SILVERLIGHT
                throw new NotImplementedException();
#else
                propertyGridType = typeof(PropertyGrid <>).MakeGenericType(objectType);

#if XBOX360
                throw new NotImplementedException("No PropertyGrid support on 360");
#else
                newGrid = Activator.CreateInstance(propertyGridType, cursor) as PropertyGrid;
#endif
#endif
            }

            #endregion

            #endregion


            #region Modify the new object based off of settings set at the user level

#if !SILVERLIGHT
            if (PropertyGrid.sPropertyGridMemberSettings.ContainsKey(objectType))
            {
                PropertyGridMemberSettings memberSettings =
                    PropertyGrid.sPropertyGridMemberSettings[objectType];

                foreach (string member in memberSettings)
                {
                    newGrid.ExcludeMember(member);
                }
            }
#endif

            Window newWindow = null;

            if (newGrid != null)
            {
                newWindow = newGrid;
            }
            else if (newListDisplayWindow != null)
            {
                newWindow = newListDisplayWindow;
            }
            else if (objectToReturn is Window)
            {
                newWindow = objectToReturn as Window;
            }

#if !SILVERLIGHT
            if (PropertyGrid.sNewWindowCallbacks.ContainsKey(objectType))
            {
                PropertyGrid.sNewWindowCallbacks[objectType](newWindow);
            }
            if (PropertyGrid.sNewWindowCallbacksByTypeAsString.ContainsKey(objectType.FullName))
            {
                PropertyGrid.sNewWindowCallbacksByTypeAsString[objectType.FullName](newWindow);
            }
#endif

            if (AnyNewWindowCreated != null)
            {
                ObjectDisplayManager.AnyNewWindowCreated(newWindow);
            }

            #endregion


            if (newGrid != null)
            {
#if SILVERLIGHT
                throw new NotImplementedException();
#else
                newGrid.ContentManagerName = ContentManagerName;
                return(newGrid);
#endif
            }
            else if (newListDisplayWindow != null)
            {
#if SILVERLIGHT
                throw new NotImplementedException();
#else
                newListDisplayWindow.ContentManagerName = ContentManagerName;
                return(newListDisplayWindow);
#endif
            }
            else
            {
                // This is probably a custom UI element created by the user, so we'll let it slide :)
                return(objectToReturn);
            }
        }