示例#1
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("maxdateyear") || propertyName.Equals("maxdatemonth") || propertyName.Equals("maxdateday") ||
                    propertyName.Equals("mindateyear") || propertyName.Equals("mindatemonth") || propertyName.Equals("mindateday"))
                {
                    int value;
                    if (!int.TryParse(propertyValue, out value))
                    {
                        isPropertyValid = false;
                    }
                    if (propertyName.Equals("maxdateyear"))
                    {
                        if (MinDate > MaxDate.AddYears(-1 * (MaxDate.Year - value)) || value > MaxYear) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("maxdatemonth"))
                    {
                        if (value <= 12 && value >= 1)
                        {
                            if (MinDate > MaxDate.AddMonths(-1 * (MaxDate.Month - value))) isPropertyValid = false;
                        }
                        else
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("maxdateday"))
                    {
                        int month = MaxDate.Month;
                        if (MinDate > MaxDate.AddDays(value - MaxDate.Day)) isPropertyValid = false;
                        // If the month have changed it means that the day value was not valid.
                        if (month != MaxDate.AddDays(value - MaxDate.Day).Month) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("mindateyear"))
                    {
                        if (MinDate.AddYears(-1 * (MinDate.Year - value)) > MaxDate || value < MinYear) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("mindatemonth"))
                    {
                        if (value <= 12 && value >= 1)
                        {
                            if (MinDate.AddMonths(-1 * (MinDate.Month - value)) > MaxDate) isPropertyValid = false;
                        }
                        else
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("mindateday"))
                    {
                        int month = MinDate.Month;
                        if (MinDate.AddDays(value - MinDate.Day) > MaxDate) isPropertyValid = false;
                        // IF the month have changed it means that the day value was not valid.
                        if (month != MinDate.AddDays(value - MinDate.Day).Month) isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#2
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);

            if (RenderUplevel)
            {
                if (Helpers.EnableLegacyRendering())
                {
                    writer.AddAttribute("evaluationfunction", "ClientValidateDate", false);
                    writer.AddAttribute("required", Required.ToString().ToLower(), false);
                    writer.AddAttribute("dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false);
                    writer.AddAttribute("shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false);
                    writer.AddAttribute("minDate", MinDate.ToString(), false);
                    writer.AddAttribute("maxDate", MaxDate.ToString(), false);
                    writer.AddAttribute("invalidErrorMessage", InvalidErrorMessage, true);
                    writer.AddAttribute("requiredErrorMessage", RequiredErrorMessage, true);
                }
                else
                {
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "evaluationfunction", "ClientValidateDate", false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "required", Required.ToString().ToLower(), false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "minDate", MinDate.ToString(), false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "maxDate", MaxDate.ToString(), false);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "invalidErrorMessage", InvalidErrorMessage, true);
                    Page.ClientScript.RegisterExpandoAttribute(ClientID, "requiredErrorMessage", RequiredErrorMessage, true);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TimePicker"/> class.
 /// </summary>
 public TimePicker()
 {
     Format       = DateTimePickerFormat.Custom;
     CustomFormat = "mmm minutes ss seconds";
     ShowUpDown   = true;
     MinDate      = DateTime.MinValue;
     MaxDate      = MinDate.AddDays(1).AddSeconds(-1);
 }
示例#4
0
 protected virtual IDictionary <string, object> GetSettings()
 {
     return(new Dictionary <string, object>
     {
         { "minDate", MinDate > DateTime.MinValue ? $"$new Date('{MinDate.ToString(Format, CultureInfo.InvariantCulture)}')$" : "" },
         { "maxDate", MaxDate > DateTime.MinValue ? $"$new Date('{MaxDate.ToString(Format, CultureInfo.InvariantCulture)}')$" : "" },
         { "format", ClientFormat }
     });
 }
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            var rule = new ModelClientValidationRule();

            rule.ValidationType = "daterange";
            rule.ValidationParameters["mindate"] = MinDate.ToString("dd/MM/yyyy");
            rule.ValidationParameters["maxdate"] = MaxDate.ToString("dd/MM/yyyy");
            rule.ErrorMessage = FormatErrorMessage(metadata.GetDisplayName());
            yield return(rule);
        }
示例#6
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var date = (DateTime)value;

            if (date >= MinDate && date <= MaxDate)
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult($"Date must be since {MinDate.ToString()} till {MaxDate.ToString()}"));
            }
        }
