// Constructor.
	public ItemCheckEventArgs
				(int index, CheckState newCheckValue, CheckState currentValue)
			{
				this.index = index;
				this.newCheckValue = newCheckValue;
				this.currentValue = currentValue;
			}
 // used by DataGridViewCheckBoxCell
 internal static void DrawCheckBackground(bool controlEnabled, CheckState controlCheckState, Graphics g, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ColorData colors)
 {                       
     using ( WindowsGraphics wg = WindowsGraphics.FromGraphics( g )) {
         WindowsBrush brush;
         if (!controlEnabled && disabledColors) {
             brush = new WindowsSolidBrush(wg.DeviceContext, SystemColors.Control);
         }
         else if (controlCheckState == CheckState.Indeterminate && checkBackground == SystemColors.Window && disabledColors) {
             Color comboColor = SystemInformation.HighContrast ? SystemColors.ControlDark :
                     SystemColors.Control;
             byte R = (byte)((comboColor.R + SystemColors.Window.R) / 2);
             byte G = (byte)((comboColor.G + SystemColors.Window.G) / 2);
             byte B = (byte)((comboColor.B + SystemColors.Window.B) / 2);
             brush = new WindowsSolidBrush(wg.DeviceContext, Color.FromArgb(R, G, B));
         }
         else {
             brush = new WindowsSolidBrush(wg.DeviceContext, checkBackground);
         }
         
         try {
             wg.FillRectangle(brush, bounds);
         }
         finally {
             if (brush != null) {
                 brush.Dispose();
             }
         }
     }
 }
        private void DrawCheckBox(Graphics g, Rectangle bounds, CheckState state)
        {
            // If I Were A Painter... That would look way better. Sorry.

            int size;
            int boxTop;

            size = bounds.Size.Height < bounds.Size.Width ? bounds.Size.Height : bounds.Size.Width;
            size = size > ((int)g.DpiX / 7) ? ((int)g.DpiX / 7) : size;

            boxTop = bounds.Y + (bounds.Height - size) / 2;

            using (Pen p = new Pen(this.Owner.ForeColor))
            {
                g.DrawRectangle(p, bounds.X, boxTop, size, size);
            }

            if (state != CheckState.Unchecked)
            {
                using (Pen p = new Pen(state == CheckState.Indeterminate ? SystemColors.GrayText : SystemColors.ControlText))
                {
                    g.DrawLine(p, bounds.X, boxTop, bounds.X + size, boxTop + size);
                    g.DrawLine(p, bounds.X, boxTop + size, bounds.X + size, boxTop);
                }
            }
        }
예제 #4
0
        protected override void SetCheckState(TreeNodeAdv node, CheckState value)
        {
            if (node.Tag is FileNode)
                return;

            base.SetCheckState(node, value);
        }
        internal override void PaintUp(PaintEventArgs e, CheckState state)
        {
            if (Control.Appearance == Appearance.Button) {
				ButtonAdapter.PaintUp(e, Control.CheckState);
            }
            else {
                ColorData colors = PaintRender(e.Graphics).Calculate();
                LayoutData layout = Layout(e).Layout();
                PaintButtonBackground(e, Control.ClientRectangle, null);

                //minor adjustment to make sure the appearance is exactly the same as Win32 app.
                int focusRectFixup = layout.focus.X & 0x1; // if it's odd, subtract one pixel for fixup.
                if (!Application.RenderWithVisualStyles) {
                    focusRectFixup = 1 - focusRectFixup;
                }

                if (!layout.options.everettButtonCompat) {
                    layout.textBounds.Offset(-1, -1); 
                }
                layout.imageBounds.Offset(-1, -1);
                layout.focus.Offset(-(focusRectFixup+1), -2);
                layout.focus.Width = layout.textBounds.Width + layout.imageBounds.Width - 1;
                layout.focus.Intersect(layout.textBounds);

                if( layout.options.textAlign != LayoutUtils.AnyLeft && layout.options.useCompatibleTextRendering && layout.options.font.Italic) {
                    // fixup for GDI+ text rendering.  VSW#515164
                    layout.focus.Width += 2;
                }

                PaintImage(e, layout);
                DrawCheckBox(e, layout);
                PaintField(e, layout, colors, colors.windowText, true);
            }
        }
 internal override void PaintUp(PaintEventArgs e, CheckState state)
 {
     if (base.Control.Appearance == Appearance.Button)
     {
         this.ButtonAdapter.PaintUp(e, base.Control.CheckState);
     }
     else
     {
         ButtonBaseAdapter.ColorData colors = base.PaintRender(e.Graphics).Calculate();
         ButtonBaseAdapter.LayoutData layout = this.Layout(e).Layout();
         base.PaintButtonBackground(e, base.Control.ClientRectangle, null);
         int num = layout.focus.X & 1;
         if (!Application.RenderWithVisualStyles)
         {
             num = 1 - num;
         }
         if (!layout.options.everettButtonCompat)
         {
             layout.textBounds.Offset(-1, -1);
         }
         layout.imageBounds.Offset(-1, -1);
         layout.focus.Offset(-(num + 1), -2);
         layout.focus.Width = (layout.textBounds.Width + layout.imageBounds.Width) - 1;
         layout.focus.Intersect(layout.textBounds);
         if (((layout.options.textAlign != (ContentAlignment.BottomLeft | ContentAlignment.MiddleLeft | ContentAlignment.TopLeft)) && layout.options.useCompatibleTextRendering) && layout.options.font.Italic)
         {
             layout.focus.Width += 2;
         }
         base.PaintImage(e, layout);
         base.DrawCheckBox(e, layout);
         base.PaintField(e, layout, colors, colors.windowText, true);
     }
 }
예제 #7
0
 public static Int32 CheckState2Int32(CheckState state)
 {
     Int32 stateInt32 = 0;
     if(state == CheckState.Indeterminate) stateInt32 = 1;
     else if(state == CheckState.Checked)  stateInt32 = 2;
     return stateInt32;
 }
예제 #8
0
        internal override void PaintOver(PaintEventArgs e, CheckState state) {
            System.Drawing.Graphics g = e.Graphics;
            if (Control.Appearance == Appearance.Button) {
                ButtonPopupAdapter adapter = new ButtonPopupAdapter(Control);
                adapter.PaintOver(e, Control.CheckState);
            }
            else {
                ColorData colors = PaintPopupRender(e.Graphics).Calculate();
                LayoutData layout = PaintPopupLayout(e, true).Layout();

                Region original = e.Graphics.Clip;
                PaintButtonBackground(e, Control.ClientRectangle, null);

                PaintImage(e, layout);
                
                DrawCheckBackground(e, layout.checkBounds, colors.windowText, colors.options.highContrast ? colors.buttonFace : colors.highlight, true, colors);
                DrawPopupBorder(g, layout.checkBounds, colors);
                DrawCheckOnly(e, layout, colors, colors.windowText, colors.highlight, true);

                e.Graphics.Clip = original;
                e.Graphics.ExcludeClip(layout.checkArea);

                PaintField(e, layout, colors, colors.windowText, true);
            }
        }
        internal override void PaintOver(PaintEventArgs e, CheckState state) {
            ColorData colors = PaintPopupRender(e.Graphics).Calculate();
            LayoutData layout = PaintPopupLayout(e, state == CheckState.Unchecked, SystemInformation.HighContrast ? 2 : 1).Layout();

            Graphics g = e.Graphics;
            //Region original = g.Clip;

            Rectangle r = Control.ClientRectangle;

            Brush backbrush = null;
            if (state == CheckState.Indeterminate) {
                backbrush = CreateDitherBrush(colors.highlight, colors.buttonFace);
            }

            try {
                PaintButtonBackground(e, r, backbrush);
            }
            finally {
                if (backbrush != null) {
                    backbrush.Dispose();
                    backbrush = null;
                }
            }
            if (Control.IsDefault) {
                r.Inflate(-1, -1);
            }

            PaintImage(e, layout);
            PaintField(e, layout, colors, colors.windowText, true);

            DrawDefaultBorder(g, r, colors.options.highContrast ? colors.windowText : colors.buttonShadow, this.Control.IsDefault);

            if (SystemInformation.HighContrast) {
                using (Pen windowFrame = new Pen(colors.windowFrame),
                       highlight = new Pen(colors.highlight),
                       buttonShadow = new Pen(colors.buttonShadow)) {

                    // top, left white
                    g.DrawLine(windowFrame, r.Left + 1, r.Top + 1, r.Right - 2, r.Top + 1);
                    g.DrawLine(windowFrame, r.Left + 1, r.Top + 1, r.Left + 1, r.Bottom - 2);

                    // bottom, right white
                    g.DrawLine(windowFrame, r.Left, r.Bottom - 1, r.Right, r.Bottom - 1);
                    g.DrawLine(windowFrame, r.Right - 1, r.Top, r.Right - 1, r.Bottom);

                    // top, left gray
                    g.DrawLine(highlight, r.Left, r.Top, r.Right, r.Top);
                    g.DrawLine(highlight, r.Left, r.Top, r.Left, r.Bottom);

                    // bottom, right gray
                    g.DrawLine(buttonShadow, r.Left + 1, r.Bottom - 2, r.Right - 2, r.Bottom - 2);
                    g.DrawLine(buttonShadow, r.Right - 2, r.Top + 1, r.Right - 2, r.Bottom - 2);
                }

                r.Inflate(-2, -2);
            }
            else {
                Draw3DLiteBorder(g, r, colors, true);
            }
        }
        public static void Fill(this CheckedListBox source, string[] values, CheckState initCheckState)
        {
            source.Items.Clear();

            foreach (string value in values)
                source.Items.Add(value, initCheckState);
        }
 internal static void DrawCheckBackground(bool controlEnabled, CheckState controlCheckState, Graphics g, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ButtonBaseAdapter.ColorData colors)
 {
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(g))
     {
         WindowsBrush brush;
         if (!controlEnabled && disabledColors)
         {
             brush = new WindowsSolidBrush(graphics.DeviceContext, SystemColors.Control);
         }
         else if (((controlCheckState == CheckState.Indeterminate) && (checkBackground == SystemColors.Window)) && disabledColors)
         {
             Color color = SystemInformation.HighContrast ? SystemColors.ControlDark : SystemColors.Control;
             byte red = (byte) ((color.R + SystemColors.Window.R) / 2);
             byte green = (byte) ((color.G + SystemColors.Window.G) / 2);
             byte blue = (byte) ((color.B + SystemColors.Window.B) / 2);
             brush = new WindowsSolidBrush(graphics.DeviceContext, Color.FromArgb(red, green, blue));
         }
         else
         {
             brush = new WindowsSolidBrush(graphics.DeviceContext, checkBackground);
         }
         try
         {
             graphics.FillRectangle(brush, bounds);
         }
         finally
         {
             if (brush != null)
             {
                 brush.Dispose();
             }
         }
     }
 }
		void SetAllItem(CheckState state)
		{
			foreach (ListViewItem item in listView1.SelectedItems)
			{
				item.Tag = state;
			}
			SetState();
		}
        internal override void PaintDown(PaintEventArgs e, CheckState state) {
            if (Control.Appearance == Appearance.Button) {
				ButtonAdapter.PaintDown(e, Control.CheckState);
            }
            else {
                PaintUp(e, state);
            }
        }
