VS 2010 Drawing On A Canvas With Wpf?

Jun 30, 2010

Finally took the plunge for wpf, all was going well until i needed to do a simple drawing on a canvas control (presume this is the right surface to use). First thing i noticed is that there is no paint event in wpf so i looked at a few others (Initialized, layout updated) at this point i looked under google and found very little on this. would anyone here have or know of a tutorial to allow this functionality? My application (a testbed) will draw an archery target within the canvas along with score numbers in the correct place as follows to do this it will need to draw several filled circles with black (or white) borders and text objects in the correct position. the locations and widths of the circles will be determined using a simple algorithm so my question is on the structure of paint events within wpf, are the commands the same as in gdi+?

View 3 Replies


ADVERTISEMENT

Drawing Multiple Lines On A Canvas?

Jun 29, 2012

So I built myself a simple program to work out the kinks of drawing in my programs. I have a button that I press that when the textbox.text reads 1 it then draws a line of a specific height, color and position, the problem is when I click that button again it will crash informing me that...
"Specified Visual is already a child of another Visual or the root of a CompositionTarget."
[code..]

I know where the problem lies, its with the Canvas1.children.add(line), cause its telling me the line variable is already been used or in use on the canvas, I'm just unsure of how to turn that into a solution that will allow me to click the button a hundred times or more without being forced to MANUALLY make a hundred or more individual variables to store the line.

View 5 Replies

Drawing A Line In Silverlight / Canvas Width Is Invalid

Mar 17, 2011

I'm trying to make a very simple Silverlight application.I want it to be full-screen, and I want to draw a line onto a Canvas.My problem is that the .Width and .Height of the canvas never seem to have a valid value. The website shows the canvas at 400x300 pixels or so, and when you click on it, it goes into Fullscreen mode.I want to use the Height and Width to find the usable space of the screen. I've tried adding events (thinking that the canvas wasn't yet ready to be used immediate after the full-screen line of code) but the LayoutChanged and Resized events don't seem to yield anything.

View 1 Replies

C# :: WP7 : Can't Get Canvas.RenderTransform Value

Feb 6, 2012

I have about 3-4 canvas controls and each contains about 750-1200 paths.Users needs to make some transform to them and I use for that a global

Canvas SelectedCanvas;
Initially (in the constructor) SelectedCanvas takes the value of one my canvas controls.
SelectedCanvas = canvas1;

[code].....

View 1 Replies

Wpf :: Exporting Canvas To Xps Vb?

Apr 26, 2012

I tried to export my canvas to a file. First I tried to export it to a png and it worked fine, everything looks the same as on the canvas.After that I modified my code to export to a xps file.

Dim thePack As IO.Packaging.Package = IO.Packaging.Package.Open(path.LocalPath,IO.FileMode.Create)
Dim doc As New Xps.Packaging.XpsDocument(thePack)

[code]....

View 1 Replies

VS 2010 : Drawing Over The Controls?

Mar 14, 2011

I have a form populated with controls. Short of looping through every control and hiding them, is there a way I can draw something like a message over them using the form's paint event? Or would I be better off putting an actual control in the middle of the form over all the controls?

View 3 Replies

VS 2010 Drawing On A Image?

Sep 28, 2010

I currently have a application that takes a image of the selected area that is set by the user.

I now would like to draw a black box in the section of a image

Top left
7, 458
Bottom right
512, 472

I would like that area filled up with a black box.

View 4 Replies

VS 2010 VB6 Drawing On A Picture Box

Dec 22, 2010

In the project I am translating from vb6 to vb.net, one of the key features is in drawing various graphics like lines, circles, arcs, rectangles, etc in a Picture Box control. From what I have run into, there seems to be at least two different approaches, using WPF and GDI.

View 2 Replies

C# - Canvas With Ruler Control In .NET?

Mar 2, 2012

Is there a control or something similar to a canvas with a margin(ruler), like in MS Word,in .NET WPF or WinForms?

I need to place some custom elements inside that user can modify in that canvas.

View 2 Replies

C# - Move A Rectangle Around A Canvas?

Sep 4, 2010

I have a canvas in the middle of my application with controls around it. I have a socket that recieves Points and saves them in a list.

I draw small 4x4 rectangles on the canvas for the number of points in my list.. say theres 4 points.. theres 4 rectangles.

I want to be able to move the rectangles when the points change with code.
is this possible without storyboards or any 'animation' class?

I have tried:

'cMap.Children.Remove(r)
'Dim nr As Rectangle = New Rectangle() With {.Width = 4, .Height = 4, .Name = "r" & P.Name, .Fill = Brushes.Red}

[Code].....

View 2 Replies

Cannot Find The Canvas Control In .NET

Jun 2, 2011

I am trying to convert some old VB6 code to VB.NET. The VB6 uses a Canvas control, simply

Dim cv as Canvas

I cannot for the life of me figure out how to use the Canvas control in VB.NET (using VS2005). MSDN says it is in the System.Windows.Controls namespace, which doesn't seem to exist? All I see is System.Windows.Forms, which doesn't include the Canvas control.

View 2 Replies

Use System.Drawing.ColorTranslator In 2010?

Jun 8, 2010

i have used this code in Vb6 to color the background and parallely added a colo selection fuctionality on right click.Now i want the functionality to be working in VB.net 2010.

Me.BackColor = System.Drawing.ColorTranslator.FromOle(CInt(colorCode))

View 1 Replies

VS 2010 - Clearing The Drawing In PictureBox

Mar 13, 2012

I've problem with clearing the drawing in PictureBox. The parts of a drawing are created with PictureBox1_ Paint Event like this: Name is one of the Subs (just part of a drawing). I've created a second event Timer1_Tick in which I want to clear the drawing created before but I can't reach it just with g.Clear(Color.White).

View 8 Replies

VS 2010 Circle Diagram Drawing?

May 13, 2012

I'm trying to draw some kind of circle diagram. Input data are only two integers: "a" (even or odd) and "b" (even). Here is the

HTML Imports System.Drawing.Drawing2D
Public Class Form1
Dim P As New Pen(Brushes.Red, 1)
Dim a As Integer = 24
Dim b As Integer = 2
Dim Angle As Single = b / a * Math.PI

[Code]...

View 2 Replies

VS 2010 Drawing A Line From A Number?

Jan 18, 2012

I have been working on an angle calculating program. I have incorprated a feature so you can type the angle and the program draw it. I have since added a few new features and updated everything as such. For the life of me I can't figure out why the draw angle has stoped working. let me just paste some code.

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data

[Code]....

Right, the program isn't so complicated. The important bit is that you type an angle in textbox1 and hit enter. Then what happens is the angle is calculated against a base line (one of the new features is that this base line can be moved from left to right and center.) the problem occurs when you hit enter, the program doesnt actually draw the line for you.

View 2 Replies

VS 2010 Drawing Complicated Pattern

Aug 13, 2010

I am refining my VS2010 control renderers and I'm working on the TabControl at the moment. If you take a screenshot of the VS2010 IDE and zoom in on the background of the TabControl (where there are no tabs), then you might see that it consists of a pattern of dots with a slightly different color than the surrounding background. I am trying to draw these dots (yes, I'm going for perfection), but I cannot find a brush that allows me to do this.I am pretty sure I'd have to use a HatchBrush with the right HatchStyle, but I cannot find a matching style.Here is a screenshot showing:

