static void ListTest() { SingleLinkedList <ImageNode> imageList = new SingleLinkedList <ImageNode>(); imageList = new SingleLinkedList <ImageNode>(); for (int i = 0; i < 20; i++) { var name = "bild-" + i + ".png"; ImageNode n = new ImageNode(); n.Data = name; imageList.AddLast(n); } Console.WriteLine(imageList); var addFirst = new ImageNode("addFirst.png"); var addAfter = new ImageNode("AddAfter.png"); var addBefore = new ImageNode("AddBefore.png"); imageList.AddFirst(addFirst); imageList.AddAfter(addFirst, addAfter); imageList.AddBefore(addFirst, addBefore); Console.WriteLine(imageList); imageList.Remove(addFirst); Console.WriteLine(imageList); imageList.Remove(addAfter); Console.WriteLine(imageList); imageList.Remove(addBefore); Console.WriteLine(imageList); // }
public void ResultNode() { RtfTree tree = new RtfTree(); tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf"); RtfTreeNode node = tree.MainGroup.SelectSingleNode("object").ParentNode; ObjectNode objNode = new ObjectNode(node); RtfTreeNode resNode = objNode.ResultNode; Assert.That(resNode, Is.SameAs(tree.MainGroup.SelectSingleGroup("object").SelectSingleChildGroup("result"))); RtfTreeNode pictNode = resNode.SelectSingleNode("pict").ParentNode; ImageNode imgNode = new ImageNode(pictNode); Assert.That(imgNode.Height, Is.EqualTo(2247)); Assert.That(imgNode.Width, Is.EqualTo(9320)); Assert.That(imgNode.DesiredHeight, Is.EqualTo(1274)); Assert.That(imgNode.DesiredWidth, Is.EqualTo(5284)); Assert.That(imgNode.ScaleX, Is.EqualTo(100)); Assert.That(imgNode.ScaleY, Is.EqualTo(100)); Assert.That(imgNode.ImageFormat, Is.EqualTo(ImageFormat.Emf)); }
public void putBitmap(string url, Editor editor) { CanvasBitmap image = loadBitmap(url, editor); var imageBytes = image.GetPixelBytes().Length; // Too big for cache if (imageBytes > _maxBytes) { // Use fallback (cache it to avoid reloading it each time for size check) image = createFallbackBitmap(); imageBytes = 4; } // Remove LRUs if max size reached while (_curBytes + imageBytes > _maxBytes) { string lruKey = _lru.Last.Value; ImageNode lruNode = _cache[lruKey]; _curBytes -= lruNode.Cost; _cache.Remove(lruKey); _lru.RemoveLast(); } // Add to cache _cache.Add(url, new ImageNode(image, imageBytes)); _curBytes += imageBytes; _lru.AddFirst(url); }
public static Node Build() { Node root = new Node(); root.Size = new Size(300, 300); ImageNode m_child = new ImageNode(); m_child.Res = ResourceManager.Instance.ComposeDefaultResURL("4880yuanbao.png"); m_child.Position = new Point(50, 50); m_child.Size = new Size(50, 50); root.Attach(m_child); ImageNode m_child2 = new ImageNode(); m_child2.Res = ResourceManager.Instance.ComposeDefaultResURL("+.png"); m_child2.Position = new Point(150, 50); m_child2.Size = new Size(50, 50); root.Attach(m_child2); TextNode m_child3 = new TextNode(); m_child3.Text = "hello world"; m_child3.TextColor = Color.Purple; m_child3.Position = new Point(50, 120); m_child3.Size = new Size(100, 30); root.Attach(m_child3); return(root); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); sceneView.Session.Run(new ARWorldTrackingConfiguration { AutoFocusEnabled = true, LightEstimationEnabled = true, PlaneDetection = ARPlaneDetection.Horizontal, WorldAlignment = ARWorldAlignment.Gravity }, ARSessionRunOptions.ResetTracking | ARSessionRunOptions.RemoveExistingAnchors); ImageNode imageNode = new ImageNode("Xamagon.png", size, size); imageNode.Position = new SCNVector3(0, 0, zPosition / 2); sceneView.Scene.RootNode.AddChildNode(imageNode); UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer(HandleTapGesture); sceneView.AddGestureRecognizer(tapGestureRecognizer); UIPinchGestureRecognizer pinchGestureRecognizer = new UIPinchGestureRecognizer(HandlePinchGesture); sceneView.AddGestureRecognizer(pinchGestureRecognizer); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleMode"/> class. /// </summary> public SvgSquaresMode() { // Create a list of gem images. SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>(); RootSceneNode = nodes; // Load the image into memory. svgLoader = new SvgLoader(new FileInfo("Images/1cm.svg")); float screenScale = Platform.Instance.Window.Resolution.Height / 16f; svgLoader.Scale = screenScale * SvgImageLoader.Meter100px; TextureLoader textureLoader = new TextureLoader(svgLoader); // Create squares across the board. rows = (int) (440 / screenScale); columns = (int) (600 / (2 * screenScale)); for (int i = 0; i < columns; i++) { for (int j = 0; j < rows; j++) { ImageNode<float> image = new ImageNode<float>(textureLoader); image.Point = new Point2<float>((j % 2) * screenScale + i * 2 * screenScale, j * screenScale); if (i % 4 == 0) image.Tint = new Color<float>(1, 1, 0, 0); if (j % 4 == 0) image.Tint = new Color<float>(1, 0, 1, 0); nodes.Add(image); } } }
public override void Render(Node node, Context context) { ImageNode image = node as ImageNode; ImageSurface surfaceCache = image.Data as ImageSurface; if (surfaceCache == null) { surfaceCache = new ImageSurface(image.File); } int x = (int)((image.Width - surfaceCache.Width) * image.XAlign); int y = (int)((image.Height - surfaceCache.Height) * image.YAlign); context.SetSourceSurface(surfaceCache, x, y); double opacity = image.Opacity; if (opacity == 1) { context.Paint(); } else { context.PaintWithAlpha(image.Opacity); } }
public ImagesView(Rect rect, ImageNode image) : base(rect) { if (_slider == null) { _slider = (Texture2D)Resources.Load("slide_arrow"); } var k = ResizeHelper.k; _image = image; _selectedImage = 0; _textures = new Texture2D[_image.Images.Length]; _rects = new Rect[_image.Images.Length]; for (int i = 0; i < _image.Images.Length; i++) { var path = _image.Images[i].Path.StartsWith("/") ? _image.Images[i].Path : System.IO.Path.Combine(Application.persistentDataPath, _image.Images[i].Path); _textures[i] = new Texture2D(1, 1, TextureFormat.RGB565, false); _textures[i].LoadImage(System.IO.File.ReadAllBytes(path)); _rects[i] = GetImageRect(new Vector2(_image.Images[i].Width, _image.Images[i].Height)); } _leftSliderUV = new Rect(1, 0, -1, 1); _rightSliderUV = new Rect(0, 0, 1, 1); LeftSlider = new Rect(_innerRect.x, _innerRect.y, 40f * k, _innerRect.height); RightSlider = new Rect(_innerRect.xMax - 40f * k, _innerRect.y, 40f * k, _innerRect.height); }
protected virtual Rectangle DrawNode(ImageNode node, bool isRightChild, int depth, Rectangle parentBounds) { int x, y; if (node == null) { return(new Rectangle()); } int offset = (isRightChild) ? node.LeftTreeWidth + NodeWidth + DX : -node.RightTreeWidth - NodeWidth - DX; x = parentBounds.X + offset; y = depth * (DY + NodeWidth) - HalfNodeWidth; Rectangle bounds = new Rectangle(x, y, NodeWidth, NodeWidth); _graphics.DrawEllipse(Pens.Red, bounds); DrawNodeText(node, bounds); if (node.Left != null) { Rectangle leftBounds = DrawNode(node.Left, false, depth + 1, bounds); _graphics.DrawLine(MainPen, leftBounds.X + HalfNodeWidth, leftBounds.Y, bounds.X + HalfNodeWidth, bounds.Y + NodeWidth); } if (node.Right != null) { Rectangle rightBounds = DrawNode(node.Right, true, depth + 1, bounds); _graphics.DrawLine(MainPen, rightBounds.X + HalfNodeWidth, rightBounds.Y, bounds.X + HalfNodeWidth, bounds.Y + NodeWidth); } return(bounds); }
private EquationObj Wmf2Equation(ImageNode imageNode) { EquationObj equationObj = new EquationObj(); ConvertEquation ce = new ConvertEquation(); EquationInput ei = new EquationInputFileWMF(imageNode.GetByteData()); string strEquation = ce.ConvertToText(ei); Regex regex = new Regex(@"<([^>]+)>(.*?)</\1>"); var v = regex.Match(strEquation); string latexString = v.Groups[2].ToString(); if (latexString.Length > 0) { equationObj.attr("latex", latexString); } string gifBase64Code = ""; Image gifbit = ce.ConvertToGif(ei); if (gifbit != null) { gifBase64Code = ImageToBase64(gifbit, ImageFormat.Gif); equationObj.content = gifBase64Code; equationObj.attr("width", gifbit.Width); equationObj.attr("height", gifbit.Height); } return(equationObj); }
public void putBitmap(string url, string mimeType) { BitmapSource image = loadBitmap(url, mimeType); int imageBytes = (int)((image.Format.BitsPerPixel * image.PixelWidth * image.PixelHeight) / 8.0); // Too big for cache if (imageBytes > _maxBytes) { // Use fallback (cache it to avoid reloading it each time for size check) image = createFallbackBitmap(); imageBytes = 4; } // Remove LRUs if max size reached while (_curBytes + imageBytes > _maxBytes) { string lruKey = _lru.Last.Value; ImageNode lruNode = _cache[lruKey]; _curBytes -= lruNode.Cost; _cache.Remove(lruKey); _lru.RemoveLast(); } // Add to cache _cache.Add(url, new ImageNode(image, imageBytes)); _curBytes += imageBytes; _lru.AddFirst(url); }
private static void ExtractImages() { RtfTree tree = new RtfTree(); tree.LoadRtfFile("..\\..\\testdocs\\test-doc.rtf"); RtfNodeCollection imageNodes = tree.RootNode.SelectNodes("pict"); Console.WriteLine("Extracting images..."); int i = 1; foreach (RtfTreeNode node in imageNodes) { ImageNode imageNode = new ImageNode(node.ParentNode); if (imageNode.ImageFormat == ImageFormat.Png) { imageNode.SaveImage("..\\..\\testdocs\\image" + i + ".png"); Console.WriteLine("File '" + "image" + i + ".png" + "' created."); i++; } } Console.WriteLine(""); }
private static ImageNode getImageNode(Ricetta r, Image g, ToolTip t) { ImageNode node = nodeFactory.createImageNode(((a, b) => new RicettaVisualizzation(r.idRicetta).ShowDialog()), g); RicettarioGestorDataContext db = RicettarioDB.getInstance(); String caratteristiche = ""; (from rs in db.RicettaStrumento join def in db.Definito on rs.idRicettaStrum equals def.idRicettaStrum where rs.idRicetta == r.idRicetta && def.idRicetta == r.idRicetta select def.Caratteristica).Distinct().ToList().ForEach(x => caratteristiche = caratteristiche + " " + x.Nome); double kcal = 0; int count = 0; (from rs in db.RicettaStrumento where rs.idRicetta == r.idRicetta select rs.Kcal).ToList().ForEach(x => { kcal += x; count++; }); if (count > 0) { kcal = kcal / count; } t.SetToolTip(node.getImage(), "Nome " + r.Nome + "\nPortata " + r.portata + "\nCaratteristiche :" + caratteristiche + "\nKcal = " + kcal + "\nPersone = " + r.Persone); return(node); }
protected void Page_Load(object sender, EventArgs e) { ImageNode node = new ImageNode(); node.Name = "Image1"; node.Source = "../Content/diagram/drilldown/image2.png"; Dictionary <string, object> addinfo = new Dictionary <string, object>(); addinfo.Add("toolvalue", "Click on node to drill down"); node.AddInfo = addinfo; DiagramWebControl1.Model.Nodes.Add(node); DiagramWebControl1.Model.Layout.Type = LayoutTypes.HierarchicalTree; DiagramWebControl1.Model.Layout.Margin = new Margin() { Top = 60 }; DiagramWebControl1.Model.Layout.VerticalSpacing = 60; TextNode text = new TextNode(); text.Name = "textNode"; text.Width = 200; text.Height = 60; text.Constraints = NodeConstraints.None; text.OffsetX = 310; text.OffsetY = 30; text.ExcludeFromLayout = true; text.TextBlock.Text = "Coevals Diagram"; text.TextBlock.FontColor = "blue"; text.TextBlock.FontSize = 20; text.TextBlock.FontFamily = "Segoe UI"; DiagramWebControl1.Model.Nodes.Add(text); DiagramWebControl1.Model.DefaultSettings.Node = new ImageNode() { Width = 50, Height = 50, BorderColor = "transparent", Labels = new Collection() { new Label() { ReadOnly = true } } }; DiagramWebControl1.Model.DefaultSettings.Connector = new Connector() { Segments = new Collection() { new Segment() { Type = Segments.Orthogonal } } }; DiagramWebControl1.OnClientClick = "click"; DiagramWebControl1.Model.SelectedItems.Constraints = SelectorConstraints.None; DiagramWebControl1.OnClientDoubleClick = "doubleclick"; }
private void button6_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); //Se establecen las propiedades del cuadro de diálogo "Abrir" openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "Archivos RTF (*.rtf)|*.rtf|Todos los archivos (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; //Se muestra el cuadro de diálogo Abrir y se espera a que se seleccione un fichero RTF. if (openFileDialog1.ShowDialog() == DialogResult.OK) { //Se crea un árbol RTF RtfTree arbol = new RtfTree(); //Se carga el documento seleccionado (Este método parsea el documento y crea la estructura de árbol interna) arbol.LoadRtfFile(openFileDialog1.FileName); //Busca el primer nodo de tipo objeto. RtfTreeNode node = arbol.RootNode.SelectSingleNode("object"); //Se crea un nodo RTF especializado en imágenes ObjectNode objectNode = new ObjectNode(node.ParentNode); //Se escriben al cuadro de texto superior algunos datos del objeto txtArbol.Text += "Object type: " + objectNode.ObjectType + "\r\n"; txtArbol.Text += "Object class: " + objectNode.ObjectClass + "\r\n"; //Se extrae la imagen insertada como representación del objeto //Se obtiene el nodo "\result" del objeto (representación externa del objeto en el documento RTF) RtfTreeNode resultNode = objectNode.ResultNode; RtfTreeNode auxNode = null; //Si existe un nodo imagen en el grupo "\result" la extraemos a un fichero y mostramos algunas características en //el cuadro de texto superior de la ventana. if ((auxNode = resultNode.SelectSingleNode("pict")) != null) { //Creamos el nodo especializado de tipo Imagen ImageNode imageNode = new ImageNode(auxNode.ParentNode); //Mostramos algunas características de la imagen txtArbol.Text += "Image width: " + imageNode.Width / 20 + "\r\n"; txtArbol.Text += "Image heigh: " + imageNode.Height / 20 + "\r\n"; txtArbol.Text += "Image format: " + imageNode.ImageFormat + "\r\n"; //Se guarda la imagen a fichero MessageBox.Show("Se va a crear el fichero: image-example3." + getExtension(imageNode.ImageFormat)); imageNode.SaveImage("image-example3." + getExtension(imageNode.ImageFormat)); } else { MessageBox.Show("El grupo '\result' del objeto no contiene imágenes!"); } } }
public void InitImagePos(GameObject image, ImageNode node) { Transform rT = image.GetComponent <Transform>(); rT.localPosition = new Vector3(node.beginPos.x, node.beginPos.y, rT.localPosition.z); rT.localEulerAngles = new Vector3(0, 0, node.beginRot); rT.localScale = new Vector3(node.beginScale.x, node.beginScale.y, rT.localScale.z);; }
public ImageStack(IEnumerable<string> files) { foreach (string file in files) { var image = new ImageNode (file); image.IsOpaque = true; Add (image); } UpdatePreferedSize (); }
// Sets the active tile to be used on the grid private void SetSelectedTileImage(ImageNode node) { if (node == null) return; ImageBrush brush = new ImageBrush { ImageSource = node.Image.Source }; _selectedTile = node; _selectedTile.Image = node.Image; SelectedTileGrid.Background = brush; _selectedTile.CollisionMap = node.CollisionMap; }
void ReCreateImageNodes() { for (int i = 0; i < currentArraySize; ++i) { Object.Destroy(imageNodes[i].go); } imageNodes = null; if (frameCount > 0) { imageNodes = new ImageNode[frameCount]; currentArraySize = frameCount; } if (null == imageNodes) { return; } const string ROOTNODENAME = "__imagenodes"; Transform roottrans = transform.Find(ROOTNODENAME); if (roottrans) { Object.Destroy(roottrans.gameObject); } GameObject rootgo = new GameObject(ROOTNODENAME); roottrans = rootgo.transform; roottrans.parent = this.transform; roottrans.transform.localPosition = skinnedMeshRenderer.transform.localPosition; roottrans.transform.localRotation = skinnedMeshRenderer.transform.localRotation; for (int i = 0; i < currentArraySize; ++i) { ImageNode node = new ImageNode(); imageNodes[i] = node; node.go = new GameObject(i.ToString()); node.go.transform.parent = roottrans; node.go.transform.localPosition = Vector3.zero; node.go.transform.localRotation = Quaternion.Euler(Vector3.zero); node.mesh = new Mesh(); node.meshFilter = node.go.AddComponent <MeshFilter>(); node.meshFilter.mesh = node.mesh; node.meshRenderer = node.go.AddComponent <MeshRenderer>(); node.meshRenderer.sharedMaterials = skinnedMeshRenderer.sharedMaterials; Material[] mats = node.meshRenderer.materials; for (int j = 0; j < mats.Length; ++j) { mats[j].shader = transparentShader; } node.tick = -i - 1; node.go.SetActive(false); } }
public ImageNodeView(Context context, ImageNode image) : base(context, image) { this.image = image; this.view = new ImageView (context); var bitmap = Resources.GetBitmap(image.File); view.SetImageBitmap (bitmap); AddView (view); bitmap.Dispose (); }
public void Image_Node_Releases_Reference_To_Bitmap_On_Dispose() { var bitmap = RefCountable.Create(Mock.Of <IBitmapImpl>()); var imageNode = new ImageNode(Matrix.Identity, bitmap, 1, new Rect(1, 1, 1, 1), new Rect(1, 1, 1, 1)); Assert.Equal(2, bitmap.RefCount); imageNode.Dispose(); Assert.Equal(1, bitmap.RefCount); }
public ImageStack(IEnumerable <string> files) { foreach (string file in files) { var image = new ImageNode(file); image.IsOpaque = true; Add(image); } UpdatePreferedSize(); }
public static ImageNode Read(BinaryReader br) { ImageNode ret = new ImageNode(); ret.PartListId = br.ReadUInt32(); ret.PartId = br.ReadUInt32(); ret.FlipH = br.ReadBoolean(); ret.FlipV = br.ReadBoolean(); ret.Wrap = br.ReadByte(); ret.Unk1 = br.ReadByte(); return(ret); }
public ImageNodeView(Context context, ImageNode image) : base(context, image) { this.image = image; this.view = new ImageView(context); var bitmap = Resources.GetBitmap(image.File); view.SetImageBitmap(bitmap); AddView(view); bitmap.Dispose(); }
IEnumerator CrossFade(ImageNode node, Image image) { image.color = new Color(image.color.r, image.color.g, image.color.b, 0f); float timer = Time.time; while (Time.time - timer < node.crossfadeDuration) { float ratio = (Time.time - timer) / node.crossfadeDuration; image.color = new Color(image.color.r, image.color.g, image.color.b, ratio); yield return(null); } }
protected virtual void DrawNodeText(ImageNode node, Rectangle nodeBounds) { StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Center; RectangleF typeBounds = new RectangleF(nodeBounds.X - 50, nodeBounds.Y + HalfNodeWidth - TextFont.GetHeight(), 100 + NodeWidth, TextFont.GetHeight()); _graphics.DrawString(node.Node.Info.ToString(), TextFont, TextBrush, typeBounds, strFormat); //RectangleF valueBounds = new RectangleF(nodeBounds.X - 50, nodeBounds.Y + NodeWidth - ValueFont.GetHeight(), 100 + NodeWidth, ValueFont.GetHeight()); //_graphics.DrawString(node.Node.Info.ToString(), ValueFont, ValueBrush, valueBounds, strFormat); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleMode"/> class. /// </summary> public GemsMode() { // Create a list of gem images. SceneNodeLinkedList <float> nodes = new SceneNodeLinkedList <float>(); RootSceneNode = nodes; // Create the blue gem. BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/Gem Blue.png")); TextureLoader textureLoader = new TextureLoader(systemLoader); ImageNode <float> image = new ImageNode <float>(textureLoader); image.Point = new Point2 <float>(10, 10); image.DrawableRenderAnimators.Add( new DisappearingFlickerDrawableAnimation <float>()); image.DrawableRenderAnimators.Add( new UnsteadyFlickerDrawableAnimation <float>() { OpacityScale = 0.2, TimeScale = 1, }); Updating += image.OnUpdate; nodes.Add(image); // Create the green gem. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Green.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode <float>(textureLoader); image.Point = new Point2 <float>(60, 90); nodes.Add(image); // Create the translucent orange. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Orange.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode <float>(textureLoader); image.Tint = new Color <float>(0.5f, 1f, 1f, 1f); image.Point = new Point2 <float>(110, 10); nodes.Add(image); // Create an animated image. AnimatedImageNodeController <float> animatedController = new AnimatedImageNodeController <float>(); animatedController.NeedImageKey += OnLoadImageKey; animatedController.Load(new FileInfo("Images/Gem Animation.xml")); AnimatedImageNode <float> animatedImage = new AnimatedImageNode <float>(animatedController); animatedImage.Point = new Point2 <float>(10, 200); Updating += animatedImage.OnUpdate; nodes.Add(animatedImage); }
public override void LayoutOutline(Node node, Context context) { ImageNode image = node as ImageNode; ImageSurface surfaceCache = image.Data as ImageSurface; if (surfaceCache == null) { // will improve with CGLayer surfaces surfaceCache = new ImageSurface(image.File); } context.Rectangle(0, 0, image.Width, image.Height); }
private void CreateNode(double offsetx, double offsety, double angle, string src) { ImageNode node = new ImageNode(); node.Name = "node" + DiagramWebControl1.Model.Nodes.Count.ToString(); node.Width = 102; node.Height = 142; node.OffsetX = offsetx + 51; node.OffsetY = offsety + 71; node.BorderColor = "none"; node.RotateAngle = angle; node.Source = src; DiagramWebControl1.Model.Nodes.Add(node); }
private void CreateNode(Collection nodes, double offsetx, double offsety, double angle, string src) { ImageNode node = new ImageNode(); node.Name = "node" + nodes.Count.ToString(); node.Width = 102; node.Height = 142; node.OffsetX = offsetx - 51; node.OffsetY = offsety - 71; node.BorderColor = "none"; node.RotateAngle = angle; node.Source = src; nodes.Add(node); }
public ImageNodeRenderer(ImageNode node) : base(node) { this.node = node; var imageView = new UIImageView (new UIImage (node.File)); imageView.Layer.ShouldRasterize = true; imageView.Opaque = node.IsOpaque; SetView (imageView); if (node.Hints.Shadow) { imageView.Layer.ShadowOpacity = 0.5f; imageView.Layer.ShadowOffset = new SizeF (0, 0); } }
public void ImageBinData() { RtfTree tree = new RtfTree(); tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf"); RtfTreeNode pictNode = tree.MainGroup.SelectNodes("pict")[2].ParentNode; ImageNode imgNode = new ImageNode(pictNode); imgNode.SaveImage("..\\..\\testdocs\\img-result.png", ImageFormat.Jpeg); Stream fs1 = new FileStream("..\\..\\testdocs\\img-result.jpg", FileMode.Open); Stream fs2 = new FileStream("..\\..\\testdocs\\image1.jpg", FileMode.Open); Assert.That(fs1, Is.EqualTo(fs2)); }
public ImageNodeRenderer(ImageNode node) : base(node) { this.node = node; var imageView = new UIImageView(new UIImage(node.File)); imageView.Layer.ShouldRasterize = true; imageView.Opaque = node.IsOpaque; SetView(imageView); if (node.Hints.Shadow) { imageView.Layer.ShadowOpacity = 0.5f; imageView.Layer.ShadowOffset = new SizeF(0, 0); } }
protected void copy(ImageNode nodeToCopy) { base.copy(nodeToCopy); imagePath = nodeToCopy.imagePath; beginPosX = nodeToCopy.beginPosX; beginPosY = nodeToCopy.beginPosY; beginRot = nodeToCopy.beginRot; beginScaleX = nodeToCopy.beginScaleX; beginScaleY = nodeToCopy.beginScaleY; crossfade = nodeToCopy.crossfade; }
public void DisplayImage(ImageNode node) { GameObject gO; gO = Instantiate(imagePrefab); gO.transform.SetParent(imageCanvas, false); gO.GetComponent <Image>().sprite = node.image; currentImages.Add(gO.GetComponent <Image>()); InitImagePos(gO, node); if (node.crossfade) { StartCoroutine(CrossFade(node, gO.GetComponent <Image> ())); } }
/// <summary> /// Initializes a new instance of the <see cref="RectangleMode"/> class. /// </summary> public GemsMode() { // Create a list of gem images. SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>(); RootSceneNode = nodes; // Create the blue gem. BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/Gem Blue.png")); TextureLoader textureLoader = new TextureLoader(systemLoader); ImageNode<float> image = new ImageNode<float>(textureLoader); image.Point = new Point2<float>(10, 10); image.DrawableRenderAnimators.Add( new DisappearingFlickerDrawableAnimation<float>()); image.DrawableRenderAnimators.Add( new UnsteadyFlickerDrawableAnimation<float>() { OpacityScale = 0.2, TimeScale = 1, }); Updating += image.OnUpdate; nodes.Add(image); // Create the green gem. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Green.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode<float>(textureLoader); image.Point = new Point2<float>(60, 90); nodes.Add(image); // Create the translucent orange. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Orange.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode<float>(textureLoader); image.Tint = new Color<float>(0.5f, 1f, 1f, 1f); image.Point = new Point2<float>(110, 10); nodes.Add(image); // Create an animated image. AnimatedImageNodeController<float> animatedController = new AnimatedImageNodeController<float>(); animatedController.NeedImageKey += OnLoadImageKey; animatedController.Load(new FileInfo("Images/Gem Animation.xml")); AnimatedImageNode<float> animatedImage = new AnimatedImageNode<float>(animatedController); animatedImage.Point = new Point2<float>(10, 200); Updating += animatedImage.OnUpdate; nodes.Add(animatedImage); }
public void ImageHexData() { RtfTree tree = new RtfTree(); tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf"); RtfTreeNode pictNode = tree.MainGroup.SelectNodes("pict")[2].ParentNode; ImageNode imgNode = new ImageNode(pictNode); StreamReader sr = null; sr = new StreamReader("..\\..\\testdocs\\imghexdata.txt"); string hexdata = sr.ReadToEnd(); sr.Close(); Assert.That(imgNode.HexData, Is.EqualTo(hexdata)); }
public void LoadImageNode() { RtfTree tree = new RtfTree(); tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf"); RtfTreeNode pictNode = tree.MainGroup.SelectNodes("pict")[2].ParentNode; ImageNode imgNode = new ImageNode(pictNode); Assert.That(imgNode.Height, Is.EqualTo(6615)); Assert.That(imgNode.Width, Is.EqualTo(7938)); Assert.That(imgNode.DesiredHeight, Is.EqualTo(3750)); Assert.That(imgNode.DesiredWidth, Is.EqualTo(4500)); Assert.That(imgNode.ScaleX, Is.EqualTo(100)); Assert.That(imgNode.ScaleY, Is.EqualTo(100)); Assert.That(imgNode.ImageFormat, Is.EqualTo(ImageFormat.Png)); }
private void LoadAvailableFieldsTree() { IDataSourceFieldSchema[] fieldSchemas = this.GetFieldSchemas(); if ((fieldSchemas != null) && (fieldSchemas.Length > 0)) { this._selectedDataSourceNode = new DataSourceNode(); this._availableFieldsTree.Nodes.Add(this._selectedDataSourceNode); this._selectedCheckBoxDataSourceNode = new BoolDataSourceNode(); this._availableFieldsTree.Nodes.Add(this._selectedCheckBoxDataSourceNode); } HyperLinkNode node = new HyperLinkNode(this); this._availableFieldsTree.Nodes.Add(node); ImageNode node2 = new ImageNode(this); this._availableFieldsTree.Nodes.Add(node2); ButtonNode node3 = new ButtonNode(this); this._availableFieldsTree.Nodes.Add(node3); CommandNode node4 = new CommandNode(this); this._availableFieldsTree.Nodes.Add(node4); CommandNode node5 = new CommandNode(this, 0, System.Design.SR.GetString("DCFEditor_Node_Edit"), 6); node4.Nodes.Add(node5); if (this.Control is GridView) { CommandNode node6 = new CommandNode(this, 2, System.Design.SR.GetString("DCFEditor_Node_Select"), 5); node4.Nodes.Add(node6); } CommandNode node7 = new CommandNode(this, 3, System.Design.SR.GetString("DCFEditor_Node_Delete"), 7); node4.Nodes.Add(node7); if (this.Control is DetailsView) { CommandNode node8 = new CommandNode(this, 1, System.Design.SR.GetString("DCFEditor_Node_Insert"), 11); node4.Nodes.Add(node8); } TemplateNode node9 = new TemplateNode(this); this._availableFieldsTree.Nodes.Add(node9); }
private void imageToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Image Files (*.png;*.jpg;*.bmp)|*.png;*.jpg;*.bmp|All Files(*.*)|*.*"; if (DialogResult.OK != dlg.ShowDialog()) return; ImageNode node = new ImageNode(); node.SetImage(new AnyCAD.Platform.Path(dlg.FileName)); node.SetWidth(100); node.SetHeight(200); renderView.ShowSceneNode(node); }
/// <summary> /// Función encargada de procesar los nodos hijo de un nodo padre RTF un nodo del documento RTF /// y generar las etiquetas HTML necesarias /// </summary> private void ProcessChildNodes(RtfNodeCollection nodos, int inicio) { for (int i = inicio; i < nodos.Count; i++) { RtfTreeNode nodo = nodos[i]; switch (nodo.NodeType) { case RtfNodeType.Control: if (nodo.NodeKey == "'") //Símbolos especiales, como tildes y "ñ" { WriteText(Encoding.Default.GetString(new[] { (byte)nodo.Parameter })); } break; case RtfNodeType.Keyword: switch (nodo.NodeKey) { case "pard": //Reinicio de formato _currentFormat.Reset(); break; case "f": //Tipo de fuente if (nodo.Parameter < _fontTable.Count) _currentFormat.FontName = _fontTable[nodo.Parameter]; break; case "cf": //Color de fuente if (nodo.Parameter < _colorTable.Count) _currentFormat.ForeColor = _colorTable[nodo.Parameter]; break; case "highlight": //Color de fondo if (nodo.Parameter < _colorTable.Count) _currentFormat.BackColor = _colorTable[nodo.Parameter]; break; case "fs": //Tamaño de fuente _currentFormat.FontSize = nodo.Parameter; break; case "b": //Negrita _currentFormat.Bold = !nodo.HasParameter || nodo.Parameter == 1; break; case "i": //Cursiva _currentFormat.Italic = !nodo.HasParameter || nodo.Parameter == 1; break; case "ul": //Subrayado ON _currentFormat.Underline = true; break; case "ulnone": //Subrayado OFF _currentFormat.Underline = false; break; case "super": //Superscript _currentFormat.Superscript = true; _currentFormat.Subscript = false; break; case "sub": //Subindice _currentFormat.Subscript = true; _currentFormat.Superscript = false; break; case "nosupersub": _currentFormat.Superscript = _currentFormat.Subscript = false; break; case "qc": //Alineacion centrada _currentFormat.Alignment = HorizontalAlignment.Center; break; case "qr": //Alineacion derecha _currentFormat.Alignment = HorizontalAlignment.Right; break; case "li": //tabulacion _currentFormat.Margin = nodo.Parameter; break; case "line": case "par": //Nueva línea _builder.Append("<br />"); break; } break; case RtfNodeType.Group: //Procesar nodos hijo, si los tiene if (nodo.HasChildNodes()) { if (nodo["pict"] != null) //El grupo es una imagen { ImageNode imageNode = new ImageNode(nodo); WriteImage(imageNode); } else { ProcessChildNodes(nodo.ChildNodes, 0); } } break; case RtfNodeType.Text: WriteText(nodo.NodeKey); break; default: throw new ArgumentOutOfRangeException(); } } }
/// <summary> /// Función encargada de añadir una imagen al código HTML resultado /// </summary> /// <param name="imageNode"></param> private void WriteImage(ImageNode imageNode) { Bitmap b = imageNode.Bitmap; Size imageSize; if (imageNode.DesiredHeight > 0 && imageNode.DesiredWidth > 0)//Aproximar twips a px dividiendo entre 15 imageSize = new Size(imageNode.DesiredWidth / 15, imageNode.DesiredHeight / 15); else imageSize = b.Size; //Buscar codec ImageCodecInfo imageCodec = null; foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders()) { if (imageCodec == null || codec.FormatID == ImageFormat.Guid) imageCodec = codec; } //Reducir imagen si el tamaño final es menor que el actual if (b.Size.Height > imageSize.Height || b.Size.Width > imageSize.Width) { Bitmap bmpResized = new Bitmap(imageSize.Width, imageSize.Height); Graphics g = Graphics.FromImage(bmpResized); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.DrawImage(b, 0, 0, imageSize.Width, imageSize.Height); b.Dispose(); b = bmpResized; } //Generar imagen en el formato adecuado string imageSrc; if (IncrustImages) { using (var buffer = new MemoryStream()) { b.Save(buffer, ImageFormat); imageSrc = string.Format("data:{0};base64,{1}", imageCodec.MimeType, System.Convert.ToBase64String(buffer.GetBuffer(), 0, (int)buffer.Length)); } } else { int index = 1; string ext = imageCodec.FilenameExtension.Split(';')[0].Substring(2).ToLower(); string path; do { path = Path.Combine(ImagePath, string.Format("Imagen{0}.{1}", index, ext)); index++; } while (File.Exists(path)); b.Save(path, ImageFormat); //imageSrc = "file://" + path; imageSrc = path; } //Añadir imagen al resultado HTML _builder.Append(string.Format("<img src=\"{0}\" style=\"width:{1}px;height:{2}px;\" />" , imageSrc, imageSize.Width, imageSize.Height)); //Limpiar memoria b.Dispose(); }