예제 #14
0
 public static AppointmentTimeVisibility CheckStateToTimeVisibility(CheckState state)
 {
     if (state == CheckState.Checked)
         return AppointmentTimeVisibility.Always;
     if (state == CheckState.Unchecked)
         return AppointmentTimeVisibility.Never;
     return AppointmentTimeVisibility.Auto;
 }
예제 #15
0
 internal override void PaintOver(PaintEventArgs e, CheckState state) {
     if (Control.Appearance == Appearance.Button) {
         ButtonAdapter.PaintOver(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
     }
     else {
         PaintUp(e, state);
     }
 }        
 public void RaiseDeviceTypeCheck(int index, CheckState newCheckValue, CheckState currentValue)
 {
     ItemCheckEventArgs args = new ItemCheckEventArgs(index, newCheckValue, currentValue);
     if (null != DeviceTypeCheck)
     {
         DeviceTypeCheck(this, args);
     }
 }
예제 #17
0
파일: Routes.cs 프로젝트: JordanChin/Ingres
 public SearchParams(String DepartingAirport, String ArrivingAirport,
     String OnDays, CheckState RoundTrip)
 {
     departingAirport = DepartingAirport;
     arrivingAirport = ArrivingAirport;
     onDays = OnDays;
     roundTrip = RoundTrip;
 }
예제 #18
0
		public static CheckState Combine(this CheckState checkState1, CheckState checkState2)
		{
			if (checkState1 == CheckState.Checked && checkState2 == CheckState.Checked)
				return CheckState.Checked;
			if (checkState1 == CheckState.Unchecked && checkState2 == CheckState.Unchecked)
				return CheckState.Unchecked;
			return CheckState.Indeterminate;
		}
예제 #19
0
 private CheckState GetNewState(CheckState state)
 {
     if (state == CheckState.Indeterminate)
     return CheckState.Unchecked;
       else if (state == CheckState.Unchecked)
     return CheckState.Checked;
       else
     return ThreeState ? CheckState.Indeterminate : CheckState.Unchecked;
 }
예제 #20
0
 public void CheckUserImput(CheckState shoulBe)
 {
     var item = _manager.Get();
     var result =
         _manager.Check(shoulBe == CheckState.Correct
             ? CorrectInputByWord(item.Word)
             : IncorrectInputByWord(item.Word));
     result.State.Should().Be(shoulBe);
 }
		protected void SetState(bool value)
		{
			this.state = value ? CheckState.Checked : CheckState.Unchecked;

			this.Invalidate();
			this.PerformSetValue();
			this.PerformGetValue();
			this.OnEditingFinished(FinishReason.LeapValue);
		}
 private Filter.YNA c2y(CheckState c)
 {
     if (c == CheckState.Checked)
         return Filter.YNA.Yes;
     else if (c == CheckState.Indeterminate)
         return Filter.YNA.All;
     else
         return Filter.YNA.No;
 }
예제 #23
0
        /// <summary>
        /// Sets the check state of the node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="value">The value.</param>
        protected override void SetCheckState(TreeNodeAdv node, CheckState value)
        {
            var threeStateNode = node.Tag as ThreeStateNode;

            if (threeStateNode == null)
                return;

            threeStateNode.CheckState = value;
        }
예제 #24
0
		public override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown(e);

			if (_checkState != CheckState.Checked) {
				_checkState = CheckState.Checked;
				_dontUncheck = true;
			}
		}
 internal override void PaintOver(PaintEventArgs e, CheckState state)
 {
     ButtonBaseAdapter.ColorData colors = base.PaintPopupRender(e.Graphics).Calculate();
     ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, state == CheckState.Unchecked, SystemInformation.HighContrast ? 2 : 1).Layout();
     Graphics g = e.Graphics;
     Rectangle clientRectangle = base.Control.ClientRectangle;
     Brush background = null;
     if (state == CheckState.Indeterminate)
     {
         background = ButtonBaseAdapter.CreateDitherBrush(colors.highlight, colors.buttonFace);
     }
     try
     {
         base.PaintButtonBackground(e, clientRectangle, background);
     }
     finally
     {
         if (background != null)
         {
             background.Dispose();
             background = null;
         }
     }
     if (base.Control.IsDefault)
     {
         clientRectangle.Inflate(-1, -1);
     }
     base.PaintImage(e, layout);
     base.PaintField(e, layout, colors, colors.windowText, true);
     ButtonBaseAdapter.DrawDefaultBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.buttonShadow, base.Control.IsDefault);
     if (SystemInformation.HighContrast)
     {
         using (Pen pen = new Pen(colors.windowFrame))
         {
             using (Pen pen2 = new Pen(colors.highlight))
             {
                 using (Pen pen3 = new Pen(colors.buttonShadow))
                 {
                     g.DrawLine(pen, (int) (clientRectangle.Left + 1), (int) (clientRectangle.Top + 1), (int) (clientRectangle.Right - 2), (int) (clientRectangle.Top + 1));
                     g.DrawLine(pen, (int) (clientRectangle.Left + 1), (int) (clientRectangle.Top + 1), (int) (clientRectangle.Left + 1), (int) (clientRectangle.Bottom - 2));
                     g.DrawLine(pen, clientRectangle.Left, clientRectangle.Bottom - 1, clientRectangle.Right, clientRectangle.Bottom - 1);
                     g.DrawLine(pen, clientRectangle.Right - 1, clientRectangle.Top, clientRectangle.Right - 1, clientRectangle.Bottom);
                     g.DrawLine(pen2, clientRectangle.Left, clientRectangle.Top, clientRectangle.Right, clientRectangle.Top);
                     g.DrawLine(pen2, clientRectangle.Left, clientRectangle.Top, clientRectangle.Left, clientRectangle.Bottom);
                     g.DrawLine(pen3, (int) (clientRectangle.Left + 1), (int) (clientRectangle.Bottom - 2), (int) (clientRectangle.Right - 2), (int) (clientRectangle.Bottom - 2));
                     g.DrawLine(pen3, (int) (clientRectangle.Right - 2), (int) (clientRectangle.Top + 1), (int) (clientRectangle.Right - 2), (int) (clientRectangle.Bottom - 2));
                 }
             }
         }
         clientRectangle.Inflate(-2, -2);
     }
     else
     {
         ButtonBaseAdapter.Draw3DLiteBorder(g, clientRectangle, colors, true);
     }
 }
        /// <summary>
        /// fill check-box-list by DataTable's field values
        /// </summary>
        /// <param name="source"></param>
        /// <param name="dt"></param>
        /// <param name="field"></param>
        /// <param name="initCheckState"></param>
        public static void Fill(this CheckedListBox source, DataTable dt, string field, CheckState initCheckState)
        {
            source.Items.Clear();

            foreach (DataRow row in dt.Rows)
            {
                string fieldValue = row[field].ToString();
                source.Items.Add(fieldValue, initCheckState);
            }
        }