1. The VS2010 background I'm trying to draw (higher contrast and brightness otherwise it's hardly visible),

2. The HatchStyle that is closest to this (DottedDiamond)

3. Why this HatchStyle is not correct (it's missing dots where the green dots are, which I photoshopped in).

Now of course I'm going to have to draw the pattern twice (there are two patterns, offset by 1 pixel, with a slightly different color), but the more pressing problem is the green dots seen in the third image. They aren't there with the DottedDiamond style, and no other style (I think I've tried them all, but hey I might have missed some..) produces a better output.

View 4 Replies

VS 2010 Drawing Image To Picturebox?

Jul 20, 2011

I have 4 control 3 button and 1 picturebox

vb.net
Private sub Button1 Dim bm As Bitmap = New Bitmap("D:Trening4 - Copy.bmp"

[code].....

View 4 Replies

VS 2010 Drawing In Inches And Feet

Jan 23, 2011

I am trying to make a drawing program that you can draw floor plans and the like with vb .net 2010.I know how to use gdi but I need to know how to draw lines that are scaled in inches and feet.Can anyone out there help me out with this problem?I have tried the dpi x and y but it only gives me the resolution which is 96 dpi.

View 3 Replies

VS 2010 Drawing Inverted Text?

Feb 17, 2011

Is it possible to draw text on a Graphics object that inverts what it's drawn on?

View 2 Replies

VS 2010 Drawing Strings On A New Image?

Oct 18, 2010

My goal is actually very simple: I simply want a (shared) function that accepts a List(Of String) which creates an image and writes those strings (line by line) onto the image. There's a bit more to it than that, but for the sake of example this is all you need to know.Usually when drawing on an image I would create a Bitmap object and get the graphics object from Graphics.FromImage:

Dim bmp As New Bitmap(100, 100)
Using g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(...)

[code]....

Seems easy enough, but the problem is that I don't know how many strings there will be in the list, nor how long they will be. The image should 'scale itself' according to the strings in the list. If the list contains 5 strings it should be 5 strings high (plus a little extra for borders). If the list contains only 1 string it should be only one string high. Same goes for the width, if the longest string is 150 pixels, the image needs to be at least 150 pixels (160, 170 or something).

This is all good, I can get the dimensions of the strings by using Graphics.MeasureString. The problem now is that I need the dimensions of the image to create the bitmap. I need the Graphics object to get the dimensions. But, I need the bitmap to get the Graphics object I'm stuck in a loop here, if I don't have the Graphics object (I can't create it from nothing..) then I cannot measure the strings, but if I cannot measure the strings then I cannot determine how large my image will be, so I cannot create a bitmap and associated Graphics object...

View 5 Replies

VS 2010 Save Drawing From PictureBox?

Jun 4, 2011

I'm trying to save the lines I drew in a PictureBox as a bitmap, but it just returns blank images...This is the code I have now:

vb
'Draw a grid on PictureBox named draw
For x As Integer = 0 To bWidth

[code]....

View 3 Replies

VS 2010 Transparent Drawing Layer?

Feb 15, 2011

Okay, I'm making a fresh start and re-exploring my options. I'm trying to put a layer of transparency over a program that will act as a drawing layer. The cursor should be able to sniff to see whether it's sitting on transparency, or a drawn object. Transparency it will click through, while clicking on a drawn object will enable the user to edit said drawn object.

I've been trying to do this using a user control I made from scratch, but this is starting to look more and more like a dead end the deeper I get into it. Currently the layer of transparency works, along with the cursor sniffing, but the user control refuses to be brought to the front.

Any ideas on other ways to go about this / ways to make the user control work?

View 6 Replies

VS 2010 Usercontrol Drawing Refreshing?

Jan 15, 2011

i'm an old VB6 programmer that has just starting dabbling in VB.NET 2010 and my first project is a Usercontrol Button project and i'm running into some trouble with refreshing the usercontrol on events.

For example when you mousedown on the usercontrol i want it to act as if the button is being pressed in, to do this i make the caption move 2 pixels down and to the left. And then reverse this when the usercontrol mouseup is triggered.I think my code is correct but i'm not 100% sure what i'm doing with me.refresh and the usercontrol_paint events.

[Code]...

View 6 Replies

Capture Part Of A Canvas To Save As BMP / GIF?

Apr 5, 2009

I have an application that generates a replay of Air Traffic and I need to allow the user to capture parts of the canvas so it can be exported as a BMP of GIF. I did this in VB6, but not sure how to do it in WPF. I plan on drawing a rectangle around the intended capture area following the mouse till the user triggers the capture.

View 1 Replies

Wpf - Get Mouse Position On Canvas (But NOT On Window)?

Apr 17, 2011

I have a project in WPF 4 and vb.net 2010.

I have a canvas inside a window. The window is full screen, but the canvas is set to a solid 640x480 in the center of the window. I need to get the mouse position inside of the canvas, but NOT inside of the window. How do I do this?

View 1 Replies

Drawing Tools In Visual Studio 2010?

Jul 18, 2012

I am unable to find line , oval ,rectangle etc Drawing tools in Visual Studio 2010 I am also unable to find VisualBasic.PowerPack

View 1 Replies

System.Drawing.Point Non-existent In VB 2010?

Mar 15, 2011

Im getting an error right now for this code, and I'm wondering if it's me, or VB2010 has changed?

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Left Then

[code].....

View 4 Replies

VS 2010 Drawing A Curve/graph In Picturebox?

Nov 21, 2009

My problem is centering the 0,0 points of my graph to the center of my picturebox

Dim picBoxWidth As Integer = picGraf.Size.Width
Dim picBoxHeight As Integer = picGraf.Size.Height
Dim halfWidth As Integer = picGraf.Size.Width / 2

[code]....

So how to I tell it to start at the center of my picturebox names (picgraf) btw.

View 1 Replies

VS 2010 Drawing A Line Over DirectX Fullscreen?

Jan 25, 2012

Basically I want to Position a line from The middle of my screen to the bottom right of my screen. But I need to draw over the game to do this. I dont mind if it flickers as long as its there is all i want. Like this VV

View 4 Replies

VS 2010 Drawing Circles In A Chart Temporarily

Jan 13, 2011

Im drawing a chart based on values from a database as an image in a picturebox. I can then add lines and circles etc in the picturebox, so as to highlight areas in the chart.

The next step I would like to do is to have temporary lines and circles, so when I move the mouse, the circle grows or shrinks and only when I release the mousebutton the circle is assigned to the chart picturebox.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved