public RDTInkTextureAtlasViewModel(inkTextureAtlas atlas, CBitmapTexture xbm, RedDocumentViewModel file) : base(xbm, file) { _atlas = atlas; Header = "Part Mapping"; Width = xbm.Width; Height = xbm.Height; Bitmap sourceBitmap; using (var outStream = new MemoryStream()) { BitmapEncoder enc = new TiffBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create((BitmapSource)Image)); enc.Save(outStream); sourceBitmap = new Bitmap(outStream); } var destBitmap = new Bitmap((int)Math.Round(Width), (int)Math.Round(Height), System.Drawing.Imaging.PixelFormat.Format64bppArgb); using (var gfx = Graphics.FromImage(destBitmap)) { // this is doesn't account for premultipied alpha, so the opacity mask is still needed var matrix = new ColorMatrix(new float[][] { new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, new float[] { 0, 0, 0, 0, 0 }, }); //matrix.Matrix03 = 1F; //matrix.Matrix13 = TintColor.Alpha / 3F; //matrix.Matrix23 = TintColor.Alpha / 3F; //matrix.Matrix40 = TintColor.R / 255F; //matrix.Matrix41 = TintColor.G / 255F; //matrix.Matrix42 = TintColor.B / 255F; var attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); gfx.DrawImage(sourceBitmap, new Rectangle(0, 0, (int)Width, (int)Height), 0, 0, Width, Height, GraphicsUnit.Pixel, attributes); } sourceBitmap.Dispose(); Image = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( destBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); foreach (var part in atlas.Slots[0].Parts) { OverlayItems.Add(new InkTextureAtlasMapperViewModel(part, xbm, atlas.Slots[0].Texture.DepotPath.ToString(), file.RelativePath, (BitmapSource)Image)); } }
public void _Paint(OverlayItems Item) { ushort ID = GetID(); Position.Add(ID); GameManager.Instance.GManager.GRef.ItemOverlay.Remove((OverlayItems)Item); if (Item.ItemType == OverlayItems.Type.Item) { PaintItem(Item, ID); } // else // Dunno yet }
public void Add(OverlayItems item) { string PathValue = ""; item.Position = GetId(); OverlayItems.SimpleItem Item = item.Item; item._Legendary = new UniqueItem { ItemName = "Unknown", LegendaryItemType = (UniqueItemType)Item.SNOItem.ItemType }; PathValue = item.Legendary.LegendaryItemType.ToString(); if (Item.ItemQuality == Controller.Enums.ItemQuality.Legendary) { if (UniqueItemsController.TryGet(Item.SNOItem.ActorName.ToLower()) != null) { item._Legendary = UniqueItemsController.TryGet(Item.SNOItem.ActorName.ToLower()); PathValue = item.Legendary.LegendaryItemType.ToString(); if (item.Legendary.LegendaryItemType == UniqueItemType.PlanLegendary_Smith) { PathValue = "PlanLegendary_Smith"; } } } else // Magic, Rare, White { item._Legendary.ItemName = ItemsTypesConversion.TryGet(((LegendaryItemsTypes)Item.SNOItem.ItemType).ToString()); if (item._Legendary.LegendaryItemType.ToString().Contains("Generic")) { PathValue = item.Legendary.ItemName; } } string Path = UniqueItemsController.GetBaseItemName(Item.SNOItem.ActorName.ToLower()); string ItemNamePath = string.IsNullOrWhiteSpace(item._Legendary.Override) ? Path : Path + "_" + item._Legendary.Override; string ItemNamePather = (item._Legendary.LegendaryItemType == UniqueItemType.PlanLegendary_Smith) ? "SmithPlan" : ItemNamePath; item.PathType = Extensions.ItemImage(PathValue + "/" + ItemNamePather); Extensions.Execute.UIThread(() => itemsToAdd.Add(item)); }
public void PaintItem(OverlayItems Items, ushort ID) { OverlayItems.SimpleItem Item = Items.Item; Brush Color = TextColors.TryGet(Item.ItemQuality.ToString()); UniqueItem Legendary = new UniqueItem { ItemName = "Unknown", LegendaryItemType = (UniqueItemType)Item.SNOItem.ItemType }; string PathType = Legendary.LegendaryItemType.ToString(); if (Item.ItemQuality == Controller.Enums.ItemQuality.Legendary) { if (Item.SNOItem.SetItem) { Color = TextColors.TryGet("Set"); } if (UniqueItemsController.TryGet(Item.SNOItem.ActorName.ToLower()) != null) { Legendary = UniqueItemsController.TryGet(Item.SNOItem.ActorName.ToLower()); PathType = Legendary.LegendaryItemType.ToString(); if (Legendary.LegendaryItemType == UniqueItemType.PlanLegendary_Smith) { PathType = "PlanLegendary_Smith"; } } } else // Magic, Rare, White { Legendary.ItemName = ItemsTypesConversion.TryGet(((LegendaryItemsTypes)Item.SNOItem.ItemType).ToString()); if (Legendary.LegendaryItemType.ToString().Contains("Generic")) { PathType = Legendary.ItemName; } } Extensions.Execute.UIThread(() => { Canvas xContainer = new Canvas { Width = 370 }; Grid Container = new Grid { Width = 370 }; Border Border = new Border { Height = 64, BorderBrush = Transition.BorderBrush, BorderThickness = new Thickness(2), Opacity = 0.7 }; Grid NameContainerGrid = new Grid { Height = 90, VerticalAlignment = VerticalAlignment.Center }; StackPanel NameContainer = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; StackPanel ItemContainer = new StackPanel { Height = 90, Orientation = Orientation.Horizontal }; Canvas Background = new Canvas { Background = BackgroundGradient, Opacity = 1, Height = 59, Margin = new Thickness(1, 0, 0, 0) }; StackPanel Image = new StackPanel { Width = 85 }; StackPanel Name = new StackPanel(); TextBlock ItemName = new TextBlock { FontFamily = Transition.FontFamily, VerticalAlignment = VerticalAlignment.Center, FontWeight = FontWeights.Normal, Text = Legendary.ItemName, Height = 25, FontSize = 18, Foreground = Color }; StackPanel Ancient = new StackPanel { Width = 4, Height = 60, Background = Brushes.Orange, Opacity = 0.5 }; string Path = UniqueItemsController.GetBaseItemName(Item.SNOItem.ActorName.ToLower()); string ItemNamePath = string.IsNullOrWhiteSpace(Legendary.Override) ? Path : Path + "_" + Legendary.Override; string ItemNamePather = (Legendary.LegendaryItemType == UniqueItemType.PlanLegendary_Smith) ? "SmithPlan" : ItemNamePath; Image.Children.Add(new Image { Source = Extensions.ItemImage(PathType + "/" + ItemNamePather), Width = 75, Height = 90 }); NameContainer.Children.Add(ItemName); if (Items.Account != null) { TextBlock ItemNames = new TextBlock { FontFamily = Transition.FontFamily, VerticalAlignment = VerticalAlignment.Center, FontWeight = FontWeights.Normal, Text = Items.Account.Nickname, Height = 20, FontSize = 12.1, Foreground = Items.Account.Foreground }; NameContainer.Children.Add(ItemNames); } NameContainerGrid.Children.Add(NameContainer); Name.Children.Add(NameContainerGrid); if (Item.ShowAncient && Item.AncientItem) { Border.BorderBrush = Color; Ancient.Height = 64; } ItemContainer.Children.Add(Image); ItemContainer.Children.Add(Name); Border.Child = Background; Container.Children.Add(Border); Container.Children.Add(ItemContainer); xContainer.Children.Add(Container); Elements.Children.Add(xContainer); xContainer.AnimateFade <Canvas>(0, 1, TimeSpan.FromSeconds(1)); Active.Add(xContainer); Canvas.SetTop(xContainer, ID * 90); DeleteTimer(xContainer, Items.Transition, ID); }); }
public System.Windows.DependencyObject GetObject(OverlayItems item) { var i = ((ItemOverlay)Control).FControls.ItemContainerGenerator.ContainerFromItem(item); return(Extensions.FindVisualChildren <StackPanel>(i).FirstOrDefault()); }