public void SomeMethod() { ImageEx img = new ImageEx(@"C:\1.jpg"); Debug.WriteLine("Loaded file: {0}", img.Filename); Debug.WriteLine("Dimensions: {0}x{1}", img.Image.Width, img.Image.Height); }
private void Image_ImageExFailed(object sender, Microsoft.Toolkit.Uwp.UI.Controls.ImageExFailedEventArgs e) { ImageEx img = sender as ImageEx; string fallbackImage = "ms-appx:///Assets/StoreLogo.png"; img.Source = fallbackImage; }
private void AddImage(bool broken, bool placeholder, bool round = false) { ImageEx newImage = new ImageEx(); newImage.Style = resources["BaseStyle"] as Style; if (round) { newImage.CornerRadius = new CornerRadius(999); } newImage.Source = broken ? photos[imageIndex].Thumbnail + "broken" : photos[imageIndex].Thumbnail; if (placeholder) { newImage.PlaceholderSource = new BitmapImage(new Uri("ms-appx:///Assets/Photos/ImageExPlaceholder.jpg")); } container?.Children?.Add(newImage); // Move to next image imageIndex++; if (imageIndex >= photos.Count) { imageIndex = 0; } }
public async Task SetSourceToUri(string uri) { await App.DispatcherQueue.EnqueueAsync(async() => { var imageLoader = new ImageEx(); await SetTestContentAsync(imageLoader); Assert.AreEqual("Unloaded", GetCurrentState(imageLoader)); var imageOpendedCallCount = 0; imageLoader.ImageExOpened += (s, e) => { imageOpendedCallCount++; Assert.AreEqual("Loaded", GetCurrentState(imageLoader)); }; imageLoader.Source = new Uri(uri); // TODO (2021.05.11): Test in a more deterministic way. // Setting source causes some async code to trigger and // we have no way to await or handle its complementation regardless of the result. await Task.Delay(1000); Assert.AreEqual(1, imageOpendedCallCount, "{0} should only be called once", nameof(ImageEx.ImageExOpened)); }); }
private void AddImage(bool broken, bool placeholder) { var newImage = new ImageEx { IsCacheEnabled = true, Stretch = Stretch.UniformToFill, Source = broken ? photos[imageIndex].Thumbnail + "broken" : photos[imageIndex].Thumbnail, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, MaxWidth = 300, Background = new SolidColorBrush(Colors.Transparent), Foreground = new SolidColorBrush(Colors.White) }; if (placeholder) { newImage.PlaceholderSource = new BitmapImage(new Uri("ms-appx:///Assets/Photos/ImageExPlaceholder.jpg")); newImage.PlaceholderStretch = Stretch.UniformToFill; } Container.Children.Add(newImage); // Move to next image imageIndex++; if (imageIndex >= photos.Count) { imageIndex = 0; } }
public static GameObject CreateButton(Resources resources) { GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize); GameObject childText = new GameObject("Text"); childText.AddComponent <RectTransform>(); SetParentAndAlign(childText, buttonRoot); ImageEx image = buttonRoot.AddComponent <ImageEx>(); image.sprite = resources.standard; image.type = ImageEx.Type.Sliced; image.color = s_DefaultSelectableColor; ButtonEx bt = buttonRoot.AddComponent <ButtonEx>(); SetDefaultColorTransitionValues(bt); TextEx text = childText.AddComponent <TextEx>(); text.text = "Button"; text.alignment = TextAnchor.MiddleCenter; SetDefaultTextValues(text); RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; return(buttonRoot); }
public async Task SetSourceToOpenedBitmapImage() { await App.DispatcherQueue.EnqueueAsync(async() => { var bitmapImage = new BitmapImage(); using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"UnitTests.UWP.Assets.StoreLogo.embeded.png"); using var memStream = new MemoryStream(); await stream.CopyToAsync(memStream); memStream.Seek(0, SeekOrigin.Begin); await bitmapImage.SetSourceAsync(memStream.AsRandomAccessStream()); var imageLoader = new ImageEx(); await SetTestContentAsync(imageLoader); Assert.AreEqual("Unloaded", GetCurrentState(imageLoader)); var imageOpendedCallCount = 0; imageLoader.ImageExOpened += (s, e) => { imageOpendedCallCount++; Assert.AreEqual("Loaded", GetCurrentState(imageLoader)); }; imageLoader.Source = bitmapImage; Assert.AreEqual(1, imageOpendedCallCount, "{0} should only be called once", nameof(ImageEx.ImageExOpened)); }); }
void ValidatePassword(EntryEx targetEntry, ImageEx targetImage) { var pass = targetEntry.Text; if (string.IsNullOrEmpty(pass)) { _passModel.Reset(); } else { _passModel.Validate(pass); } targetImage.IsVisible = _passModel.AllCriteriaMet; if (EntryPasswordNew.IsFocused) { GridPassConditions.IsVisible = !_passModel.AllCriteriaMet; } if (InputValidator.IsValidPassword(EntryPasswordCurrent.Text) && InputValidator.IsValidPassword(EntryPasswordNew.Text)) { _model.NotReadyToSave = false; } }
/// <summary> /// This method returns the Chips /// </summary> private static List <ImageEx> AddChips(List <ImageEx> chips, ChipEnum chip, ref double amount) { // local int chipValue = 0; // If the chips object exists if ((NullHelper.Exists(chips)) && (chip != ChipEnum.Unknown) && (amount > 0)) { // get the chipValue chipValue = (int)chip; // if the amount is greater than this chip if (amount >= chipValue) { do { // Create the image based upo the chip type Image chipPic = new Bitmap(GetChipImage(chip), new Size(24, 24)); // Cast the chipImage as an ImageEx ImageEx chipImage = new ImageEx(chipPic); // Ad this image chips.Add(chipImage); // subtract the value of htis chip from amount amount -= chipValue; } while (amount >= chipValue); } } // return value return(chips); }
private async void ImageExDraw_Loaded(object sender, RoutedEventArgs e) { await RunOnUIThreadAsync(CoreDispatcherPriority.High, () => { ImageEx image = (ImageEx)sender; Grid grid = (Grid)image.Parent; ScrollViewer scrollViewer = (ScrollViewer)grid.Parent; image.MinWidth = scrollViewer.ViewportWidth; image.MaxWidth = scrollViewer.ViewportWidth; image.MinHeight = scrollViewer.ViewportHeight; image.MaxHeight = scrollViewer.ViewportHeight; scrollViewer.SizeChanged += async(x, y) => { await RunOnUIThreadAsync(CoreDispatcherPriority.High, () => { image.MinWidth = scrollViewer.ViewportWidth; image.MaxWidth = scrollViewer.ViewportWidth; image.MinHeight = scrollViewer.ViewportHeight; image.MaxHeight = scrollViewer.ViewportHeight; }); }; }); }
void CreateEmoji() { int count = m_emjDataLst.Count; int min = Mathf.Min(count, m_emjImgLst.Count); for (int i = 0; i < min; i++) { m_emjImgLst[i].gameObject.SetActive(true); m_emjImgLst[i].SetEmojiName(m_emjDataLst[i].emj); } while (m_emjImgLst.Count < count) { GameObject obj = new GameObject("emoji"); obj.transform.SetParent(transform); obj.transform.localScale = Vector3.one; ImageEx img = obj.AddComponent <ImageEx>(); img.raycastTarget = false; img.rectTransform.anchorMin = Vector2.up; img.rectTransform.anchorMax = Vector2.up; img.rectTransform.pivot = Vector2.up * 0.16f; img.rectTransform.sizeDelta = Vector2.one * fontSize; img.SetEmojiName(m_emjDataLst[m_emjImgLst.Count].emj); m_emjImgLst.Add(img); obj.SetActive(true); obj.hideFlags = HideFlags.DontSaveInEditor; } }
public Fill(ImageEx image) { Check.NotNull(image, nameof(image)); Picture = image; Type = FillType.Picture; }
private void imageView1_OnItemClick(object sender, DevExpress.XtraEditors.TileItemEventArgs e) { try { if (e.Item == null) { return; } TileImageInfo imageInfo = e.Item.Tag as TileImageInfo; if (imageInfo == null) { return; } if (imageInfo.MediaType != "图像") { MessageBox.Show("音视频不能进行处理。", "提示"); return; } _selectImageID = imageInfo.MediaId; imageProcessControl1.LoadBackImage(ImageEx.LoadFile(imageInfo.File) as Bitmap); } catch (Exception ex) { MsgBox.ShowException(ex, this); } }
internal static IXImage GetCommandIcon(this CommandItemInfo info, IIconsProvider[] iconsProviders) { IXImage icon = null; try { var provider = iconsProviders.FirstOrDefault(p => p.Matches(info.IconPath)); if (provider != null) { icon = provider.GetIcon(info.IconPath); } } catch { } if (icon == null) { if (info is CommandMacroInfo) { icon = new ImageEx(ImageIcon.ImageToByteArray(Resources.macro_icon_default), Resources.macro_vector); } else if (info is CommandGroupInfo) { icon = new ImageEx(ImageIcon.ImageToByteArray(Resources.group_icon_default), Resources.macros_vector); } } return(icon); }
private void LoadBGImage() { { PreImage_AlphaCover = Properties.Resources.IMG_AlphaCover; } { if (File.Exists("Data/bg.jpg")) { Image image = Image.FromFile("Data/bg.jpg"); Image cloneImage = new Bitmap(image); image.Dispose(); PreImage_BG = (Bitmap)cloneImage; } else { PreImage_BG = Properties.Resources.IMG_BG; } //PreImage_BG = ImageZoom.GetThumbnail(PreImage_BG, PreImage_BG.Height * 1920 / PreImage_BG.Width, 1920); PreImage_BG = ImageEx.SmallPic(PreImage_BG, 1920); { //Bitmap b = new Bitmap(Width, Height); //Graphics g = Graphics.FromImage(); } //PreImage_BG.Save("0.jpg"); Color_PrimaryColor = ColorHelper.GetPrimaryColor(PreImage_BG); Color_SecondColor = ImageEx.ChangeColor(Color_PrimaryColor, -0.75f); PreImage_AlphaCover = (Bitmap)ImageEx.SetImageColorAllWithoutAlpha(PreImage_AlphaCover, Color.Black, Color_SecondColor, 255); //PreImage_AlphaCover.Save("2.png"); PreImage_BG = ImageEx.JoinMImage(PreImage_BG, PreImage_AlphaCover, new Rectangle(0, 0, PreImage_AlphaCover.Width, PreImage_AlphaCover.Height)); //BackgroundImage = PreImage_BG; } { Graphics g; PreImage_Header = new Bitmap(PreImage_BG.Width, Header_Height); g = Graphics.FromImage(PreImage_Header); Rectangle srcRect = new Rectangle(0, 0, PreImage_Header.Width, PreImage_Header.Height); GraphicsUnit units = GraphicsUnit.Pixel; g.DrawImage(PreImage_BG, 0, 0, srcRect, units); g.Save(); g.Dispose(); PreImage_Header = ImageEx.BrightnessP(PreImage_Header, -10); PreImage_Header = GB.ProcessImage(PreImage_Header); //PreImage_Header.Save("1.jpg"); //Bitmap b = new Bitmap(PictureBox_Header.Width, PictureBox_Header.Height); //g = Graphics.FromImage(b); //Pen p = new Pen(Color_PrimaryColor); //g.DrawImage(PreImage_Header, new Rectangle(0, 0, PictureBox_Header.Width, PictureBox_Header.Height), // new Rectangle((PreImage_Header.Width - Width) / 2, 0, Width, Height), GraphicsUnit.Pixel); ////Pen p = new Pen(Color.Red); //g.DrawLine(p, new Point(0, 0), new Point(b.Width, 0)); //g.DrawLine(p, new Point(b.Width - 1, 0), new Point(b.Width - 1, b.Height - 1)); //g.DrawLine(p, new Point(b.Width - 1, b.Height - 1), new Point(0, b.Height - 1)); //g.DrawLine(p, new Point(0, b.Height), new Point(0, 0)); //g.Save(); //g.Dispose(); } ControlNeedRefresh = true; }
private void FrameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (FrameComboBox.SelectedItem != null) { var index = int.Parse(FrameComboBox.SelectedItem.ToString()); ImageEx.GotoFrame(index); } }
public static void setBackgroundImage(ImageEx imgControl) { BackgroundImageTemplate img = BackgroundImageCache.selectedImage; if (img is null || img.imagePath is null) { imgControl.Source = null; imgControl.Visibility = Visibility.Collapsed; }
private void ParseInlineUIContainer(MessagePack msgPack, InlineUIContainer inlineUIContainer) { ImageEx child = inlineUIContainer.Child as ImageEx; if (child != null) { this.ParseImage(msgPack, child); } }
public static GameObject CreateToggle(Resources resources) { // Set up hierarchy GameObject toggleRoot = CreateUIElementRoot("Toggle", s_ThinElementSize); GameObject background = CreateUIObject("Background", toggleRoot); GameObject checkmark = CreateUIObject("Checkmark", background); GameObject childLabel = CreateUIObject("Label", toggleRoot); // Set up components Toggle toggle = toggleRoot.AddComponent <Toggle>(); toggle.isOn = true; ImageEx bgImage = background.AddComponent <ImageEx>(); bgImage.sprite = resources.standard; bgImage.type = ImageEx.Type.Sliced; bgImage.color = s_DefaultSelectableColor; ImageEx checkmarkImage = checkmark.AddComponent <ImageEx>(); checkmarkImage.sprite = resources.checkmark; TextEx label = childLabel.AddComponent <TextEx>(); label.text = "Toggle"; SetDefaultTextValues(label); toggle.graphic = checkmarkImage; toggle.targetGraphic = bgImage; SetDefaultColorTransitionValues(toggle); RectTransform bgRect = background.GetComponent <RectTransform>(); bgRect.anchorMin = new Vector2(0f, 1f); bgRect.anchorMax = new Vector2(0f, 1f); bgRect.anchoredPosition = new Vector2(10f, -10f); bgRect.sizeDelta = new Vector2(kThinHeight, kThinHeight); RectTransform checkmarkRect = checkmark.GetComponent <RectTransform>(); checkmarkRect.anchorMin = new Vector2(0.5f, 0.5f); checkmarkRect.anchorMax = new Vector2(0.5f, 0.5f); checkmarkRect.anchoredPosition = Vector2.zero; checkmarkRect.sizeDelta = new Vector2(20f, 20f); RectTransform labelRect = childLabel.GetComponent <RectTransform>(); labelRect.anchorMin = new Vector2(0f, 0f); labelRect.anchorMax = new Vector2(1f, 1f); labelRect.offsetMin = new Vector2(23f, 1f); labelRect.offsetMax = new Vector2(-5f, -2f); return(toggleRoot); }
/// <summary> /// <inheritdoc cref="IImageExFactory.TryFromXmlShape"/> /// </summary> public ImageEx TryFromXmlShape(SlidePart xmlSldPart, OpenXmlCompositeElement ce) { Check.NotNull(xmlSldPart, nameof(xmlSldPart)); Check.NotNull(ce, nameof(ce)); var shape = (P.Shape)ce; var aBlipFill = shape.ShapeProperties.GetFirstChild <A.BlipFill>(); ImageEx backgroundImage = TryFromBlipFill(xmlSldPart, aBlipFill); return(backgroundImage); }
//不在运行中时,Handle的类型或者m_go改变的时候会刷新值 public override void OnReset(Handle h, bool resetBegin = true, bool resetEnd = false) { if (h.m_go) { ImageEx s = h.m_go.GetComponent <ImageEx>(); if (s) { h.m_b1 = s.m_grey; } } }
public static GameObject CreateInputField(Resources resources) { GameObject root = CreateUIElementRoot("InputField", s_ThickElementSize); GameObject childPlaceholder = CreateUIObject("Placeholder", root); GameObject childText = CreateUIObject("Text", root); ImageEx image = root.AddComponent <ImageEx>(); image.sprite = resources.inputField; image.type = ImageEx.Type.Sliced; image.color = s_DefaultSelectableColor; InputField inputField = root.AddComponent <InputField>(); SetDefaultColorTransitionValues(inputField); TextEx text = childText.AddComponent <TextEx>(); text.text = ""; text.supportRichText = false; SetDefaultTextValues(text); TextEx placeholder = childPlaceholder.AddComponent <TextEx>(); placeholder.text = "Enter text..."; placeholder.fontStyle = FontStyle.Italic; // Make placeholder color half as opaque as normal text color. Color placeholderColor = text.color; placeholderColor.a *= 0.5f; placeholder.color = placeholderColor; RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; textRectTransform.offsetMin = new Vector2(10, 6); textRectTransform.offsetMax = new Vector2(-10, -7); RectTransform placeholderRectTransform = childPlaceholder.GetComponent <RectTransform>(); placeholderRectTransform.anchorMin = Vector2.zero; placeholderRectTransform.anchorMax = Vector2.one; placeholderRectTransform.sizeDelta = Vector2.zero; placeholderRectTransform.offsetMin = new Vector2(10, 6); placeholderRectTransform.offsetMax = new Vector2(-10, -7); inputField.textComponent = text; inputField.placeholder = placeholder; return(root); }
private static ImageEx TryFromBlipFill(SlidePart sldPart, A.BlipFill aBlipFill) { ImageEx backgroundImage = null; var blipRelateId = aBlipFill?.Blip?.Embed?.Value; // try to get blip relationship ID if (blipRelateId != null) { backgroundImage = new ImageEx(sldPart, blipRelateId); } return(backgroundImage); }
public static List <ImageEx> LoadBitmaps(List <string> files, int maxSize) { List <ImageEx> images = new List <ImageEx>(); foreach (var file in files) { ImageEx img = new ImageEx(); img.Path = file; try { img.Image = new MagickImage(file); if (img.Image.Width < maxSize && img.Image.Height < maxSize) { if (img.Image.ColorType == ColorType.Palette) { images.Add(img); } else { Console.WriteLine($"Skip: {img.Path} Reason: Not 8 bpp"); } } else { Console.WriteLine($"Skip: {img.Path} Reason: File too big {img.Image.Width}x{img.Image.Height}"); } } catch (Exception e) { Console.WriteLine($"Error: {file} Reason: {e.Message}"); } //if (images.Count > 10) // break; } images.Sort((ImageEx a, ImageEx b) => { if (a.Image.Width * a.Image.Height > b.Image.Width * b.Image.Height) { return(-1); } else { return(1); } }); return(images); }
private void SaveAsImage(ImageFormat outputFormat, Stream stream, int width, int height) { byte[] numArray = new byte[width * height * GraphicsExtensions.Size(this.Format)]; this.GetData <byte>(numArray); using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) { BitmapData bitmapdata = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, bitmap.PixelFormat); Marshal.Copy(numArray, 0, bitmapdata.Scan0, numArray.Length); bitmap.UnlockBits(bitmapdata); ImageEx.RGBToBGR((Image)bitmap); bitmap.Save(stream, outputFormat); } }
// 查找并设置给Image(包括Sprite和材质) public void SetToImage(ImageEx image, string name) { Sprite data = GetSpriteData(name); if (data != null) { SetImage(image, this, data); } else { image.sprite = null; image.material = null; } }
public override void OnEnd(Handle h) { if (h.m_go == null) { return; } ImageEx s = h.m_go.GetComponent <ImageEx>(); if (s == null) { return; } s.SetGrey(h.m_b1); }
public void UpdateTileImage(TileItem tileItem, string imgFile) { if (tileItem == null) { tileItem = SelItem; } if (tileItem == null) { return; } tileItem.Image = ImageEx.LoadFile(imgFile); }
public static void setBackgroundImage(ImageEx imgControl) { BackgroundImageTemplate img = BackgroundImageCache.selectedImage; if (img == null || img.imagePath == null) { imgControl.Source = null; imgControl.Visibility = Visibility.Collapsed; } else { imgControl.Source = new BitmapImage(new Uri(img.imagePath)); imgControl.Visibility = Visibility.Visible; } }
private void ParseImage(MessagePack msgPack, ImageEx image) { EmoticonItem tag = image.Tag as EmoticonItem; if (tag.IsSysEmoticon) { SysFaceElement element = (SysFaceElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_SYSFACE); element.Index = Convert.ToByte(tag.Id); } else { ImageElement element2 = (ImageElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_IMAGE); element2.Path = "OSRoot:" + tag.Fileorg; } }
public static void ParseImage(MessagePack msgPack, ImageEx image) { EmoticonItem tag = image.Tag as EmoticonItem; if (tag.IsSysEmoticon) { SysFaceElement element = (SysFaceElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_SYSFACE); element.Index = Convert.ToByte(tag.Id); } else { ImageElement element2 = (ImageElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_IMAGE); element2.Path = "OSRoot:" + tag.Fileorg; ImageElementNum++; } }
private void InsertImage(ImageEx image) { base.Selection.Text = ""; TextPointer insertionPosition = base.CaretPosition.GetInsertionPosition(LogicalDirection.Forward); InlineUIContainer container = new InlineUIContainer(image, insertionPosition); insertionPosition = insertionPosition.GetNextContextPosition(LogicalDirection.Forward); base.CaretPosition = container.ElementEnd; }
public void AddMsgToOutputBox(IMMessage imMessage, string senderName, AddMsgToOutputBoxCallBackHandler callBack) { this.CheckMsgPiece(); InputBox box = this; MessagePack messagePack = imMessage.MessagePack; if (messagePack != null) { if (messagePack.NeedShowHeader && (imMessage.Sender == null)) { messagePack.NeedShowHeader = false; } if (messagePack.NeedShowHeader && string.IsNullOrEmpty(senderName)) { senderName = imMessage.SenderName; if (string.IsNullOrEmpty(senderName)) { senderName = imMessage.Sender.NickName; } } uint elemCount = messagePack.GetElemCount(); Section newItem = new Section(); Block lastBlock = box.Document.Blocks.LastBlock; if ((lastBlock != null) && (string.Compare(lastBlock.Tag as string, "LastTag") != 0)) { lastBlock = null; } if (lastBlock == null) { Paragraph paragraph = new Paragraph { Tag = "LastTag", Margin = new Thickness(0.0) }; lastBlock = paragraph; box.Document.Blocks.Add(lastBlock); } if (messagePack.NeedShowHeader) { if ((imMessage.Sender != null) && (imMessage.Sender.Uin == Util_Buddy.GetCurrentBuddy().Uin)) { newItem.Tag = "me"; } else { newItem.Tag = "other"; } } else { newItem.Tag = "info"; } box.Document.Blocks.InsertBefore(lastBlock, newItem); Paragraph item = new Paragraph(); if (messagePack.NeedShowHeader) { string str; Paragraph paragraph3 = new Paragraph { Foreground = new SolidColorBrush((imMessage.Sender.Uin == Util_Buddy.GetCurrentBuddy().Uin) ? this._selfColor : this._oppColor) }; if (this.IsMsgRecord) { str = senderName + " " + imMessage.DateTime.ToLocalTime().ToString(); } else { str = senderName + " " + imMessage.DateTime.ToLocalTime().ToLongTimeString(); item.Margin = new Thickness(13.0, 0.0, 0.0, 0.0); } paragraph3.Inlines.Add(str); newItem.Blocks.Add(paragraph3); } SetDateTime(newItem, imMessage.DateTime); Paragraph paragraph4 = new Paragraph { Margin = new Thickness(13.0, 0.0, 0.0, 0.0) }; string fontName = messagePack.Header.FontName; if ((string.IsNullOrEmpty(fontName) || (fontName == "宋体")) || (((fontName == "新宋体") || (fontName == "仿宋")) || (fontName == "黑体"))) { fontName = "Microsoft YaHei"; } if (messagePack.Header.FontSize == 0) { messagePack.Header.FontSize = 9; } item.FontFamily = new FontFamily(fontName); item.FontSize = messagePack.Header.FontSize + 3; item.Foreground = new SolidColorBrush(messagePack.Header.FontColor); paragraph4.FontFamily = new FontFamily(messagePack.Header.FontName); paragraph4.FontSize = messagePack.Header.FontSize + 3; paragraph4.Foreground = new SolidColorBrush(messagePack.Header.FontColor); Dictionary<string, bool> imagelist = new Dictionary<string, bool>(); Paragraph paragraph5 = item; bool flag = false; for (uint i = 0; i < elemCount; i++) { ImageElement element4; string path; ImageEx ex2; MessageElement elem = messagePack.GetElem(i); switch (elem.Category) { case MsgPackCat.ELEMTYPE_TEXT: { Guid guid; Guid guid2; TextElement element2 = (TextElement)elem; string text = element2.GetText(); if (!flag && element2.NeedIndent) { Span lastInline = item.Inlines.LastInline as Span; if (lastInline != null) { Run run = lastInline.Inlines.LastInline as Run; if (run != null) { run.Text = run.Text.Replace("\r", "").Replace("\n", ""); } } paragraph5 = paragraph4; } string url = element2.GetUrl(out guid, out guid2); Span span2 = new Span(); Span span3 = span2; paragraph5.Inlines.Add(span3); if ((messagePack.Header.FontEffect & 2) != 0) { span2.FontStyle = FontStyles.Italic; } if ((messagePack.Header.FontEffect & 1) != 0) { span2.FontWeight = FontWeights.Bold; } if (string.IsNullOrEmpty(url)) { if ((messagePack.Header.FontEffect & 4) != 0) { Underline underline = new Underline(); span2.Inlines.Add(underline); span2 = underline; } span2.Inlines.Add(text); } else { ImageHyperlink hyperlink = new ImageHyperlink { Guid = guid, SoureUrl = url }; span2.Inlines.Add(hyperlink); span2 = hyperlink; hyperlink.AddText(text); this.OnImageHyperLinkAdd(imMessage, hyperlink); } continue; } case MsgPackCat.ELEMTYPE_SYSFACE: { SysFaceElement element = (SysFaceElement)elem; ImageEx uiElement = ReplaceControls.CreateImageExWithId(element.FileName, element.Index.ToString()); uiElement.Width = element.FaceWidth; uiElement.Height = element.FaceHeight; paragraph5.Inlines.Add(uiElement); if (callBack != null) { callBack(imMessage, element); } continue; } case MsgPackCat.ELEMTYPE_IMAGE: case MsgPackCat.ELEMTYPE_OFFLINEPIC: element4 = (ImageElement)elem; path = element4.Path; if (string.IsNullOrEmpty(path)) { continue; } ex2 = new ImageEx { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.None, SnapsToDevicePixels = true, Tag = element4 }; path = path.ToLower(); if (!CheckFileExists(imagelist, path)) { break; } ex2.Source = path; goto Label_0710; case MsgPackCat.ELEMTYPE_FILE: { FileElement element5 = (FileElement)elem; string str7 = Helper_Icon.MakeSysIconFileByFileName(element5.Path); string fileSize = element5.GetFileSize(); string fileName = element5.GetFileName(); if (!string.IsNullOrEmpty(str7)) { ImageEx ex3 = new ImageEx { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.Uniform, SnapsToDevicePixels = true, Width = 32.0, Height = 32.0 }; if (!string.IsNullOrEmpty(element5.Tip)) { ex3.ToolTip = element5.Tip; } ex3.Source = str7; StackPanel panel = new StackPanel { Margin = new Thickness(0.0, 2.0, 0.0, 2.0), Orientation = Orientation.Horizontal }; panel.Children.Add(ex3); TextBlock block2 = new TextBlock(new Run(fileName + "\n" + fileSize)) { Margin = new Thickness(0.0, 4.0, 0.0, 0.0) }; panel.Children.Add(block2); paragraph5.Inlines.Add(panel); } continue; } default: goto Label_087B; } if (this.IsMsgRecord) { ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "errorBmp.gif"; } else if (MsgPackCat.ELEMTYPE_IMAGE == elem.Category) { TXLog.TXLogImage(string.Concat(new object[] { "收到图片文件需要下载:", element4.Id, " ", path })); ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "sendingBmp.gif"; this.AddToImagesDownloadingList(element4.Id, ex2); } else if (MsgPackCat.ELEMTYPE_OFFLINEPIC == elem.Category) { TXLog.TXLogImage(string.Concat(new object[] { "收到离线图片文件需要下载:", element4.Id, " ", path })); ex2.IsEnabledClick = true; ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "OfflinepicManualGet.png"; ex2.ToolTip = "点击获取图片"; ex2.Cursor = Cursors.Hand; } Label_0710: paragraph5.Inlines.Add(ex2); continue; Label_087B: TXLog.TXLog3("Msg", "AIO 未处理的消息类型, "); } if (item.Inlines.Count > 0) { newItem.Blocks.Add(item); } if (paragraph4.Inlines.Count > 0) { newItem.Blocks.Add(paragraph4); } box.ScrollToEnd(); } }
private static void DisabledImageClickStyle(ImageEx image) { image.IsEnabledClick = false; image.ToolTip = null; image.Cursor = null; if (image.Tag is ImageElement) { image.Tag = null; } }
private void AddToImagesDownloadingList(Guid guid, ImageEx image) { if (this.imagesDownloading.ContainsKey(guid)) { this.imagesDownloading[guid].Add(image); } else { List<ImageEx> list2 = new List<ImageEx> { image }; this.imagesDownloading.Add(guid, list2); } }
protected override void SetScreenshot(ImageEx img, HtmlNode node) { img.Source = GetImageSrc(node); }
public static ImageEx CreateImageEx(string file, EmoticonItem item) { ImageEx ex = new ImageEx(); if (item == null) { ex.Tag = EmoticonItem.CreateImageItem(file, null); } else { ex.Tag = item; } ex.Source = file; ex.HorizontalAlignment = HorizontalAlignment.Left; ex.VerticalAlignment = VerticalAlignment.Top; ex.Stretch = Stretch.None; return ex; }
protected override void SetScreenshot(ImageEx img, HtmlNode node) { img.Source = GetEmbebedImage("AppStudio.Uwp.Controls.HtmlBlock.channel9-screen.png"); img.Background = new SolidColorBrush(Color.FromArgb(255, 249, 203, 66)); }
private static Viewbox GetImageControl(Action<ImageEx> setSource) { var viewbox = new Viewbox { StretchDirection = StretchDirection.DownOnly }; var image = new ImageEx { Stretch = Stretch.Uniform, Background = new SolidColorBrush(Colors.Transparent), Foreground = new SolidColorBrush(Colors.Transparent) }; setSource(image); viewbox.Child = image; return viewbox; }
protected abstract void SetScreenshot(ImageEx img, HtmlNode node);
public void InsertImage(string path) { if (!this.isInsertedImage) { if (this.icon == null) { this.icon = new ImageEx(); this.icon.Width = this.Width; this.icon.Height = this.Height; this.icon.Stretch = Stretch.Fill; this.icon.IsCache = true; SetEnableCopy(this.icon, false); } if (this.container == null) { this.container = new InlineUIContainer(); this.container.Child = this.icon; } base.Inlines.InsertBefore(this.hyperlink, this.container); this.isInsertedImage = true; } this.icon.Source = path; }