示例#7
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Flags.ToBytes(),
                Peer.ToBytes(),
                Query.ToBytes(),
                Filter.ToBytes(),
                MinDate.ToBytes(),
                MaxDate.ToBytes(),
                Offset.ToBytes(),
                MaxId.ToBytes(),
                Limit.ToBytes()));
 }
示例#8
0
        /// <summary>
        /// Returns the next value for the data element.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The next value
        /// </returns>
        public object NextValue(GenerationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var difference = (MaxDate - MinDate).TotalMilliseconds;
            var random     = context.Random.NextDouble();
            var offset     = random * difference;

            var value = MinDate.AddMilliseconds(offset);

            return(this.DateOnly ? value.Date : value);
        }
示例#9
0
        public PatientSearchPageViewModel(INavigationService navigationService, IGenericRepo <mstr_ward_details> mstrWardRepo,
                                          IGenericRepo <mstr_bed_details> mstrBedRepo, IPatientManager patientManager, IGenericRepo <mstr_patient_info> patientRepo, IPageDialogService pageDialog) : base(navigationService, pageDialog)
        {
            _mstrWardRepo   = mstrWardRepo;
            _mstrBedRepo    = mstrBedRepo;
            _patientManager = patientManager;
            _patientRepo    = patientRepo;

            SearchBtnCommand = new DelegateCommand <string>(GetPatientsList);

            LoadData();
            var currentDate = DateTime.UtcNow.Date;

            MaxDate = MinDate.AddDays(1);
        }
        private void RefreshAddictionalInfo(double lineLeftMargin = double.NaN)
        {
            if (double.IsNaN(lineLeftMargin))
            {
                lineLeftMargin = line.Margin.Left;
            }
            else
            {
                line.Margin = new Thickness(lineLeftMargin, 0, 0, 0);
            }

            var totalSeconds = (int)(MaxDate - MinDate).TotalSeconds;
            var secondStart  = Scroll;
            var secondEnd    = secondStart + (int)(totalSeconds / Zoom);

            var rangeX = secondEnd - secondStart;
            var kX     = (mainGrid.ActualWidth - (Constants.ScaleLeftMargin + Constants.DiagramsMargin.Left + Constants.DiagramsMargin.Right)) / rangeX;
            var second = (lineLeftMargin - (Constants.ScaleLeftMargin + Constants.DiagramsMargin.Left)) / kX;

            var dateTime = MinDate.AddSeconds(Scroll + second);

            foreach (var captionPair in _captions)
            {
                captionPair.Key.SelectPoint(dateTime);
                var statisticsItem = captionPair.Key.GetItemNear(dateTime);
                captionPair.Value.Refresh(statisticsItem, dateTime);
                if (lineLeftMargin + captionPair.Value.ActualWidth > mainGrid.ActualWidth - Constants.DiagramsMargin.Left)
                {
                    captionPair.Value.Margin = new Thickness(mainGrid.ActualWidth - Constants.DiagramsMargin.Left - captionPair.Value.ActualWidth, -5, 0, 0);
                }
                else
                {
                    captionPair.Value.Margin = new Thickness(lineLeftMargin, -5, 0, 0);
                }
            }

            if (lineLeftMargin + lblSelectedTime.ActualWidth > mainGrid.ActualWidth - Constants.DiagramsMargin.Left)
            {
                lblSelectedTime.Margin = new Thickness(mainGrid.ActualWidth - Constants.DiagramsMargin.Left - lblSelectedTime.ActualWidth, 0, 0, 0);
            }
            else
            {
                lblSelectedTime.Margin = new Thickness(lineLeftMargin, 0, 0, 0);
            }

            lblSelectedTime.Content = dateTime.ToString();
        }
        public PatientSearchPageViewModel(INavigationService navigationService, IGenericRepo <mstr_ward_details> mstrWardRepo,
                                          IGenericRepo <mstr_bed_details> mstrBedRepo, IPatientManager patientManager, IGenericRepo <mstr_patient_info> patientRepo, IPageDialogService pageDialog) : base(navigationService, pageDialog)
        {
            _mstrWardRepo   = mstrWardRepo;
            _mstrBedRepo    = mstrBedRepo;
            _patientManager = patientManager;
            _patientRepo    = patientRepo;

            SearchBtnCommand = new DelegateCommand <string>(GetPatientsList);

            Library.KEY_langchangedfrommealpage = "no";

            LoadData();

            var currentDate = DateTime.UtcNow.Date;

            MaxDate = Device.RuntimePlatform == Device.Android ? MinDate.AddDays(2) : MinDate.AddDays(1);
        }
