private void StartTimer(TimeName timeName, string timeValue)
        {
            // Get human readable version of time name
            string timeNameDescription = EnumDescription.Get <TimeName>(timeName);

            // Stop colour annimation, if it is currently going
            StopAnimation();

            try
            {
                countdownTime = TimeSpan.Parse(timeValue);
                countdownTimer.Start();
                if (timeName == TimeName.WORK)
                {
                    this.WindowState = FormWindowState.Minimized;
                }
            }
            catch (OverflowException)
            {
                MessageBox.Show("One value in " + timeNameDescription + " time is too large or has incorrect number of digits");
            }
            catch (FormatException)
            {
                MessageBox.Show(timeNameDescription + " time value is not in correct format (hh:mm:ss)");
            }
            catch (Exception ex)
            {
                var t = ex.GetType();
                MessageBox.Show("Exception in " + timeNameDescription + " time : " + ex.Message);
            }
        }
        public void Should_Get_Description_Of_None_Value_In_Enum_Test()
        {
            var _enum           = EnumTest.None;
            var descriptionNone = EnumDescription.Get(_enum);

            Assert.Equal("-", descriptionNone);
        }
Example #3
0
        public static IEnumerable <KeyAndValue> EnumValueAndDescriptionToKeyAndValue <T>() where T : Enum
        {
            var result = new List <KeyAndValue>();

            foreach (var t in Enum.GetValues(typeof(T)))
            {
                result.Add(new KeyAndValue(t.ToString(), EnumDescription.Get((Enum)t)));
            }
            return(result);
        }
Example #4
0
        public static Dictionary <string, string> EnumValueAndDescriptionToDictionary <T>() where T : Enum
        {
            var result = new Dictionary <string, string>();

            foreach (var t in Enum.GetValues(typeof(T)))
            {
                result.Add(t.ToString(), EnumDescription.Get((Enum)t));
            }
            return(result);
        }
Example #5
0
        public JsonResult GetPagination(DataTableParameters parameters, MessageStatus status)
        {
            var search   = parameters.Search.Value?.ToLower() ?? string.Empty;
            var repo     = new RepositoryBase <Message>(_db);
            var items    = repo.GetItemsByExpression(w => w.Title.Contains(search), x => x.Title, parameters.Start, parameters.Length, out var recordsTotal).ToList();
            var dtResult = new DataTableResultSet(parameters.Draw, recordsTotal);

            var buttons = new ButtonsMessage();

            foreach (var item in items)
            {
                dtResult.data.Add(new object[]
                {
                    item.Status == MessageStatus.Unread,
                    item.Title,
                    EnumDescription.Get(item.Subject),
                    buttons.ToPagination(item.MessageId, Account.Current.Roles)
                });
            }
            return(Json(dtResult, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public static MvcHtmlString SemanticEnumDropDownListFor <TModel, TProperty>(this HtmlHelper <TModel> html, Expression <Func <TModel, TProperty> > expression, string optionLabel = "Selecione...", object htmlAttributes = null)
        {
            var fullBindingName = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression));
            var metadata        = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
            var validations     = html.GetUnobtrusiveValidationAttributes(metadata.PropertyName, metadata);
            var tag             = new TagBuilder("select");

            InsertValidateAttribute(tag, validations);

            if (htmlAttributes != null)
            {
                tag.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
            }

            if (tag.Attributes.ContainsKey("class"))
            {
                tag.Attributes["class"] = $"ui fluid search dropdown {tag.Attributes["class"]}";
            }
            else
            {
                tag.Attributes.Add("class", "ui fluid search dropdown");
            }

            tag.Attributes.Add("id", TagBuilder.CreateSanitizedId(fullBindingName));
            tag.Attributes.Add("name", fullBindingName);
            tag.InnerHtml += $"<option value=''>{optionLabel}</option>";

            foreach (Enum item in Enum.GetValues(Nullable.GetUnderlyingType(typeof(TProperty)) ?? typeof(TProperty)))
            {
                tag.InnerHtml += $"<option value='{item}' {(Equals(item, metadata.Model) ? "selected" : string.Empty)}>{EnumDescription.Get(item)}</option>";
            }

            return(new MvcHtmlString(tag.ToString()));
        }
Example #7
0
        static void ThrowForError(FidoU2FHidMessage message)
        {
            var error = GetError(message);

            throw new Exception("Error: " + EnumDescription.Get(error));
        }
        public ActionResult Attachment(int id)
        {
            AnswerAttachment img = db.AnswerAttachments.Find(id);

            return(File(img.Data, EnumDescription.Get(img.FileType)));
        }