Exemplo n.º 1
0
        /// <summary>
        /// Gets a Rectangle that is sized for being used to paint the value properly in Visual Studio's
        ///		(or wherever it is used) Property Window.
        /// </summary>
        /// <param name="td">TextDir to base the Rectangle size and position on.</param>
        /// <param name="rct">Starting Rectangle.</param>
        /// <returns></returns>
        private Rectangle GetModifiedClientRectangle(MWCommon.TextDir td, Rectangle rct)
        {
            Rectangle result = rct;

            switch (td)
            {
            case MWCommon.TextDir.Normal:
                result = new Rectangle(rct.X + 1, rct.Y, rct.Width, rct.Height);
                break;

            case MWCommon.TextDir.UpsideDown:
                result = new Rectangle(rct.X - 2, rct.Y - 1, rct.Width, rct.Height);
                break;

            case MWCommon.TextDir.Left:
                result = new Rectangle(rct.X - 5, rct.Y + 4, rct.Width, rct.Height);
                break;

            case MWCommon.TextDir.Right:
                result = new Rectangle(rct.X - 2, rct.Y + 1, rct.Width, rct.Height);
                break;

            default:
                result = rct;
                break;
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This takes care of the actual value-change of the property.
        /// </summary>
        /// <param name="itdc">Standard ITypeDescriptorContext object.</param>
        /// <param name="isp">Standard IServiceProvider object.</param>
        /// <param name="value">The value as an object.</param>
        /// <returns>The new value as an object.</returns>
        public override object EditValue(ITypeDescriptorContext itdc, IServiceProvider isp, object value)
        {
            if (itdc != null && itdc.Instance != null && isp != null)
            {
                iwfes = (IWindowsFormsEditorService)isp.GetService(typeof(IWindowsFormsEditorService));

                if (iwfes != null)
                {
                    MWCommon.TextDir td = MWCommon.TextDir.Normal;

                    if (value is MWCommon.TextDir)
                    {
                        td        = (MWCommon.TextDir)itdc.PropertyDescriptor.GetValue(itdc.Instance);
                        pd        = itdc.PropertyDescriptor;
                        oInstance = itdc.Instance;
                    }

                    EditorTextDirUI etdui = new EditorTextDirUI();
                    etdui.IWFES           = iwfes;
                    etdui.ITDC            = itdc;
                    etdui.TextDir         = (MWCommon.TextDir)value;
                    etdui.TextDirChanged += new EditorTextDirUI.TextDirEventHandler(this.ValueChanged);

                    iwfes.DropDownControl(etdui);
                    value = etdui.TextDir;
                }
            }

            return(value);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Paint the value in Visual Studio's (or wherever it is used) Property Window.
        /// </summary>
        /// <param name="e">Standard PaintValueEventArgs object.</param>
        public override void PaintValue(PaintValueEventArgs e)
        {
            //See e.Graphics.Restore further down.
            GraphicsState gs = e.Graphics.Save();

            MWCommon.TextDir td     = (MWCommon.TextDir)e.Value;
            StringFormat     strfmt = StringFormat.GenericDefault;

            strfmt.Alignment     = StringAlignment.Center;
            strfmt.LineAlignment = StringAlignment.Center;

            switch (td)
            {
            case MWCommon.TextDir.Normal:
                break;

            case MWCommon.TextDir.UpsideDown:
                e.Graphics.RotateTransform(180);
                e.Graphics.TranslateTransform(-e.Bounds.Width, -e.Bounds.Height);
                break;

            case MWCommon.TextDir.Left:
                e.Graphics.RotateTransform(270);
                e.Graphics.TranslateTransform(-e.Bounds.Height, 0);
                break;

            case MWCommon.TextDir.Right:
                e.Graphics.RotateTransform(90);
                e.Graphics.TranslateTransform(0, -e.Bounds.Width);
                break;
            }

            e.Graphics.DrawString("A", new Font("Arial", 8), new SolidBrush(Color.Black), GetModifiedClientRectangle(td, e.Bounds), strfmt);

            //Important. Without this Visual Studio (or whatever) cannot draw its Property Window properly.
            e.Graphics.Restore(gs);

            base.PaintValue(e);
        }