示例#12
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Flags.ToBytes(),
                Peer.ToBytes(),
                Query.ToBytes(),
                ToBytes(FromId, Flags, (int)SearchFlags.FromId),
                Filter.ToBytes(),
                MinDate.ToBytes(),
                MaxDate.ToBytes(),
                OffsetId.ToBytes(),
                AddOffset.ToBytes(),
                Limit.ToBytes(),
                MaxId.ToBytes(),
                MinId.ToBytes(),
                Hash.ToBytes()));
 }
示例#13
0
 protected void ComputeDateRange(IEnumerable <IHistogramable> items)
 {
     if (items == null)
     {
         throw new ArgumentNullException("items");
     }
     foreach (IHistogramable h in items)
     {
         DateTime dt = (DateTime)h.BucketSelector;
         if (MinDate.CompareTo(dt) > 0)
         {
             MinDate = dt;
         }
         if (MaxDate.CompareTo(dt) < 0)
         {
             MaxDate = dt;
         }
     }
 }
        public void Refresh()
        {
            if (_items?.Any() ?? false)
            {
                var minDate = MinDate.AddSeconds(Scroll);
                var seconds = (MaxDate - MinDate).TotalSeconds / Zoom;
                var maxDate = minDate.AddSeconds(seconds);
                lblStart.Content = minDate.ToString();
                lblEnd.Content   = maxDate.ToString();


                foreach (var item in _items)
                {
                    item.MaxDate = MaxDate;
                    item.MinDate = MinDate;

                    item.Zoom   = Zoom;
                    item.Scroll = Scroll;

                    item.Refresh();
                }

                lblEnd.Visibility          = Visibility.Visible;
                lblStart.Visibility        = Visibility.Visible;
                line.Visibility            = Visibility.Visible;
                lblSelectedTime.Visibility = Visibility.Visible;
                scrollBar.Visibility       = Visibility.Visible;
                RefreshAddictionalInfo();
            }
            else
            {
                lblEnd.Visibility          = Visibility.Collapsed;
                lblStart.Visibility        = Visibility.Collapsed;
                scrollBar.Visibility       = Visibility.Collapsed;
                line.Visibility            = Visibility.Collapsed;
                lblSelectedTime.Visibility = Visibility.Collapsed;
            }
        }
