private void Intervals() { if ( PointsNumberList.SelectedItem == null || XAxisIntervalList.SelectedItem == null || YAxisIntervalList.SelectedItem == null ) { return; } Chart1.BackColor = Color.White; // Set interval and interval type for the Y axis if (YAxisIntervalList.GetItemText(YAxisIntervalList.SelectedItem) != "Auto") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisY, double.Parse(YAxisIntervalList.GetItemText(YAxisIntervalList.SelectedItem)), DateTimeIntervalType.Number); } else { SetAxisInterval(Chart1.ChartAreas["Default"].AxisY, Double.NaN, DateTimeIntervalType.Auto, Double.NaN, DateTimeIntervalType.Auto); } // Set interval and interval type for the X axis if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Every Week (Starting Sunday)") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 1, DateTimeIntervalType.Weeks); } else if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Every Week (Starting Monday)") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 1, DateTimeIntervalType.Weeks, 1, DateTimeIntervalType.Days); } else if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Every 2 Weeks") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 2, DateTimeIntervalType.Weeks); } else if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Every Month (Starting at 1st)") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 1, DateTimeIntervalType.Months); } else if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Every Month (Starting at 15th)") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 1, DateTimeIntervalType.Months, 14, DateTimeIntervalType.Days); } else if (XAxisIntervalList.GetItemText(XAxisIntervalList.SelectedItem) == "Auto") { SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, Double.NaN, DateTimeIntervalType.Auto, Double.NaN, DateTimeIntervalType.Auto); } }
private void AutoComplete_KeyUp(ComboBox comboBox2, KeyEventArgs e) { string sTypedText = null; int iFoundIndex = 0; object oFoundItem = null; string sFoundText = null; string sAppendText = null; //Allow select keys without Autocompleting switch (e.KeyCode) { case Keys.Back: case Keys.Left: case Keys.Right: case Keys.Up: case Keys.Delete: case Keys.Down: case Keys.ShiftKey: case Keys.Shift: case Keys.RShiftKey: case Keys.LShiftKey: case Keys.Oem1: case Keys.Oem102: case Keys.Oem2: case Keys.Oem3: case Keys.Oem4: case Keys.Oem5: case Keys.Oem6: case Keys.Oem7: case Keys.Oem8: return; } //Get the Typed Text and Find it in the list sTypedText = comboBox2.Text; iFoundIndex = comboBox2.FindString(sTypedText); //If we found the Typed Text in the list then Autocomplete if (iFoundIndex >= 0) { //Get the Item from the list (Return Type depends if Datasource was bound or List Created) oFoundItem = comboBox2.Items[iFoundIndex]; //Use the ListControl.GetItemText to resolve the Name in case the Combo was Data bound sFoundText = comboBox2.GetItemText(oFoundItem); //Append then found text to the typed text to preserve case sAppendText = sFoundText.Substring(sTypedText.Length); comboBox2.Text = sTypedText + sAppendText; //Select the Appended Text comboBox2.SelectionStart = sTypedText.Length; comboBox2.SelectionLength = sAppendText.Length; label10.Text = ((Person)oFoundItem).Name; label11.Text = ((Person)oFoundItem).Email; label12.Text = ((Person)oFoundItem).SSN; } }
private void AreaSeries() { // Attach the first series to a chart area. if (Series1.SelectedIndex == 0) { Chart1.Series["Series1"].ChartArea = ""; } else { Chart1.Series["Series1"].ChartArea = Series1.GetItemText(Series1.SelectedItem); } // Attach the second series to a chart area. if (Series2.SelectedIndex == 0) { Chart1.Series["Series2"].ChartArea = ""; } else { Chart1.Series["Series2"].ChartArea = Series2.GetItemText(Series2.SelectedItem); } // Attach the Third series to a chart area. if (Series3.SelectedIndex == 0) { Chart1.Series["Series3"].ChartArea = ""; } else { Chart1.Series["Series3"].ChartArea = Series3.GetItemText(Series3.SelectedItem); } }
private void Labels() { if ( this.AngleList.SelectedItem == null || this.FontColorCombo.SelectedItem == null || this.FontNameList.SelectedItem == null || this.LabelPosition.SelectedItem == null || this.LabelPosition.SelectedItem == null || this.FontNameSize.SelectedItem == null || this.comboBoxBackColor.SelectedItem == null || this.BorderColor.SelectedItem == null || this.BorderSize.SelectedItem == null ) { return; } foreach (Series series in Chart1.Series) { // Set labels Position series["LabelStyle"] = LabelPosition.GetItemText(LabelPosition.SelectedItem); // Set labels font series.Font = new Font(FontNameList.GetItemText(FontNameList.SelectedItem), int.Parse(FontNameSize.GetItemText(FontNameSize.SelectedItem)), FontStyle.Bold); // Set labels angle - smart ables must be disabled to set LabelAngel series.SmartLabelStyle.Enabled = false; series.LabelAngle = int.Parse(AngleList.GetItemText(AngleList.SelectedItem)); // Set labels color series.LabelForeColor = Color.FromName(FontColorCombo.GetItemText(FontColorCombo.SelectedItem)); // Set labels background color series.LabelBackColor = Color.FromName(FontColorCombo.GetItemText(comboBoxBackColor.SelectedItem)); // Set labels border color series.LabelBorderColor = Color.FromName(FontColorCombo.GetItemText(BorderColor.SelectedItem)); // Set labels border width series.LabelBorderWidth = int.Parse((string)BorderSize.SelectedItem); } }
internal void SetItemInternal(int index, object value) { if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException(nameof(index), index, string.Format(SR.InvalidArgument, nameof(index), index)); } InnerList[index].Item = value ?? throw new ArgumentNullException(nameof(value)); // If the native control has been created, and the display text of the new list item object // is different to the current text in the native list item, recreate the native list item... if (_owner.IsHandleCreated) { bool selected = (index == _owner.SelectedIndex); if (string.Compare(_owner.GetItemText(value), _owner.NativeGetItemText(index), true, CultureInfo.CurrentCulture) != 0) { _owner.NativeRemoveAt(index); _owner.NativeInsert(index, value); if (selected) { _owner.SelectedIndex = index; _owner.UpdateText(); } if (_owner.AutoCompleteSource == AutoCompleteSource.ListItems) { _owner.SetAutoComplete(false, false); } } else { // NEW - FOR COMPATIBILITY REASONS // Minimum compatibility fix if (selected) { _owner.OnSelectedItemChanged(EventArgs.Empty); //we do this because set_SelectedIndex does this. (for consistency) _owner.OnSelectedIndexChanged(EventArgs.Empty); } } } }
private void WallWidth_SelectedIndexChanged(object sender, System.EventArgs e) { if (WallWidth.SelectedItem == null) { return; } int val = int.Parse(WallWidth.GetItemText(WallWidth.SelectedItem)); chart1.ChartAreas[0].Area3DStyle.WallWidth = val; }
private void AppearanceChange(object sender) { // Set Back Color Chart1.ChartAreas["Default"].BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.ChartAreas["Default"].BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem)); // Set Border Color Chart1.ChartAreas["Default"].BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem)); // Set Gradient Type if (Gradient.SelectedItem != null) { Chart1.ChartAreas["Default"].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem)); } // Set Gradient Type if (HatchStyle.SelectedItem != null) { Chart1.ChartAreas["Default"].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem)); } if (sender == Gradient && Chart1.ChartAreas["Default"].BackGradientStyle != GradientStyle.None) { HatchStyle.SelectedIndex = 0; } if (sender == HatchStyle && Chart1.ChartAreas["Default"].BackHatchStyle != ChartHatchStyle.None) { Gradient.SelectedIndex = 0; } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.ChartAreas["Default"].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyle.SelectedItem != null) { Chart1.ChartAreas["Default"].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem)); } // Set Shadow Offset if (ShadowOffset.SelectedItem != null) { Chart1.ChartAreas["Default"].ShadowOffset = int.Parse(ShadowOffset.GetItemText(ShadowOffset.SelectedItem)); } }
private void PointsNumberList_SelectedIndexChanged(object sender, System.EventArgs e) { // Populate series data Random random = new Random(); DateTime dateCurrent = DateTime.Now.Date; Chart1.Series["Series1"].Points.Clear(); for (int pointIndex = 0; pointIndex < int.Parse(PointsNumberList.GetItemText(PointsNumberList.SelectedItem)); pointIndex++) { Chart1.Series["Series1"].Points.AddXY(dateCurrent.AddDays(pointIndex), random.Next(100, 1000)); } Chart1.Invalidate(); }
public virtual int Compare(object item1, object item2) { if (item1 == null) { if (item2 == null) { return(0); } else { return(-1); } } if (item2 == null) { return(1); } string s1 = owner.GetItemText(item1); string s2 = owner.GetItemText(item2); return(Application.CurrentCulture.CompareInfo.Compare(s1, s2)); }
public void callDB1() { String compare = cbDB1.GetItemText(cbDB1.SelectedItem); int type = 0; if (compare.Equals(DBType.CubridDB + "")) { type = 1; } Class1.start(tbAdr1.Text, tbPort1.Text, tbdatabasename1.Text, tbUser1.Text, tbPw1.Text, type); //Class1.start(); }
public int Compare(object item1, object item2) { if (item1 is null) { if (item2 is null) { return(0); //both null, then they are equal } return(-1); //item1 is null, but item2 is valid (greater) } if (item2 is null) { return(1); //item2 is null, so item 1 is greater } string itemName1 = _comboBox.GetItemText(item1); string itemName2 = _comboBox.GetItemText(item2); CompareInfo compInfo = (Application.CurrentCulture).CompareInfo; return(compInfo.Compare(itemName1, itemName2, CompareOptions.StringSort)); }
// Calculates maximum required width of the dropdown portion for the ComboBox. // This is done in order not to cut off the longest dropdown item. public static int CalculateComboBoxDropdownWidth(ComboBox comboBox) { if (comboBox == null) return SystemInformation.VerticalScrollBarWidth; int scrollbarOffset = 0; if (comboBox.Items.Count > comboBox.MaxDropDownItems) { scrollbarOffset = SystemInformation.VerticalScrollBarWidth; try { scrollbarOffset += SystemInformation.HorizontalFocusThickness; // padding } catch (NotSupportedException) { scrollbarOffset += 2; // 2 pixels padding } } float maxWidth = 0.0f; using (System.Drawing.Graphics ds = comboBox.CreateGraphics()) { foreach (object item in comboBox.Items) { maxWidth = Math.Max(maxWidth, ds.MeasureString(comboBox.GetItemText(item), comboBox.Font).Width); } } int newWidth = (int)decimal.Round((decimal)maxWidth, 0) + scrollbarOffset; //If the width is bigger than the screen, ensure //we stay within the bounds of the screen if (newWidth > Screen.GetWorkingArea(comboBox).Width) { newWidth = Screen.GetWorkingArea(comboBox).Width; } // Don't let dropdown area to be outside of the screen if (comboBox.Parent != null) { int screenWidth = Screen.FromControl(comboBox).Bounds.Width; Point pt = comboBox.Parent.PointToScreen(new Point(comboBox.Left + newWidth, comboBox.Bottom)); if (pt.X > screenWidth) newWidth = Math.Max(comboBox.Bounds.Width, newWidth - (pt.X - screenWidth)); } // Only change the width if the calculated width is larger that the current width return comboBox.Bounds.Width > newWidth ? comboBox.Bounds.Width : newWidth; }
private int ArchivoSeleccionado(string Archivo) { int i = 0; int max; max = cboArchivoOrigen.Items.Count - 1; for (i = 0; i <= max; i++) { if (cboArchivoOrigen.GetItemText(cboArchivoOrigen.Items[i]) == Archivo) { break; } } return(i); }
public void callDB2() { String compare2 = cbDB2.GetItemText(cbDB2.SelectedItem); int type = 0; if (compare2.Equals(DBType.OracleSQL + "")) { type = 3; } if (compare2.Equals(DBType.MSSQL + "")) { type = 2; } Class1.start(tbAdr2.Text, tbPort2.Text, tbdatabasename2.Text, tbUser2.Text, tbPw2.Text, type); }
private void Keywords() { if ( AxisLabelsList.SelectedItem == null || PointLabelsList.SelectedItem == null ) { return; } // Set axis labels Chart1.Series["Series1"].AxisLabel = AxisLabelsList.GetItemText(AxisLabelsList.SelectedItem); // Set series point's labels Chart1.Series["Series1"].Label = PointLabelsList.GetItemText(PointLabelsList.SelectedItem); }
private void UpdateChartSettings() { Series series1 = chart1.Series[0]; if (this.checkBoxCollectPieSlices.Checked) { comboBoxChartType.Enabled = true; comboBoxCollectedColor.Enabled = true; comboBoxCollectedThreshold.Enabled = true; textBoxCollectedLabel.Enabled = true; textBoxCollectedLegend.Enabled = true; checkBoxCollectPieSlices.Enabled = true; checkBoxCollectPieSlices.Enabled = true; checkBoxShowExploded.Enabled = true; // Set the threshold under which all points will be collected series1["CollectedThreshold"] = comboBoxCollectedThreshold.GetItemText(comboBoxCollectedThreshold.SelectedItem); // Set the label of the collected pie slice series1["CollectedLabel"] = textBoxCollectedLabel.Text; // Set the legend text of the collected pie slice series1["CollectedLegendText"] = textBoxCollectedLegend.Text; // Set the collected pie slice to be exploded series1["CollectedSliceExploded"] = checkBoxShowExploded.Checked.ToString(); // Set collected color series1["CollectedColor"] = comboBoxCollectedColor.GetItemText(comboBoxCollectedColor.SelectedItem); // Set chart type series1.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), comboBoxChartType.Text, true); } else { series1["CollectedThreshold"] = "0"; comboBoxChartType.Enabled = false; comboBoxCollectedColor.Enabled = false; comboBoxCollectedThreshold.Enabled = false; textBoxCollectedLabel.Enabled = false; textBoxCollectedLegend.Enabled = false; checkBoxShowExploded.Enabled = false; } }
/// <summary> /// Automatically adjusts the width according to items. /// </summary> /// <param name="this">This ComboBox.</param> public static void AutoAdjustWidth(this ComboBox @this) { var items = @this.Items; var vertScrollBarWidth = items.Count > @this.MaxDropDownItems // visible scrollbar? ? SystemInformation.VerticalScrollBarWidth : 0 ; var font = @this.Font; @this.Width = items .Cast <object>() .Select(i => TextRenderer.MeasureText(@this.GetItemText(i), font).Width) .Max() + vertScrollBarWidth ; }
public PopUpImp(ComboBox owner) { this.owner = owner; popup = new NSPopUpButton(); popup.BezelStyle = NSBezelStyle.Rounded; popup.Alignment = NSTextAlignment.Natural; popup.Enabled = owner.Enabled; popup.Font = owner.Font.ToNSFont(); //popup.PullsDown = true; popup.Activated += owner.OnImpSelectedItemChanged; foreach (object item in owner.items) popup.AddItem(owner.GetItemText(item)); if (owner.selected_index >= 0 && owner.selected_index < popup.Items().Length) popup.SelectItem(owner.selected_index); }
private void SetSecondary() { if (Series1X.SelectedItem == null || Series1Y.SelectedItem == null) { return; } ChartArea area = Chart1.ChartAreas["Default"]; AxisType axisXType = (AxisType)AxisType.Parse(typeof(AxisType), Series1X.GetItemText(Series1X.SelectedItem)); AxisType axisYType = (AxisType)AxisType.Parse(typeof(AxisType), Series1Y.GetItemText(Series1Y.SelectedItem)); area.CursorX.AxisType = axisXType; area.CursorY.AxisType = axisYType; if (axisXType == AxisType.Primary) { area.AxisX.LineColor = Color.Black; area.AxisX2.LineColor = Color.FromArgb(64, 64, 64, 64); } else { area.AxisX2.LineColor = Color.Black; area.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64); } if (axisYType == AxisType.Primary) { area.AxisY.LineColor = Color.Black; area.AxisY2.LineColor = Color.FromArgb(64, 64, 64, 64); } else { area.AxisY2.LineColor = Color.Black; area.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64); } }
public static void ResizeDropDownListToMaxWidth(this ComboBox senderComboBox) { int width = senderComboBox.DropDownWidth; Graphics g = senderComboBox.CreateGraphics(); Font font = senderComboBox.Font; int vertScrollBarWidth = (senderComboBox.Items.Count > senderComboBox.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0; int newWidth; foreach (object item in senderComboBox.Items) { string s = senderComboBox.GetItemText(item); newWidth = (int)g.MeasureString(s, font).Width + vertScrollBarWidth; if (width < newWidth) { width = newWidth; } } senderComboBox.DropDownWidth = width; }
private void Labels() { if ( FontNameList.SelectedItem == null || FontSizeList.SelectedItem == null || AngleList.SelectedItem == null ) { return; } // Disable axis labels text auto fitting Chart1.ChartAreas["Default"].AxisX.IsLabelAutoFit = false; // Set axis labels font Chart1.ChartAreas["Default"].AxisX.LabelStyle.Font = new Font(FontNameList.GetItemText(FontNameList.SelectedItem), int.Parse(FontSizeList.GetItemText(FontSizeList.SelectedItem))); // Set axis labels angle AngleList.Enabled = !OffsetLabels.Checked; Chart1.ChartAreas["Default"].AxisX.LabelStyle.Angle = int.Parse(AngleList.GetItemText(AngleList.SelectedItem)); // Set offset labels style Chart1.ChartAreas["Default"].AxisX.LabelStyle.IsStaggered = OffsetLabels.Checked; // Disable X axis labels Chart1.ChartAreas["Default"].AxisX.LabelStyle.Enabled = EnableLabels.Checked; // Enable AntiAliasing for either Text and Graphics or just Graphics if (TextAntiAlias.Checked) { Chart1.AntiAliasing = AntiAliasingStyles.All; } else { Chart1.AntiAliasing = AntiAliasingStyles.Graphics; } }
public void FormatEventValueType () { string event_log = null; ComboBox comboBox = new ComboBox (); comboBox.FormattingEnabled = true; comboBox.Format += delegate(object sender, ListControlConvertEventArgs e) { event_log = e.Value.GetType ().Name; }; int [] objects = new int [] { 1, 2, 3 }; comboBox.DataSource = objects; comboBox.GetItemText (1); Assert.AreEqual (typeof (int).Name, event_log, "#A0"); }
//*************************** //BEGIN GenerateSource METHOD //*************************** private void GenerateSource_Click(object sender, System.EventArgs e) { try { //************************************************************ //Create connection string from values entered in text boxes //************************************************************ string CONN_STRING = "Server=" + ServerNameBox.Text + ";" + "Database=" + DatabaseBox.Text + ";" + "User ID=" + UserNameBox.Text + ";" + "Password="******";"; //********************************************************** //Create DataBaseReader object using above connection string //********************************************************** DataBaseReader dbreader1 = new DataBaseReader(CONN_STRING); dbreader1.ReadDataBase(TableBox.GetItemText(TableBox.Text)); //***************************** //Send messages to message box //***************************** TableLabel.Text = "Table:" + TableBox.Text; SourceLabel.Text = "Source:" + TableBox.Text + ".cs"; OutputBox.AppendText("Parsed Table:" + TableBox.Text + "\r\n"); //************************** //Clear out both View boxes //************************** TableViewBox.Text = ""; ViewBox.Text = ""; ViewGroup.Enabled = true; //************************************************************************* //Create GenertaeSourceObject for creating the source file * //************************************************************************* GenerateSourceObject gen_source1 = new //source filename = selected table GenerateSourceObject(TableBox.GetItemText(TableBox.Text)); //******************************* //Create the source file //******************************* gen_source1.WriteStream_const1(); gen_source1.WriteStream_const2(); gen_source1.WriteVariableDeclarations (dbreader1.GetTypeArray(), dbreader1.GetFieldArray()); gen_source1.WriteStream_const3(); gen_source1.WriteMemberFunctions (dbreader1.GetTypeArray(), dbreader1.GetFieldArray(), dbreader1.GetNullListArray(), dbreader1.GetKeyNameArray(), dbreader1.GetIsUniqueArray(), dbreader1.GetColNameArray()); gen_source1.CloseStream(); //******************************* //Close DataBaseReader connection //******************************* dbreader1.CloseDBConnection(); //************************************************************************* //Ouput generated source to Source View Box * //************************************************************************* StreamReader Instrm = new StreamReader("sources\\" + TableBox.GetItemText(TableBox.Text) + ".cs"); string line; do { line = Instrm.ReadLine(); ViewBox.AppendText(line + "\r\n"); }while (line != null); Instrm.Close(); //************************************************************************** //Output table in TableViewBox * //************************************************************************** ArrayList TypeList = new ArrayList(); ArrayList FieldList = new ArrayList(); TypeList = dbreader1.GetMysqlTypeArray(); FieldList = dbreader1.GetMysqlFieldArray(); for (int ct = 0; ct < TypeList.Count; ct++) { TableViewBox.AppendText(TypeList[ct].ToString().PadRight(15) + "\t\t" + FieldList[ct] + "\r\n"); } //************************************************************************** //************************************************************************** } catch (System.Exception caught) { MessageBox.Show(caught.Message); } }
private void Order() { if (SeriesOrder.SelectedItem == null) { return; } // Set solid colors foreach (Series ser in Chart1.Series) { ser.Color = Color.FromArgb(255, ser.Color.R, ser.Color.G, ser.Color.B); } // Create references to series Series [] series = new Series[3]; series[0] = Chart1.Series["Series1"]; series[1] = Chart1.Series["Series2"]; series[2] = Chart1.Series["Series3"]; // Remove all series from the collection Chart1.Series.Clear(); // Add chart series into the collection in selected order switch (SeriesOrder.GetItemText(SeriesOrder.SelectedItem)) { case "Column-Spline-Area": Chart1.Series.Add(series[0]); Chart1.Series.Add(series[1]); Chart1.Series.Add(series[2]); break; case "Column-Area-Spline": Chart1.Series.Add(series[0]); Chart1.Series.Add(series[2]); Chart1.Series.Add(series[1]); break; case "Spline-Column-Area": Chart1.Series.Add(series[1]); Chart1.Series.Add(series[0]); Chart1.Series.Add(series[2]); break; case "Spline-Area-Column": Chart1.Series.Add(series[1]); Chart1.Series.Add(series[2]); Chart1.Series.Add(series[0]); break; case "Area-Column-Spline": Chart1.Series.Add(series[2]); Chart1.Series.Add(series[0]); Chart1.Series.Add(series[1]); break; case "Area-Spline-Column": Chart1.Series.Add(series[2]); Chart1.Series.Add(series[1]); Chart1.Series.Add(series[0]); break; } // Set transparent colors if (!Transparent.Checked) { foreach (Series ser in Chart1.Series) { ser.Color = Color.FromArgb(220, ser.Color.R, ser.Color.G, ser.Color.B); } } }
public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e) { Color back_color, fore_color; Rectangle text_draw = e.Bounds; StringFormat string_format = new StringFormat (); string_format.FormatFlags = StringFormatFlags.LineLimit; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { back_color = ColorHighlight; fore_color = ColorHighlightText; } else { back_color = e.BackColor; fore_color = e.ForeColor; } if (!ctrl.Enabled) fore_color = ColorInactiveCaptionText; e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds); if (e.Index != -1) { e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font, ResPool.GetSolidBrush (fore_color), text_draw, string_format); } if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) { CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color); } string_format.Dispose (); }
private void AgregaDescuento() { try { this.Cursor = Cursors.WaitCursor; if (txtDescuento.Text.IndexOf(".") <= 3) { if (this.txtDescuento.Text.Trim() != "") { if (ValidaDescuentosActivos()) { if (ValidaZonaEconomicaDescuento()) { if (MessageBox.Show(this, "Se agregará el descuento: " + txtDescuento.Text + " En la Posición RI: " + cboPosicion.GetItemText(cboPosicion.SelectedItem) + " para la : " + cboZonaEconomica.GetItemText(cboZonaEconomica.SelectedItem).Trim() + " ¿Desea Continuar?", "Descuentos Fijos", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { des = new DescuentoFijo(_datos, Convert.ToDecimal(this.txtDescuento.Text), Convert.ToInt16(cboPosicion.GetItemText(cboPosicion.SelectedItem)), Convert.ToInt16(cboZonaEconomica.SelectedValue), "ACTIVO"); des.GuardarDescuentoFijo(); this.DialogResult = DialogResult.OK; this.Close(); } } else { MessageBox.Show(this, "El descuento ya está registrado para ese ZonaEconomica", "Descuentos Fijos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { MessageBox.Show(this, "Capture los campos del descuento que desea agregar", "Descuentos Fijos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show(this, "El descuento es mayor al valor permitido", "Descuentos Fijos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index) { var item = owner.items[(int)index]; var title = owner.GetItemText(item); return (NSString)title; }
public static void SetComboBoxDropDownWidth(ComboBox cbx) { //if (!cbx.IsHandleCreated || !(cbx.DataSource is DataTable)) { return; } //bool isDatabound = cbx.DataSource != null && cbx.DisplayMember != null && cbx.DisplayMember != ""; int width = cbx.DropDownWidth, vScrollbarWidth = cbx.Items.Count > cbx.MaxDropDownItems ? SystemInformation.VerticalScrollBarWidth : 0; using (System.Drawing.Graphics g = cbx.CreateGraphics()) { for (int i = 0; i < cbx.Items.Count; i++) { width = Math.Max((int)g.MeasureString(cbx.GetItemText(cbx.Items[i]), cbx.Font).Width + vScrollbarWidth, width); } } cbx.DropDownWidth = width; }
private void SelectInCombo(ComboBox combo, string text) { for (int i = 0; i < combo.Items.Count; i++) { if (text == combo.GetItemText(combo.Items[i])) { combo.SelectedIndex = i; break; } } }
private void AppearanceChange() { // suppress appearance settings during loading if (this.initializing) { return; } // load default chart settings if (defaultChartView.Length > 0) { defaultChartView.Position = 0; Chart1.Serializer.Load(defaultChartView); } // Set Back Color Chart1.Series[0].Points[2].Color = Color.FromName(ColorCom.GetItemText(ColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.Series[0].Points[2].BackSecondaryColor = Color.FromName(EndColorCom.GetItemText(EndColorCom.SelectedItem)); // Set Border Color Chart1.Series[0].Points[2].BorderColor = Color.FromName(BorderColorCom.GetItemText(BorderColorCom.SelectedItem)); // Set Gradient Type if (GradientCom.SelectedItem != null) { Chart1.Series[0].Points[2].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientCom.GetItemText(GradientCom.SelectedItem)); } // Set Gradient Type if (HatchingCom.SelectedItem != null) { Chart1.Series[0].Points[2].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingCom.GetItemText(HatchingCom.SelectedItem)); } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.Series[0].Points[2].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyleCom.SelectedItem != null) { Chart1.Series[0].Points[2].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleCom.GetItemText(BorderDashStyleCom.SelectedItem)); } if (!this.ThirdPoint.Checked) { // Set Back Color Chart1.Series[0].Color = Color.FromName(ColorCom.GetItemText(ColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.Series[0].BackSecondaryColor = Color.FromName(EndColorCom.GetItemText(EndColorCom.SelectedItem)); // Set Border Color Chart1.Series[0].BorderColor = Color.FromName(BorderColorCom.GetItemText(BorderColorCom.SelectedItem)); // Set Gradient Type if (GradientCom.SelectedItem != null) { Chart1.Series[0].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientCom.GetItemText(GradientCom.SelectedItem)); } // Set Gradient Type if (HatchingCom.SelectedItem != null) { Chart1.Series[0].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingCom.GetItemText(HatchingCom.SelectedItem)); } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.Series[0].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyleCom.SelectedItem != null) { Chart1.Series[0].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleCom.GetItemText(BorderDashStyleCom.SelectedItem)); } // Set Shadow Offset if (ShadowOffset.SelectedItem != null) { Chart1.Series[0].ShadowOffset = int.Parse(ShadowOffset.GetItemText(ShadowOffset.SelectedItem)); } } }
/// <summary> /// 根据下拉框内容设置下拉列表显示宽度 /// </summary> /// <param name="cbx">要进行设置的下拉框组件</param> private void SetComboBoxDropDownWidth(ComboBox cbx) { int dropDownWidth = 0; foreach (object item in cbx.Items) { dropDownWidth = Math.Max(dropDownWidth, TextRenderer.MeasureText(cbx.GetItemText(item), cbx.Font).Width); } cbx.DropDownWidth = dropDownWidth; }
private void EmptyPoints() { // Inserting empty points changes // the series data so we have to store the original data. if (seriesData == null) { // Populate series data double[] yValues = { 23, 56, 67, 98, 45, 67, 23, 29, 87, 65, 49, 77, 56, 34, 76 }; DateTime currentDate = DateTime.Now.Date; Random random = new Random(); Chart1.Series["Series1"].Points.Clear(); for (int pointIndex = 0; pointIndex < 15; pointIndex++) { Chart1.Series["Series1"].Points.AddXY(currentDate, yValues[pointIndex]); currentDate = currentDate.AddDays(random.Next(1, 5)); } seriesData = GetSeriesValues(); } else { Chart1.Series["Series1"].Points.DataBind(seriesData.Tables[0].Rows, "X", "Y", String.Empty); } Chart1.Series["Series1"]["EmptyPointValue"] = EmptyPointValue.SelectedItem.ToString(); Chart1.Series["Series1"].EmptyPointStyle.MarkerSize = 7; Chart1.Series["Series1"].EmptyPointStyle.MarkerStyle = MarkerStyle.Diamond; // Check point existance for every day if (EmptyPointIntervalList.GetItemText(EmptyPointIntervalList.SelectedItem) == "Every Day") { Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "Series1"); } // Check point existance for every 12 hours else if (EmptyPointIntervalList.GetItemText(EmptyPointIntervalList.SelectedItem) == "Every 12 Hours") { Chart1.Series["Series1"].EmptyPointStyle.MarkerSize = 3; Chart1.DataManipulator.InsertEmptyPoints(12, IntervalType.Hours, "Series1"); } // Check point existance for every week day else if (EmptyPointIntervalList.GetItemText(EmptyPointIntervalList.SelectedItem) == "Every Week Day") { Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series1"); Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 2, IntervalType.Days, "Series1"); Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 3, IntervalType.Days, "Series1"); Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 4, IntervalType.Days, "Series1"); Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 5, IntervalType.Days, "Series1"); } // Check point existance for every Monday else if (EmptyPointIntervalList.GetItemText(EmptyPointIntervalList.SelectedItem) == "Every Monday") { Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series1"); } // Use point index instead of the X value if (ShowAsIndexedList.GetItemText(ShowAsIndexedList.SelectedItem) == "True") { Chart1.Series["Series1"].IsXValueIndexed = true; Chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 1; Chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = 1; Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1; } else { Chart1.Series["Series1"].IsXValueIndexed = false; Chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 0; Chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = 0; Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 0; } }
private static IEnumerable<string> GetItemTexts(ComboBox comboBox) { return (from object item in comboBox.Items select comboBox.GetItemText(item)); }
private void ChartAppearanceChange() { // Enable/disable appearance controls ForeColorCom.Enabled = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0); BorderColor.Enabled = (BorderDashStyle.SelectedIndex != 0); BorderSizeCom.Enabled = (BorderDashStyle.SelectedIndex != 0); // Set Back Color Chart1.BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem)); // Set Gradient Type if (Gradient.SelectedItem != null) { Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem)); } // Set Gradient Type if (HatchStyle.SelectedItem != null) { Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem)); } // Set background image if (!ShowImageCheck.Checked) { Chart1.BackImage = ""; ImageAlign.Enabled = false; ImageMode.Enabled = false; } else { ImageMode.Enabled = true; ImageAlign.Enabled = (ImageMode.SelectedIndex == 5); // Set chart image MainForm mainForm = (MainForm)this.ParentForm; string imageFileName = mainForm.CurrentSamplePath; imageFileName += "\\Flag.gif"; Chart1.BackImage = imageFileName; Chart1.BackImageTransparentColor = Color.Red; // Set Image Mode if (ImageMode.SelectedItem != null) { Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.ToString()); } // Set Image Alignment if (ImageAlign.SelectedItem != null) { Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign.SelectedItem.ToString()); } } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyle.SelectedItem != null) { Chart1.BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem)); } // Set Border Color Chart1.BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem)); }
private void SetSecondary() { if (Series1X.SelectedItem == null || Series1Y.SelectedItem == null || Series2X.SelectedItem == null || Series2Y.SelectedItem == null) { return; } Chart1.Series["Series1"].XAxisType = (AxisType)AxisType.Parse(typeof(AxisType), Series1X.GetItemText(Series1X.SelectedItem)); Chart1.Series["Series1"].YAxisType = (AxisType)AxisType.Parse(typeof(AxisType), Series1Y.GetItemText(Series1Y.SelectedItem)); Chart1.Series["Series2"].XAxisType = (AxisType)AxisType.Parse(typeof(AxisType), Series2X.GetItemText(Series2X.SelectedItem)); Chart1.Series["Series2"].YAxisType = (AxisType)AxisType.Parse(typeof(AxisType), Series2Y.GetItemText(Series2Y.SelectedItem)); }