public IFluentDisplayWithDisplayOnBreakpointWithDirection WithDirection(DisplayDirection direction) { currentDisplay.Direction = direction; Dirty(); return(this); }
public static async Task <RepositoryResponse <PaginationModel <TView> > > GetAttributeDataByParent <TView>( string culture, string mixDatabaseName, string parentId, MixDatabaseParentType parentType, string orderBy = "CreatedDateTime", DisplayDirection direction = DisplayDirection.Desc, int?pageSize = null, int?pageIndex = 0, MixCmsContext _context = null, IDbContextTransaction _transaction = null) where TView : ViewModelBase <MixCmsContext, MixDatabaseData, TView> { return(await ViewModels.MixDatabaseDatas.Helper.GetAttributeDataByParent <TView>( culture, mixDatabaseName, parentId, parentType, orderBy, direction, pageSize, pageIndex, _context, _transaction)); }
public static MvcHtmlString RadioListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, int cols) { if (direction == DisplayDirection.Vertical) { return(RadioListFor(htmlHelper, expression, 1, null, null)); } else { return(RadioListFor(htmlHelper, expression, cols, null, null)); } }
public static async Task <PaginationModel <ReadMvcViewModel> > GetMixData( string mixDatabaseName, string culture = null, string keyword = null, string fieldName = null, string filterType = "contain", // or "equal" int?pageIndex = 0, int pageSize = 100, string orderBy = "Priority", DisplayDirection direction = DisplayDirection.Asc, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { return(await GetMixData <ReadMvcViewModel>(mixDatabaseName, culture, keyword, fieldName, filterType, pageIndex, pageSize , orderBy, direction)); }
public static async Task <RepositoryResponse <PaginationModel <ReadMvcViewModel> > > GetMixDataByParent( string mixDatabaseName, string parentId, MixDatabaseParentType parentType, string culture = null, string orderBy = "CreatedDateTime", DisplayDirection direction = DisplayDirection.Desc, int?pageSize = null, int?pageIndex = 0, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { culture ??= MixService.GetAppSetting <string>(MixAppSettingKeywords.DefaultCulture); return(await Helper.GetMixDataByParent <ReadMvcViewModel>( culture, mixDatabaseName, parentId, parentType, orderBy, direction, pageSize, pageIndex, _context, _transaction)); }
public void Write(string text, Color color, DisplayDirection rotation = DisplayDirection.Deg0) { SenseHat.Display.Reset(); SenseHat.Display.Direction = rotation; if (text.Length > 2) { // Too long to fit the display! text = text.Substring(0, 2); } var tinyFont = new TinyFont(); SenseHat.Display.Clear(); tinyFont.Write(SenseHat.Display, text, color); SenseHat.Display.Update(); }
private void UpdateDrawingDirection(ref DisplayDirection direction, ref bool flipHorizontal, ref bool flipVertical) { if (SenseHat.Joystick.EnterKey == KeyState.Pressed) { direction++; if (direction > DisplayDirection.Deg270) { direction = DisplayDirection.Deg0; flipHorizontal = !flipHorizontal; if (!flipHorizontal) { flipVertical = !flipVertical; } } } }
public async static Task <RepositoryResponse <PaginationModel <TView> > > GetPostlistByAdditionalField <TView>( string fieldName, string value, string culture , string orderByPropertyName = null, DisplayDirection direction = DisplayDirection.Asc , int?pageSize = null, int?pageIndex = 0 , MixCmsContext _context = null, IDbContextTransaction _transaction = null) where TView : ViewModelBase <MixCmsContext, MixPost, TView> { int maxPageSize = MixService.GetConfig <int>("MaxPageSize"); string orderBy = MixService.GetConfig <string>("OrderBy"); pageSize = (pageSize > 0 && pageSize < maxPageSize) ? pageSize : maxPageSize; pageIndex = (pageIndex >= 0) ? pageIndex : 0; return(await Mix.Cms.Lib.ViewModels.MixPosts.Helper.SearchPostByField <TView>( fieldName, value, culture, orderByPropertyName ?? orderBy, direction, pageSize, pageIndex - 1, _context, _transaction)); }
public void AreBreakpoints_OnAll(string expected, DisplayType displayType, DisplayDirection direction, Breakpoint breakpoint) { var display = new FluentDisplay(); display.WithDisplay(displayType); if (direction != DisplayDirection.None) { display.WithDirection(direction); } if (breakpoint != Breakpoint.None) { display.WithBreakpoint(breakpoint); } var classname = display.Class(classProvider); Assert.Equal(expected, classname); }
public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, object htmlAttribute) { return(CheckBoxListFor(htmlHelper, expression, direction, 2, null, new { style = "display:inline-block;width:70px;" })); }
public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, int colOrRows, object htmlAttribute, object itemAttribute) { string resultStr = ""; string checkPropertyName; string displayPropertyName; MemberExpression nameExpr = (MemberExpression)expression.Body; checkPropertyName = nameExpr.Member.Name; PropertyInfo property = typeof(TModel).GetProperty(checkPropertyName); KeyValueAttribute attribute = (KeyValueAttribute)property.GetCustomAttributes(typeof(KeyValueAttribute), false)[0]; if (attribute == null) { throw new Exception(); } displayPropertyName = attribute.DisplayProperty; string validAttribute = ""; //RequiredAttribute requiredAttribute = (RequiredAttribute)property.GetCustomAttributes(typeof(RequiredAttribute), false)[0]; //if (requiredAttribute != null) //{ // validAttribute += " data-val='true' "; // if (String.IsNullOrEmpty(requiredAttribute.ErrorMessage)) // { // string template = "The {0} field is required."; // validAttribute += " data-val-required='" + string.Format(template, displayPropertyName) + "' "; // } // else // { // validAttribute += " data-val-required='" + requiredAttribute.ErrorMessage + "' "; // } //} IEnumerable checkList = (IEnumerable)htmlHelper.ViewData.Eval(displayPropertyName); var isCheckedList = htmlHelper.ViewData.Eval(checkPropertyName) as IEnumerable; IDictionary <string, object> htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute); IDictionary <string, object> itemAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(itemAttribute); string htmlAttributeStr = ""; foreach (var item in htmlAttributes) { htmlAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string itemAttributeStr = ""; foreach (var item in itemAttributes) { itemAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string directionAppend = ""; if (direction == DisplayDirection.Vertical) { directionAppend = "<br/>"; } int index = 1; resultStr += "<div " + validAttribute + htmlAttributeStr + ">"; foreach (KeyValueModel check in checkList) { resultStr += "<span " + itemAttributeStr + ">"; string checkedStr = ""; bool isCheck = false; foreach (var checkvalue in isCheckedList) { isCheck = check.Value == checkvalue.ToString(); if (isCheck) { checkedStr = " checked='checked' "; break; } } KeyValueModel checkModel = (KeyValueModel)check; if (check.Disable == "disabled" && check.Disable != null) { resultStr += "<label class='label-multi'><input class='" + check.Disable + "'disabled='" + check.Disable + "'name='" + checkPropertyName + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + " ></input>" + " "; resultStr += checkModel.Text + "</label>"; } else { resultStr += "<label class='label-multi'><input name='" + checkPropertyName + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + " ></input>" + " "; resultStr += checkModel.Text + "</label>"; } resultStr += "</span>"; if (index % colOrRows == 0) { resultStr += directionAppend; } index = index + 1; } resultStr += "</div>"; MvcHtmlString result = new MvcHtmlString(resultStr); return(result); }
public void Draw( ISenseHatDisplay display, int offsetX, int offsetY, bool transparent, DisplayDirection direction, bool flipHorizontal, bool flipVertical) { int right = offsetX + 7; int bottom = offsetY + 7; if ((offsetY > 7) || (bottom < 0) || (offsetX > 7) || (right < 0)) { return; } int spritePixelX0 = _spriteXIndex * 8; int spritePixelY0 = _spriteYIndex * 8; int spritePixelXOffset; int spritePixelYOffset; if (offsetX < 0) { spritePixelXOffset = -offsetX; offsetX = 0; } else { spritePixelXOffset = 0; } if (offsetY < 0) { spritePixelYOffset = -offsetY; offsetY = 0; } else { spritePixelYOffset = 0; } if (right > 7) { right = 7; } if (bottom > 7) { bottom = 7; } bool leftToRight; bool topToBottom; bool flipAxis; PixelSupport.ConvertDirectionParameters( direction, flipHorizontal, flipVertical, out leftToRight, out topToBottom, out flipAxis); int xStart; int xStep; int yStart; int yStep; if (leftToRight) { xStart = 0; xStep = 1; } else { xStart = 7; xStep = -1; spritePixelXOffset = -spritePixelXOffset; } if (topToBottom) { yStart = 0; yStep = 1; } else { yStart = 7; yStep = -1; spritePixelYOffset = -spritePixelYOffset; } int spritePixelY = yStart; for (int screenY = offsetY; screenY <= bottom; screenY++) { int spritePixelX = xStart; for (int screenX = offsetX; screenX <= right; screenX++) { int dX = flipHorizontal ? 7 - spritePixelXOffset - spritePixelX : spritePixelXOffset + spritePixelX; int dY = flipVertical ? 7 - spritePixelYOffset - spritePixelY : spritePixelYOffset + spritePixelY; Color spriteColor = flipAxis ? _spriteMap.Pixels[spritePixelX0 + dY, spritePixelY0 + dX] : _spriteMap.Pixels[spritePixelX0 + dX, spritePixelY0 + dY]; if (transparent) { Color screenColor = display.Screen[screenX, screenY]; spriteColor = GetTransparentPixel(screenColor, spriteColor); } display.Screen[screenX, screenY] = spriteColor; spritePixelX += xStep; } spritePixelY += yStep; } }
public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, object htmlAttribute, object itemAttribute) { return(CheckBoxListFor(htmlHelper, expression, direction, 2, htmlAttribute, itemAttribute)); }
public void DrawWrapped( ISenseHatDisplay display, int offsetX, int offsetY, bool transparent, DisplayDirection direction, bool flipHorizontal, bool flipVertical) { int spritePixelX0 = _spriteXIndex * 8; int spritePixelY0 = _spriteYIndex * 8; if (offsetX < 0) { offsetX = 8 + (offsetX % 8); } if (offsetY < 0) { offsetY = 8 + (offsetY % 8); } bool leftToRight; bool topToBottom; bool flipAxis; PixelSupport.ConvertDirectionParameters( direction, flipHorizontal, flipVertical, out leftToRight, out topToBottom, out flipAxis); int xStart; int xStep; int yStart; int yStep; if (leftToRight) { xStart = 0; xStep = 1; } else { xStart = 7; xStep = -1; offsetX = 8 - offsetX; } if (topToBottom) { yStart = 0; yStep = 1; } else { yStart = 7; yStep = -1; offsetY = 8 - offsetY; } int spritePixelY = yStart; for (int screenY = 0; screenY <= 7; screenY++) { int spritePixelX = xStart; for (int screenX = 0; screenX <= 7; screenX++) { int dX = (8 + spritePixelX - offsetX) % 8; int dY = (8 + spritePixelY - offsetY) % 8; Color spriteColor = flipAxis ? _spriteMap.Pixels[spritePixelX0 + dY, spritePixelY0 + dX] : _spriteMap.Pixels[spritePixelX0 + dX, spritePixelY0 + dY]; if (transparent) { Color screenColor = display.Screen[screenX, screenY]; spriteColor = GetTransparentPixel(screenColor, spriteColor); } display.Screen[screenX, screenY] = spriteColor; spritePixelX += xStep; } spritePixelY += yStep; } }
public static MvcHtmlString RadioListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction) { return(RadioListFor(htmlHelper, expression, direction, 15)); }
public override void Run() { // A big thanks to Johan Vinet, pixel artist and animator, for the Mario animation! :-) // http://johanvinet.tumblr.com/ // Twitter handle: @johanvinet // Get the pixels of the animation frames. // (The image below is serialized using the ImageSerializer.Serialize() method.) const string serializedImage = "ATAAAAAIAAAAAP///wD///8A//////8ATf//AE3//wBN///x6AD///8A////AP///wD//////wBN//8ATf//8ej//wBNAP///wD/" + "//8A////AP//////AE3//wBN///x6P//AE0A////AP///wD///8A//////8ATf//AE3//wBN///x6AD///8A////AP///wD/////" + "/wBN//8ATf//AE3//wBNAP///wD///8A////AP//////AE3//wBN//8ATf//AE0A////AP///wD///8A//////8ATf//AE3//wBN" + "//8ATf//AE0A////AP///wD//////wBN//8ATf//AE3//wBN//8ATQD///8A////AP//////AE3//wBN//8ATf//AE3//wBNAP//" + "/wD///8A//////8ATf//AE3//wBN//8ATf//AE0A////AP///wD//////wBN//8ATf//AE3//wBN//8ATQD///8A////AP//////" + "AE3//wBN//8ATf//AE3//wBNAP///wD/////q1I2///Mqv+rUjb/AAAA///MqgD///8A////AP//////zKr/q1I2/wAAAP//zKoA" + "////AP///wD///8A///////Mqv+rUjb/AAAA///MqgD///8A////AP///wD/////q1I2///Mqv+rUjb/AAAA///MqgD///8A////" + "AP////+rUjb/q1I2///Mqv+rUjb/AAAAAP///wD///8A/////6tSNv+rUjb//8yq/6tSNv8AAAAA////AP///wD/////q1I2///M" + "qv//zKr/q1I2/6tSNv//zKoA////AP//////zKr//8yq/6tSNv+rUjb//8yq/6tSNgD///8A///////Mqv//zKr/q1I2/6tSNv//" + "zKr/q1I2AP///wD/////q1I2///Mqv//zKr/q1I2/6tSNv//zKoA////AP////+rUjb/q1I2///Mqv//zKr/q1I2/6tSNgD///8A" + "/////6tSNv+rUjb//8yq///Mqv+rUjb/q1I2AP///wD///8A/////6tSNv//zKr//8yq///MqgD///8A////AP///wD//////8yq" + "///Mqv//zKr//8yqAP///wD//////wBN//8ATf//zKr//8yq///Mqv//zKoA////AP///wD///8A/////6tSNv//zKr//8yq///M" + "qgD///8A////AP///wD/////q1I2/6tSNv//zKr//8yqAP///wD///8A////AP////+rUjb/q1I2///Mqv//zKoA////AP///wD/" + "/////wBN//8ATf///yf/Ka3//x0rUwD///8A//////8ATf//AE3///8n/ymt//8prf///6MAAP//////8egA//////8ATf///yf/" + "Ka3//ymt////owD///HoAP///wD//////wBN//8ATf///yf/Ka3//x0rUwD///8A////AP////8prf///wBN//8ATf///yf/HStT" + "AP///wD///8A/////ymt////AE3//wBN////J/8dK1P///HoAP///wD//////wBN///x6P8prf//Ka3//x0rUwD///////HoAP//" + "//8prf//Ka3//ymt//8prf//HStT/4N2nAD/////fiVT/ymt//8prf//Ka3//ymt//8dK1MA////AP///wD//////wBN///x6P8p" + "rf//Ka3//x0rUwD///8A////AP////8prf//Ka3///8ATf//AE3///HoAP///wD/////q1I2/ymt//8prf//Ka3///8ATf//AE0A" + "////AP///wD///8A/////6tSNv+rUjb/fiVTAP///wD///8A////AP////9+JVMA////AP////+rUjYA////AP///wD///8A////" + "AP///wD///8A////AP////+rUjYA////AP///wD///8A/////6tSNv+rUjb/fiVTAP///wD///8A////AP////+rUjYA////AP//" + "//9+JVMA////AP///wD///8A////AP///wD///8A////AP////9+JVMA////"; Image image = ImageSerializer.Deserialize(serializedImage); // Create a sprite map from the pixels. var spriteMap = new SpriteMap(image); // Keep track of the animation frame... int animationIndex = 0; Sprite sprite = spriteMap.GetSprite(animationIndex); // ...and when it's time to update it. TimeSpan frameDuration = TimeSpan.FromMilliseconds(70); DateTime nextAnimationUpdateTime = DateTime.Now.Add(frameDuration); // Keep track of the location and orientation of the sprite. int spriteX = 0; int spriteY = 0; DisplayDirection direction = DisplayDirection.Deg0; bool flipHorizontal = false; bool flipVertical = false; while (true) { bool redrawSprite = false; //Is it time to update the animation ? if (DateTime.Now >= nextAnimationUpdateTime) { // Yes. The next time to update is: nextAnimationUpdateTime = DateTime.Now.Add(frameDuration); // Needs to redraw the sprite. redrawSprite = true; // Select the next sprite index. animationIndex++; if (animationIndex >= 6) { animationIndex = 0; } // Pick out the sprite. sprite = spriteMap.GetSprite(animationIndex); } if (SenseHat.Joystick.Update()) // Has any of the buttons on the joystick changed? { UpdatePosition(ref spriteX, ref spriteY); // Move the sprite. UpdateDrawingDirection(ref direction, ref flipHorizontal, ref flipVertical); // Re-orientate the sprite. // Needs to redraw the sprite. redrawSprite = true; } if (redrawSprite) { SenseHat.Display.Clear(); // Clear the screen. // Draw the sprite. sprite.Draw(SenseHat.Display, spriteX, spriteY, true, direction, flipHorizontal, flipVertical); SenseHat.Display.Update(); // Update the physical display. } // Take a short nap. Sleep(TimeSpan.FromMilliseconds(2)); } }
public static MvcHtmlString BooleanFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayType displayType, DisplayDirection direction, object[] values, object htmlAttribute) { return(htmlHelper.BooleanFor(expression, displayType, direction, values, htmlAttribute, null)); }
internal static void ConvertDirectionParameters( DisplayDirection direction, bool flipHorizontal, bool flipVertical, out bool leftToRight, out bool topToBottom, out bool flipAxis) { switch (direction) { case DisplayDirection.Deg0: if (!flipHorizontal && !flipVertical) { leftToRight = true; topToBottom = true; } else if (flipHorizontal && !flipVertical) { leftToRight = false; topToBottom = true; } else if (!flipHorizontal /* && flipVertical */) { leftToRight = true; topToBottom = false; } else /* if (flipHorizontal && flipVertical) */ { leftToRight = false; topToBottom = false; } flipAxis = false; break; case DisplayDirection.Deg90: if (!flipHorizontal && !flipVertical) { leftToRight = false; topToBottom = true; } else if (flipHorizontal && !flipVertical) { leftToRight = true; topToBottom = true; } else if (!flipHorizontal /* && flipVertical */) { leftToRight = false; topToBottom = false; } else /* if (flipHorizontal && flipVertical) */ { leftToRight = true; topToBottom = false; } flipAxis = true; break; case DisplayDirection.Deg180: if (!flipHorizontal && !flipVertical) { leftToRight = false; topToBottom = false; } else if (flipHorizontal && !flipVertical) { leftToRight = true; topToBottom = false; } else if (!flipHorizontal /* && flipVertical */) { leftToRight = false; topToBottom = true; } else /* if (flipHorizontal && flipVertical) */ { leftToRight = true; topToBottom = true; } flipAxis = false; break; case DisplayDirection.Deg270: if (!flipHorizontal && !flipVertical) { leftToRight = true; topToBottom = false; } else if (flipHorizontal && !flipVertical) { leftToRight = false; topToBottom = false; } else if (!flipHorizontal /* && flipVertical */) { leftToRight = true; topToBottom = true; } else /* if (flipHorizontal && flipVertical) */ { leftToRight = false; topToBottom = true; } flipAxis = true; break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } }
public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction) { string checkPropertyName; string displayPropertyName; MemberExpression nameExpr = (MemberExpression)expression.Body; checkPropertyName = nameExpr.Member.Name; PropertyInfo property = typeof(TModel).GetProperty(checkPropertyName); KeyValueAttribute attribute = (KeyValueAttribute)property.GetCustomAttributes(typeof(KeyValueAttribute), false)[0]; if (attribute == null) { throw new Exception(); } displayPropertyName = attribute.DisplayProperty; IEnumerable checkList = (IEnumerable)htmlHelper.ViewData.Eval(displayPropertyName); var isCheckedList = htmlHelper.ViewData.Eval(checkPropertyName) as IEnumerable; #region Build html string var htmlStr = new StringBuilder("<div class=\"checkbox-list\">"); int index = 1; foreach (KeyValueModel check in checkList) { if (direction == DisplayDirection.Horizon) { htmlStr.Append("<label class=\"checkbox-inline\">"); } else { htmlStr.Append("<label>"); } string checkedStr = ""; bool isCheck = false; foreach (var checkvalue in isCheckedList) { isCheck = check.Value == checkvalue.ToString(); if (isCheck) { checkedStr = "checked=\"checked\""; break; } } KeyValueModel checkModel = (KeyValueModel)check; if (check.Disable == "disabled" && check.Disable != null) { htmlStr.Append(string.Format("<input type=\"checkbox\" name=\"{0}\" disabled=\"{1}\" value=\"{2}\" {3} /> ", checkPropertyName, check.Disable, check.Value, checkedStr)); } else { htmlStr.Append(string.Format("<input type='checkbox' name='{0}' value='{1}' {2} /> ", checkPropertyName, check.Value, checkedStr)); } htmlStr.Append(checkModel.Text + "</label>"); index = index + 1; } htmlStr.Append("</div>"); #endregion MvcHtmlString result = new MvcHtmlString(htmlStr.ToString()); return(result); }
public void LoadData(int?postId = null, int?productId = null, int?pageId = null , int?pageSize = null, int?pageIndex = 0 , MixCmsContext _context = null, IDbContextTransaction _transaction = null) { UnitOfWorkHelper <MixCmsContext> .InitTransaction(_context, _transaction, out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot); try { string sortBy = Property <string>("sortBy") ?? MixService.GetAppSetting <string>(MixAppSettingKeywords.SortBy); Enum.TryParse(typeof(DisplayDirection), Property <string>("sortDirection"), out object direction); DisplayDirection sortDirection = direction != null ? (DisplayDirection)direction : MixService.GetEnumConfig <DisplayDirection>(MixAppSettingKeywords.SortBy);; pageSize = pageSize > 0 ? pageSize : PageSize; pageIndex = pageIndex > 0 ? pageIndex : 0; Expression <Func <MixModuleData, bool> > dataExp = null; Expression <Func <MixModulePost, bool> > postExp = null; switch (Type) { case MixModuleType.Content: case MixModuleType.Data: dataExp = m => m.ModuleId == Id && m.Specificulture == Specificulture; //postExp = n => n.ModuleId == Id && n.Specificulture == Specificulture; //productExp = m => m.ModuleId == Id && m.Specificulture == Specificulture; break; case MixModuleType.ListPost: postExp = n => n.ModuleId == Id && n.Specificulture == Specificulture; break; default: dataExp = m => m.ModuleId == Id && m.Specificulture == Specificulture; postExp = n => n.ModuleId == Id && n.Specificulture == Specificulture; break; } if (dataExp != null) { var getDataResult = MixModuleDatas.ReadViewModel.Repository .GetModelListBy( dataExp, sortBy, sortDirection, pageSize, pageIndex , _context: context, _transaction: transaction); if (getDataResult.IsSucceed) { //getDataResult.Data.JsonItems = new List<JObject>(); //getDataResult.Data.Items.ForEach(d => getDataResult.Data.JsonItems.Add(d.JItem)); Data = getDataResult.Data; } } if (postExp != null) { var getPosts = MixModulePosts.ReadViewModel.Repository .GetModelListBy(postExp , sortBy, sortDirection , pageSize, pageIndex , _context: context, _transaction: transaction); if (getPosts.IsSucceed) { Posts = getPosts.Data; } } } catch (Exception ex) { UnitOfWorkHelper <MixCmsContext> .HandleException <PaginationModel <ReadMvcViewModel> >(ex, isRoot, transaction); } finally { if (isRoot) { //if current Context is Root UnitOfWorkHelper <MixCmsContext> .CloseDbContext(ref context, ref transaction); } } }
public static MvcHtmlString CheckListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayDirection direction, object htmlAttribute) { return(CheckListFor(htmlHelper, expression, false, direction, 2, null, new { style = "display:inline-block;font-size: inherit; font-weight: inherit;margin-right:10px;" })); }
public override void Run() { // A big thanks to Johan Vinet, pixel artist and animator, for the Mario animation! :-) // http://johanvinet.tumblr.com/ // Twitter handle: @johanvinet var imageUri = new Uri("ms-appx:///Assets/MiniMario.png"); // Get the pixels of the animation frames. Color[,] pixels = PixelSupport.GetPixels(imageUri).Result; // Create a sprite map from the pixels. var spriteMap = new SpriteMap(pixels); // Keep track of the animation frame... int animationIndex = 0; Sprite sprite = spriteMap.GetSprite(animationIndex); // ...and when it's time to update it. TimeSpan frameDuration = TimeSpan.FromMilliseconds(70); DateTime nextAnimationUpdateTime = DateTime.Now.Add(frameDuration); // Keep track of the location and orientation of the sprite. int spriteX = 0; int spriteY = 0; DisplayDirection direction = DisplayDirection.Deg0; bool flipHorizontal = false; bool flipVertical = false; while (true) { bool redrawSprite = false; //Is it time to update the animation ? if (DateTime.Now >= nextAnimationUpdateTime) { // Yes. The next time to update is: nextAnimationUpdateTime = DateTime.Now.Add(frameDuration); // Needs to redraw the sprite. redrawSprite = true; // Select the next sprite index. animationIndex++; if (animationIndex >= 6) { animationIndex = 0; } // Pick out the sprite. sprite = spriteMap.GetSprite(animationIndex); } if (SenseHat.Joystick.Update()) // Has any of the buttons on the joystick changed? { UpdatePosition(ref spriteX, ref spriteY); // Move the sprite. UpdateDrawingDirection(ref direction, ref flipHorizontal, ref flipVertical); // Re-orientate the sprite. // Needs to redraw the sprite. redrawSprite = true; } if (redrawSprite) { SenseHat.Display.Clear(); // Clear the screen. // Draw the sprite. sprite.Draw(SenseHat.Display, spriteX, spriteY, true, direction, flipHorizontal, flipVertical); SenseHat.Display.Update(); // Update the physical display. } // Take a short nap. Sleep(TimeSpan.FromMilliseconds(2)); } }
public static MvcHtmlString BooleanFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DisplayType displayType, DisplayDirection direction, object[] values, object htmlAttribute, object itemAttribute) { IDictionary <string, object> htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute); MemberExpression nameExpr = (MemberExpression)expression.Body; string propertyName = nameExpr.Member.Name; bool? propertyValue = (bool?)htmlHelper.ViewData.Eval(propertyName); IDictionary <string, object> itemAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(itemAttribute); if (values.Length < 2) { throw new ArgumentException("aleast 2 values, for three condition:true, false, null"); } switch (displayType) { case DisplayType.CheckList: return(null); case DisplayType.DropdownList: List <SelectListItem> selectList = new List <SelectListItem>(); if (values.Length > 2) { selectList.Add(new SelectListItem() { Text = values[2].ToString(), Selected = (!propertyValue.HasValue) }); } selectList.Add(new SelectListItem() { Text = values[0].ToString(), Value = "true", Selected = (propertyValue.HasValue ? propertyValue.Value : false) }); selectList.Add(new SelectListItem() { Text = values[1].ToString(), Value = "false", Selected = (propertyValue.HasValue ? propertyValue.Value : false) }); return(htmlHelper.DropDownList(propertyName, selectList, htmlAttributes)); case DisplayType.RadioList: string itemStr = ""; int checkedIndex = 2; if (propertyValue.HasValue) { if (propertyValue.Value) { checkedIndex = 0; } else { checkedIndex = 1; } } for (int i = 0; i < values.Length; i++) { bool isCheck = false; isCheck = (i == checkedIndex); object value = ""; switch (i) { case 0: value = true; break; case 1: value = false; break; case 2: value = ""; break; } itemStr += (htmlHelper.RadioButton(propertyName, value, isCheck, itemAttributes)).ToHtmlString(); itemStr += " " + values[i].ToString(); // ResourceHelper.GetResourceObject(typeof(CommonResource), radio.ResourceKey); if (direction == DisplayDirection.Vertical) { itemStr += "<br/>"; } else { itemStr += " "; } } return(new MvcHtmlString(itemStr)); } return(null); }
public static MvcHtmlString CheckListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, bool vaild, DisplayDirection direction, int colOrRows, object htmlAttribute, object itemAttribute, object checkAttribute = null) { string resultStr = ""; string checkPropertyName; string displayPropertyName; MemberExpression nameExpr = (MemberExpression)expression.Body; checkPropertyName = nameExpr.Member.Name; PropertyInfo property = typeof(TModel).GetProperty(checkPropertyName); KeyValueAttribute attribute = (KeyValueAttribute)property.GetCustomAttributes(typeof(KeyValueAttribute), false)[0]; if (attribute == null) { throw new Exception(); } displayPropertyName = attribute.DisplayProperty; string needVaild = ""; if (vaild) { needVaild = "_needVaild"; } string validAttribute = ""; //RequiredAttribute requiredAttribute = (RequiredAttribute)property.GetCustomAttributes(typeof(RequiredAttribute), false)[0]; RequiredAttribute requiredAttribute = new RequiredAttribute(); if (property.GetCustomAttributes(typeof(RequiredAttribute), false).Count() > 0) { requiredAttribute = (RequiredAttribute)property.GetCustomAttributes(typeof(RequiredAttribute), false)[0]; } if (requiredAttribute != null) { validAttribute += " data-val='true' "; if (String.IsNullOrEmpty(requiredAttribute.ErrorMessage)) { string template = "The {0} field is required."; validAttribute += " data-val-required='" + string.Format(template, displayPropertyName) + "' "; } else { validAttribute += " data-val-required='" + ResourceHelper.GetValue(requiredAttribute.ErrorMessage) + "' "; } } IEnumerable checkList = (IEnumerable)htmlHelper.ViewData.Eval(displayPropertyName); var isCheckedList = htmlHelper.ViewData.Eval(checkPropertyName) as IEnumerable; IDictionary <string, object> htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute); IDictionary <string, object> itemAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(itemAttribute); IDictionary <string, object> checkAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(checkAttribute); string htmlAttributeStr = ""; foreach (var item in htmlAttributes) { htmlAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string itemAttributeStr = ""; foreach (var item in itemAttributes) { itemAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string checkAttributeStr = ""; foreach (var item in checkAttributes) { checkAttributeStr += " " + item.Key + "='" + item.Value + "' "; } string directionAppend = ""; if (direction == DisplayDirection.Vertical) { directionAppend = "<br/>"; } int index = 1; resultStr += "<div " + htmlAttributeStr + ">"; foreach (KeyValueModel check in checkList) { if (check.Disable == "disabled" && check.Disable != null) { index--; resultStr += "<label style=\"display:none\">"; } else { resultStr += "<label " + itemAttributeStr + ">"; } string checkedStr = ""; bool isCheck = false; if (isCheckedList != null) { foreach (var checkvalue in isCheckedList) { isCheck = check.Value == checkvalue.ToString(); if (isCheck) { checkedStr = " checked='checked' "; break; } } } KeyValueModel checkModel = (KeyValueModel)check; if (check.Disable == "disabled" && check.Disable != null) { resultStr += "<input" + validAttribute + " class='" + check.Disable + "'style=\"display:none\" id='" + checkPropertyName + needVaild + "' name='" + checkPropertyName + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + checkAttributeStr + " ></input>" + " "; resultStr += checkModel.Text; } else { resultStr += "<input" + validAttribute + " name='" + checkPropertyName + "' id='" + checkPropertyName + needVaild + "' type=\"checkbox\" value='" + check.Value + "'" + checkedStr + checkAttributeStr + " ></input>" + " "; resultStr += checkModel.Text; } resultStr += "</label>"; if (index % colOrRows == 0) { resultStr += directionAppend; } index = index + 1; } if (resultStr == "<div >") { resultStr += "<label " + itemAttributeStr + " style=\"display:none\"><input" + validAttribute + " name='" + checkPropertyName + "' id='" + checkPropertyName + needVaild + "' type=\"checkbox\" value='1' " + checkAttributeStr + " style=\"visibility:hidden\"></input></label>"; } resultStr += "</div>"; MvcHtmlString result = new MvcHtmlString(resultStr); return(result); }
public static async Task <PaginationModel <TView> > GetMixData <TView>( string mixDatabaseName, string culture = null, string keyword = null, string fieldName = null, string filterType = "contain", // or "equal" int?pageIndex = 0, int pageSize = 100, string orderBy = "Priority", DisplayDirection direction = DisplayDirection.Asc, MixCmsContext _context = null, IDbContextTransaction _transaction = null) where TView : ViewModelBase <MixCmsContext, MixDatabaseData, TView> { culture ??= MixService.GetAppSetting <string>(MixAppSettingKeywords.DefaultCulture); UnitOfWorkHelper <MixCmsContext> .InitTransaction(_context, _transaction, out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot); try { var getfields = await ViewModels.MixDatabaseColumns.ReadViewModel.Repository.GetModelListByAsync( m => m.MixDatabaseName == mixDatabaseName, context, transaction); var fields = getfields.IsSucceed ? getfields.Data : new List <ViewModels.MixDatabaseColumns.ReadViewModel>(); // Data predicate Expression <Func <MixDatabaseData, bool> > predicate = m => m.Specificulture == culture && (m.MixDatabaseName == mixDatabaseName); // val predicate Expression <Func <MixDatabaseDataValue, bool> > attrPredicate = m => m.Specificulture == culture && (m.MixDatabaseName == mixDatabaseName); // if filter by field name or keyword => filter by attr value if (!string.IsNullOrEmpty(keyword)) { // filter by all fields if have keyword Expression <Func <MixDatabaseDataValue, bool> > pre = null; if (!string.IsNullOrEmpty(fieldName)) // filter by specific field name { pre = m => m.MixDatabaseColumnName == fieldName; pre = pre.AndAlsoIf(filterType == "equal", m => m.StringValue == keyword); pre = pre.AndAlsoIf(filterType == "contain", m => EF.Functions.Like(m.StringValue, $"%{keyword}%")); attrPredicate = attrPredicate.AndAlsoIf(pre != null, pre); } else { foreach (var field in fields) { Expression <Func <MixDatabaseDataValue, bool> > keywordPredicate = m => m.MixDatabaseColumnName == field.Name; keywordPredicate = keywordPredicate.AndAlsoIf(filterType == "equal", m => m.StringValue == keyword); keywordPredicate = keywordPredicate.AndAlsoIf(filterType == "contain", m => EF.Functions.Like(m.StringValue, $"%{keyword}%")); pre = pre == null ? keywordPredicate : pre.Or(keywordPredicate); } attrPredicate = attrPredicate.AndAlsoIf(pre != null, pre); } var valDataIds = context.MixDatabaseDataValue.Where(attrPredicate).Select(m => m.DataId).Distinct(); predicate = predicate.AndAlsoIf(valDataIds != null, m => valDataIds.Any(id => m.Id == id)); } else { predicate = m => m.Specificulture == culture && (m.MixDatabaseName == mixDatabaseName); predicate = predicate.AndAlso(m => m.Status == MixContentStatus.Published); } var getData = await DefaultRepository <MixCmsContext, MixDatabaseData, TView> .Instance.GetModelListByAsync( predicate, orderBy, direction, pageSize, pageIndex, null, null, context, transaction); return(getData.Data); } catch (Exception ex) { Console.WriteLine(ex); return(null); } finally { if (isRoot) { //if current Context is Root UnitOfWorkHelper <MixCmsContext> .CloseDbContext(ref context, ref transaction); } } }
public BonusOverlay(BonusAction action) { bonusEntryDirection = DisplayDirection.Enter; bonusEntryPosAdjustment = Vector2.Zero; bonusEntryTimeIn = AssaultWingCore.Instance.DataEngine.ArenaTotalTime; bonusActionData = action; }