/// <summary> /// Change view of the tile /// </summary> /// <param name="newState"></param> public void SetAppearance(TileViewState newState) { //if (newState == currentState) // return; hexagonPath.BeginAnimation(OpacityProperty, null); switch(newState) { case TileViewState.Idle: hexagonPath.Opacity = 1; break; case TileViewState.Selected: bgPath.Fill = new SolidColorBrush(Color.FromRgb(222,222,222)); hexagonPath.Opacity = 0.6; break; case TileViewState.MoveReachable: bgPath.Fill = new SolidColorBrush(Color.FromRgb(100,255,100)); hexagonPath.Opacity = 0.7; break; case TileViewState.MoveReachableFavorite: bgPath.Fill = new SolidColorBrush(Color.FromRgb(100, 255, 120)); DoubleAnimation daM = new DoubleAnimation(); daM.From = 0.9; daM.To = 0.5; daM.Duration = new Duration(TimeSpan.FromSeconds(1)); daM.AutoReverse = true; daM.RepeatBehavior = RepeatBehavior.Forever; hexagonPath.BeginAnimation(OpacityProperty, daM); break; case TileViewState.AttackReachable: bgPath.Fill = new SolidColorBrush(Color.FromRgb(255,64,32)); hexagonPath.Opacity = 0.6; break; case TileViewState.AttackReachableFavorite: bgPath.Fill = new SolidColorBrush(Color.FromRgb(255, 64, 32)); DoubleAnimation daA = new DoubleAnimation(); daA.From = 0.8; daA.To = 0.4; daA.Duration = new Duration(TimeSpan.FromSeconds(1)); daA.AutoReverse = true; daA.RepeatBehavior = RepeatBehavior.Forever; hexagonPath.BeginAnimation(OpacityProperty, daA); break; case TileViewState.Unreachable: bgPath.Fill = new SolidColorBrush(Color.FromRgb(0,0,0)); hexagonPath.Opacity = 0.6; break; default: throw new NotImplementedException(); } currentState = newState; }
public void RenderTiles() { int x = 0; int y = 6; var doc = document.createDocumentFragment(); var div = new Control(); div.Width = "100%"; div.SetLocation(0, 0); div.Style.zIndex = "10"; var div2 = new Control("primary"); div2.Width = "100%"; div2.Style.minHeight = "100%"; div2.SetLocation(0, 0); div2.Style.filter = "brightness(50%)"; div2.Style.opacity = "0.9"; div2.Style.zIndex = "9"; foreach (var page in RibbonPages) { if (!string.IsNullOrWhiteSpace(page.Caption)) { var llb = Control.Label(page.Caption, 6, y); llb.style.fontSize = "14px"; llb.style.color = "white"; doc.appendChild(llb); y += 26; } foreach (var group in page.RibbonGroups) { foreach (var item in group.Items) { if (item is RibbonButton) { var button = (RibbonButton)item; item.ExchangeClass("ribbonbuttonsmall", "ribbonbutton"); item.Style.borderRadius = "4px"; button.AfterItemClick = (ev) => { ViewState = TileViewState.Hidden; }; if (item.Enabled) { item.ExchangeClass("primary", "primary"); item.Style.border = "0"; item.Style.filter = "brightness(110%)"; } else { item.ExchangeClass("primary", ""); item.Style.border = "1px"; item.Style.filter = ""; } item.Style.opacity = "1"; item.Style.boxShadow = "0px 0px 10px -2px rgba(0,0,0,0.25)"; button.IsSmallItem = false; item.ProcessCaption(); button.ProcessImage(); item.Size = new Vector2("((100% - 24px) * 0.33)", 100); item.Location = new Vector2("(((100% - 24px) * (" + (x * 0.33m) + ")) + (" + (6 * (x)) + "px) + 6px)", y); if (item.captionDiv != null) { if (item.Enabled) { item.captionDiv.style.color = "white"; } else { item.captionDiv.style.color = "grey"; } item.captionDiv.style.fontSize = "14px"; item.captionDiv.style.top = "65px"; } if (button.imageDiv != null) { button.imageDiv.ExchangeClass("ribbonbuttonsmallicon", "ribbonbuttonicon"); button.IconURL = (button.IconURL + "").Replace("x16x16", "x32x32"); button.imageDiv.style.top = "27px"; if (item.Enabled) { // button.imageDiv.Style.filter = "brightness(90%) grayscale(100%) contrast(60%) brightness(180%)"; } else { // button.imageDiv.Style.filter = ""; } } if (x == 2) { x = 0; y += 106; } else { x++; } item.Style.opacity = "1"; doc.appendChild((Node)item); } } } if (x != 0) { x = 0; y += 106; } } div.Height = y; div2.Height = y; Content.Empty(); div.Content.appendChild(doc); div2.Content.onmousedown = (ev) => { ev.stopPropagation(); }; Content.appendChild((Node)div2); Content.appendChild((Node)div); div.Content.click(); }
/// <summary> /// Init position of the tile /// </summary> private void OnTileLoaded(object sender, RoutedEventArgs e) { // Set position (hexagon disposition) TranslateTransform trTns = new TranslateTransform(Tile.X * 60 + ((Tile.Y % 2 == 0) ? 0 : 30), Tile.Y * 50); TransformGroup trGrp = new TransformGroup(); trGrp.Children.Add(trTns); grid.RenderTransform = trGrp; currentState = TileViewState.Idle; SetGround(); }