static int TryParseExact(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string[]), typeof(IFormatProvider), typeof(System.Globalization.DateTimeStyles), null)) { string arg0 = LuaScriptMgr.GetString(L, 1); string[] objs1 = LuaScriptMgr.GetArrayString(L, 2); IFormatProvider arg2 = (IFormatProvider)LuaScriptMgr.GetLuaObject(L, 3); System.Globalization.DateTimeStyles arg3 = (System.Globalization.DateTimeStyles)LuaScriptMgr.GetLuaObject(L, 4); DateTime arg4; bool o = DateTime.TryParseExact(arg0, objs1, arg2, arg3, out arg4); LuaScriptMgr.Push(L, o); LuaScriptMgr.PushValue(L, arg4); return(2); } else if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string), typeof(IFormatProvider), typeof(System.Globalization.DateTimeStyles), null)) { string arg0 = LuaScriptMgr.GetString(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); IFormatProvider arg2 = (IFormatProvider)LuaScriptMgr.GetLuaObject(L, 3); System.Globalization.DateTimeStyles arg3 = (System.Globalization.DateTimeStyles)LuaScriptMgr.GetLuaObject(L, 4); DateTime arg4; bool o = DateTime.TryParseExact(arg0, arg1, arg2, arg3, out arg4); LuaScriptMgr.Push(L, o); LuaScriptMgr.PushValue(L, arg4); return(2); } else { LuaDLL.luaL_error(L, "invalid arguments to method: DateTime.TryParseExact"); } return(0); }
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewRow rw = dataGridView.Rows[e.RowIndex]; if (e.ColumnIndex == 0) { string v = rw.Cells[0].Value as string; System.Globalization.DateTimeStyles dts = EDDConfig.Instance.DisplayUTC ? System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal : System.Globalization.DateTimeStyles.AssumeLocal | System.Globalization.DateTimeStyles.AdjustToUniversal; if (v != null && DateTime.TryParse(v, System.Globalization.CultureInfo.CurrentCulture, dts, out DateTime res)) { rw.Cells[0].Tag = res; StoreRow(rw); } else { ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Bad Date Time format".Tx(this, "DTF"), "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Error); DateTime prev = (DateTime)rw.Cells[0].Tag; rw.Cells[0].Value = EDDConfig.Instance.DisplayUTC ? prev : prev.ToLocalTime(); } } else if (e.ColumnIndex <= 2) { if (rw.Cells[3].Value != null && ((string)rw.Cells[3].Value).Length > 0) { StoreRow(rw); } } }
static int Parse(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); DateTime o = DateTime.Parse(arg0); LuaScriptMgr.PushValue(L, o); return(1); } else if (count == 2) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); IFormatProvider arg1 = (IFormatProvider)LuaScriptMgr.GetNetObject(L, 2, typeof(IFormatProvider)); DateTime o = DateTime.Parse(arg0, arg1); LuaScriptMgr.PushValue(L, o); return(1); } else if (count == 3) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); IFormatProvider arg1 = (IFormatProvider)LuaScriptMgr.GetNetObject(L, 2, typeof(IFormatProvider)); System.Globalization.DateTimeStyles arg2 = (System.Globalization.DateTimeStyles)LuaScriptMgr.GetNetObject(L, 3, typeof(System.Globalization.DateTimeStyles)); DateTime o = DateTime.Parse(arg0, arg1, arg2); LuaScriptMgr.PushValue(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: DateTime.Parse"); } return(0); }
public static bool TryParse(string s, IFormatProvider provider, System.Globalization.DateTimeStyles style, out WfDateTime result) { DateTime dtm; bool ret = DateTime.TryParse(s, provider, style, out dtm); result = (WfDateTime)dtm; return(ret); }
public static bool TryParse(string input, IFormatProvider formatProvider, System.Globalization.DateTimeStyles styles, out System.DateTimeOffset result) { Contract.Ensures(false); result = default(System.DateTimeOffset); return(default(bool)); }
/// <summary> /// Convierte la fecha y hora de una cadena utilizando un formato estricto /// </summary> public static DateTime?GetDateTime(this string value, string format, System.Globalization.DateTimeStyles style = System.Globalization.DateTimeStyles.AssumeUniversal) { if (DateTime.TryParseExact(value, format, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat, style, out DateTime result)) { return(result); } else { return(null); } }
private bool CheckTime(string time) { string strTime = bbl.GetDate() + " " + time + ":00"; string format = "yyyy/MM/dd HH:mm:ss"; System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture; System.Globalization.DateTimeStyles dts = System.Globalization.DateTimeStyles.None; DateTime dateTime; if (DateTime.TryParseExact(strTime, format, ci, dts, out dateTime)) { return(true); } return(false); }
/// <summary> /// Tries the parse. /// </summary> /// <param name="s">The s.</param> /// <param name="provider">The provider.</param> /// <param name="styles">The styles.</param> /// <param name="result">The result.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static bool TryParse(string s, IFormatProvider provider, System.Globalization.DateTimeStyles styles, out DateTime result) { var parsed = new DateTime(); bool status = false; try { parsed = DateTime.Parse(s, provider, styles); status = true; } catch { status = false; } result = parsed; return(status); }
public static DateTime DateTimeParse( [param: Required] string value, IFormatProvider provider = null, System.Globalization.DateTimeStyles styles = System.Globalization.DateTimeStyles.None ) { // nullチェック if (value == null) { throw new ArgumentNullException(MethodBase.GetCurrentMethod().Name + Utility.ConstUtili.ERR_SEPA + nameof(value)); } return(DateTime.TryParse( s: value, provider: provider, styles: styles, result: out var o ) ? o : DateTime.Now); }
public static DateTime?AsNullableDateTime(this object val, DateTime?dflt = null, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault, System.Globalization.DateTimeStyles styles = System.Globalization.DateTimeStyles.None) { try { if (val == null) { return(null); } return(val.AsDateTime(styles)); } catch { if (handling != ConvertErrorHandling.ReturnDefault) { throw; } return(dflt); } }
static StackObject *Parse_24(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Globalization.DateTimeStyles @styles = (System.Globalization.DateTimeStyles) typeof(System.Globalization.DateTimeStyles).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.IFormatProvider @provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String @s = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = System.DateTime.Parse(@s, @provider, @styles); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static bool ParseGameTime(string str, out DateTime gameTime, out string errorDetails) { const DateTimeStyles k_styles = DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite | DateTimeStyles.NoCurrentDateDefault; bool result = false; gameTime = new DateTime(1, 1, 1); errorDetails = ""; if (!str.Contains(':')) { int seconds; result = int.TryParse(str, out seconds); if (!result) { errorDetails = "Invalid 'seconds' value"; } else { gameTime = gameTime.AddSeconds(seconds); } } else { result = DateTime.TryParseExact(str, "mm:ss", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat, k_styles, out gameTime); if (!result) { errorDetails = "Invalid 'time' value"; } } return(result); }
private void frmSample3_Load(object sender, System.EventArgs e) { grid.Redim(46, 3); SourceGrid2.VisualModels.Common l_TitleModel = new SourceGrid2.VisualModels.Common(false); l_TitleModel.BackColor = Color.SteelBlue; l_TitleModel.ForeColor = Color.White; l_TitleModel.TextAlignment = ContentAlignment.MiddleCenter; SourceGrid2.VisualModels.Common l_CaptionModel = new SourceGrid2.VisualModels.Common(false); l_CaptionModel.BackColor = grid.BackColor; int l_CurrentRow = 0; #region Base Types grid[l_CurrentRow, 0] = new Cells.Cell("Base Types", null, l_TitleModel); grid[l_CurrentRow, 0].ColumnSpan = 3; l_CurrentRow++; //string grid[l_CurrentRow, 0] = new Cells.Cell("String", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell("String Value", typeof(string)); l_CurrentRow++; //double grid[l_CurrentRow, 0] = new Cells.Cell("Double", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(1.5, typeof(double)); l_CurrentRow++; //int grid[l_CurrentRow, 0] = new Cells.Cell("Int", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(5, typeof(int)); l_CurrentRow++; //DateTime grid[l_CurrentRow, 0] = new Cells.Cell("DateTime", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(DateTime.Now, typeof(DateTime)); l_CurrentRow++; //Boolean grid[l_CurrentRow, 0] = new Cells.Cell("Boolean", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(true, typeof(Boolean)); l_CurrentRow++; #endregion #region Complex Types grid[l_CurrentRow, 0] = new Cells.Cell("Complex Types", null, l_TitleModel); grid[l_CurrentRow, 0].ColumnSpan = 3; l_CurrentRow++; //Font grid[l_CurrentRow, 0] = new Cells.Cell("Font", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(this.Font, typeof(Font)); l_CurrentRow++; //Cursor grid[l_CurrentRow, 0] = new Cells.Cell("Cursor", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(Cursors.Arrow, typeof(Cursor)); l_CurrentRow++; //Point grid[l_CurrentRow, 0] = new Cells.Cell("Point", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(new Point(2, 3), typeof(Point)); l_CurrentRow++; //Rectangle grid[l_CurrentRow, 0] = new Cells.Cell("Rectangle", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); l_CurrentRow++; //Image grid[l_CurrentRow, 0] = new Cells.Cell("Image", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(null, typeof(Image)); l_CurrentRow++; //Enum AnchorStyle grid[l_CurrentRow, 0] = new Cells.Cell("AnchorStyle", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); l_CurrentRow++; //Enum grid[l_CurrentRow, 0] = new Cells.Cell("Enum", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); l_CurrentRow++; #endregion #region Special Editors and Cells grid[l_CurrentRow, 0] = new Cells.Cell("Special Editors and Cells", null, l_TitleModel); grid[l_CurrentRow, 0].ColumnSpan = 3; l_CurrentRow++; //Double Chars Validation grid[l_CurrentRow, 0] = new Cells.Cell("Double Chars Validation", null, l_CaptionModel); SourceGrid2.DataModels.EditorTextBoxNumeric l_NumericEditor = new SourceGrid2.DataModels.EditorTextBoxNumeric(typeof(double)); l_NumericEditor.NumericCharStyle = SourceLibrary.Windows.Forms.NumericCharStyle.DecimalSeparator | SourceLibrary.Windows.Forms.NumericCharStyle.NegativeSymbol; grid[l_CurrentRow, 1] = new Cells.Cell(0.5, l_NumericEditor); l_CurrentRow++; //String Chars (ABC) grid[l_CurrentRow, 0] = new Cells.Cell("String Chars Validation(only ABC)", null, l_CaptionModel); SourceGrid2.DataModels.EditorTextBox l_StringEditor = new SourceGrid2.DataModels.EditorTextBox(typeof(string)); l_StringEditor.ValidCharacters = new char[] { 'A', 'B', 'C' }; grid[l_CurrentRow, 1] = new Cells.Cell("AABB", l_StringEditor); l_CurrentRow++; //Int 0-100 or null grid[l_CurrentRow, 0] = new Cells.Cell("Int 0-100 or null", null, l_CaptionModel); SourceGrid2.DataModels.EditorTextBoxNumeric l_NumericEditor0_100 = new SourceGrid2.DataModels.EditorTextBoxNumeric(typeof(int)); l_NumericEditor0_100.NumericCharStyle = SourceLibrary.Windows.Forms.NumericCharStyle.None; l_NumericEditor0_100.MinimumValue = 0; l_NumericEditor0_100.MaximumValue = 100; l_NumericEditor0_100.AllowNull = true; grid[l_CurrentRow, 1] = new Cells.Cell(7, l_NumericEditor0_100); l_CurrentRow++; //Enum Custom Display grid[l_CurrentRow, 0] = new Cells.Cell("Enum Custom Display", null, l_CaptionModel); SourceGrid2.DataModels.EditorComboBox l_KeysCombo = new SourceGrid2.DataModels.EditorComboBox(typeof(Keys)); l_KeysCombo.ConvertingValueToDisplayString += new SourceLibrary.ComponentModel.ConvertingObjectEventHandler(l_KeysCombo_ConvertingValueToDisplayString); grid[l_CurrentRow, 1] = new Cells.Cell(Keys.Enter); grid[l_CurrentRow, 1].DataModel = l_KeysCombo; l_CurrentRow++; string[] l_CmbArr = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[l_CurrentRow, 0] = new Cells.Cell("ComboBox String", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.ComboBox(l_CmbArr[0], typeof(string), l_CmbArr, false); l_CurrentRow++; //ComboBox 2 grid[l_CurrentRow, 0] = new Cells.Cell("ComboBox String Exclusive", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.ComboBox(l_CmbArr[0], typeof(string), l_CmbArr, true); l_CurrentRow++; //ComboBox 3 grid[l_CurrentRow, 0] = new Cells.Cell("ComboBox String No TextBox", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.ComboBox(l_CmbArr[0], typeof(string), l_CmbArr, true); grid[l_CurrentRow, 1].DataModel.AllowStringConversion = false; l_CurrentRow++; //ComboBox DateTime Editable grid[l_CurrentRow, 0] = new Cells.Cell("ComboBox DateTime", null, l_CaptionModel); DateTime[] l_CmbArrDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; grid[l_CurrentRow, 1] = new Cells.ComboBox(l_CmbArrDt[0], typeof(DateTime), l_CmbArrDt, false); l_CurrentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[l_CurrentRow, 0] = new Cells.Cell("ComboBox Custom Display", null, l_CaptionModel); int[] l_CmbArrInt = new int[] { 0, 1, 2, 3, 4 }; SourceGrid2.DataModels.EditorComboBox l_ComboBoxDescription = new SourceGrid2.DataModels.EditorComboBox(typeof(int), l_CmbArrInt, true); SourceLibrary.ComponentModel.Validator.ValueMapping l_ComboMapping = new SourceLibrary.ComponentModel.Validator.ValueMapping(); l_ComboMapping.DisplayStringList = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; l_ComboMapping.ValueList = l_CmbArrInt; l_ComboMapping.BindValidator(l_ComboBoxDescription); grid[l_CurrentRow, 1] = new Cells.Cell(0); grid[l_CurrentRow, 1].DataModel = l_ComboBoxDescription; Cells.Cell l_CellComboRealValue = new Cells.Cell(grid[l_CurrentRow, 1].Value, null, l_CaptionModel); SourceGrid2.BehaviorModels.BindProperty l_ComboBindProperty = new SourceGrid2.BehaviorModels.BindProperty(typeof(Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[l_CurrentRow, 1].Behaviors.Add(l_ComboBindProperty); grid[l_CurrentRow, 2] = l_CellComboRealValue; l_CurrentRow++; //Numeric Up Down Editor grid[l_CurrentRow, 0] = new Cells.Cell("NumericUpDown", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(0); SourceGrid2.DataModels.EditorNumericUpDown l_NumericUpDownEditor = new SourceGrid2.DataModels.EditorNumericUpDown(typeof(int), 100, 0, 1); grid[l_CurrentRow, 1].DataModel = l_NumericUpDownEditor; l_CurrentRow++; //Multiline Textbox grid[l_CurrentRow, 0] = new Cells.Cell("Multiline Textbox", null, l_CaptionModel); grid[l_CurrentRow, 0].ColumnSpan = 1; grid[l_CurrentRow, 0].RowSpan = 2; grid[l_CurrentRow, 1] = new Cells.Cell("Hello\r\nWorld"); SourceGrid2.DataModels.EditorTextBox l_MultilineEditor = new SourceGrid2.DataModels.EditorTextBox(typeof(string)); l_MultilineEditor.Multiline = true; grid[l_CurrentRow, 1].DataModel = l_MultilineEditor; grid[l_CurrentRow, 1].RowSpan = 2; l_CurrentRow++; l_CurrentRow++; //Boolean (CheckBox) grid[l_CurrentRow, 0] = new Cells.Cell("Boolean (CheckBox)", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.CheckBox(true); Cells.CheckBox l_DisabledCheckBox = new Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.EnableEdit = false; grid[l_CurrentRow, 2] = l_DisabledCheckBox; l_CurrentRow++; //Cell Button grid[l_CurrentRow, 1] = new Cells.Button("CellButton"); l_CurrentRow++; //Cell Link grid[l_CurrentRow, 1] = new Cells.Link("CellLink"); l_CurrentRow++; #endregion #region Custom Formatting grid[l_CurrentRow, 0] = new Cells.Cell("Custom Formatting", null, l_TitleModel); grid[l_CurrentRow, 0].ColumnSpan = 3; l_CurrentRow++; //Percent Editor grid[l_CurrentRow, 0] = new Cells.Cell("Percent Format", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(0.5); SourceGrid2.DataModels.EditorTextBox l_PercentEditor = new SourceGrid2.DataModels.EditorTextBox(typeof(double)); l_PercentEditor.TypeConverter = new SourceLibrary.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[l_CurrentRow, 1].DataModel = l_PercentEditor; l_CurrentRow++; //Currency Editor grid[l_CurrentRow, 0] = new Cells.Cell("Currency Format", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(50.0M); SourceGrid2.DataModels.EditorTextBox l_CurrencyEditor = new SourceGrid2.DataModels.EditorTextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new SourceLibrary.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[l_CurrentRow, 1].DataModel = l_CurrencyEditor; l_CurrentRow++; //Custom Format Number Editor grid[l_CurrentRow, 0] = new Cells.Cell("Custom Format Number", null, l_CaptionModel); Cells.Cell l_CellNumberEditor = new Cells.Cell(84.23); SourceGrid2.DataModels.EditorTextBox l_CustomFormatEditor = new SourceGrid2.DataModels.EditorTextBox(typeof(double)); l_CustomFormatEditor.EnableEdit = false; SourceLibrary.ComponentModel.Converter.NumberTypeConverter l_NumberConverter = new SourceLibrary.ComponentModel.Converter.NumberTypeConverter(typeof(double)); l_CustomFormatEditor.TypeConverter = l_NumberConverter; l_CellNumberEditor.DataModel = l_CustomFormatEditor; l_CellNumberEditor.VisualModel = l_CaptionModel; grid[l_CurrentRow, 1] = l_CellNumberEditor; grid[l_CurrentRow, 2] = new Cells.ComboBox(l_NumberConverter.Format, typeof(string), new string[] { "G", "C", "P", "000.00", "#.000" }, false); SourceGrid2.BehaviorModels.BindProperty l_BindProperty = new SourceGrid2.BehaviorModels.BindProperty(typeof(SourceLibrary.ComponentModel.Converter.NumberTypeConverter).GetProperty("Format"), l_NumberConverter); grid[l_CurrentRow, 2].Behaviors.Add(l_BindProperty); SourceGrid2.BehaviorModels.CustomEvents l_Event = new SourceGrid2.BehaviorModels.CustomEvents(); l_Event.ValueChanged += new SourceGrid2.PositionEventHandler(CellCustomFormat_ValueChanged); grid[l_CurrentRow, 2].Behaviors.Add(l_Event); l_CurrentRow++; //DateTime 2 (using custom formatting) string l_FormatDt2 = "yyyy MM dd"; grid[l_CurrentRow, 0] = new Cells.Cell("Date(" + l_FormatDt2 + ")", null, l_CaptionModel); string[] l_ParseFormat = new string[] { l_FormatDt2 }; System.Globalization.DateTimeStyles l_dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter l_dtConverter = new SourceLibrary.ComponentModel.Converter.DateTimeTypeConverter(l_FormatDt2, l_ParseFormat, l_dtStyles); string tmp = l_dtConverter.ConvertToString(DateTime.Today); DateTime l_dtValue = (DateTime)l_dtConverter.ConvertFromString(tmp); SourceGrid2.DataModels.EditorUITypeEditor l_editorDt2 = new SourceGrid2.DataModels.EditorUITypeEditor(typeof(DateTime)); l_editorDt2.TypeConverter = l_dtConverter; grid[l_CurrentRow, 1] = new Cells.Cell(DateTime.Today, l_editorDt2); l_CurrentRow++; #endregion #region Image And Text Properties grid[l_CurrentRow, 0] = new Cells.Cell("Image And Text Properties", null, l_TitleModel); grid[l_CurrentRow, 0].ColumnSpan = 3; l_CurrentRow++; //Cell Image Cells.Cell l_CellImage1 = new Cells.Cell("Single Image", null, l_CaptionModel); grid[l_CurrentRow, 2] = l_CellImage1; l_CellImage1.RowSpan = 5; SourceGrid2.VisualModels.Common l_ModelImage = new SourceGrid2.VisualModels.Common(false); l_ModelImage.Image = SampleImages.FACE02; l_CellImage1.VisualModel = l_ModelImage; grid[l_CurrentRow, 0] = new Cells.Cell("Image Alignment", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(l_ModelImage.ImageAlignment, typeof(ContentAlignment)); grid[l_CurrentRow, 1].Behaviors.Add(new SourceGrid2.BehaviorModels.BindProperty(typeof(SourceGrid2.VisualModels.Common).GetProperty("ImageAlignment"), l_ModelImage)); l_CurrentRow++; grid[l_CurrentRow, 0] = new Cells.Cell("Stretch Image", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(l_ModelImage.ImageStretch, typeof(bool)); grid[l_CurrentRow, 1].Behaviors.Add(new SourceGrid2.BehaviorModels.BindProperty(typeof(SourceGrid2.VisualModels.Common).GetProperty("ImageStretch"), l_ModelImage)); l_CurrentRow++; grid[l_CurrentRow, 0] = new Cells.Cell("Text Alignment", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(l_ModelImage.TextAlignment, typeof(ContentAlignment)); grid[l_CurrentRow, 1].Behaviors.Add(new SourceGrid2.BehaviorModels.BindProperty(typeof(SourceGrid2.VisualModels.Common).GetProperty("TextAlignment"), l_ModelImage)); l_CurrentRow++; grid[l_CurrentRow, 0] = new Cells.Cell("AlignTextToImage", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(l_ModelImage.AlignTextToImage, typeof(bool)); grid[l_CurrentRow, 1].Behaviors.Add(new SourceGrid2.BehaviorModels.BindProperty(typeof(SourceGrid2.VisualModels.Common).GetProperty("AlignTextToImage"), l_ModelImage)); l_CurrentRow++; grid[l_CurrentRow, 0] = new Cells.Cell("StringFormat.FormatFlags", null, l_CaptionModel); grid[l_CurrentRow, 1] = new Cells.Cell(l_ModelImage.StringFormat.FormatFlags, typeof(StringFormatFlags)); grid[l_CurrentRow, 1].Behaviors.Add(new SourceGrid2.BehaviorModels.BindProperty(typeof(StringFormat).GetProperty("FormatFlags"), l_ModelImage.StringFormat)); l_CurrentRow++; // Cell VisualModelMultiImages grid[l_CurrentRow, 2] = new Cells.Cell("Multi Images"); grid[l_CurrentRow, 2].RowSpan = 5; SourceGrid2.VisualModels.MultiImages l_ModelMultiImages = new SourceGrid2.VisualModels.MultiImages(false); l_ModelMultiImages.SubImages.Add(new SourceGrid2.PositionedImage(SampleImages.FACE00, ContentAlignment.TopLeft)); l_ModelMultiImages.SubImages.Add(new SourceGrid2.PositionedImage(SampleImages.FACE01, ContentAlignment.TopRight)); l_ModelMultiImages.SubImages.Add(new SourceGrid2.PositionedImage(SampleImages.FACE02, ContentAlignment.BottomLeft)); l_ModelMultiImages.SubImages.Add(new SourceGrid2.PositionedImage(SampleImages.FACE04, ContentAlignment.BottomRight)); l_ModelMultiImages.StringFormat.FormatFlags = StringFormatFlags.DirectionVertical; grid[l_CurrentRow, 2].VisualModel = l_ModelMultiImages; l_CurrentRow++; l_CurrentRow++; l_CurrentRow++; l_CurrentRow++; #endregion grid.AutoSizeAll(); grid.AutoStretchColumnsToFitWidth = true; grid.StretchColumnsToFitWidth(); }
public static System.DateTimeOffset ParseExact(string input, string[] formats, IFormatProvider formatProvider, System.Globalization.DateTimeStyles styles) { Contract.Ensures(false); return(default(System.DateTimeOffset)); }
public static DateTime Parse(string s, IFormatProvider provider, System.Globalization.DateTimeStyles styles) { return(default(DateTime)); }
/// <summary> /// 是否日期 /// </summary> /// <param name="value">日期字符串</param> /// <param name="format">格式化字符串</param> /// <param name="provider">格式化提供者</param> /// <param name="styles">日期格式</param> /// <returns></returns> public static bool IsDate(this string value, string format, IFormatProvider provider, System.Globalization.DateTimeStyles styles) { if (value.IsNullOrEmpty()) { return(false); } return(DateTime.TryParseExact(value, format, provider, styles, out DateTime _)); }
/// <summary> /// Changes the type, may throw exceptions. /// <locDE><para />Führt eine Typumwandlung durch, kann Ausnahmen werfen.</locDE> /// </summary> /// <typeparam name="T">The type of the T.<locDE><para />Generischer Datentyp T.</locDE></typeparam> /// <param name="value">The value.<locDE><para />Der Wert.</locDE></param> /// <param name="fieldName">Name of the field (i.e. check suffix "Utc" for DateTime). /// <locDE><para />Name des Feldes (z.B. zur Prüfung auf Suffix "Utc" bei Datumswerten).</locDE></param> /// <returns>Changed value.<locDE><para />Geänderter Wert.</locDE></returns> public static T ChangeType <T>(this object value, string fieldName = null) { // See also: below + DALBaseConnection.ConvertJsonDataType() Type targetType = typeof(T); #region Null value if (null == value) { // Find a suitable match for a null value with non-nullable data types if (typeof(Guid) == targetType) { return(default(T)); // Guid.Empty; } if (typeof(System.DateTime) == targetType) { return((T)(object)DateTimeHelper.InvalidDateTime); } if (targetType.IsSubclassOf(typeof(System.Enum))) { return((T)Enum.ToObject(targetType, 0)); } return(default(T)); } #endregion Type sourceType = value.GetType(); if (sourceType == targetType) { return((T)value); } #region Guid? if (typeof(Guid?) == targetType) { // Expect Guid if (value is string) { string strValue = value.ToStringOrDefault(); if (string.IsNullOrWhiteSpace(strValue)) { return(default(T)); } return((T)(object)Guid.Parse(strValue).ValueOrNullIfEmpty()); } return((T)(object)((Guid)Convert.ChangeType(value, typeof(Guid), null)).ValueOrNullIfEmpty()); } #endregion #region If target type is Nullable, get underlying type instead if (targetType.IsGenericType__Workaround() && targetType.GetGenericTypeDefinition() == typeof(Nullable <>)) { targetType = Nullable.GetUnderlyingType(targetType); } #endregion #region Guid if (typeof(Guid) == targetType) { // Expect Guid if (value is string) { string strValue = value.ToStringOrDefault(); if (string.IsNullOrWhiteSpace(strValue)) { return(default(T)); // Guid.Empty; } return((T)(object)Guid.Parse(strValue)); } return((T)Convert.ChangeType(value, typeof(Guid), null)); } #endregion #region Enum if (sourceType.IsSubclassOf(typeof(System.Enum))) { // Cast enum to int value = (int)value; } if (targetType.IsSubclassOf(typeof(System.Enum))) { // Cast int to enum //return (T)Enum.ToObject(targetType, (value is int) ? (int)value : value.ToStringOrDefault().ToInt32(0)); return((T)Enum.ToObject(targetType, DataTypeConverter.Int32Converter.ParseInvariantCulture(value, 0))); } #endregion #region Bool if (typeof(bool) == targetType) { // 0/1 --> false/true return((T)(object)DataTypeConverter.BoolConverter.ParseInvariantCulture(value, false)); } #endregion #region Byte if (typeof(byte) == targetType) { return((T)(object)DataTypeConverter.ByteConverter.ParseInvariantCulture(value, 0)); } #endregion #region Decimal if (typeof(decimal) == targetType) { // "12,34" or "12.34" --> 12.34 return((T)(object)DataTypeConverter.DecimalConverter.ParseInvariantCulture(value, 0)); } #endregion #region Double if (typeof(double) == targetType) { // "12,34" or "12.34" --> 12.34 return((T)(object)DataTypeConverter.DoubleConverter.ParseInvariantCulture(value, double.NaN)); } #endregion #region Float if (typeof(float) == targetType) { // "12,34" or "12.34" --> 12.34 return((T)(object)DataTypeConverter.FloatConverter.ParseInvariantCulture(value, float.NaN)); } #endregion #region Int32 if (typeof(Int32) == targetType) { return((T)(object)DataTypeConverter.Int32Converter.ParseInvariantCulture(value, 0)); } #endregion #region Int64 if (typeof(Int64) == targetType) { return((T)(object)DataTypeConverter.Int64Converter.ParseInvariantCulture(value, 0)); } #endregion #region UInt16 if (typeof(UInt16) == targetType) { return((T)(object)DataTypeConverter.UInt16Converter.ParseInvariantCulture(value, 0)); } #endregion #region UInt32 if (typeof(UInt32) == targetType) { return((T)(object)DataTypeConverter.UInt32Converter.ParseInvariantCulture(value, 0)); } #endregion #region UInt64 if (typeof(UInt64) == targetType) { return((T)(object)DataTypeConverter.UInt64Converter.ParseInvariantCulture(value, 0)); } #endregion #region DateTime if (typeof(System.DateTime) == targetType) { string strValue = value.ToStringOrDefault(); if (string.IsNullOrWhiteSpace(strValue)) { return((T)(object)DateTimeHelper.InvalidDateTime); } if (strValue.Right(1).EqualsSafeIgnoreCase("Z")) { // Handle Suffix "Z" to ensure UTC kind! System.Globalization.DateTimeStyles dateTimeStyles = //System.Globalization.DateTimeStyles.AssumeLocal | // incompatible with RoundtripKind System.Globalization.DateTimeStyles.RoundtripKind | // Preserve time zone information if contained (i.e. "Z(ulu)") System.Globalization.DateTimeStyles.NoCurrentDateDefault | System.Globalization.DateTimeStyles.AllowWhiteSpaces; DateTime dt = DateTime.Parse(strValue, CultureHelper.InvariantCulture, dateTimeStyles); if (DateTimeKind.Utc != dt.Kind) { dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); } return((T)(object)dt); } else { DateTime dt; // Maybe we can guess the DateTime kind from the field name? if (null != fieldName && fieldName.EndsWith("utc", StringComparison.OrdinalIgnoreCase)) { System.Globalization.DateTimeStyles dateTimeStyles = //System.Globalization.DateTimeStyles.AssumeLocal | // incompatible with RoundtripKind System.Globalization.DateTimeStyles.RoundtripKind | // Preserve time zone information if contained (i.e. "Z(ulu)") System.Globalization.DateTimeStyles.NoCurrentDateDefault | System.Globalization.DateTimeStyles.AllowWhiteSpaces; dt = DateTime.Parse(strValue, CultureHelper.InvariantCulture, dateTimeStyles); if (DateTimeKind.Utc != dt.Kind) { dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); } return((T)(object)dt); } // No more ideas right now to determine if this is an UTC value... try { // Try standard parsing with invariant culture dt = (DateTime)Convert.ChangeType(value, targetType, CultureHelper.InvariantCulture); return((T)(object)dt); } catch { } // Last resort: Try to parse using locale settings and placeholder values if (DateTimeHelper.TryParse(strValue, out dt, true)) { return((T)(object)dt); } throw new FormatException("ObjectExtension.ChangeType(): Could not parse DateTime value!"); } } #endregion return((T)Convert.ChangeType(value, targetType, CultureHelper.InvariantCulture)); }
public DateTimeTypeConverter(string p_ToStringFormat, string[] p_ParseFormats, System.Globalization.DateTimeStyles p_DateTimeStyles) { m_ParseFormats = p_ParseFormats; m_Format = p_ToStringFormat; m_DateTimeStyles = p_DateTimeStyles; }
public static DateTime AsDateTime(this object val, System.Globalization.DateTimeStyles styles = System.Globalization.DateTimeStyles.None) { if (val is string) { var sval = ((string)val).Trim(); if (DateTime.TryParse(sval, null, styles, out var dtval)) { return(dtval); } long ival; if (long.TryParse(sval, out ival)) { return(ival.FromSecondsSinceUnixEpochStart()); } double dval; if (double.TryParse(sval, out dval)) { return(((long)dval).FromSecondsSinceUnixEpochStart()); } decimal dcval; if (decimal.TryParse(sval, out dcval)) { return(((long)dcval).FromSecondsSinceUnixEpochStart()); } } if (val is int _int) { return(((long)_int).FromSecondsSinceUnixEpochStart()); } if (val is uint _uint) { return(((long)_uint).FromSecondsSinceUnixEpochStart()); } if (val is long _long) { return((_long).FromSecondsSinceUnixEpochStart()); } if (val is ulong _ulong) { return((_ulong).FromSecondsSinceUnixEpochStart()); } if (val is double _double) { return(((long)_double).FromSecondsSinceUnixEpochStart()); } if (val is float _float) { return(((long)_float).FromSecondsSinceUnixEpochStart()); } if (val is decimal _decimal) { return(((long)_decimal).FromSecondsSinceUnixEpochStart()); } return(Convert.ToDateTime(val)); }
// // Summary: // Converts the specified string representation of a date and time to its DeltaSpace.DateTimeOffset // equivalent using the specified array of formats, culture-specific format // information, and style. The format of the string representation must match // one of the specified formats exactly. // // Parameters: // input: // A string that contains a date and time to convert. // // formats: // An array that defines the expected formats of input. // // formatProvider: // An object that supplies culture-specific formatting information about input. // // styles: // A bitwise combination of enumeration values that indicates the permitted // format of input. A typical value to specify is None. // // result: // When the method returns, contains the DeltaSpace.DateTimeOffset equivalent to // the date and time of input, if the conversion succeeded, or DeltaSpace.DateTimeOffset.MinValue, // if the conversion failed. The conversion fails if the input does not contain // a valid string representation of a date and time, or does not contain the // date and time in the expected format defined by format, or if formats is // null. This parameter is passed uninitialized. // // Returns: // true if the input parameter is successfully converted; otherwise, false. // // Exceptions: // System.ArgumentException: // styles includes an undefined System.Globalization.DateTimeStyles value.-or-System.Globalization.DateTimeStyles.NoCurrentDateDefault // is not supported.-or-styles includes mutually exclusive System.Globalization.DateTimeStyles // values. public static bool TryParseExact( string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result ) { SystemDateTimeOffset systemResult; bool success = SystemDateTimeOffset.TryParseExact(input, formats, formatProvider, styles, out systemResult); result = new DateTimeOffset(systemResult); return success; }
// // Summary: // Converts the specified string representation of a date and time to its DeltaSpace.DateTimeOffset // equivalent using the specified formats, culture-specific format information, // and style. The format of the string representation must match one of the // specified formats exactly. // // Parameters: // input: // A string that contains a date and time to convert. // // formats: // An array of format specifiers that define the expected formats of input. // // formatProvider: // An object that supplies culture-specific formatting information about input. // // styles: // A bitwise combination of enumeration values that indicates the permitted // format of input. // // Returns: // An object that is equivalent to the date and time that is contained in the // input parameter, as specified by the formats, formatProvider, and styles // parameters. // // Exceptions: // System.ArgumentException: // The offset is greater than 14 hours or less than -14 hours.-or-styles includes // an unsupported value.-or-The styles parameter contains System.Globalization.DateTimeStyles // values that cannot be used together. // // System.ArgumentNullException: // input is null. // // System.FormatException: // input is an empty string ("").-or-input does not contain a valid string representation // of a date and time.-or-No element of formats contains a valid format specifier.-or-The // hour component and the AM/PM designator in input do not agree. public static DateTimeOffset ParseExact( string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles ) { return new DateTimeOffset(SystemDateTimeOffset.ParseExact(input, formats, formatProvider, styles)); }
public static bool TryParseExact(string s, string[] formats, IFormatProvider provider, System.Globalization.DateTimeStyles styleout, DateTime& result) { }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) { cancelEvent.Cancel = true; } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) { convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController <SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
public static DateTimeOffset ParseExact(string input, string[] formats, IFormatProvider formatProvider, System.Globalization.DateTimeStyles styles) { }
public static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, System.Globalization.DateTimeStyles stylesout, DateTimeOffset& result) { }
public static DateTime ParseExact(string s, string[] formats, IFormatProvider provider, System.Globalization.DateTimeStyles style) { }
/// <summary> /// Convierte la fecha y hora de una cadena con un formato estricto /// </summary> public static DateTime GetDateTime(this string value, string format, DateTime defaultValue, System.Globalization.DateTimeStyles style = System.Globalization.DateTimeStyles.AssumeUniversal) { return(GetDateTime(value, format, style) ?? defaultValue); }
public static WfDateTime ParseExact(string s, string[] formats, IFormatProvider provider, System.Globalization.DateTimeStyles style) { return((WfDateTime)DateTime.ParseExact(s, formats, provider, style)); }
public static bool TryParseExact(this string value, string format, IFormatProvider formatProvider, System.Globalization.DateTimeStyles dateTimeStyles, out DateTime result) { return(DateTime.TryParseExact(value, format, formatProvider, dateTimeStyles, out result)); }
public static DateTime Parse(string s, IFormatProvider provider, System.Globalization.DateTimeStyles styles) { }
public static DateTime DateTime(this JToken tk, DateTime def, System.Globalization.CultureInfo ci, System.Globalization.DateTimeStyles ds = System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal) { if (tk != null && tk.IsString && System.DateTime.TryParse((string)tk.Value, ci, ds, out DateTime ret)) { return(ret); } else { return(def); } }
/// <summary> /// Recupera o valor da configuração no caminho informado. /// </summary> /// <param name="configuration">Instancia da configuração do sistema.</param> /// <param name="path">Caminho com os dados da configuração.</param> /// <param name="provider">Provedor de formatação.</param> /// <param name="style">Estilo da tada.</param> /// <returns></returns> public static DateTime Get(this ISystemConfiguration configuration, string path, IFormatProvider provider = null, System.Globalization.DateTimeStyles style = System.Globalization.DateTimeStyles.None) { DateTime result = DateTime.Now; if (DateTime.TryParse(Configuration.Configuration.Instance.ReadPath(path), provider, style, out result)) { return(result); } return(DateTime.Now); }