Click here to Skip to main content
15,909,953 members
Home / Discussions / Graphics
   

Graphics

 
GeneralRe: save & open file... Pin
mr jets2-May-07 13:58
mr jets2-May-07 13:58 
Questionscreen view Pin
instalator25-Apr-07 2:00
instalator25-Apr-07 2:00 
AnswerRe: screen view Pin
Christian Graus29-Apr-07 0:49
protectorChristian Graus29-Apr-07 0:49 
QuestionColor Eraser..! Pin
mr jets24-Apr-07 16:17
mr jets24-Apr-07 16:17 
AnswerRe: Color Eraser..! Pin
Christian Graus29-Apr-07 0:50
protectorChristian Graus29-Apr-07 0:50 
QuestionZoom in/out ...by c# !! Pin
mr jets24-Apr-07 8:17
mr jets24-Apr-07 8:17 
AnswerRe: Zoom in/out ...by c# !! Pin
MatrixCoder25-Apr-07 7:35
MatrixCoder25-Apr-07 7:35 
Question(WPF) Zooming & Panning [modified] Pin
Frostsnow23-Apr-07 23:18
Frostsnow23-Apr-07 23:18 
Hi, we're a couple of students on our internship, and we're kinda stuck in the project we're doing. I'll first try to explain what it is we are expected to make.

You have to imagine a white empty 2D paper which is virtually unlimited in size. An admin can place a question on this paper, users can then reply on the active question. The admin can also zoom in and zoom out and drag the paper around and post new questions. So we have to work with an environment that contains a fair amount of questions linked to answers. Every question can be differently scaled, so this means that you have to zoom in more on some questions than others.

Basic functionality would have to be panning the paper, by that I mean hold mouse down and dragging it to another position, thus moving all objects on the paper in that direction.

We've tried this with the following code, however the performance was really bad.

void Window_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)<br />
        {<br />
            if (mbMouseDown)<br />
            {<br />
                Point bNew = e.GetPosition(Window);<br />
                foreach (UIElement oObject in LayoutRoot.Children)<br />
                {<br />
                    Canvas.SetTop(oObject, bNew.X - mpBegin.X);<br />
                    Canvas.SetLeft(oObject, bNew.Y - mpBegin.Y);<br />
                }<br />
            }<br />
            mbMouseDown = false;<br />
        }<br />
<br />
        void LayoutRoot_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)<br />
        {<br />
            if (mbMouseDown)<br />
            {<br />
                Point bNew = e.GetPosition(Window);<br />
                foreach (UIElement oObject in LayoutRoot.Children)<br />
                {<br />
                    Canvas.SetTop(oObject, bNew.X - mpBegin.X);<br />
                    Canvas.SetLeft(oObject, bNew.Y - mpBegin.Y);<br />
                }<br />
            }<br />
        }<br />
<br />
        void LayoutRoot_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)<br />
        {<br />
            mbMouseDown = true;<br />
            mpBegin = e.GetPosition(Window);<br />
        }

With the zooming we tried the scaling functionality of wpf.
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)<br />
<br />
        {<br />
<br />
            if (e.Delta > 0)<br />
<br />
            {<br />
<br />
                mpScaleSize = new Point((mpScaleSize.X - 0.05), (mpScaleSize.Y - 0.05));<br />
<br />
                grdCanvas.LayoutTransform = new ScaleTransform(mpScaleSize.X, mpScaleSize.Y);<br />
<br />
                zoomX.Content = mpScaleSize.X.ToString();<br />
<br />
                zoomY.Content = mpScaleSize.Y.ToString();<br />
<br />
            }<br />
<br />
            else<br />
<br />
            {<br />
<br />
                mpScaleSize = new Point((mpScaleSize.X + 0.05), (mpScaleSize.Y + 0.05));<br />
<br />
                grdCanvas.LayoutTransform = new ScaleTransform(mpScaleSize.X, mpScaleSize.Y);<br />
<br />
                zoomX.Content = mpScaleSize.X.ToString();<br />
<br />
                zoomY.Content = mpScaleSize.Y.ToString();<br />
<br />
            }<br />
<br />
        }

This again wasn't going smoothly.
(My laptop is a IBM Thinkpad r50p, 1,7Ghrz Centrino, 1gig RAM, maybe it's just not fast enough?)

Anyway , I've posted this same question on the msdn forums. One person with little experience with the subject suggested me that I should try to work with visualBrushes and use it as some kind of view. I've been playing around with the VisualBrushes for a while now.

I've managed to get controls from code onto the VisualBrush(which is on a rectangle in the center of my app), however working with VisualBrush as some kind of view isn't working for me.What I "discovered"is that working with the viewbox property of the visualbrush might be the solution, but I can't seem to get it to work.

To my understanding the viewbox is a rectangle with it's x & y as panning values, and it's with & height as crop/stretch values (zoom).

Anyone with some experience in the area, I would really appreciate the help.









Thanks,
Tobias


-- modified at 8:14 Tuesday 24th April, 2007
QuestionMenus at runtime(C#/OpenGL) Pin
a_david12323-Apr-07 22:54
a_david12323-Apr-07 22:54 
QuestionFilter on an images Pin
azmoodeh22-Apr-07 10:33
azmoodeh22-Apr-07 10:33 
AnswerRe: Filter on an images Pin
Dave Kreskowiak22-Apr-07 12:34
mveDave Kreskowiak22-Apr-07 12:34 
GeneralRe: Filter on an images Pin
Christian Graus29-Apr-07 0:50
protectorChristian Graus29-Apr-07 0:50 
QuestionAvi Compression Pin
mjmim20-Apr-07 6:16
mjmim20-Apr-07 6:16 
AnswerRe: Avi Compression Pin
Mark Salsbery20-Apr-07 8:47
Mark Salsbery20-Apr-07 8:47 
QuestionRe: Avi Compression Pin
Mark Salsbery20-Apr-07 8:51
Mark Salsbery20-Apr-07 8:51 
AnswerRe: Avi Compression Pin
mjmim20-Apr-07 10:38
mjmim20-Apr-07 10:38 
GeneralRe: Avi Compression Pin
mjmim20-Apr-07 10:46
mjmim20-Apr-07 10:46 
GeneralRe: Avi Compression Pin
Mark Salsbery20-Apr-07 11:02
Mark Salsbery20-Apr-07 11:02 
GeneralRe: Avi Compression Pin
mjmim21-Apr-07 2:42
mjmim21-Apr-07 2:42 
GeneralRe: Avi Compression Pin
mjmim22-Apr-07 3:57
mjmim22-Apr-07 3:57 
GeneralRe: Avi Compression Pin
mjmim23-Apr-07 8:27
mjmim23-Apr-07 8:27 
GeneralRe: Avi Compression Pin
mjmim29-Apr-07 0:14
mjmim29-Apr-07 0:14 
QuestionCircle Image Recognition Pin
softwaremonkey19-Apr-07 5:41
softwaremonkey19-Apr-07 5:41 
AnswerRe: Circle Image Recognition Pin
Vega0219-Apr-07 16:10
Vega0219-Apr-07 16:10 
Questiondrawing in a picture box(using C-Sharp) Pin
Raza568018-Apr-07 19:35
Raza568018-Apr-07 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.