Ejemplo n.º 1
0
  //-------------------------------------------------------------------------------------
  /// <summary>
  /// Отображает контрол во всплывающем контроле.
  /// </summary>
  /// <param name="screenPoint">Положение контрола в оконных координатах.</param>
  /// <param name="caption">Текст метки</param>
  /// <param name="value">Значение ввода</param>
  /// <param name="twoLines">Определяет отображение в две строки.</param>
  /// <param name="format">Формат ввода</param>
  /// <param name="formatException">Строка символов исключений формата.</param>
  /// <param name="width">Ширина</param>
  /// <returns></returns>
  public static SimQuickEdit ShowPopup(Point screenPoint, string caption, string value, bool twoLines,
                                             TextBoxFormat format = TextBoxFormat.NotSet, string formatException = "",
                                             int width = 170)
  {
   SimQuickEdit c = new SimQuickEdit();
   c.Caption = caption;
   c.Value = value;
   c.TwoLines = twoLines;
   c.Format = format;
   c.FormatExceptions = formatException;
   c.ctrl.Width = width;

   c.Show(screenPoint);
   return c;
  }
Ejemplo n.º 2
0
  //-------------------------------------------------------------------------------------
  #region << Methods >>
  private ToolStripDropDown GetEditor()
  {
   Type t = null;
   if(_binding.IsDefined)
    t = _binding.PropDescriptor.PropertyType;
   if(_pd != null)
    t = _pd.PropertyType;
   else
    t = _val == null ? typeof(string) : _val.GetType();

   if(t == null)
    return null;

   if(InputFormat != TextBoxFormat.NotSet || t == typeof(string) || t == typeof(RefString))
   {
    #region
    SimQuickEdit box = new SimQuickEdit();
    box.Value = (Value ?? "").ToString();
    box.Format = InputFormat;
    box.FormatExceptions = InputFormatExceptions;
    box.InputDone += (String_InputDone);
    if(box.Width < slValue.Width)
     box.Control.Width = slValue.Width - 10;
    return box;
    #endregion
   }
   if(t.IsPrimitive || t == typeof(decimal) || t == typeof(Money) || t == typeof(MoneyPrecise) || t == typeof(Amount) || t == typeof(UInt))
   {
    #region
    SimQuickEdit box = new SimQuickEdit();
    box.Value = (Value ?? "").ToString();
    box.Format = TextBoxFormat.Digits;
    if(t == typeof(int) || t == typeof(long) || t == typeof(sbyte) || t == typeof(short) )
     box.FormatExceptions += "-";
    else if(t == typeof(decimal) || t == typeof(float) || t == typeof(double) ||
            t == typeof(Money) || t == typeof(MoneyPrecise))
     box.FormatExceptions += "-.,";
    box.InputDone += (Number_InputDone);
    if(box.Width < slValue.Width)
     box.Control.Width = slValue.Width - 10;
    box.Tag = t;
    return box;
    #endregion
   }
   else if(t.IsEnum)
   {
    #region
    object val = Value;
    List<ComboBoxItem<Enum>> list = new List<ComboBoxItem<Enum>>();
    SimSelectList box = new SimSelectList(list);
    foreach(Enum i in Enum.GetValues(t))
    {
     var ci = new ComboBoxItem<Enum>(i, EnumTypeConverter.GetItemDisplayName(i));
     list.Add(ci);
     if(i.Equals(val))
      box.SelectedItem = ci;
    }
    box.ItemSelected += Enum_InputDone;
    box.SetAutoWidth(30);
    return box;
    #endregion
   }
   else if(_pd.PropertyType == typeof(DateTime) || _pd.PropertyType == typeof(DateTime?))
   {
    #region
    object val = Value;
    SimDateSelect mc = new SimDateSelect();
    if(val != null)
     mc.Value = (DateTime)val;
    mc.UIValueChanged += new Pulsar.EventHandler<object,DateTime>(DateTime_Closed);
    return mc;
    #endregion
   }
   return null;

  }
Ejemplo n.º 3
0
 void Number_InputDone(SimQuickEdit sender, bool args)
 {
  sender.InputDone -= Number_InputDone;
  if(args)
  {
   Type t = (Type)sender.Tag;
   if(t == null)
    Value = sender.Value;//Convert.ChangeType(, _pd.PropertyType));
   else
   try
   {
    TypeConverter td = TypeDescriptor.GetConverter(t);
    if(td.CanConvertFrom(typeof(string)))
     Value = td.ConvertFromString(sender.Value.AsNumeric());
   }
   catch(InvalidCastException) { }
   catch(FormatException) { }
   catch(OverflowException) { }
   catch(ArgumentNullException) { }
  }
 }
Ejemplo n.º 4
0
 //-------------------------------------------------------------------------------------
 void String_InputDone(SimQuickEdit sender, bool args)
 {
  sender.InputDone -= String_InputDone;
  if(args)
   Value = sender.Value;
 }
Ejemplo n.º 5
0
 void box_InputDone(SimQuickEdit sender, bool args)
 {
  sender.Hide();
  if(args)
  {
   Value = sender.Value;
   OnUIValueChanged(Value);
  }
 }
Ejemplo n.º 6
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
  base.OnMouseClick(e);
  if(Image != null && e.Button == System.Windows.Forms.MouseButtons.Left && OnEditButtonClick() == false)
  {
   Rectangle r = this.ClientRectangle;
   r = new Rectangle(r.Width - this.Image.Width - this.Padding.Right - 6, 0, this.Image.Width + this.Padding.Right + 3, r.Height);
   if(r.Contains(e.Location))
   {
    SimQuickEdit box = new SimQuickEdit();
    box.Value = this.Text;
    box.Format = _format;
    box.FormatExceptions = _formatExceptions;
    box.InputDone += new Pulsar.EventHandler<SimQuickEdit, bool>(box_InputDone);
    Point pp = PointToScreen(new Point(this.Width - 1, this.Height - 2));
    pp.X -= box.Width;
    box.Show(pp);
   }
  }
 }