예제 #27
0
 public CacheItem()
 {
     cacheHost = null;
     checkState = System.Windows.Forms.CheckState.Checked;
     Url = string.Empty;
     Local = string.Empty;
     ResponseHeaders = new List<CacheHeader>();
     //new NameValueCollection();
     //new Dictionary<string, string>();
     Creation = DateTime.Now;
 }
예제 #28
0
		public void PaintCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, ElementState state, FlatStyle style, CheckState checkState)
		{
			switch (style) {
				case FlatStyle.Standard:
				case FlatStyle.System:
					switch (state) {
						case ElementState.Normal:
							DrawNormalCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Hot:
							DrawHotCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Pressed:
							DrawPressedCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Disabled:
							DrawDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
					}
					break;
				case FlatStyle.Flat:
					switch (state) {
						case ElementState.Normal:
							DrawFlatNormalCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Hot:
							DrawFlatHotCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Pressed:
							DrawFlatPressedCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Disabled:
							DrawFlatDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
					}
					break;
				case FlatStyle.Popup:
					switch (state) {
						case ElementState.Normal:
							DrawPopupNormalCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Hot:
							DrawPopupHotCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Pressed:
							DrawPopupPressedCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
						case ElementState.Disabled:
							DrawPopupDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
							break;
					}
					break;
			}
		}
 internal override void PaintDown(PaintEventArgs e, CheckState state)
 {
     if (base.Control.Appearance == Appearance.Button)
     {
         this.ButtonAdapter.PaintDown(e, base.Control.Checked ? CheckState.Checked : CheckState.Unchecked);
     }
     else
     {
         this.PaintUp(e, state);
     }
 }
예제 #30
0
        public SettingsWindow(ProgramSettings PersonalSettings)
        {
            InitializeComponent();

              // this is just to check an item by just a single click on it.
              checkListBox.CheckOnClick = true;

              this.PersonalSettings = PersonalSettings;
              //LoadSettings();
              ShowOnStartup_OldValue = checkListBox.GetItemCheckState(0);
              SniffCurrentRemovalbeDrivesInSilentMode_OldValue = checkListBox.GetItemCheckState(1);
        }
        /// <summary>
        /// This member overrides DataGridViewCell.Paint.
        /// </summary>
        /// <param name="graphics">The Graphics used to paint the DataGridViewCell.</param>
        /// <param name="clipBounds">A Rectangle that represents the area of the DataGridView that needs to be repainted.</param>
        /// <param name="cellBounds">A Rectangle that contains the bounds of the DataGridViewCell that is being painted.</param>
        /// <param name="rowIndex">The row index of the cell that is being painted.</param>
        /// <param name="cellState">A bitwise combination of DataGridViewElementStates values that specifies the state of the cell.</param>
        /// <param name="value">The data of the DataGridViewCell that is being painted.</param>
        /// <param name="formattedValue">The formatted data of the DataGridViewCell that is being painted.</param>
        /// <param name="errorText">An error message that is associated with the cell.</param>
        /// <param name="cellStyle">A DataGridViewCellStyle that contains formatting and style information about the cell.</param>
        /// <param name="advancedBorderStyle">A DataGridViewAdvancedBorderStyle that contains border styles for the cell that is being painted.</param>
        /// <param name="paintParts">A bitwise combination of the DataGridViewPaintParts values that specifies which parts of the cell need to be painted.</param>
        protected override void Paint(Graphics graphics,
                                      Rectangle clipBounds,
                                      Rectangle cellBounds,
                                      int rowIndex,
                                      DataGridViewElementStates cellState,
                                      object value,
                                      object formattedValue,
                                      string errorText,
                                      DataGridViewCellStyle cellStyle,
                                      DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      DataGridViewPaintParts paintParts)
        {
            if (DataGridView is KryptonDataGridView kDgv)
            {
                // Should we draw the content foreground?
                if ((paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground)
                {
                    CheckState checkState = CheckState.Unchecked;

                    if (formattedValue is CheckState state)
                    {
                        checkState = state;
                    }
                    else if (formattedValue is bool)
                    {
                        if ((bool)formattedValue)
                        {
                            checkState = CheckState.Checked;
                        }
                        else
                        {
                            checkState = CheckState.Unchecked;
                        }
                    }

                    // Is this cell the currently active cell
                    bool currentCell = (rowIndex == DataGridView.CurrentCellAddress.Y) &&
                                       (ColumnIndex == DataGridView.CurrentCellAddress.X);

                    // Is this cell the same as the one with the mouse inside it
                    Point mouseEnteredCellAddress = MouseEnteredCellAddressInternal;
                    bool  mouseCell = (rowIndex == mouseEnteredCellAddress.Y) &&
                                      (ColumnIndex == mouseEnteredCellAddress.X);

                    // Snoop tracking and pressed status from the base class implementation
                    bool tracking = mouseCell && MouseInContentBoundsInternal;
                    bool pressed  = currentCell && ((ButtonStateInternal & ButtonState.Pushed) == ButtonState.Pushed);

                    using (RenderContext renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer))
                    {
                        Size checkBoxSize;

                        // Find out the requested size of the check box drawing
                        using (ViewLayoutContext viewContent = new ViewLayoutContext(kDgv, kDgv.Renderer))
                        {
                            checkBoxSize = renderContext.Renderer.RenderGlyph.GetCheckBoxPreferredSize(viewContent,
                                                                                                       kDgv.Redirector,
                                                                                                       kDgv.Enabled && !base.ReadOnly,
                                                                                                       checkState,
                                                                                                       tracking,
                                                                                                       pressed);
                        }
                        // Remember the original cell bounds
                        Rectangle startBounds = cellBounds;

                        // Prevent check box overlapping the bottom/right border
                        cellBounds.Width--;
                        cellBounds.Height--;

                        // Adjust the horizontal alignment
                        switch (cellStyle.Alignment)
                        {
                        case DataGridViewContentAlignment.NotSet:
                        case DataGridViewContentAlignment.TopCenter:
                        case DataGridViewContentAlignment.MiddleCenter:
                        case DataGridViewContentAlignment.BottomCenter:
                            cellBounds.X += (cellBounds.Width - checkBoxSize.Width) / 2;
                            break;

                        case DataGridViewContentAlignment.TopRight:
                        case DataGridViewContentAlignment.MiddleRight:
                        case DataGridViewContentAlignment.BottomRight:
                            cellBounds.X = cellBounds.Right - checkBoxSize.Width;
                            break;
                        }

                        // Adjust the vertical alignment
                        switch (cellStyle.Alignment)
                        {
                        case DataGridViewContentAlignment.NotSet:
                        case DataGridViewContentAlignment.MiddleLeft:
                        case DataGridViewContentAlignment.MiddleCenter:
                        case DataGridViewContentAlignment.MiddleRight:
                            cellBounds.Y += (cellBounds.Height - checkBoxSize.Height) / 2;
                            break;

                        case DataGridViewContentAlignment.BottomLeft:
                        case DataGridViewContentAlignment.BottomCenter:
                        case DataGridViewContentAlignment.BottomRight:
                            cellBounds.Y = cellBounds.Bottom - checkBoxSize.Height;
                            break;
                        }

                        // Make the cell the same size as the check box itself
                        cellBounds.Width  = checkBoxSize.Width;
                        cellBounds.Height = checkBoxSize.Height;

                        // Remember the current drawing bounds
                        _contentBounds = new Rectangle(cellBounds.X - startBounds.X,
                                                       cellBounds.Y - startBounds.Y,
                                                       cellBounds.Width, cellBounds.Height);

                        // Perform actual drawing of the check box
                        renderContext.Renderer.RenderGlyph.DrawCheckBox(renderContext,
                                                                        cellBounds,
                                                                        kDgv.Redirector,
                                                                        kDgv.Enabled && !base.ReadOnly,
                                                                        checkState,
                                                                        tracking,
                                                                        pressed);
                    }
                }
            }
            else
            {
                base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                           cellState, value, formattedValue, errorText,
                           cellStyle, advancedBorderStyle, paintParts);
            }
        }
