private static void DrawSearchInput(DictionaryGUIState state, Inspector.Options options)
        {
            if (state.searchInput == null)
            {
                state.searchInput = new SearchInputState();
            }

            if (state.Size() < options.showSearchAtSize)
            {
                ClearSearchInput(state);
                return;
            }

            var now = DateTime.Now;
            SearchInputState input = state.searchInput;

            using (GUITools.Indent())
            {
                using (GUITools.HorizontalScope())
                {
                    var newInput = GUITools.TextField("Search: ", input.text ?? "");
                    if (newInput != input.text)
                    {
                        input.text           = newInput;
                        input.lastTextChange = now;
                        if (input.inputStart.Ticks == 0)
                        {
                            input.inputStart = now;
                        }
                    }
                    else
                    {
                        if (Math.Abs((now - input.lastTextChange).TotalSeconds) > 0.5)
                        {
                            input.inputStart = new DateTime();
                        }
                    }

                    if (input.text != input.filter &&
                        (
                            input.inputStart.Ticks == 0 ||
                            Math.Abs((now - input.lastFilterChange).TotalSeconds) > 1 &&
                            Math.Abs((now - input.inputStart).TotalSeconds) > 1
                        ))
                    {
                        input.changed          = true;
                        input.filter           = input.text;
                        input.lastFilterChange = DateTime.Now;
                    }
                    else
                    {
                        input.changed = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            if (data == null)
            {
                GUITools.LabelField(name, "null");
                return(false);
            }

            return(ApplyValueIfNotEqual(ref data, GUITools.TextField(name, (string)data)));
        }
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            var time = (DateTime)data;

            string oldstrdate = time.ToString(CultureInfo.CurrentCulture);
            string strdate    = GUITools.TextField(oldstrdate);

            if (oldstrdate != strdate)
            {
                time = ParseDateTime(strdate, time.Kind, time);
            }

            return(ApplyValueIfNotEqual(ref data, time));
        }
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            var span = (TimeSpan)data;

            string oldstrdate = span.ToString();
            string str        = GUITools.TextField(name, oldstrdate);

            if (oldstrdate != str)
            {
                span = ParseTimeSpan(str, span);
            }

            return(ApplyValueIfNotEqual(ref data, span));
        }
        // Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single.
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            object result;

            if (data == null)
            {
                GUITools.LabelField(name, "null");
                result = null;
            }
            else if (data is bool)
            {
                result = (bool)GUITools.Toggle(name, (bool)data);
            }
            else if (data is byte)
            {
                result = (byte)GUITools.IntField(name, (byte)data);
            }
            else if (data is sbyte)
            {
                result = (sbyte)GUITools.IntField(name, (sbyte)data);
            }
            else if (data is short)
            {
                result = (short)GUITools.IntField(name, (short)data);
            }
            else if (data is ushort)
            {
                result = (ushort)GUITools.IntField(name, (ushort)data);
            }
            else if (data is int)
            {
                result = (int)GUITools.IntField(name, (int)data);
            }
            else if (data is uint)
            {
                result = (uint)GUITools.LongField(name, (uint)data);
            }
            else if (data is long)
            {
                result = (long)ParseLong(GUITools.TextField(name, data.ToString()), (long)data);
            }
            else if (data is ulong)
            {
                result = (ulong)ParseULong(GUITools.TextField(name, data.ToString()), (ulong)data);
            }
            else if (data is IntPtr)
            {
                GUITools.TextField(name, data.ToString());
                result = data;
            }
            else if (data is UIntPtr)
            {
                GUITools.TextField(name, data.ToString());
                result = data;
            }
            else if (data is char)
            {
                result = (char)ParseChar(GUITools.TextField(name, data.ToString()), (char)data);
            }
            else if (data is float)
            {
                result = (float)GUITools.FloatField(name, (float)data);
            }
            else if (data is double)
            {
                result = (double)GUITools.DoubleField(name, (double)data);
            }
            else
            {
                throw new NotImplementedException(type.Name);
            }

            return(ApplyValueIfNotEqual(ref data, result));
        }