public static DateTime?DateTimeValue(this TimeField field, DateField dateField) { if (dateField == null) { return(null); } var dateNull = dateField.DateTimeValue(); if (dateNull == null) { return(null); } var date = (DateTime)dateNull; var str = field.Text; if (string.IsNullOrWhiteSpace(str)) { return(date.Date); } var result = date; str = date.ToString("yyyy-MM-dd") + " " + str.Trim(); if (DateTime.TryParse(str, out result)) { return(result); } return(date.Date); }
public void CleanTest() { TimeField target = new TimeField(); // Required AssertExtras.Raises <ValidationException>(delegate { target.Clean(null); }).WithMessage("This field is required."); target.Required = false; Assert.IsNull(target.Clean(null)); var expected = new TimeSpan(14, 30, 59); Assert.AreEqual(expected, target.Clean(new DateTime?(new DateTime(2006, 10, 25, 14, 30, 59)))); Assert.AreEqual(expected, target.Clean("14:30:59")); Assert.AreEqual(new TimeSpan(14, 30, 00), target.Clean("14:30")); AssertExtras.Raises <ValidationException>(delegate { target.Clean("14:65:59"); }).WithMessage("Enter a valid time."); }
public void Constructors_Defaults() { var tf = new TimeField(); Assert.False(tf.IsShortFormat); Assert.Equal(TimeSpan.MinValue, tf.Time); Assert.Equal(1, tf.CursorPosition); Assert.Equal(new Rect(0, 0, 10, 1), tf.Frame); var time = DateTime.Now.TimeOfDay; tf = new TimeField(time); Assert.False(tf.IsShortFormat); Assert.Equal(time, tf.Time); Assert.Equal(1, tf.CursorPosition); Assert.Equal(new Rect(0, 0, 10, 1), tf.Frame); tf = new TimeField(1, 2, time); Assert.False(tf.IsShortFormat); Assert.Equal(time, tf.Time); Assert.Equal(1, tf.CursorPosition); Assert.Equal(new Rect(1, 2, 10, 1), tf.Frame); tf = new TimeField(3, 4, time, true); Assert.True(tf.IsShortFormat); Assert.Equal(time, tf.Time); Assert.Equal(1, tf.CursorPosition); Assert.Equal(new Rect(3, 4, 7, 1), tf.Frame); tf.IsShortFormat = false; Assert.Equal(new Rect(3, 4, 10, 1), tf.Frame); Assert.Equal(10, tf.Width); }
public override void Setup() { var s = "This is a test intended to show how TAB key works (or doesn't) across text fields."; Win.Add(new TextField(s) { X = 5, Y = 1, Width = Dim.Percent(80), ColorScheme = Colors.Dialog }); var textView = new TextView() { X = 5, Y = 3, Width = Dim.Percent(80), Height = Dim.Percent(40), ColorScheme = Colors.Dialog }; textView.Text = s; Win.Add(textView); // BUGBUG: 531 - TAB doesn't go to next control from HexView var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))) { X = 5, Y = Pos.Bottom(textView) + 1, Width = Dim.Percent(80), Height = Dim.Percent(40), ColorScheme = Colors.Dialog }; Win.Add(hexView); var dateField = new DateField(System.DateTime.Now) { X = 5, Y = Pos.Bottom(hexView) + 1, Width = Dim.Percent(40), ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(dateField); var timeField = new TimeField(System.DateTime.Now) { X = Pos.Right(dateField) + 5, Y = Pos.Bottom(hexView) + 1, Width = Dim.Percent(40), ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(timeField); }
public static string StringValue(this TimeField field, DateTime defaultValue, DateField dateField) { var dtime = field.DateTimeValue(defaultValue, dateField); if (dtime == null) { return(null); } return(DateTimeStringValue((DateTime)dtime)); }
/// <summary> /// Constructor for the class /// </summary> /// <param name="frm">The parent form</param> /// <param name="field">The fied to be edited</param> public TimeFieldDefinition(MainForm frm, TimeField field) : base(frm) { InitializeComponent(); this.mode = FormMode.Edit; this.field = field; this.page = field.Page; PopulatePatterns(); cbxPattern.SelectedIndex = -1; LoadFormData(); }
protected override ChartData <TimeProfileXValue, TimeProfileYValue> BuildChartsData() { var statisticalAnalysis = _analysis.DowncastTo <PopulationStatisticalAnalysis>(); var paneFieldNames = _analysis.StringFieldNamesOn(PivotArea.RowArea); var paneFieldComparers = GetFieldComparers(PivotArea.RowArea); var seriesFieldNames = new List <string> { _dataColumnName, STATISTICAL_AGGREGATION_DISPLAY_NAME }; if (_analysis.ColorField != null) { seriesFieldNames.Add(_analysis.ColorField.Name); } var seriesFieldComparers = GetFieldComparers(PivotArea.ColumnArea); var timeField = new TimeField { Dimension = _dimensionRepository.Time, DisplayUnit = statisticalAnalysis.TimeUnit }; _data.AddColumn <StatisticalAggregation>(STATISTICAL_AGGREGATION); _data.AddColumn <string>(STATISTICAL_AGGREGATION_DISPLAY_NAME); _data.AddColumn <Tuple <QuantityValues, FloatMatrix> >(TIME_AND_VALUES); // Create rows for each combination of row<=>DATA_FIELD value and selected STATISTICAL_AGGREGATION var dataCopy = _data.Copy(); _data.Clear(); foreach (DataRow row in dataCopy.Rows) { var timeAndAllValues = getTimeAndAllValuesFor(row); // calculate once because expensive foreach (var statisticalAggregation in statisticalAnalysis.SelectedStatistics) { row[STATISTICAL_AGGREGATION] = statisticalAggregation; row[STATISTICAL_AGGREGATION_DISPLAY_NAME] = _representationInfoRepository.DisplayNameFor(statisticalAggregation); row[TIME_AND_VALUES] = timeAndAllValues; _data.ImportRow(row); } } var chart = CreateChart(timeField, paneFieldComparers); // Create series for each row (combination of DATA_FIELD value and selected STATISTICAL_AGGREGATION) foreach (DataRow row in _data.Rows) { var yAxisField = DataField <PopulationAnalysisOutputField>(row); var series = GetCurveData(row, paneFieldNames, paneFieldComparers, seriesFieldNames, seriesFieldComparers, chart, yAxisField); setSeriesValues(series, row); } //add observed data if availables addObservedDataToChart(chart); return(chart); }
public void InputFormatsTest() { TimeField target = new TimeField { InputFormats = new string[] { "HH:mm:ss" } }; Assert.AreEqual(1, target.InputFormats.Length); }
protected TriggerSlotInfo GetCurrentTriggerSlot(TriggerInfo trigger, DateTime time) { bool specialSlotFound = false; TriggerSlotInfo specialSlot; TriggerSlotInfo generalSlot = new TriggerSlotInfo() { SlotId = -1 }; TimeField currentTime = TimeField.FromDateTime(time); int dayInt = (time.DayOfWeek == DayOfWeek.Sunday) ? 7 : (int)time.DayOfWeek; string sql = "SELECT id, text, weekday, start, end FROM triggerslots WHERE trigger_id = @TriggerId AND (weekday = @CurrentWeekday OR weekday = @GeneralWeekDay)"; MySqlCommand cmd = DatabaseService.TryCreateCommand(); cmd.CommandText = sql; cmd.Parameters.AddWithValue("TriggerId", trigger.Id); cmd.Parameters.AddWithValue("CurrentWeekDay", dayInt); cmd.Parameters.AddWithValue("GeneralWeekDay", 8); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { TriggerSlotInfo slot = new TriggerSlotInfo() { SlotId = reader.GetInt32(0), Text = reader.GetString(1), DayOfWeek = reader.GetInt32(2), StartTime = TimeField.Parse(reader.GetString(3)), EndTime = TimeField.Parse(reader.GetString(4)) }; if (slot.DayOfWeek == 8) { generalSlot = slot; } else { if (currentTime.IsBetween(slot.StartTime, slot.EndTime)) { return(slot); } } } return(generalSlot); } }
public static DateTime DateTimeValue(this TimeField field, DateTime defaultValue, DateField dateField) { if (dateField == null) { return(defaultValue); } var dtime = field.DateTimeValue(dateField); if (dtime == null) { return(defaultValue); } return((DateTime)dtime); }
public void CursorPosition_Min_Is_Always_One_Max_Is_Always_Max_Format() { var tf = new TimeField(); Assert.Equal(1, tf.CursorPosition); tf.CursorPosition = 0; Assert.Equal(1, tf.CursorPosition); tf.CursorPosition = 9; Assert.Equal(8, tf.CursorPosition); tf.IsShortFormat = true; tf.CursorPosition = 0; Assert.Equal(1, tf.CursorPosition); tf.CursorPosition = 6; Assert.Equal(5, tf.CursorPosition); }
public static void SetCurrentFrame(int frame, float time) { if (AnimationWindow == null) { return; } object state = GetState(); #if UNITY_5_0 TimeField.SetValue(state, time); FrameField.SetValue(state, frame); PreviewFrame.Invoke(AnimationWindow, new object[] { frame }); #else CurrentTimeField.SetValue(state, time); #endif _animationWindow.Repaint(); }
public void KeyBindings_Command() { TimeField tf = new TimeField(TimeSpan.Parse("12:12:19")); tf.ReadOnly = true; Assert.True(tf.ProcessKey(new KeyEvent(Key.DeleteChar, new KeyModifiers()))); Assert.Equal(" 12:12:19", tf.Text); tf.ReadOnly = false; Assert.True(tf.ProcessKey(new KeyEvent(Key.D | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(" 02:12:19", tf.Text); tf.CursorPosition = 4; tf.ReadOnly = true; Assert.True(tf.ProcessKey(new KeyEvent(Key.Delete, new KeyModifiers()))); Assert.Equal(" 02:12:19", tf.Text); tf.ReadOnly = false; Assert.True(tf.ProcessKey(new KeyEvent(Key.Backspace, new KeyModifiers()))); Assert.Equal(" 02:02:19", tf.Text); Assert.True(tf.ProcessKey(new KeyEvent(Key.Home, new KeyModifiers()))); Assert.Equal(1, tf.CursorPosition); Assert.True(tf.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); Assert.Equal(8, tf.CursorPosition); Assert.True(tf.ProcessKey(new KeyEvent(Key.A | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(1, tf.CursorPosition); Assert.True(tf.ProcessKey(new KeyEvent(Key.E | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(8, tf.CursorPosition); Assert.True(tf.ProcessKey(new KeyEvent(Key.CursorLeft, new KeyModifiers()))); Assert.Equal(7, tf.CursorPosition); Assert.True(tf.ProcessKey(new KeyEvent(Key.CursorRight, new KeyModifiers()))); Assert.Equal(8, tf.CursorPosition); Assert.False(tf.ProcessKey(new KeyEvent(Key.A, new KeyModifiers()))); tf.ReadOnly = true; tf.CursorPosition = 1; Assert.True(tf.ProcessKey(new KeyEvent(Key.D1, new KeyModifiers()))); Assert.Equal(" 02:02:19", tf.Text); tf.ReadOnly = false; Assert.True(tf.ProcessKey(new KeyEvent(Key.D1, new KeyModifiers()))); Assert.Equal(" 12:02:19", tf.Text); }
/// <summary> /// Sets the appropriate properties for a given field, based on the specified column conversion information /// </summary> /// <param name="field">The Epi Info 7 field</param> /// <param name="cci">The column conversion information</param> private void SetFieldProperties(Field field, ColumnConversionInfo cci) { if (cci.Prompt == null) { cci.Prompt = cci.DestinationColumnName; } switch (field.FieldType) { case MetaFieldType.Checkbox: CheckBoxField checkboxField = (CheckBoxField)field; checkboxField.TabIndex = cci.TabIndex; checkboxField.IsReadOnly = cci.IsReadOnly; checkboxField.IsRequired = cci.IsRequired; checkboxField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.YesNo: YesNoField yesNoField = (YesNoField)field; yesNoField.TabIndex = cci.TabIndex; yesNoField.IsReadOnly = cci.IsReadOnly; yesNoField.IsRequired = cci.IsRequired; yesNoField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.Text: SingleLineTextField textField = (SingleLineTextField)field; textField.TabIndex = cci.TabIndex; textField.IsReadOnly = cci.IsReadOnly; textField.IsRequired = cci.IsRequired; textField.ShouldRepeatLast = cci.IsRepeatLast; if (cci.UpperBound is int) { textField.MaxLength = (int)cci.UpperBound; } break; case MetaFieldType.Multiline: MultilineTextField multilineTextField = (MultilineTextField)field; multilineTextField.TabIndex = cci.TabIndex; multilineTextField.IsReadOnly = cci.IsReadOnly; multilineTextField.IsRequired = cci.IsRequired; multilineTextField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.Date: DateField dateField = (DateField)field; dateField.TabIndex = cci.TabIndex; dateField.IsReadOnly = cci.IsReadOnly; dateField.IsRequired = cci.IsRequired; dateField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.DateTime: DateTimeField dateTimeField = (DateTimeField)field; dateTimeField.TabIndex = cci.TabIndex; dateTimeField.IsReadOnly = cci.IsReadOnly; dateTimeField.IsRequired = cci.IsRequired; dateTimeField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.Time: TimeField timeField = (TimeField)field; timeField.TabIndex = cci.TabIndex; timeField.IsReadOnly = cci.IsReadOnly; timeField.IsRequired = cci.IsRequired; timeField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.Number: NumberField numberField = (NumberField)field; numberField.TabIndex = cci.TabIndex; numberField.IsReadOnly = cci.IsReadOnly; numberField.IsRequired = cci.IsRequired; numberField.ShouldRepeatLast = cci.IsRepeatLast; break; case MetaFieldType.LegalValues: DDLFieldOfLegalValues legalValuesField = (DDLFieldOfLegalValues)field; legalValuesField.TabIndex = cci.TabIndex; legalValuesField.IsReadOnly = cci.IsReadOnly; legalValuesField.IsRequired = cci.IsRequired; legalValuesField.ShouldRepeatLast = cci.IsRepeatLast; if (string.IsNullOrEmpty(cci.ListSourceTableName)) { DataTable dt = new DataTable(cci.SourceColumnName); dt.Columns.Add(new DataColumn(cci.SourceColumnName, typeof(string))); // table is blank, so assume user wants to use a SELECT DISTINCT as the value source Query selectDistinctQuery = sourceDriver.CreateQuery("SELECT DISTINCT [" + cci.SourceColumnName + "] FROM [" + tableName + "]"); IDataReader distinctReader = sourceDriver.ExecuteReader(selectDistinctQuery); while (distinctReader.Read()) { dt.Rows.Add(distinctReader[0].ToString()); } cci.ListSourceTable = dt; cci.ListSourceTableName = cci.SourceColumnName; cci.ListSourceTextColumnName = cci.SourceColumnName; IDbDriver db = project.CollectedData.GetDatabase(); if (!db.TableExists(cci.ListSourceTableName)) { project.CreateCodeTable(cci.ListSourceTableName, cci.ListSourceTextColumnName); project.SaveCodeTableData(cci.ListSourceTable, cci.ListSourceTableName, cci.ListSourceTextColumnName); } legalValuesField.SourceTableName = cci.ListSourceTableName; legalValuesField.TextColumnName = cci.ListSourceTextColumnName; legalValuesField.CodeColumnName = cci.ListSourceTextColumnName; } else { IDbDriver db = project.CollectedData.GetDatabase(); if (!db.TableExists(cci.ListSourceTableName)) { project.CreateCodeTable(cci.ListSourceTableName, cci.ListSourceTextColumnName); string[] columns = new string[1]; columns[0] = cci.ListSourceTextColumnName; project.InsertCodeTableData(cci.ListSourceTable, cci.ListSourceTableName, columns); } legalValuesField.SourceTableName = cci.ListSourceTableName; legalValuesField.TextColumnName = cci.ListSourceTextColumnName; legalValuesField.CodeColumnName = cci.ListSourceTextColumnName; } break; default: throw new ApplicationException("Invalid field type"); //break; } double ControlHeightPercentage = 0.0; double ControlWidthPercentage = 0.0; if (field is FieldWithSeparatePrompt) { FieldWithSeparatePrompt fieldWithPrompt; fieldWithPrompt = (FieldWithSeparatePrompt)field; fieldWithPrompt.PromptText = cci.Prompt; fieldWithPrompt.PromptFont = cci.PromptFont; fieldWithPrompt.ControlFont = cci.ControlFont; fieldWithPrompt.PromptLeftPositionPercentage = cci.ControlLeftPosition / 100; fieldWithPrompt.PromptTopPositionPercentage = cci.ControlTopPosition / 100; fieldWithPrompt.Name = cci.DestinationColumnName; fieldWithPrompt.ControlHeightPercentage = ControlHeightPercentage / 100; fieldWithPrompt.ControlWidthPercentage = ControlWidthPercentage / 100; fieldWithPrompt.ControlTopPositionPercentage = cci.ControlTopPosition / 100; fieldWithPrompt.ControlLeftPositionPercentage = (cci.ControlLeftPosition / 100) + 0.090702947845805; fieldWithPrompt.UpdatePromptPosition(); fieldWithPrompt.UpdateControlPosition(); } else { FieldWithoutSeparatePrompt fieldWithoutPrompt; fieldWithoutPrompt = (FieldWithoutSeparatePrompt)field; fieldWithoutPrompt.PromptText = cci.Prompt; fieldWithoutPrompt.PromptFont = cci.PromptFont; fieldWithoutPrompt.Name = cci.DestinationColumnName; fieldWithoutPrompt.ControlHeightPercentage = ControlHeightPercentage / 100; fieldWithoutPrompt.ControlWidthPercentage = ControlWidthPercentage / 100; fieldWithoutPrompt.ControlTopPositionPercentage = cci.ControlTopPosition / 100; fieldWithoutPrompt.ControlLeftPositionPercentage = (cci.ControlLeftPosition / 100) + 0.090702947845805; fieldWithoutPrompt.UpdateControlPosition(); } }
private void CalcMomentary(List <Field> Fields, DateTime Now, ushort Raw) { Fields.Add(new Int32Field(this, Now, "Raw", Raw, FieldType.Momentary, FieldQoS.AutomaticReadout, typeof(Module).Namespace, 26)); if (this.exp is null && !string.IsNullOrEmpty(this.expression)) { this.exp = new Expression(this.expression); } if (this.exp != null) { Variables v = new Variables() { { "Raw", (double)Raw } }; object Value = this.exp.Evaluate(v); Field F; if (Value is double dbl) { F = new QuantityField(this, Now, this.fieldName, dbl, this.nrDecimals, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is PhysicalQuantity qty) { F = new QuantityField(this, Now, this.fieldName, qty.Magnitude, this.nrDecimals, qty.Unit.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is bool b) { F = new BooleanField(this, Now, this.fieldName, b, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is DateTime DT) { F = new DateTimeField(this, Now, this.fieldName, DT, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is Duration D) { F = new DurationField(this, Now, this.fieldName, D, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is Enum E) { F = new EnumField(this, Now, this.fieldName, E, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is int i32) { if (string.IsNullOrEmpty(this.unit)) { F = new Int32Field(this, Now, this.fieldName, i32, FieldType.Momentary, FieldQoS.AutomaticReadout); } else { F = new QuantityField(this, Now, this.fieldName, i32, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout); } } else if (Value is long i64) { if (string.IsNullOrEmpty(this.unit)) { F = new Int64Field(this, Now, this.fieldName, i64, FieldType.Momentary, FieldQoS.AutomaticReadout); } else { F = new QuantityField(this, Now, this.fieldName, i64, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout); } } else if (Value is string s) { F = new StringField(this, Now, this.fieldName, s, FieldType.Momentary, FieldQoS.AutomaticReadout); } else if (Value is TimeSpan TS) { F = new TimeField(this, Now, this.fieldName, TS, FieldType.Momentary, FieldQoS.AutomaticReadout); } else { F = new StringField(this, Now, this.fieldName, Value.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout); } if (this.fieldName == "Value") { F.Module = typeof(Module).Namespace; F.StringIdSteps = new LocalizationStep[] { new LocalizationStep(13) }; } Fields.Add(F); } }
public void TimeFieldConstructorTest() { var target = new TimeField(new Widgets.TextArea()); Assert.IsInstanceOfType(target.Widget, typeof(Widgets.TextArea)); }
public void TimeFieldConstructorTest1() { TimeField target = new TimeField(); // No error is a pass }
static void Dir( [Description("Specifies drive, directory, and/or files to list.")] string fileName = null, [Argument("A")] [Description("Displays files with specified attributes.")] Attributes attributes = Attributes.None, [Argument("B")] [Description("Uses bare format (no heading information or summary).")] bool bareFormat = false, [Argument("C")] [Description("Display the thousand separator in file sizes. This is the\r\ndefault. Use /-C to disable display of separator.")] bool thousandSeparator = true, [Argument("D")] [Description("Same as wide but files are list sorted by column.")] bool wideListFormatSorted = false, [Argument("L")] [Description("Uses lowercase.")] bool lowercase = false, [Argument("N")] [Description("New long list format where filenames are on the far right.")] bool longListFormat = false, [Argument("O")] [Description("List by files in sorted order.")] string sortOrder = null, [Argument("P")] [Description("Pauses after each screenful of information.")] bool pauses = false, [Argument("Q")] [Description("Display the owner of the file.")] bool displayOwner = false, [Argument("R")] [Description("Display alternate data streams of the file.")] bool displayAltStreams = false, [Argument("S")] [Description("Displays files in specified directory and all subdirectories.")] bool includeSubdirectories = false, [Argument("T")] [Description("Controls which time field displayed or used for sorting.")] TimeField timeField = TimeField.LastWritten, [Argument("W")] [Description("Uses wide list format.")] bool wideListFormat = false, [Argument("X")] [Description( "This displays the short names generated for non-8dot3 file\r\n" + "names. The format is that of /N with the short name inserted\r\n" + "before the long name. If no short name is present, blanks are\r\n" + "displayed in its place." )] bool displayShortNames = false, [Argument("4")] [Description("Displays four-digit years.")] bool fourDigitYears = false ) { }
public override void Setup() { var s = "TAB to jump between text fields."; var textField = new TextField(s) { X = 1, Y = 1, Width = Dim.Percent(50), //ColorScheme = Colors.Dialog }; Win.Add(textField); var labelMirroringTextField = new Label(textField.Text) { X = Pos.Right(textField) + 1, Y = Pos.Top(textField), Width = Dim.Fill(1) }; Win.Add(labelMirroringTextField); textField.TextChanged += (prev) => { labelMirroringTextField.Text = textField.Text; }; var textView = new TextView() { X = 1, Y = 3, Width = Dim.Percent(50), Height = Dim.Percent(30), ColorScheme = Colors.Dialog }; textView.Text = s; Win.Add(textView); var labelMirroringTextView = new Label(textView.Text) { X = Pos.Right(textView) + 1, Y = Pos.Top(textView), Width = Dim.Fill(1), Height = Dim.Height(textView), }; Win.Add(labelMirroringTextView); textView.TextChanged += () => { labelMirroringTextView.Text = textView.Text; }; // BUGBUG: 531 - TAB doesn't go to next control from HexView var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))) { X = 1, Y = Pos.Bottom(textView) + 1, Width = Dim.Fill(1), Height = Dim.Percent(30), //ColorScheme = Colors.Dialog }; Win.Add(hexView); var dateField = new DateField(System.DateTime.Now) { X = 1, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(dateField); var labelMirroringDateField = new Label(dateField.Text) { X = Pos.Right(dateField) + 1, Y = Pos.Top(dateField), Width = Dim.Width(dateField), Height = Dim.Height(dateField), }; Win.Add(labelMirroringDateField); dateField.TextChanged += (prev) => { labelMirroringDateField.Text = dateField.Text; }; _timeField = new TimeField(DateTime.Now.TimeOfDay) { X = Pos.Right(labelMirroringDateField) + 5, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(_timeField); _labelMirroringTimeField = new Label(_timeField.Text) { X = Pos.Right(_timeField) + 1, Y = Pos.Top(_timeField), Width = Dim.Width(_timeField), Height = Dim.Height(_timeField), }; Win.Add(_labelMirroringTimeField); _timeField.TimeChanged += TimeChanged; }
public void SelectCFTimeField(string cfName, TimeField timeField, string value) { this.SelectCFTimeField(this.GetCFItemID(cfName), timeField, value); }
public static FieldDefinitionRecord GetField(Stream inputStream) { var type = (FieldType)inputStream.ReadByte(); FieldDefinitionRecord field; switch (type) { case FieldType.Bcd: field = new BcdField(inputStream); break; case FieldType.Byte: field = new ByteField(inputStream); break; case FieldType.Date: field = new DateField(inputStream); break; case FieldType.Double: field = new DoubleField(inputStream); break; case FieldType.FixedLengthString: field = new FixedLengthStringField(inputStream); break; case FieldType.Float: field = new FloatField(inputStream); break; case FieldType.Group: field = new GroupField(inputStream); break; case FieldType.PascalString: field = new PascalStringField(inputStream); break; case FieldType.SignedLong: field = new SignedLongField(inputStream); break; case FieldType.SignedShort: field = new SignedShortField(inputStream); break; case FieldType.Time: field = new TimeField(inputStream); break; case FieldType.UnsignedLong: field = new UnsignedLongField(inputStream); break; case FieldType.UnsignedShort: field = new UnsignedShortField(inputStream); break; case FieldType.ZeroTerminatedString: field = new ZeroTerminatedStringField(inputStream); break; default: throw new NotImplementedException(string.Format("The field type 0x{0:X2} is not implemented.", type)); } field.Type = type; return(field); }
public void SelectCFTimeField(int cfId, TimeField timeField, string value) { UIUtil.DefaultProvider.SelectWithText( string.Format(CFTimeFieldFormat, timeField.ToString(), cfId.ToString()), value, LocateBy.Id); }
/// <summary> /// 初始化 DateTimeBox 控件 FieldContainer=DateField+TimeField /// </summary> /// <param name="paramField_Start"></param> /// <param name="field"></param> /// <param name="container"></param> /// <param name="isReadonly"></param> private void IniParamDateTimeBox(string paramField_Start, ParamField field, Container container, bool isReadonly) { if (field.Type != ParamFieldType.DateTimeBox) { return; } Caption caption = uiHelper.UiData.GetCaption(field.Caption, field.FieldName); FieldContainer result = new FieldContainer(); string fieldName = paramField_Start + field.FieldName; this.IniAllParamField(fieldName, field); result.ID = fieldName; result.FieldLabel = caption.Value; result.LabelWidth = 80; result.LabelAlign = LabelAlign.Right; result.Layout = LayoutType.HBox.ToString(); result.Flex = 1; var defaultValue = field.DefaultValue; if (string.IsNullOrWhiteSpace(defaultValue)) { defaultValue = DateTime.Now.ToString("yyyy-MM-dd"); } DateTime?date = DateTime.Now; var values = defaultValue.Split('|'); if (values.Length > 0) { date = getDefaultDateTime(values[0]); } string dtDate = string.Empty; if (date != null) { dtDate = ((DateTime)date).ToString("yyyy-MM-dd"); } string dtTime = string.Empty; if (values.Length > 1) { dtTime = values[1]; } if (string.IsNullOrWhiteSpace(dtTime)) { dtTime = "08:00:00"; } DateField dateField = new DateField(); dateField.ID = result.ID + UiHelper.DATE_DATETIME_STATE_END; dateField.Format = "yyyy-MM-dd"; if (!string.IsNullOrWhiteSpace(dtDate)) { dateField.Text = dtDate; } dateField.Flex = 1; TimeField timeField = new TimeField(); timeField.ID = result.ID + UiHelper.TIME_DATETIME_STATE_END; if (!string.IsNullOrWhiteSpace(dtDate)) { timeField.Text = dtTime; } timeField.Increment = 30; timeField.Format = "HH:mm:ss"; timeField.Flex = 1; if (isReadonly || field.ReadOnly) { dateField.ReadOnly = true; timeField.ReadOnly = true; } result.Items.Add(dateField); result.Items.Add(timeField); container.Add(result); }
public override void Setup() { var longTime = new TimeField(DateTime.Now.TimeOfDay) { X = Pos.Center(), Y = 2, IsShortFormat = false, ReadOnly = false, }; longTime.TimeChanged += TimeChanged; Win.Add(longTime); var shortTime = new TimeField(DateTime.Now.TimeOfDay) { X = Pos.Center(), Y = Pos.Bottom(longTime) + 1, IsShortFormat = true, ReadOnly = false, }; shortTime.TimeChanged += TimeChanged; Win.Add(shortTime); var shortDate = new DateField(DateTime.Now) { X = Pos.Center(), Y = Pos.Bottom(shortTime) + 1, IsShortFormat = true, ReadOnly = true, }; shortDate.DateChanged += DateChanged; Win.Add(shortDate); var longDate = new DateField(DateTime.Now) { X = Pos.Center(), Y = Pos.Bottom(shortDate) + 1, IsShortFormat = false, ReadOnly = true, }; longDate.DateChanged += DateChanged; Win.Add(longDate); lblOldTime = new Label("Old Time: ") { X = Pos.Center(), Y = Pos.Bottom(longDate) + 1, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblOldTime); lblNewTime = new Label("New Time: ") { X = Pos.Center(), Y = Pos.Bottom(lblOldTime) + 1, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblNewTime); lblTimeFmt = new Label("Time Format: ") { X = Pos.Center(), Y = Pos.Bottom(lblNewTime) + 1, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblTimeFmt); lblOldDate = new Label("Old Date: ") { X = Pos.Center(), Y = Pos.Bottom(lblTimeFmt) + 2, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblOldDate); lblNewDate = new Label("New Date: ") { X = Pos.Center(), Y = Pos.Bottom(lblOldDate) + 1, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblNewDate); lblDateFmt = new Label("Date Format: ") { X = Pos.Center(), Y = Pos.Bottom(lblNewDate) + 1, TextAlignment = TextAlignment.Centered, Width = Dim.Fill(), }; Win.Add(lblDateFmt); var swapButton = new Button("Swap Long/Short & Read/Read Only") { X = Pos.Center(), Y = Pos.Bottom(Win) - 5, }; swapButton.Clicked += () => { longTime.ReadOnly = !longTime.ReadOnly; shortTime.ReadOnly = !shortTime.ReadOnly; longTime.IsShortFormat = !longTime.IsShortFormat; shortTime.IsShortFormat = !shortTime.IsShortFormat; longDate.ReadOnly = !longDate.ReadOnly; shortDate.ReadOnly = !shortDate.ReadOnly; longDate.IsShortFormat = !longDate.IsShortFormat; shortDate.IsShortFormat = !shortDate.IsShortFormat; }; Win.Add(swapButton); }
public Transaction() { date = new DateField(); date.Text = "Date"; date.AllowNull = false; time = new TimeField(); time.Text = "Time"; time.AllowNull = true; total = new MoneyField(); total.Text = "Total"; total.AllowNull = false; }
public override void Setup() { var longTime = new TimeField(DateTime.Now) { X = Pos.Center(), Y = 2, IsShortFormat = false, ReadOnly = false, }; Win.Add(longTime); var shortTime = new TimeField(DateTime.Now) { X = Pos.Center(), Y = Pos.Bottom(longTime) + 1, IsShortFormat = true, ReadOnly = false, }; Win.Add(shortTime); var shortDate = new DateField(DateTime.Now) { X = Pos.Center(), Y = Pos.Bottom(shortTime) + 1, IsShortFormat = true, ReadOnly = true, }; Win.Add(shortDate); var longDate = new DateField(DateTime.Now) { X = Pos.Center(), Y = Pos.Bottom(shortDate) + 1, IsShortFormat = false, ReadOnly = true, }; Win.Add(longDate); Win.Add(new Button("Swap Long/Short & Read/Read Only") { X = Pos.Center(), Y = Pos.Bottom(Win) - 5, Clicked = () => { longTime.ReadOnly = !longTime.ReadOnly; shortTime.ReadOnly = !shortTime.ReadOnly; longTime.IsShortFormat = !longTime.IsShortFormat; shortTime.IsShortFormat = !shortTime.IsShortFormat; longDate.ReadOnly = !longDate.ReadOnly; shortDate.ReadOnly = !shortDate.ReadOnly; longDate.IsShortFormat = !longDate.IsShortFormat; shortDate.IsShortFormat = !shortDate.IsShortFormat; } }); }
/// <summary> /// Constructor. /// </summary> internal TimeFieldHelper(TimeField fieldEntity) { _field = fieldEntity; }
public override void Setup() { var s = "TAB to jump between text fields."; var textField = new TextField(s) { X = 1, Y = 1, Width = Dim.Percent(50), //ColorScheme = Colors.Dialog }; Win.Add(textField); var labelMirroringTextField = new Label(textField.Text) { X = Pos.Right(textField) + 1, Y = Pos.Top(textField), Width = Dim.Fill(1) }; Win.Add(labelMirroringTextField); textField.TextChanged += (prev) => { labelMirroringTextField.Text = textField.Text; }; var textView = new TextView() { X = 1, Y = 3, Width = Dim.Percent(50), Height = Dim.Percent(30), ColorScheme = Colors.Dialog }; textView.Text = s; Win.Add(textView); var labelMirroringTextView = new Label(textView.Text) { X = Pos.Right(textView) + 1, Y = Pos.Top(textView), Width = Dim.Fill(1), Height = Dim.Height(textView), }; Win.Add(labelMirroringTextView); textView.TextChanged += () => { labelMirroringTextView.Text = textView.Text; }; var btnMultiline = new Button("Toggle Multiline") { X = Pos.Right(textView) + 1, Y = Pos.Top(textView) + 1 }; btnMultiline.Clicked += () => textView.Multiline = !textView.Multiline; Win.Add(btnMultiline); // BUGBUG: 531 - TAB doesn't go to next control from HexView var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))) { X = 1, Y = Pos.Bottom(textView) + 1, Width = Dim.Fill(1), Height = Dim.Percent(30), //ColorScheme = Colors.Dialog }; Win.Add(hexView); var dateField = new DateField(System.DateTime.Now) { X = 1, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(dateField); var labelMirroringDateField = new Label(dateField.Text) { X = Pos.Right(dateField) + 1, Y = Pos.Top(dateField), Width = Dim.Width(dateField), Height = Dim.Height(dateField), }; Win.Add(labelMirroringDateField); dateField.TextChanged += (prev) => { labelMirroringDateField.Text = dateField.Text; }; _timeField = new TimeField(DateTime.Now.TimeOfDay) { X = Pos.Right(labelMirroringDateField) + 5, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(_timeField); _labelMirroringTimeField = new Label(_timeField.Text) { X = Pos.Right(_timeField) + 1, Y = Pos.Top(_timeField), Width = Dim.Width(_timeField), Height = Dim.Height(_timeField), }; Win.Add(_labelMirroringTimeField); _timeField.TimeChanged += TimeChanged; // MaskedTextProvider var netProviderLabel = new Label(".Net MaskedTextProvider [ 999 000 LLL >LLL| AAA aaa ]") { X = Pos.Left(dateField), Y = Pos.Bottom(dateField) + 1 }; Win.Add(netProviderLabel); var netProvider = new NetMaskedTextProvider("999 000 LLL > LLL | AAA aaa"); var netProviderField = new TextValidateField(netProvider) { X = Pos.Right(netProviderLabel) + 1, Y = Pos.Y(netProviderLabel) }; Win.Add(netProviderField); // TextRegexProvider var regexProvider = new Label("Gui.cs TextRegexProvider [ ^([0-9]?[0-9]?[0-9]|1000)$ ]") { X = Pos.Left(netProviderLabel), Y = Pos.Bottom(netProviderLabel) + 1 }; Win.Add(regexProvider); var provider2 = new TextRegexProvider("^([0-9]?[0-9]?[0-9]|1000)$") { ValidateOnInput = false }; var regexProviderField = new TextValidateField(provider2) { X = Pos.Right(regexProvider) + 1, Y = Pos.Y(regexProvider), Width = 30, TextAlignment = TextAlignment.Centered }; Win.Add(regexProviderField); }
private void InitControls() { #region Fields var userSecionLabel = new Label(1, 1, "Rezerwacja:"); Add(userSecionLabel); var dateFromLabel = new Label("Data od:") { X = Pos.Left(userSecionLabel), Y = Pos.Top(userSecionLabel) + 1, }; Add(dateFromLabel); var fromTime = new TimeField() { X = Pos.Left(dateFromLabel), Y = Pos.Top(dateFromLabel) + 1, }; Add(fromTime); var fromDate = new DateField() { X = Pos.Right(fromTime) + 5, Y = Pos.Top(fromTime), }; Add(fromDate); var dateToLabel = new Label("Data do:") { X = Pos.Left(fromTime), Y = Pos.Top(fromTime) + 1, }; Add(dateToLabel); var toTime = new TimeField() { X = Pos.Left(dateToLabel), Y = Pos.Top(dateToLabel) + 1, }; Add(toTime); var toDate = new DateField() { X = Pos.Right(toTime) + 5, Y = Pos.Top(toTime), }; Add(toDate); var commentsLabel = new Label("Uwagi:") { X = Pos.Left(toTime), Y = Pos.Top(toTime) + 1, }; Add(commentsLabel); var commentsText = new TextField("") { X = Pos.Left(commentsLabel), Y = Pos.Top(commentsLabel) + 1, Width = Dim.Fill() }; Add(commentsText); var carLabel = new Label("Samochód:") { X = Pos.Left(commentsText), Y = Pos.Top(commentsText) + 1, }; Add(carLabel); var carList = new ListView() { X = Pos.Left(carLabel), Y = Pos.Top(carLabel) + 1, Width = Dim.Fill(), Height = 5 }; carList.SetSource(cars); Add(carList); var datewLabel = new Label("Zajęte terminy:") { X = Pos.Left(carList), Y = Pos.Top(carList) + 6, }; Add(datewLabel); var dateList = new ListView() { X = Pos.Left(datewLabel), Y = Pos.Top(datewLabel) + 1, Width = Dim.Fill(), Height = Dim.Fill() - 5, }; Add(dateList); #endregion #region Button var saveButton = new Button("Rezerwuj", true) { X = Pos.Center() - 20, Y = Pos.Percent(100) - 2, }; Add(saveButton); var backButton = new Button("Anuluj") { X = Pos.Center() + 5, Y = Pos.Top(saveButton) }; Add(backButton); #endregion carList.SelectedItemChanged += (a) => { dateList.SetSource(controller.manageReservation.GetCarReservationDates(cars[carList.SelectedItem].CarId)); }; #region Set Data if (selectedCar != null) { carList.SelectedItem = cars.FindIndex(c => c.CarId == selectedCar.CarId); } #endregion fromTime.Time = DateTime.Now.TimeOfDay; fromDate.Date = DateTime.Now; toTime.Time = DateTime.Now.TimeOfDay; toDate.Date = DateTime.Now.AddDays(3); #region bind-button-events saveButton.Clicked += () => { if (string.IsNullOrEmpty(commentsText.Text.ToString())) { MessageBox.ErrorQuery(25, 8, "Błąd", "Pole uwagi nie może być puste.", "Ok"); return; } var dateFrom = fromDate.Date.Date + fromTime.Time; var dateTo = toDate.Date.Date + toTime.Time; if (dateFrom > dateTo) { MessageBox.ErrorQuery(25, 8, "Błąd", "Data rozpoczęcia musi być mniejsza niż data zakończenia.", "Ok"); return; } if (dateFrom < DateTime.Now) { MessageBox.ErrorQuery(25, 8, "Błąd", "Data rozpoczęcia musi być większa od obecnej daty.", "Ok"); return; } Model.Reservation newReservationData = new Model.Reservation() { DateFrom = dateFrom, DateTo = dateTo, Comments = commentsText.Text.ToString(), Status = (int)Model.ReservationStatus.Verification, User = user, Car = cars[carList.SelectedItem] }; OnSave?.Invoke(newReservationData); }; backButton.Clicked += () => { OnBack?.Invoke(); Close(); }; #endregion }
public static IFieldHelper ConvertToFieldHelper(IEntity fieldEntity) { if (fieldEntity == null) { throw new ArgumentNullException("fieldEntity"); } // Ensure we have the specific type of field in question. IEntity field = Entity.AsNative(fieldEntity); if (field == null) { throw new Exception("Assert false"); } StringField stringField = field as StringField; if (stringField != null) { return(new StringFieldHelper(stringField)); } AliasField aliasField = field as AliasField; if (aliasField != null) { return(new AliasFieldHelper(aliasField)); } AutoNumberField autoNumberField = field as AutoNumberField; if (autoNumberField != null) { return(new AutoNumberFieldHelper(autoNumberField)); } BoolField boolField = field as BoolField; if (boolField != null) { return(new BoolFieldHelper(boolField)); } CurrencyField currencyField = field as CurrencyField; if (currencyField != null) { return(new CurrencyFieldHelper(currencyField)); } DateField dateField = field as DateField; if (dateField != null) { return(new DateFieldHelper(dateField)); } DateTimeField dateTimeField = field as DateTimeField; if (dateTimeField != null) { return(new DateTimeFieldHelper(dateTimeField)); } DecimalField decimalField = field as DecimalField; if (decimalField != null) { return(new DecimalFieldHelper(decimalField)); } IntField intField = field as IntField; if (intField != null) { return(new IntFieldHelper(intField)); } TimeField timeField = field as TimeField; if (timeField != null) { return(new TimeFieldHelper(timeField)); } GuidField guidField = field as GuidField; if (guidField != null) { return(new GuidFieldHelper(guidField)); } XmlField xmlField = field as XmlField; if (xmlField != null) { return(new XmlFieldHelper(xmlField)); } throw new Exception("Entity is not a valid field type: " + field.GetType().ToString()); }