예제 #32
0
        /// <summary>
        /// Gets a check box image appropriate for the provided state.
        /// </summary>
        /// <param name="enabled">Is the check box enabled.</param>
        /// <param name="checkState">Is the check box checked/unchecked/indeterminate.</param>
        /// <param name="tracking">Is the check box being hot tracked.</param>
        /// <param name="pressed">Is the check box being pressed.</param>
        /// <returns>Appropriate image for drawing; otherwise null.</returns>
        public override Image GetCheckBoxImage(bool enabled,
                                               CheckState checkState,
                                               bool tracking,
                                               bool pressed)
        {
            Image retImage = null;

            // Get the state specific image
            switch (checkState)
            {
            default:
            case CheckState.Unchecked:
                if (!enabled)
                {
                    retImage = _images.UncheckedDisabled;
                }
                else if (pressed)
                {
                    retImage = _images.UncheckedPressed;
                }
                else if (tracking)
                {
                    retImage = _images.UncheckedTracking;
                }
                else
                {
                    retImage = _images.UncheckedNormal;
                }
                break;

            case CheckState.Checked:
                if (!enabled)
                {
                    retImage = _images.CheckedDisabled;
                }
                else if (pressed)
                {
                    retImage = _images.CheckedPressed;
                }
                else if (tracking)
                {
                    retImage = _images.CheckedTracking;
                }
                else
                {
                    retImage = _images.CheckedNormal;
                }
                break;

            case CheckState.Indeterminate:
                if (!enabled)
                {
                    retImage = _images.IndeterminateDisabled;
                }
                else if (pressed)
                {
                    retImage = _images.IndeterminatePressed;
                }
                else if (tracking)
                {
                    retImage = _images.IndeterminateTracking;
                }
                else
                {
                    retImage = _images.IndeterminateNormal;
                }
                break;
            }

            // Not found, then get the common image
            if (retImage == null)
            {
                retImage = _images.Common;
            }

            // Not found, then inherit from target
            if (retImage == null)
            {
                retImage = Target.GetCheckBoxImage(enabled, checkState, tracking, pressed);
            }

            return(retImage);
        }
예제 #33
0
 /// <summary>
 /// Add an item with the given state to the control
 /// </summary>
 /// <param name="item"></param>
 /// <param name="state"></param>
 public void AddItem(object item, CheckState state)
 {
     this.Items.Add(item);
     this.CheckedListBoxControl.SetItemCheckState(this.Items.Count - 1, state);
 }
예제 #34
0
파일: Util.cs 프로젝트: pwgoertz/bvcms
        public static void AddPerson(this Control f,
                                     string first,
                                     string last,
                                     string goesby,
                                     string dob,
                                     string email,
                                     string addr,
                                     string zip,
                                     string cell,
                                     string home,
                                     string allergies,
                                     string grade,
                                     string parent,
                                     string emfriend,
                                     string emphone,
                                     string churchname,
                                     CheckState activeother,
                                     int marital,
                                     int gender)
        {
            var wc   = CreateWebClient();
            var coll = new NameValueCollection();

            coll.Add("first", first);
            coll.Add("last", last);
            coll.Add("goesby", goesby);
            coll.Add("dob", dob);
            coll.Add("email", email);
            coll.Add("addr", addr);
            coll.Add("zip", zip);
            coll.Add("cell", cell);
            if (home.HasValue())
            {
                coll.Add("home", home);
            }
            else
            {
                coll.Add("home", cell);
            }
            coll.Add("marital", marital.ToString());
            coll.Add("gender", gender.ToString());
            coll.Add("campusid", Program.settings.campusID);
            coll.Add("allergies", allergies);
            if (Program.settings.askGrade)
            {
                coll.Add("grade", grade);
                coll.Add("AskGrade", Program.settings.askGrade.ToString());
            }
            if (Program.settings.askChurchName)
            {
                coll.Add("churchname", churchname);
                coll.Add("AskChurchName", Program.settings.askChurchName.ToString());
            }
            if (Program.settings.askFriend)
            {
                coll.Add("parent", parent);
                coll.Add("emphone", emphone.GetDigits());
                coll.Add("AskEmFriend", Program.settings.askFriend.ToString());
                coll.Add("emfriend", emfriend);
            }
            if (Program.settings.askChurch)
            {
                coll.Add("activeother", (activeother == CheckState.Checked).ToString());
                coll.Add("AskChurch", Program.settings.askChurch.ToString());
            }
            var url  = Program.settings.createURI("Checkin2/AddPerson/" + Program.FamilyId);
            var resp = wc.UploadValues(url, "POST", coll);
            var s    = Encoding.ASCII.GetString(resp);
            var a    = s.Split('.');

            Program.FamilyId = a[0].ToInt();
            Program.PeopleId = a[1].ToInt();
        }