示例#15
0
        public void EditMatchDate(DateTime newMatchDate)
        {
            if (newMatchDate.Date < MinDate.Date)
            {
                throw new ArgumentOutOfRangeException($"Date cannot be edited to earlier than {MinDate.ToShortDateString()}");
            }
            if (newMatchDate.Date > MaxDate.Date)
            {
                throw new ArgumentOutOfRangeException($"Date cannot be edited to later than {MaxDate.ToShortDateString()}");
            }

            Value = newMatchDate;
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            DateTime currentDateTime;

            if (DateTime.TryParse(value.ToString(), out currentDateTime))
            {
                if (Mode == DateValidatorMode.OverOrEqualToProperty)
                {
                    DateTime refPropertyDate;
                    Object   instance = validationContext.ObjectInstance;
                    Type     type     = instance.GetType();
                    Object   data     = type.GetProperty(this.RefProperty).GetValue(instance, null);

                    if (data != null && data is DateTime)
                    {
                        refPropertyDate = (DateTime)data;
                    }
                    else
                    {
                        return(new ValidationResult("Property reference date is null or not DateTime value"));
                    }

                    if (DateTime.Compare(currentDateTime, refPropertyDate) >= 0)
                    {
                        return(ValidationResult.Success);
                    }
                    else
                    {
                        return(new ValidationResult("Current DateTime is lower than min property"));
                    }
                }
                else if (Mode == DateValidatorMode.OverNow)
                {
                    DateTime minDateTime;
                    if (MinDate.Equals("Now"))
                    {
                        minDateTime = DateTime.Now;
                    }
                    else
                    {
                        DateTime dt;
                        if (!DateTime.TryParse(MinDate, out dt))
                        {
                            return(new ValidationResult("Cannot parse reference min date to date"));
                        }
                        else
                        {
                            minDateTime = dt;
                        }
                    }

                    if (DateTime.Compare(currentDateTime, minDateTime.Date) >= 0)
                    {
                        return(ValidationResult.Success);
                    }
                    else
                    {
                        return(new ValidationResult("Current DateTime is lower than Now or min DateTime"));
                    }
                }
            }
            else
            {
                return(new ValidationResult("Cannot parse to date"));
            }

            return(new ValidationResult("Error"));
        }
示例#17
0
 protected override void UpdatePicker(UIDatePicker picker)
 {
     picker.Mode        = GetMode();
     picker.MinimumDate = MinDate == DateTime.MinValue ? (NSDate)null : (NSDate)MinDate.ToUniversalTime();
     picker.MaximumDate = MaxDate == DateTime.MaxValue ? (NSDate)null : (NSDate)MaxDate.ToUniversalTime();
     picker.Date        = (Value ?? DateTime.Now).ToUniversalTime();
 }
示例#18
0
        public object GetRandom(EntityProperty column)
        {
            var range = (MaxDate - MinDate).Days;

            return(MinDate.AddDays(Randomize.Next(range)));
        }
 public ApartmentReservationInitializer()
 {
     MinDate = DateTime.Now.AddDays(-4);
     MaxDate = MinDate.AddMonths(1);
 }
