Exemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="SplitContainerTools"/> class.</summary>
        /// <param name="container">
        /// The <see cref="System.Windows.Forms.SplitContainer"/> to which this instance will be bound.
        /// </param>
        public SplitContainerTools(SplitContainer container)
        {
            split = container;
            _keepFocus = false;
            _showGripper = true;
            _showButtons = SplitContainerButtons.None;
            _panel1Border = false;
            _panel2Border = false;
            _buttons = new SplitContainerButton[] { };
            _tooltip = new ToolTip();

            _splitRectInternal = typeof(SplitContainer).GetField("splitterRect", Reflection.BindingFlags.NonPublic |
                                                                                 Reflection.BindingFlags.GetField |
                                                                                 Reflection.BindingFlags.Instance);

            split.Paint += split_Paint;
            split.MouseDown += split_MouseDown;
            split.MouseUp += split_MouseUp;
            split.MouseClick += split_MouseClick;
            split.MouseMove += split_MouseMove;
            split.MouseLeave += (o, e) => split.Cursor = Cursors.Default;
            split.SplitterMoved += split_SplitterMoved;
            split.SizeChanged += split_Resize;
            split.Disposed += (o, e) => _tooltip.Dispose();

            ((Panel)split.Panel1).ClientSizeChanged += Split_Panel_CollapsedChanged;
            ((Panel)split.Panel2).LocationChanged += Split_Panel_CollapsedChanged;
        }
Exemplo n.º 2
0
        /// <summary>Initializes a new instance of the <see cref="SplitContainerTools"/> class.</summary>
        /// <param name="container">
        /// The <see cref="System.Windows.Forms.SplitContainer"/> to which this instance will be bound.
        /// </param>
        public SplitContainerTools(SplitContainer container)
        {
            split         = container;
            _keepFocus    = false;
            _showGripper  = true;
            _showButtons  = SplitContainerButtons.None;
            _panel1Border = false;
            _panel2Border = false;
            _buttons      = new SplitContainerButton[] { };
            _tooltip      = new ToolTip();

            _splitRectInternal = typeof(SplitContainer).GetField("splitterRect", Reflection.BindingFlags.NonPublic |
                                                                 Reflection.BindingFlags.GetField |
                                                                 Reflection.BindingFlags.Instance);

            split.Paint         += split_Paint;
            split.MouseDown     += split_MouseDown;
            split.MouseUp       += split_MouseUp;
            split.MouseClick    += split_MouseClick;
            split.MouseMove     += split_MouseMove;
            split.MouseLeave    += (o, e) => split.Cursor = Cursors.Default;
            split.SplitterMoved += split_SplitterMoved;
            split.SizeChanged   += split_Resize;
            split.Disposed      += (o, e) => _tooltip.Dispose();

            ((Panel)split.Panel1).ClientSizeChanged += Split_Panel_CollapsedChanged;
            ((Panel)split.Panel2).LocationChanged   += Split_Panel_CollapsedChanged;
        }
Exemplo n.º 3
0
        static IOrderedQueryable <T> ApplyOrder <T>(
            IQueryable <T> source,
            string property,
            string methodName)
        {
            ;

            string[] props = property.Split(new char[] { ',', ';' });
            Type     type  = typeof(T);

            Expressions.ParameterExpression arg =
                Expressions.Expression.Parameter(type, "x");

            Expressions.Expression expr = arg;
            foreach (string prop in props)
            {
                // use reflection (not ComponentModel) to mirror LINQ
                Reflection.PropertyInfo pi = type.GetProperty(prop);
                if (pi == null)
                {
                    Reflection.FieldInfo fi = type.GetField(prop);
                    expr = Expressions.Expression.Field(expr, fi);
                    type = fi.FieldType;
                }
                else
                {
                    expr = Expressions.Expression.Property(expr, pi);
                    type = pi.PropertyType;
                }
            } // Next prop

            Type delegateType = typeof(Func <,>).MakeGenericType(typeof(T), type);

            Expressions.LambdaExpression lambda =
                Expressions.Expression.Lambda(delegateType, expr, arg);

            object result = typeof(Queryable).GetMethods().Single(
                method => method.Name == methodName &&
                method.IsGenericMethodDefinition &&
                method.GetGenericArguments().Length == 2 &&
                method.GetParameters().Length == 2)
                            .MakeGenericMethod(typeof(T), type)
                            .Invoke(null, new object[] { source, lambda });

            return((IOrderedQueryable <T>)result);
        } // End Function ApplyOrder
Exemplo n.º 4
0
        /// <summary>
        /// https://stackoverflow.com/questions/1415140/can-my-enums-have-friendly-names#1415187
        /// </summary>
        public static string GetEnumDescriptionAttribute(this Enum value)
        {
            Type   type = value.GetType();
            string name = Enum.GetName(type, value);

            if (name != null)
            {
                Reflection.FieldInfo field = type.GetField(name);
                if (field != null)
                {
                    ComponentModel.DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(ComponentModel.DescriptionAttribute)) as ComponentModel.DescriptionAttribute;
                    if (attr != null)
                    {
                        return(attr.Description);
                    }
                }
            }
            return(null);
        }