예제 #35
0
        /// <summary>
        /// Called when a control has been successfully validated.
        /// </summary>
        /// <param name="sender">The control that was validated.</param>
        /// <param name="e">Parameters for the event.</param>
        protected virtual void HandleControlValidated(object sender, EventArgs e)
        {
            Control control      = (Control)sender;
            string  propertyName = (string)control.Tag;
            string  value        = null;

            TextBox  textBox  = control as TextBox;
            CheckBox checkBox = control as CheckBox;
            ComboBox comboBox = control as ComboBox;

            if (textBox != null && !textBox.Modified)
            {
                return;
            }

            string currentValue = this.ParentPropertyPage.GetProperty(propertyName);

            if (checkBox != null)
            {
                if (checkBox.CheckState == CheckState.Indeterminate)
                {
                    value = null;
                }
                else
                {
                    value = checkBox.Checked.ToString(CultureInfo.InvariantCulture);
                }

                CheckState currentCheckState = this.ParentPropertyPage.GetPropertyCheckState(propertyName);
                if (currentCheckState == CheckState.Indeterminate)
                {
                    currentValue = null;
                }
                else
                {
                    currentValue = (currentCheckState == CheckState.Checked).ToString();
                }
            }
            else if (comboBox != null)
            {
                value = comboBox.SelectedIndex.ToString(CultureInfo.InvariantCulture);
            }
            else if (textBox != null)
            {
                value = this.ParentPropertyPage.Normalize(propertyName, control.Text);
            }
            else
            {
                value = control.Text;
            }

            if (value != null && !String.Equals(value, currentValue, StringComparison.Ordinal))
            {
                // Note query-edit for TextBoxes was already done on the ModifiedChanged event.
                if (textBox != null || this.ParentPropertyPage.ProjectMgr.QueryEditProjectFile(false))
                {
                    this.ParentPropertyPage.SetProperty(propertyName, value);
                }
                else
                {
                    if (checkBox != null)
                    {
                        checkBox.CheckState = this.ParentPropertyPage.GetPropertyCheckState(propertyName);
                    }
                    else if (comboBox != null)
                    {
                        comboBox.SelectedIndex = Int32.Parse(currentValue, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        control.Text = currentValue;
                    }
                }
            }

            if (textBox != null)
            {
                // Set to normalized text.
                textBox.Text     = value;
                textBox.Modified = false;
            }
        }
예제 #36
0
        /// <summary>
        /// Private method that is called by one of the childnodes in order to report a
        /// change in state.
        /// </summary>
        /// <param name="childNewState">New state of the childnode in question</param>
        private void ChildCheckStateChanged(CheckState childNewState)
        {
            bool       notifyParent = false;
            CheckState currentState = this._nodeCheckState;
            CheckState newState     = this._nodeCheckState;

            // take action based on the child's new state
            switch (childNewState)
            {
            case CheckState.Indeterminate:                     // child state changed to indeterminate
                // if one of the children's state changes to indeterminate,
                // it's parent should do the same, if it is a container too!.
                if (IsContainer)
                {
                    newState = CheckState.Indeterminate;

                    // the same is valid for this node's parent.
                    // check if this node's state has changed and inform the parent
                    // if this is the case
                    notifyParent = (newState != currentState);
                }
                break;

            case CheckState.Checked:
                // One of the child nodes was checked so we must check:
                // 1) if the child node is the only child node, our state becomes checked too.
                // 2) if there are children with a state other then checked, our state
                //    must become indeterminate if this is a container.
                if (this.Nodes.Count == 1)                          // if there is only one child, our state changes too!
                {
                    // set our state to checked too and set the flag for
                    // parent notification.
                    newState     = CheckState.Checked;
                    notifyParent = true;
                    break;
                }

                // set to checked by default
                // if this is not a container, there is no need to check further
                newState = CheckState.Checked;
                if (!IsContainer)
                {
                    notifyParent = (newState != currentState);
                    break;
                }

                // traverse all child nodes to see if there are any with a state other then
                // checked. if so, change state to indeterminate.
                foreach (TreeNode node in this.Nodes)
                {
                    TriStateTreeNode checkedNode = node as TriStateTreeNode;
                    if (checkedNode != null && checkedNode.CheckState != CheckState.Checked)
                    {
                        newState = CheckState.Indeterminate;
                        break;
                    }
                }

                // set notification flag if our state has to be changed too
                notifyParent = (newState != currentState);
                break;

            case CheckState.Unchecked:
                // For nodes that are no containers, a child being unchecked is not relevant.
                // so we can exit at this point.
                if (!IsContainer)
                {
                    break;
                }

                // A child's state has changed to unchecked so check:
                // 1) if this is the only child. if so, uncheck this node too, if it is a container, and set
                //	  notification flag for the parent.
                // 2) Check if there are child nodes with a state other then unchecked.
                //	  if so, change our state to indeterminate.
                if (this.Nodes.Count == 1)
                {
                    // synchronize state with only child.
                    // set notification flag
                    newState     = CheckState.Unchecked;
                    notifyParent = true;
                    break;
                }

                // set to unchecked by default
                newState = CheckState.Unchecked;

                // if there is a child with a state other then unchecked,
                // our state must become indeterminate.
                foreach (TreeNode node in this.Nodes)
                {
                    TriStateTreeNode checkedNode = node as TriStateTreeNode;
                    if (checkedNode != null && checkedNode.CheckState != CheckState.Unchecked)
                    {
                        newState = CheckState.Indeterminate;
                        break;
                    }
                }

                // notify the parent only if our state is about to be changed too.
                notifyParent = (newState != currentState);
                break;
            }

            // should we notify the parent? ( has our state changed? )
            if (notifyParent)
            {
                // change state
                this._nodeCheckState = newState;

                // notify parent
                if (this.Parent != null)
                {
                    TriStateTreeNode parentNode = this.Parent as TriStateTreeNode;
                    if (parentNode != null)
                    {
                        // call the same method on the parent.
                        parentNode.ChildCheckStateChanged(this._nodeCheckState);
                    }
                }
            }
        }
 internal override void PaintDown(PaintEventArgs e, CheckState state)
 {
     PaintWorker(e, false, state);
 }
예제 #38
0
        private void PressMenuCheckBox(bool keyboard)
        {
            if (keyboard)
            {
                _menuCheckBox.ViewDrawContent.ElementState = PaletteState.Pressed;
                PerformNeedPaint();
                Application.DoEvents();
            }

            // Should we automatically try and close the context menu stack
            if (_menuCheckBox.KryptonContextMenuCheckBox.AutoClose)
            {
                // Is the menu capable of being closed?
                if (_menuCheckBox.CanCloseMenu)
                {
                    // Ask the original context menu definition, if we can close
                    CancelEventArgs cea = new CancelEventArgs();
                    _menuCheckBox.Closing(cea);

                    if (!cea.Cancel)
                    {
                        // Close the menu from display and pass in the item clicked as the reason
                        _menuCheckBox.Close(new CloseReasonEventArgs(ToolStripDropDownCloseReason.ItemClicked));
                    }
                }
            }

            // Do we need to automatically change the checked/checkstate?
            if (_menuCheckBox.KryptonContextMenuCheckBox.AutoCheck)
            {
                // Grab current state from command or ourself
                CheckState state = (_menuCheckBox.KryptonContextMenuCheckBox.KryptonCommand == null ?
                                    _menuCheckBox.KryptonContextMenuCheckBox.CheckState :
                                    _menuCheckBox.KryptonContextMenuCheckBox.KryptonCommand.CheckState);

                // Change state based on the current state
                switch (state)
                {
                case CheckState.Unchecked:
                    state = CheckState.Checked;
                    break;

                case CheckState.Checked:
                    state = (_menuCheckBox.KryptonContextMenuCheckBox.ThreeState ? CheckState.Indeterminate : CheckState.Unchecked);
                    break;

                case CheckState.Indeterminate:
                    state = CheckState.Unchecked;
                    break;
                }

                // Update correct target with new state
                if (_menuCheckBox.KryptonContextMenuCheckBox.KryptonCommand != null)
                {
                    _menuCheckBox.KryptonContextMenuCheckBox.KryptonCommand.CheckState = state;
                }
                else
                {
                    _menuCheckBox.KryptonContextMenuCheckBox.CheckState = state;
                }

                // Update visual appearance to reflect new state
                _menuCheckBox.ViewDrawCheckBox.CheckState = state;
            }

            if (Click != null)
            {
                Click(this, EventArgs.Empty);
            }

            if (keyboard)
            {
                UpdateTarget();
                PerformNeedPaint();
            }
        }
예제 #39
0
        public ListDnsReverses(SEaddress input, CheckState is128Checked, CultureInfo culture)
        {
            InitializeComponent();

            this.StartEnd.ID  = ID;
            this.incomingID   = input.ID;
            this.is128Checked = is128Checked;
            this.culture      = culture;

            this.SwitchLanguage(this.culture);

            if (input.subnetslash % 4 == 1 && is128Checked == CheckState.Checked)
            {
                upto = 64;
                this.toolTip1.SetToolTip(this.Backwd, "-64");
                this.toolTip1.SetToolTip(this.Forwd, "+64");
            }

            StartEnd.Start             = input.Start;
            StartEnd.End               = input.End;
            StartEnd.Resultv6          = input.Resultv6;
            StartEnd.LowerLimitAddress = input.LowerLimitAddress;
            StartEnd.UpperLimitAddress = input.UpperLimitAddress;
            StartEnd.upto              = upto;
            StartEnd.slash             = input.slash;
            StartEnd.subnetslash       = input.subnetslash;
            StartEnd.subnetidx         = input.subnetidx;

            subnets.Start             = input.Start;
            subnets.End               = input.End;
            subnets.slash             = input.slash;
            subnets.subnetslash       = input.subnetslash;
            subnets.LowerLimitAddress = input.LowerLimitAddress;
            subnets.UpperLimitAddress = input.UpperLimitAddress;


            BigInteger max = NumberOfZones =
                (BigInteger.One << (input.subnetslash - input.slash));

            zmaxval            = max - BigInteger.One;
            this.textBox1.Text = NumberOfZones.ToString();

            if (subnets.subnetslash % 4 != 0)
            {
                this.textBox3.Text = StringsDictionary.KeyValue("ListDNSRev_textBox3.Text", this.culture);
            }

            if (this.is128Checked == CheckState.Unchecked)
            {
                this.DefaultView();

                string s = String.Format("{0:x}", StartEnd.Start);
                if (s == "0")
                {
                    s = "0000000000000000";
                }
                else if (s.Length > 16)
                {
                    s = s.Substring(1, 16);
                }

                this.label5.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked))
                                   + "/" + StartEnd.subnetslash.ToString();

                s = String.Format("{0:x}", StartEnd.End);
                if (s == "0")
                {
                    s = "0000000000000000";
                }
                else if (s.Length > 16)
                {
                    s = s.Substring(1, 16);
                }

                this.label6.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked))
                                   + "/" + StartEnd.subnetslash.ToString();
            }
            else if (this.is128Checked == CheckState.Checked)
            {
                this.ExpandView();

                string s = String.Format("{0:x}", StartEnd.Start);
                if (s == "0")
                {
                    s = "00000000000000000000000000000000";
                }
                else if (s.Length > 32)
                {
                    s = s.Substring(1, 32);
                }
                this.label5.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked))
                                   + "/" + StartEnd.subnetslash.ToString();

                s = String.Format("{0:x}", StartEnd.End);
                if (s == "0")
                {
                    s = "00000000000000000000000000000000";
                }
                else if (s.Length > 32)
                {
                    s = s.Substring(1, 32);
                }
                this.label6.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked))
                                   + "/" + StartEnd.subnetslash.ToString();
            }

            this.FirstPage_Click(null, null);
        }
        // Let the item paint itself, and then paint the RadioButton
        // where the check mark is normally displayed.
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.Image != null)
            {
                // If the client sets the Image property, the selection behavior
                // remains unchanged, but the RadioButton is not displayed and the
                // selection is indicated only by the selection rectangle.
                base.OnPaint(e);
                return;
            }
            else
            {
                // If the Image property is not set, call the base OnPaint method
                // with the CheckState property temporarily cleared to prevent
                // the check mark from being painted.
                CheckState currentState = this.CheckState;
                this.CheckState = CheckState.Unchecked;
                base.OnPaint(e);
                this.CheckState = currentState;
            }

            // Determine the correct state of the RadioButton.
            RadioButtonState buttonState = RadioButtonState.UncheckedNormal;

            if (this.Enabled)
            {
                if (this.mouseDownState)
                {
                    if (this.Checked)
                    {
                        buttonState = RadioButtonState.CheckedPressed;
                    }
                    else
                    {
                        buttonState = RadioButtonState.UncheckedPressed;
                    }
                }
                else if (this.mouseHoverState)
                {
                    if (this.Checked)
                    {
                        buttonState = RadioButtonState.CheckedHot;
                    }
                    else
                    {
                        buttonState = RadioButtonState.UncheckedHot;
                    }
                }
                else
                {
                    if (this.Checked)
                    {
                        buttonState = RadioButtonState.CheckedNormal;
                    }
                }
            }
            else
            {
                if (this.Checked)
                {
                    buttonState = RadioButtonState.CheckedDisabled;
                }
                else
                {
                    buttonState = RadioButtonState.UncheckedDisabled;
                }
            }

            // Calculate the position at which to display the RadioButton.
            int offset = (ContentRectangle.Height -
                          RadioButtonRenderer.GetGlyphSize(
                              e.Graphics, buttonState).Height) / 2;
            Point imageLocation = new Point(
                ContentRectangle.Location.X + 4,
                ContentRectangle.Location.Y + offset);

            // Paint the RadioButton.
            RadioButtonRenderer.DrawRadioButton(
                e.Graphics, imageLocation, buttonState);
        }