示例#20
0
        /// <summary>
        /// Draw all the gridlines and labels for the gridlines
        /// </summary>
        /// <param name="size"></param>
        /// <param name="minXY"></param>
        /// <param name="maxXY"></param>
        protected void DrawGridlinesAndLabels(Size size, Point minXY, Point maxXY)
        {
            // Clear the text canvas
            textCanvas.Children.Clear();

            // Create brush for writing text
            Brush axisBrush      = new SolidColorBrush(gridLineColor);
            Brush axisScaleBrush = new SolidColorBrush(gridLineLabelColor);

            // Need to pick appropriate scale increment.
            // Go for a 2Exx, 5Exx, or 1Exx type scale
            double scaleX = 0.0;
            double scaleY = 0.0;

            // Work out all the limits

            if (maxXY.X != minXY.X)
            {
                scaleX = size.Width / (maxXY.X - minXY.X);
            }
            if (maxXY.Y != minXY.Y)
            {
                scaleY = size.Height / (maxXY.Y - minXY.Y);
            }

            double spacingX;
            int    startXmult, endXmult;

            if (ScaleXHours.HasValue && scaleX != 0)
            {
                int diff = Math.Max(1, Convert.ToInt32(Math.Truncate((MaxDate - MinDate).TotalHours / ScaleXHours.Value)));
                spacingX   = (maxXY.X - minXY.X) / diff;
                startXmult = 0;
                endXmult   = diff;
            }
            else
            {
                var optimalSpacingX = optimalGridLineSpacing.X / scaleX;
                spacingX   = ChartUtilities.Closest_1_2_5_Pow10(optimalSpacingX);
                startXmult = (int)Math.Ceiling(minXY.X / spacingX);
                endXmult   = (int)Math.Floor(maxXY.X / spacingX);
            }

            var optimalSpacingY = optimalGridLineSpacing.Y / scaleY;
            var spacingY        = ChartUtilities.Closest_1_2_5_Pow10(optimalSpacingY);
            var startYmult      = (int)Math.Ceiling(minXY.Y / spacingY);
            var endYmult        = (int)Math.Floor(maxXY.Y / spacingY);

            double maxXLabelHeight = 0;

            var pathFigure = new PathFigure();

            // Draw all the vertical gridlines
            double lastTextBorder = 0;

            for (int lineNo = startXmult; lineNo <= endXmult; ++lineNo)
            {
                double xValue = lineNo * spacingX;
                double xPos   = (xValue - minXY.X) * scaleX;

                var startPoint = new Point(xPos, size.Height);
                var endPoint   = new Point(xPos, 0);

                pathFigure.Segments.Add(new LineSegment(startPoint, false));
                pathFigure.Segments.Add(new LineSegment(endPoint, true));

                var text = new TextBlock
                {
                    TextAlignment = TextAlignment.Center,
                    Foreground    = axisScaleBrush,
                    //FontSize = 8
                };
                if (MinDate != DateTime.MaxValue)
                {
                    DateTime date = MinDate.AddSeconds(xValue);
                    text.Text = (axisDateFormat != null) ? date.ToString(axisDateFormat) : date.ToString();
                }
                else
                {
                    text.Text = xValue.ToString();
                }

                text.Measure(size);
                var textX = xPos - text.DesiredSize.Width * .5;
                if (lastTextBorder == 0 || lastTextBorder <= textX)
                {
                    if (textX + text.DesiredSize.Width > size.Width)
                    {
                        textX = size.Width - text.DesiredSize.Width;
                    }
                    text.SetValue(Canvas.LeftProperty, textX);
                    text.SetValue(Canvas.TopProperty, size.Height + 1);
                    textCanvas.Children.Add(text);
                    maxXLabelHeight = Math.Max(maxXLabelHeight, text.DesiredSize.Height);

                    lastTextBorder = textX + text.DesiredSize.Width;
                }
            }

            xGridlineLabels.Height = maxXLabelHeight + 2;

            // Set string format for vertical text
            double maxYLabelHeight = 0;

            // Draw all the horizontal gridlines

            for (int lineNo = startYmult; lineNo <= endYmult; ++lineNo)
            {
                double yValue = lineNo * spacingY;
                double yPos   = (-yValue + minXY.Y) * scaleY + size.Height;

                var startPoint = new Point(0, yPos);
                var endPoint   = new Point(size.Width, yPos);

                pathFigure.Segments.Add(new LineSegment(startPoint, false));
                pathFigure.Segments.Add(new LineSegment(endPoint, true));

                var text = new TextBlock();
                if (!yTextForDigitalView ||
                    Math.Abs(yValue - 1) < 0.00000001 ||
                    Math.Abs(yValue) < 0.00000001)
                {
                    text.Text = yValue.ToString();
                }
                else
                {
                    text.Text = " ";
                }
                text.LayoutTransform = new RotateTransform(-90);
                text.Measure(size);

                text.SetValue(Canvas.LeftProperty, -text.DesiredSize.Width - 1);
                text.SetValue(Canvas.TopProperty, yPos - text.DesiredSize.Height * .5);
                textCanvas.Children.Add(text);
                maxYLabelHeight = Math.Max(maxYLabelHeight, text.DesiredSize.Width);
            }
            yGridLineLabels.Height = maxYLabelHeight + 2;

            var path = new Path();

            path.Stroke = axisBrush;
            var pathGeometry = new PathGeometry(new PathFigure[] { pathFigure });

            pathGeometry.Transform = (Transform)textCanvas.RenderTransform.Inverse;
            path.Data = pathGeometry;

            textCanvas.Children.Add(path);
        }