コード例 #1
0
		/// <summary>
		/// </summary>
		/// <param name="targetItem"></param>
		/// <param name="minWidth"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="targetItem"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void SetNewWidth(ToolStripItem targetItem, int minWidth)
		{
			if (targetItem == null)
			{
				throw new ArgumentNullException("targetItem");
			}

			if (targetItem.Owner == null)
			{
				return;
			}

			ToolStrip toolStrip = targetItem.Owner;
			int itemsWidth = 0;

			foreach (ToolStripItem item in toolStrip.Items)
			{
				if (
					item != targetItem
					)
				{
					itemsWidth += item.Width + 1;
				}
			}

			targetItem.Width = Math.Max(minWidth, toolStrip.Width - itemsWidth);
			NuGenInvoker invoker = new NuGenInvoker(toolStrip);
			invoker.Methods["OnSizeChanged"].Invoke(EventArgs.Empty);
		}
コード例 #2
0
		public void SetUp()
		{
			_dummyClass = new DummyClass();
			_dummyClass.PrivateField = _fooValue;
			_eventSink = new EventSink();
			_invoker = new NuGenInvoker(_dummyClass);
		}
コード例 #3
0
		public void FieldAccessTest()
		{
			int privateFieldValue = _invoker.Fields["_privateField"].GetValue<int>();
			Assert.AreEqual(_fooValue, privateFieldValue);

			ParentClass parentClass = new ParentClass();
			NuGenInvoker invoker = new NuGenInvoker(parentClass);

			NuGenFieldInfo privateFieldInfo = invoker.Fields["privateField"];
			Assert.IsNotNull(privateFieldInfo);
		}
コード例 #4
0
        /*
         * CreateStringFormat
         */

        /// <summary>
        /// Builds <see cref="T:System.Drawing.StringFormat"/> for the specified <see cref="T:System.Windows.Forms.Control"/>.
        /// </summary>
        /// <param name="ctrl">Specifies the <see cref="T:System.Windows.Forms.Control"/> to build
        /// <see cref="T:System.Drawing.StringFormat"/> for.</param>
        /// <param name="textAlign">Specifies text alignment on the drawing surface.</param>
        /// <param name="showEllipsis">Specifies the value indicating whether to show ellipsis if the whole text
        /// cannot be displayed.</param>
        /// <param name="useMnemonic">Specifies the value indicating whether an ampersand (&amp;) is included in the
        /// text.</param>
        /// <returns></returns>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="ctrl"/> is <see langword="null"/>.</exception>
        public static StringFormat CreateStringFormat(
            Control ctrl,
            ContentAlignment textAlign,
            bool showEllipsis,
            bool useMnemonic
            )
        {
            if (ctrl == null)
            {
                throw new ArgumentNullException("ctrl");
            }

            StringFormat stringFormat = NuGenControlPaint.ContentAlignmentToStringFormat(textAlign);

            if (ctrl.RightToLeft == RightToLeft.Yes)
            {
                stringFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }

            if (showEllipsis)
            {
                stringFormat.Trimming     = StringTrimming.EllipsisCharacter;
                stringFormat.FormatFlags |= StringFormatFlags.LineLimit;
            }

            if (!useMnemonic)
            {
                stringFormat.HotkeyPrefix = HotkeyPrefix.None;
            }
            else if ((bool)NuGenInvoker.GetProperty(ctrl, "ShowKeyboardCues"))
            {
                stringFormat.HotkeyPrefix = HotkeyPrefix.Show;
            }
            else
            {
                stringFormat.HotkeyPrefix = HotkeyPrefix.Hide;
            }

            if (ctrl.AutoSize)
            {
                stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
            }

            return(stringFormat);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenPropertyGrid"/> class.
        /// </summary>
        /// <param name="serviceProvider">
        /// Provides:<para/>
        /// <see cref="INuGenControlStateService"/><para/>
        /// <see cref="INuGenPropertyGridRenderer"/><para/>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
        /// </exception>
        public NuGenPropertyGrid(INuGenServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            _serviceProvider = serviceProvider;

            this.ToolStripRenderer = new ToolStripProfessionalRenderer(new NuGenVisualStudioColorTable());

            NuGenInvoker invoker = new NuGenInvoker(this);

            _doccomment = invoker.Fields["doccomment"];
            _doccomment.Events["Paint"].AddHandler(new PaintEventHandler(this.doccomment_Paint));
            _doccomment.Fields["m_labelDesc"].Properties["BackColor"].SetValue(Color.Transparent);
            _doccomment.Fields["m_labelTitle"].Properties["BackColor"].SetValue(Color.Transparent);
        }
コード例 #6
0
		/// <summary>
		/// Invokes the SetStyle method of the <see cref="T:Control"/>.
		/// </summary>
		/// <param name="ctrl">Specifies the <see cref="T:System.Windows.Forms.Control"/> to invoke the SetStyle method for.</param>
		/// <param name="ctrlStyles">Control styles to set.</param>
		/// <param name="value"><see langword="true"/> to apply the specified styles to the control;
		/// otherwise, <see langword="false"/>.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// <paramref name="ctrl"/> is <see langword="null"/>.
		/// </exception>
		private static void InvokeSetStyle(Control ctrl, ControlStyles ctrlStyles, bool value)
		{
			if (ctrl == null)
			{
				throw new ArgumentNullException("ctrl");
			}

			NuGenInvoker invoker = new NuGenInvoker(ctrl);
			invoker.Methods["SetStyle"].Invoke(ctrlStyles, value);
		}
コード例 #7
0
 public void ConstructorTest()
 {
     NuGenInvoker invoker = new NuGenInvoker(null);
 }
コード例 #8
0
 public void SetUp()
 {
     _dummyClass = new DummyClass();
     _dummyClass.PrivateField = _fooValue;
     _invoker = new NuGenInvoker(_dummyClass);
 }
コード例 #9
0
		public void ConstructorTest()
		{
			NuGenInvoker invoker = new NuGenInvoker(null);
		}
コード例 #10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenPropertyGrid"/> class.
		/// </summary>
		/// <param name="serviceProvider">
		/// Provides:<para/>
		/// <see cref="INuGenControlStateService"/><para/>
		/// <see cref="INuGenPropertyGridRenderer"/><para/>
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenPropertyGrid(INuGenServiceProvider serviceProvider)
		{
			if (serviceProvider == null)
			{
				throw new ArgumentNullException("serviceProvider");
			}

			_serviceProvider = serviceProvider;

			this.ToolStripRenderer = new ToolStripProfessionalRenderer(new NuGenVisualStudioColorTable());

			NuGenInvoker invoker = new NuGenInvoker(this);

			_doccomment = invoker.Fields["doccomment"];
			_doccomment.Events["Paint"].AddHandler(new PaintEventHandler(this.doccomment_Paint));
			_doccomment.Fields["m_labelDesc"].Properties["BackColor"].SetValue(Color.Transparent);
			_doccomment.Fields["m_labelTitle"].Properties["BackColor"].SetValue(Color.Transparent);
		}