예제 #41
0
 private static CheckState GetNextCheckState(CheckState currentCheckState)
 {
     return((CheckState)(((int)currentCheckState + 1) % 3));
 }
예제 #42
0
        public void LoadPage()
        {
            var sheet = grid.CurrentWorksheet;

            WorksheetRangeStyle style = sheet.GetRangeStyles(sheet.SelectionRange);

            if (style.TextWrapMode == TextWrapMode.WordBreak ||
                style.TextWrapMode == TextWrapMode.BreakAll)
            {
                backupTextWrapState = CheckState.Checked;
            }
            else
            {
                backupTextWrapState = CheckState.Unchecked;
            }

            backupHorAlign = style.HAlign;
            backupVerAlign = style.VAlign;

            switch (style.HAlign)
            {
            case ReoGridHorAlign.General:
                cmbHorAlign.SelectedIndex = 0; break;

            case ReoGridHorAlign.Left:
                cmbHorAlign.SelectedIndex = 1; break;

            case ReoGridHorAlign.Center:
                cmbHorAlign.SelectedIndex = 2; break;

            case ReoGridHorAlign.Right:
                cmbHorAlign.SelectedIndex = 3; break;

            case ReoGridHorAlign.DistributedIndent:
                cmbHorAlign.SelectedIndex = 4; break;
            }

            switch (style.VAlign)
            {
            case ReoGridVerAlign.General:
                cmbVerAlign.SelectedIndex = 0; break;

            case ReoGridVerAlign.Top:
                cmbVerAlign.SelectedIndex = 1; break;

            case ReoGridVerAlign.Middle:
                cmbVerAlign.SelectedIndex = 2; break;

            case ReoGridVerAlign.Bottom:
                cmbVerAlign.SelectedIndex = 3; break;
            }

            chkWrapText.CheckState = backupTextWrapState;

            backupIndent    = style.Indent;
            numIndent.Value = backupIndent;

            // cell text rotate

            var angle = style.RotationAngle;

            if (angle < -90)
            {
                angle = -90;
            }
            if (angle > 90)
            {
                angle = 90;
            }

            backupRotateAngle       = angle;
            textRotateControl.Angle = (int)angle;
            numRotationAngle.Value  = (int)angle;
        }
예제 #43
0
 public void CheckedListBox_SetItemCheckState_InvokeInvalidValue_ThrowsInvalidEnumArgumentException(CheckState value)
 {
     using var control = new CheckedListBox();
     control.Items.Add(new CheckBox(), false);
     Assert.Throws <InvalidEnumArgumentException>("value", () => control.SetItemCheckState(0, value));
 }
예제 #44
0
 /// <summary>
 /// Record the change of checkstate for the given object in the model.
 /// This does not update the UI -- only the model
 /// </summary>
 /// <param name="modelObject"></param>
 /// <param name="state"></param>
 /// <returns>The check state that was recorded and that should be used to update
 /// the control.</returns>
 protected override CheckState PutCheckState(object modelObject, CheckState state)
 {
     state = base.PutCheckState(modelObject, state);
     this.checkStateMap[modelObject] = state;
     return(state);
 }
 internal override void PaintOver(PaintEventArgs e, CheckState state)
 {
     PaintUp(e, state);
 }
예제 #46
0
 public static TripleTreeNode CreateNode(String Text, object Value, CheckState State = CheckState.Checked)
 {
     return(new TripleTreeNode(Text, Value, State, TripleTreeNodeType.Default));
 }
예제 #47
0
        public void AddValue(string val, string label, CheckState check)
        {
            XDataListItem item = new XDataListItem(label, val);

            checkedListBox.Items.Add(item, check);
        }
        /// <summary>
        /// Initialize a new instance of the KryptonCheckBox class.
        /// </summary>
        public KryptonCheckBox()
        {
            // Turn off standard click and double click events, we do that manually
            SetStyle(ControlStyles.StandardClick |
                     ControlStyles.StandardDoubleClick, false);

            // Set default properties
            _style         = LabelStyle.NormalControl;
            _orientation   = VisualOrientation.Top;
            _checkPosition = VisualOrientation.Left;
            _checked       = false;
            _threeState    = false;
            _checkState    = CheckState.Unchecked;
            _useMnemonic   = true;
            AutoCheck      = true;

            // Create content storage
            Values              = new LabelValues(NeedPaintDelegate);
            Values.TextChanged += OnCheckBoxTextChanged;
            Images              = new CheckBoxImages(NeedPaintDelegate);

            // Create palette redirector
            _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _paletteCheckBoxImages = new PaletteRedirectCheckBox(Redirector, Images);

            // Create the palette provider
            StateCommon   = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);
            StateDisabled = new PaletteContent(StateCommon, NeedPaintDelegate);
            StateNormal   = new PaletteContent(StateCommon, NeedPaintDelegate);
            OverrideFocus = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);

            // Override the normal values with the focus, when the control has focus
            _overrideNormal = new PaletteContentInheritOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride, false);

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_overrideNormal, this, VisualOrientation.Top)
            {
                UseMnemonic = _useMnemonic,

                // Only draw a focus rectangle when focus cues are needed in the top level form
                TestForFocusCues = true
            };

            // Create the check box image drawer and place inside element so it is always centered
            _drawCheckBox = new ViewDrawCheckBox(_paletteCheckBoxImages)
            {
                CheckState = _checkState
            };
            _layoutCenter = new ViewLayoutCenter
            {
                _drawCheckBox
            };

            // Place check box on the left and the label in the remainder
            _layoutDocker = new ViewLayoutDocker
            {
                { _layoutCenter, ViewDockStyle.Left },
                { _drawContent, ViewDockStyle.Fill }
            };

            // Need a controller for handling mouse input
            _controller                   = new CheckBoxController(_drawCheckBox, _layoutDocker, NeedPaintDelegate);
            _controller.Click            += OnControllerClick;
            _controller.Enabled           = true;
            _layoutDocker.MouseController = _controller;
            _layoutDocker.KeyController   = _controller;

            // Change the layout to match the inital right to left setting and orientation
            UpdateForOrientation();

            // Create the view manager instance
            ViewManager = new ViewManager(this, _layoutDocker);

            // We want to be auto sized by default, but not the property default!
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
예제 #49
0
 public static TripleTreeNode CreateAllsNode(String Text, CheckState State = CheckState.Checked)
 {
     return(new TripleTreeNode(Text, null, State, TripleTreeNodeType.AllsNode));
 }
 internal override void PaintUp(PaintEventArgs e, CheckState state)
 {
     PaintWorker(e, true, state);
 }
예제 #51
0
 public static TripleTreeNode CreateMSecNode(String Text, object Value, CheckState State = CheckState.Checked)
 {
     return(new TripleTreeNode(Text, Value, State, TripleTreeNodeType.MSecDateTimeNode));
 }
