Exemple #1
0
        private DialogSourceViewModel GetTimerFormModel()
        {
            var result = new DialogSourceViewModel
            {
                PanelCaption  = DialogTitle.Get(_context),
                FontSize      = FontSize.Get(_context),
                IsMenuVisible = false,
            };

            var footerMenu = new List <ValueDataField>();
            var menuNext   = new ValueDataField
            {
                Name    = "Menu0",
                Caption = "Далее",
                Value   = Key.Enter.ToString()
            };

            menuNext.Set(ValueDataFieldConstants.Row, 0);
            menuNext.Set(ValueDataFieldConstants.Column, 1);
            footerMenu.Add(menuNext);

            ValueDataField field;
            var            message = Message.Get(_context);

            if (!string.IsNullOrEmpty(message))
            {
                field = new ValueDataField
                {
                    Name          = "txtMessage",
                    FieldType     = typeof(string),
                    LabelPosition = "None",
                    IsEnabled     = false,
                    Value         = message
                };
                field.FieldName  = field.Name;
                field.SourceName = field.Name;
                result.Fields.Add(field);
            }

            var dateFrom = DateFrom.Get(_context);

            if (dateFrom.HasValue)
            {
                field = new ValueDataField
                {
                    Name          = "dtDateFrom",
                    Caption       = "С",
                    FieldType     = typeof(DateTime),
                    LabelPosition = "Left",
                    Value         = dateFrom.Value,
                    DisplayFormat = DefaultDateTimeFormat,
                    IsEnabled     = false,
                    SetFocus      = false,
                    CloseDialog   = false
                };
                field.FieldName  = field.Name;
                field.SourceName = field.Name;
                result.Fields.Add(field);
            }

            var timevalue = TimeSpan.FromSeconds(dateFrom.HasValue ? (DateTime.Now - dateFrom.Value).TotalSeconds - TimerOffset.Get(_context) : 0);

            field = new ValueDataField
            {
                Name          = TimerFieldName,
                Caption       = "Таймер",
                FieldType     = typeof(TimeSpan),
                LabelPosition = "Left",
                DisplayFormat = "hh\\:mm\\:ss",
                Value         = timevalue,
                IsEnabled     = false,
                SetFocus      = false,
                CloseDialog   = false
            };
            field.FieldName  = field.Name;
            field.SourceName = field.Name;
            result.Fields.Add(field);

            var fieldFooterMenu = new ValueDataField
            {
                Name      = "footerMenu",
                FieldType = typeof(IFooterMenu)
            };

            fieldFooterMenu.FieldName  = fieldFooterMenu.Name;
            fieldFooterMenu.SourceName = fieldFooterMenu.Name;
            fieldFooterMenu.Properties["FooterMenu"] = footerMenu.ToArray();
            result.Fields.Add(fieldFooterMenu);

            result.UpdateSource();
            return(result);
        }