Wp7 clear canvas value - windows-phone-7

I am using canvas to add image programatically.
for example:
Image image1=new image1();
Image image2=new image1();
var left = new BitmapImage();
left.UriSource = new Uri("images/box.png", UriKind.Relative);
image1.Source = left;
image2.Source = left;
ContentPanelCanvas.Children.Add(image1);
ContentPanelCanvas.Children.Add(image2);
First time enter the loop Add Image to canvas. second time i want to clear canvas.
and again add different images same canvas.
Is this possible wp7.
tell some idea to do this.
thanks

Yes, it is possible:
ContentPanelCanvas.Children.Clear();
This will empty the canvas.

Why not simply change the Source property of the images you already added?

Related

How to use gif with UIImageView in Xamarin.iOS without using third party library?

I want to load gif image in UIImageView. I've try to use it wih FLAnimatedImage but it not worked. I have taken imageview in storyboard and added gif to resources.
If you want to load gif image with UIImageView, I find one article that you can take a look:
https://montemagno.com/animated-gif-uiimageview-in-xamarinios/
If you try to create the gif using individual images, it will be easier, as you can see here. When you convert the native code from here to C#, you get this
UIImageView gifView = new UIImageView();
gifView.AnimationImages = new UIImage[] {
UIImage.FromBundle("Image1.png"),
UIImage.FromBundle("Image2.png"),
UIImage.FromBundle("Image3.png"),
UIImage.FromBundle("Image4.png")
};
gifView.AnimationRepeatCount = 0; // Repeat forever.
gifView.AnimationDuration = 1.0; // Every 1s.
gifView.StartAnimating();
gifView.View.Frame = new CoreGraphics.CGRect(0, 20, this.View.Bounds.Size.Width, 180); // size of the animation
this.View.AddSubview(gifView);

How to use javafx to view cells that wraps horizontally and scrolls vertically

I'm trying to determine how, using javafx, to approach displaying cells (image thumbnails or images) similar to Windows Explorer where images are shown in rows that wrap at horizontal boundaries but scroll in the vertical direction.
Is a tableview the approach to use and then update the column number when the view is resized? A little help would be greatly appreciated. Better yet a simple example code.
I'm pretty new to this forum and I have searched but can't really get started on this.
Thanks
Wrapping a FlowPane inside a ScrollPane would be a much simpler approach to the problem.
Example:
This uses some rectangles with numbers instead of images, but I think it's enough to get an idea how to use the Layouts:
FlowPane contentContainer = new FlowPane();
contentContainer.setVgap(10);
contentContainer.setHgap(10);
ScrollPane scroll = new ScrollPane(contentContainer);
scroll.setFitToWidth(true);
// fill FlowPane with some content
ArrayList<Node> content = new ArrayList<>();
for (int i = 0; i < 15; i++) {
Text text = new Text(Integer.toString(i));
text.setFill(Color.YELLOW);
StackPane pane = new StackPane(text);
pane.setStyle("-fx-background-color: blue;");
pane.setPrefSize(50, 50);
content.add(pane);
}
contentContainer.getChildren().setAll(content);

How to place my logo on my map without white fields?

I have a problem with the my picturebox.
I want to place it on my map which i got in my program.
That works when i put my img in a Picturebox and then BringToFront();
i wanted to add a picture with the problem, but i just started at StackOverflow and doesnt have enough reputation yet... :(
Anyway my img got displayed but with the white fields around it. The img I use doenst have these white stuff around it.
How can i make my Picturebox transparent so that the white fields get removed.
LogoBox.Location = new Point(size.Width - 340, size.Height - 100);
LogoBox.Image = Properties.Resources.Troepoet;
LogoBox.Size = new System.Drawing.Size(250, 40);
LogoBox.SizeMode = PictureBoxSizeMode.StretchImage;
LogoBox.BackColor = Color.Transparent;
I tried to do it with only drawing a bitmap aswell but then i cant see any possibility to place it on the map. The map is a 'dominant' control.
Any help/suggestions?
Thx.
You don't need to put a picturebox on the map to draw your logo.
The easy way is to override the Map OnPainOverlays() and draw whatever you want (Logo, Text, any shape) on the map or another way if you don't want to inherit the GmapControl and work with the GMapControl by drag & drop it over a form to handle the Paint() Event:
Private Sub GMapControl1_Paint(sender As Object, e As PaintEventArgs) Handles GMapControl1.Paint
Dim logo As Image = image.FromFile("C:\transparentLogo.png")
e.Graphics.DrawImage(logo, GMapControl1.Width - logo.Width - 5, 5, logo.Width, logo.Height)
End Sub
Make sure you make image transparent and save it as PNG format.

Put an image in the center of a cell with migradoc

I need to put an image in the center of a table's cell.
When I add the image in a cell the image is aligned topleft.
How can I align the image in the center of a cell?
You might need to add a paragraph to the cell, set the alignment on the paragraph, and then add the image to the paragraph.
row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
row.Cells[0].AddParagraph().AddImage(imageLocation);
row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
In my version of MigraDoc, Jeff and Reuben's solution does not work as shown: Setting the cell's Format.Alignment property has no effect, even when the image is inside a paragraph.
However, what does work for me is to put the image in a paragraph, just as Jeff and Reuben say, then give the paragraph a named style which includes centering.
In my method which predefines all my styles, I do something like:
// Here we assume the "TableText" style has already been created
var sty = doc.Styles.AddStyle( "TableTextCenter", "TableText" );
sty.ParagraphFormat.Alignment = ParagraphAlignment.Center;
And at the point where I add the image, I do this:
var para = table.Cells[ 0 ].AddParagraph();
para.Style = "TableTextCenter"; // <----- This is the magic!
var img = para.AddImage( imageFileSpec );
img.LockAspectRatio = true;
img.Width = "4cm";
img.WrapFormat = new WrapFormat {
Style = WrapStyle.Through
};
As #Reuben says, what is interesting is:
row.Cells[0].AddParagraph().AddImage(imageLocation);
I was trying with
row.Cells[0].AddImage(imageLocation);
And the image was inserted in the document but I couln't get it centered.

How can I set an image as background for a movie clip in flash/as3?

I am working on a mini-app in Adobe Flash/ActionScript 3 in which I have to change the color of some objects on the scene by clicking a set of buttons. For the same objects I have to set some patterns (using images).
I can handle the change of the color, but I do not know how to put an image as background.
How can it be done?
Thank you!
You could use Graphics to draw the image.
// Draw the background
var shape:Shape = new Shape();
shape.graphics.beginBitmapFill(myBitmapData);
shape.drawRect(0, 0, myBitmapData.width, myBitmapData.height);
shape.endFill();
// Reference for later
var background:DisplayObject = shape;
You could also use Bitmap to display the image.
// Display the image
var bitmap:Bitmap = new Bitmap(myBitmapData);
// Reference for later
var background:DisplayObject = bitmap;
Now you can add this background to your object.
// Add the background at the lowest depth level
myObject.addChildAt(background, 0);

Resources