예제 #52
0
        private void executeFilter(object sender, DataGridViewCellEventArgs e)
        {
            int      codigo      = 0;
            string   os          = string.Empty;
            string   cliente     = string.Empty;
            string   condPag     = string.Empty;
            string   vendedor    = string.Empty;
            string   laboratorio = string.Empty;
            DateTime?DtEmiss     = null;
            decimal? total       = null;
            int?     status      = null;
            string   cancelado   = string.Empty;
            string   usuario     = string.Empty;

            if (dgvFiltro[COL_PEDIDO, e.RowIndex].Value != null)
            {
                if (!string.IsNullOrEmpty(dgvFiltro[COL_PEDIDO, e.RowIndex].Value.ToString()))
                {
                    codigo = Convert.ToInt32(dgvFiltro[COL_PEDIDO, e.RowIndex].Value);
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_OS, e.RowIndex].Value))
            {
                os = dgvFiltro[COL_OS, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CLIENTE, e.RowIndex].Value))
            {
                cliente = dgvFiltro[COL_CLIENTE, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CONDPAG, e.RowIndex].Value))
            {
                condPag = dgvFiltro[COL_CONDPAG, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_VENDEDOR, e.RowIndex].Value))
            {
                vendedor = dgvFiltro[COL_VENDEDOR, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_LABORATORIO, e.RowIndex].Value))
            {
                laboratorio = dgvFiltro[COL_LABORATORIO, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString()))
                    {
                        DtEmiss = Convert.ToDateTime(dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value);
                    }
                }
            }

            if (dgvFiltro[COL_TOTAL, e.RowIndex].Value != null)
            {
                total = Convert.ToDecimal(dgvFiltro[COL_TOTAL, e.RowIndex].Value);
            }

            if (dgvFiltro[COL_STATUS, e.RowIndex].Value != null)
            {
                status = (int)((DataGridViewComboBoxCell)dgvFiltro[COL_STATUS, e.RowIndex]).Value;
            }

            if (e.ColumnIndex == COL_CANCELADO)
            {
                DataGridViewCheckBoxCell cell = dgvFiltro.CurrentCell as DataGridViewCheckBoxCell;
                if (cell != null)
                {
                    CheckState value = (CheckState)cell.EditedFormattedValue;
                    switch (value)
                    {
                    case CheckState.Checked:
                        cancelado = "S";
                        break;

                    case CheckState.Unchecked:
                        cancelado = "N";
                        break;

                    default:
                        cancelado = string.Empty;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_USUARIO, e.RowIndex].Value))
            {
                usuario = dgvFiltro[COL_USUARIO, e.RowIndex].Value.ToString();
            }

            //var predicate = PredicateBuilder.True<Pedido_Otica>();


            Expression <Func <Pedido_Otica, bool> > predicate = p => true;


            if (codigo > 0)
            {
                predicate = predicate = p => p.codigo == codigo;
            }

            if (!string.IsNullOrEmpty(os))
            {
                predicate = predicate.And(p => p.pedido_otica_infoadic.Any(c => c.ordem_servico == os));
            }

            if (!string.IsNullOrEmpty(cliente))
            {
                predicate = predicate.And(p => p.cliente.nome_fantasia.ToLower().Contains(cliente.ToLower()));
            }

            if (!string.IsNullOrEmpty(condPag))
            {
                predicate = predicate.And(p => p.parcela.descricao.Contains(condPag));
            }

            if (!string.IsNullOrEmpty(vendedor))
            {
                predicate = predicate.And(p => p.vendedor.nome.ToLower().Contains(vendedor.ToLower()));
            }

            if (!string.IsNullOrEmpty(laboratorio))
            {
                predicate = predicate.And(p => p.pedido_otica_infoadic.Any(c => c.laboratorio.ToLower().Contains(laboratorio.ToLower())));
            }

            if ((DtEmiss != null) & (ValidateUtils.isDate(DtEmiss.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_emissao) == DbFunctions.TruncateTime(DtEmiss));
            }

            if ((total != null))
            {
                predicate = predicate.And(p => p.itempedido_otica.Any(c => c.valor_total == total));
            }

            if ((status != null) && (status != 7))
            {
                predicate = predicate.And(p => p.status == status);
            }

            if (!string.IsNullOrEmpty(cancelado))
            {
                predicate = predicate.And(p => p.cancelado == cancelado);
            }

            if (!string.IsNullOrEmpty(usuario))
            {
                predicate = predicate.And(p => p.transportadora.usuario_inclusao.ToLower().Contains(usuario.ToLower()));
            }

            List <Pedido_Otica> Pedido_OticaList = Pedido_OticaBLL.getPedido_Otica(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = Pedido_OticaBLL.ToList_Pedido_OticaView(Pedido_OticaList);
        }
예제 #53
0
 /// <inheritdoc cref="IEnvironment.GetCheckStateChar"/>
 public char GetCheckStateChar(CheckState state) => checkStateChars[(int)state];
예제 #54
0
        private void PaintWorker(PaintEventArgs e, bool up, CheckState state)
        {
            up = up && state == CheckState.Unchecked;

            ColorData  colors = PaintRender(e).Calculate();
            LayoutData layout;

            if (Application.RenderWithVisualStyles)
            {
                // Don't have the text-pressed-down effect when we use themed painting to be consistent with Win32.
                layout = PaintLayout(e, true).Layout();
            }
            else
            {
                layout = PaintLayout(e, up).Layout();
            }

            _ = Control as Button;
            if (Application.RenderWithVisualStyles)
            {
                PaintThemedButtonBackground(e, Control.ClientRectangle, up);
            }
            else
            {
                Brush?backbrush = null;
                if (state == CheckState.Indeterminate)
                {
                    backbrush = CreateDitherBrush(colors.Highlight, colors.ButtonFace);
                }

                try
                {
                    Rectangle bounds = Control.ClientRectangle;
                    if (up)
                    {
                        // We are going to draw a 2 pixel border
                        bounds.Inflate(-BorderWidth, -BorderWidth);
                    }
                    else
                    {
                        // We are going to draw a 1 pixel border.
                        bounds.Inflate(-1, -1);
                    }

                    PaintButtonBackground(e, bounds, backbrush);
                }
                finally
                {
                    backbrush?.Dispose();
                }
            }

            PaintImage(e, layout);

            // Inflate the focus rectangle to be consistent with the behavior of Win32 app
            if (Application.RenderWithVisualStyles)
            {
                layout.Focus.Inflate(1, 1);
            }

            if (up & IsHighContrastHighlighted())
            {
                Color highlightTextColor = SystemColors.HighlightText;
                PaintField(e, layout, colors, highlightTextColor, false);

                if (Control.Focused && Control.ShowFocusCues)
                {
                    // Drawing focus rectangle of HighlightText color
                    ControlPaint.DrawHighContrastFocusRectangle(e.GraphicsInternal, layout.Focus, highlightTextColor);
                }
            }
            else if (up & IsHighContrastHighlighted())
            {
                PaintField(e, layout, colors, SystemColors.HighlightText, true);
            }
            else
            {
                PaintField(e, layout, colors, colors.WindowText, true);
            }

            if (!Application.RenderWithVisualStyles)
            {
                Rectangle r = Control.ClientRectangle;
                if (Control.IsDefault)
                {
                    r.Inflate(-1, -1);
                }

                DrawDefaultBorder(e, r, colors.WindowFrame, Control.IsDefault);

                if (up)
                {
                    Draw3DBorder(e, r, colors, raised: up);
                }
                else
                {
                    // Not Draw3DBorder(..., raised: false);
                    ControlPaint.DrawBorderSimple(e, r, colors.ButtonShadow);
                }
            }
        }
예제 #55
0
        // used by DataGridViewCheckBoxCell
        internal static void DrawCheckOnly(int checkSize, bool controlChecked, bool controlEnabled, CheckState controlCheckState, Graphics g, LayoutData layout, ColorData colors, Color checkColor, Color checkBackground)
        {
            // check
            //
            if (controlChecked)
            {
                if (!controlEnabled)
                {
                    checkColor = colors.buttonShadow;
                }
                else if (controlCheckState == CheckState.Indeterminate)
                {
                    checkColor = SystemInformation.HighContrast ? colors.highlight :
                                 colors.buttonShadow;
                }

                Rectangle fullSize = layout.checkBounds;

                if (fullSize.Width == checkSize)
                {
                    fullSize.Width++;
                    fullSize.Height++;
                }

                fullSize.Width++;

                fullSize.Height++;
                Bitmap checkImage = null;
                if (controlCheckState == CheckState.Checked)
                {
                    checkImage = GetCheckBoxImage(checkColor, fullSize, ref checkImageCheckedBackColor, ref checkImageChecked);
                }
                else
                {
                    Debug.Assert(controlCheckState == CheckState.Indeterminate, "we want to paint the check box only if the item is checked or indeterminate");
                    checkImage = GetCheckBoxImage(checkColor, fullSize, ref checkImageIndeterminateBackColor, ref checkImageIndeterminate);
                }

                if (layout.options.everettButtonCompat)
                {
                    fullSize.Y -= 1;
                }
                else
                {
                    fullSize.Y -= 2;
                }

                ControlPaint.DrawImageColorized(g, checkImage, fullSize, checkColor);
            }
        }
예제 #56
0
 /// <summary>
 /// Initializes a new instance of the CellCheckStyle class with default settings
 /// </summary>
 public CellCheckStyle()
 {
     this.checkState = CheckState.Unchecked;
     this.threeState = false;
 }
        void PaintWorker(PaintEventArgs e, bool up, CheckState state)
        {
            up = up && state == CheckState.Unchecked;

            ColorData  colors = PaintRender(e.Graphics).Calculate();
            LayoutData layout;

            if (Application.RenderWithVisualStyles)
            {
                //don't have the text-pressed-down effect when we use themed painting
                //this is for consistency with win32 app.
                layout = PaintLayout(e, true).Layout();
            }
            else
            {
                layout = PaintLayout(e, up).Layout();
            }

            Graphics g = e.Graphics;

            Button thisbutton = this.Control as Button;

            if (Application.RenderWithVisualStyles)
            {
                PaintThemedButtonBackground(e, Control.ClientRectangle, up);
            }
            else
            {
                Brush backbrush = null;
                if (state == CheckState.Indeterminate)
                {
                    backbrush = CreateDitherBrush(colors.highlight, colors.buttonFace);
                }

                try {
                    Rectangle bounds = Control.ClientRectangle;
                    if (up)
                    {
                        // We are going to draw a 2 pixel border
                        bounds.Inflate(-borderWidth, -borderWidth); // VS Whidbey #459900
                    }
                    else
                    {
                        // We are going to draw a 1 pixel border.
                        bounds.Inflate(-1, -1); // VS Whidbey #503487
                    }

                    PaintButtonBackground(e, bounds, backbrush);
                }
                finally {
                    if (backbrush != null)
                    {
                        backbrush.Dispose();
                        backbrush = null;
                    }
                }
            }

            PaintImage(e, layout);
            //inflate the focus rectangle to be consistent with the behavior of Win32 app
            if (Application.RenderWithVisualStyles)
            {
                layout.focus.Inflate(1, 1);
            }

            if (up & IsHighContrastHighlighted2())
            {
                var highlightTextColor = SystemColors.HighlightText;
                PaintField(e, layout, colors, highlightTextColor, false);

                if (Control.Focused && Control.ShowFocusCues)
                {
                    // drawing focus rectangle of HighlightText color
                    ControlPaint.DrawHighContrastFocusRectangle(g, layout.focus, highlightTextColor);
                }
            }
            else if (up & IsHighContrastHighlighted())
            {
                PaintField(e, layout, colors, SystemColors.HighlightText, true);
            }
            else
            {
                PaintField(e, layout, colors, colors.windowText, true);
            }

            if (!Application.RenderWithVisualStyles)
            {
                Rectangle r = Control.ClientRectangle;
                if (Control.IsDefault)
                {
                    r.Inflate(-1, -1);
                }

                DrawDefaultBorder(g, r, colors.windowFrame, this.Control.IsDefault);

                if (up)
                {
                    Draw3DBorder(g, r, colors, up);
                }
                else
                {
                    // contrary to popular belief, not Draw3DBorder(..., false);
                    //
                    ControlPaint.DrawBorder(g, r, colors.buttonShadow, ButtonBorderStyle.Solid);
                }
            }
        }
예제 #58
0
        protected override void executeCellEndEditChild(object sender, DataGridViewCellEventArgs e)
        {
            base.executeCellEndEditChild(sender, e);

            int    id      = 0;
            string numero  = string.Empty;
            string inativo = string.Empty;


            if (dgvFiltro[COL_ID, e.RowIndex].Value != null)
            {
                id = Convert.ToInt32(dgvFiltro[COL_ID, e.RowIndex].Value);
            }

            if (dgvFiltro[COL_NUMERO, e.RowIndex].Value != null)
            {
                numero = dgvFiltro[COL_NUMERO, e.RowIndex].Value.ToString();
            }

            if (e.ColumnIndex == COL_INATIVO)
            {
                DataGridViewCheckBoxCell cell = dgvFiltro.CurrentCell as DataGridViewCheckBoxCell;
                if (cell != null)
                {
                    CheckState value = (CheckState)cell.EditedFormattedValue;
                    switch (value)
                    {
                    case CheckState.Checked:
                        inativo = "S";
                        break;

                    case CheckState.Unchecked:
                        inativo = "N";
                        break;

                    default:
                        inativo = string.Empty;
                        break;
                    }
                }
            }

            Expression <Func <Caixa, bool> > predicate = p => true;


            if (id > 0)
            {
                predicate = predicate = p => p.Id == id;
            }

            if (!string.IsNullOrEmpty(numero))
            {
                predicate = predicate.And(p => p.numero.Contains(numero));
            }

            if (!string.IsNullOrEmpty(inativo))
            {
                predicate = predicate.And(p => p.inativo == inativo);
            }

            List <Caixa> CaixaList = CaixaBLL.getCaixa(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = CaixaBLL.ToList_CaixaView(CaixaList);
        }
예제 #59
0
        /// <summary>
        /// Raises the Click event.
        /// </summary>
        /// <param name="finishDelegate">Delegate fired during event processing.</param>
        protected virtual void OnClick(EventHandler finishDelegate)
        {
            bool fireDelegate = true;

            if (!Ribbon.InDesignMode)
            {
                if (Enabled)
                {
                    if (AutoCheck)
                    {
                        // Find current state
                        CheckState checkState = CheckState.Unchecked;
                        if (KryptonCommand != null)
                        {
                            checkState = KryptonCommand.CheckState;
                        }
                        else
                        {
                            checkState = CheckState;
                        }

                        // Find new state based on the current state
                        switch (checkState)
                        {
                        case CheckState.Unchecked:
                            checkState = CheckState.Checked;
                            break;

                        case CheckState.Checked:
                            checkState = (ThreeState ? CheckState.Indeterminate : CheckState.Unchecked);
                            break;

                        case CheckState.Indeterminate:
                            checkState = CheckState.Unchecked;
                            break;
                        }

                        // Push back the change to the attached command
                        if (KryptonCommand != null)
                        {
                            KryptonCommand.CheckState = checkState;
                        }
                        else
                        {
                            CheckState = checkState;
                        }
                    }

                    // In showing a popup we fire the delegate before the click so that the
                    // minimized popup is removed out of the way before the event is handled
                    // because if the event shows a dialog then it would appear behind the popup
                    if (VisualPopupManager.Singleton.CurrentPopup != null)
                    {
                        // Do we need to fire a delegate stating the click processing has finished?
                        if (fireDelegate && (finishDelegate != null))
                        {
                            finishDelegate(this, EventArgs.Empty);
                        }

                        fireDelegate = false;
                    }

                    // Generate actual click event
                    if (Click != null)
                    {
                        Click(this, EventArgs.Empty);
                    }

                    // Clicking the button should execute the associated command
                    if (KryptonCommand != null)
                    {
                        KryptonCommand.PerformExecute();
                    }
                }
            }

            // Do we need to fire a delegate stating the click processing has finished?
            if (fireDelegate && (finishDelegate != null))
            {
                finishDelegate(this, EventArgs.Empty);
            }
        }
예제 #60
0
        /// <devdoc>
        ///
        /// Converts a value entered by the end user (through UI) into the corresponding binary value.
        ///
        /// - Converts formatted representations of 'null' into DBNull
        /// - Performs some special-case conversions (eg. CheckState to Boolean)
        /// - Uses TypeConverters or IConvertible where appropriate
        /// - Throws a FormatException is no suitable conversion can be found
        ///
        /// </devdoc>
        private static object ParseObjectInternal(object value,
                                                  Type targetType,
                                                  Type sourceType,
                                                  TypeConverter targetConverter,
                                                  TypeConverter sourceConverter,
                                                  IFormatProvider formatInfo,
                                                  object formattedNullValue)
        {
            //
            // Convert the formatted representation of 'null' to DBNull (if possible)
            //

            if (EqualsFormattedNullValue(value, formattedNullValue, formatInfo) || value == System.DBNull.Value)
            {
                return(System.DBNull.Value);
            }

            //
            // Special case conversions
            //

            TypeConverter targetTypeTypeConverter = TypeDescriptor.GetConverter(targetType);

            if (targetConverter != null && targetTypeTypeConverter != targetConverter && targetConverter.CanConvertFrom(sourceType))
            {
                return(targetConverter.ConvertFrom(null, GetFormatterCulture(formatInfo), value));
            }

            TypeConverter sourceTypeTypeConverter = TypeDescriptor.GetConverter(sourceType);

            if (sourceConverter != null && sourceTypeTypeConverter != sourceConverter && sourceConverter.CanConvertTo(targetType))
            {
                return(sourceConverter.ConvertTo(null, GetFormatterCulture(formatInfo), value, targetType));
            }

            if (value is string)
            {
                // If target type has a suitable Parse method, use that to parse strings
                object parseResult = InvokeStringParseMethod(value, targetType, formatInfo);
                if (parseResult != parseMethodNotFound)
                {
                    return(parseResult);
                }
            }
            else if (value is CheckState)
            {
                CheckState state = (CheckState)value;
                if (state == CheckState.Indeterminate)
                {
                    return(DBNull.Value);
                }
                // Explicit conversion from CheckState to Boolean
                if (targetType == booleanType)
                {
                    return(state == CheckState.Checked);
                }
                if (targetConverter == null)
                {
                    targetConverter = targetTypeTypeConverter;
                }
                if (targetConverter != null && targetConverter.CanConvertFrom(booleanType))
                {
                    return(targetConverter.ConvertFrom(null, GetFormatterCulture(formatInfo), state == CheckState.Checked));
                }
            }
            else if (value != null && targetType.IsAssignableFrom(value.GetType()))
            {
                // If value is already of a compatible type, just go ahead and use it
                return(value);
            }

            //
            // If explicit type converters not provided, supply default ones instead
            //

            if (targetConverter == null)
            {
                targetConverter = targetTypeTypeConverter;
            }

            if (sourceConverter == null)
            {
                sourceConverter = sourceTypeTypeConverter;
            }

            //
            // Standardized conversions
            //

            if (targetConverter != null && targetConverter.CanConvertFrom(sourceType))
            {
                return(targetConverter.ConvertFrom(null, GetFormatterCulture(formatInfo), value));
            }
            else if (sourceConverter != null && sourceConverter.CanConvertTo(targetType))
            {
                return(sourceConverter.ConvertTo(null, GetFormatterCulture(formatInfo), value, targetType));
            }
            else if (value is IConvertible)
            {
                return(ChangeType(value, targetType, formatInfo));
            }

            //
            // Fail if no suitable conversion found
            //

            throw new FormatException(GetCantConvertMessage(value, targetType));
        }