hi guys, first of all - thank you, this is a greate forum!! - i get alot of answers here to my problems!
but recentlly i got kinda stuck.
i am trying to build something like a "google maps", application... i have very large photos of some area, and i devided it into squers 200x200 pxls. now i am trying (using WPF), to build some program that could navigate through this HUGE map... so i made a grid that moves, accordingly to the map location, but its not working well, the grid is 5x5 squers, and each time i move it more then "1 squer size" to any direction, i reload the images, and return the grid to its initial location (with new coresponding images), but it does not work well, it kinda "jumps" all around.
anyway, maybe there is some other way to make it work? something i dont know... (I am new to programing), maybe dynamicly "resize" the grid or something? and if so, maybe a small exmple how to?
i really really thank you ahead!!
2 replies to this topic
#1
Posted 17 July 2010 - 06:31 AM
|
|
|
#2
Posted 17 July 2010 - 12:40 PM
Can you show us some code?
#3
Posted 19 July 2010 - 04:11 AM
well, here is some "test code", please note - this is a test code...
and "ImageCanves" is actually not a canvas, its a grid (as i said, test code :) )
there is an "ImageComposer" Class - its just a class that makes an "array" with image files
private void ImageCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (ImageCanvas.IsMouseCaptured)
{
End = e.GetPosition(wpfMap);
Delta.X = End.X - Start.X;
Delta.Y = End.Y - Start.Y;
panDiffX += Delta.X;
panDiffY += Delta.Y;
pntCenter.X -= (Delta.X);
pntCenter.Y -= (Delta.Y);
wpfMap.RenderTransform = new TranslateTransform(-1*(pntCenter.X - 500), -1*(pntCenter.Y - 500));
if (panDiffX <= -200 )
{
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location,5);
wpfMap.Width -= (-200);
Rectangle newplace = new Rectangle();
newplace.Width = 200;
newplace.Height = 200;
newplace.Fill = new SolidColorBrush(Colors.Azure);
ColumnDefinition newCol = new ColumnDefinition();
newCol.Width = new GridLength(200);
wpfMap.ColumnDefinitions.Add(newCol);
wpfMap.UpdateLayout();
newplace.SetValue(Grid.ColumnProperty, wpfMap.ColumnDefinitions.Count-1); //(Grid.ColumnProperty, 6);
newplace.SetValue(Grid.RowProperty, wpfMap.RowDefinitions.Count - 1);
wpfMap.Children.Add(newplace);
}
if (panDiffY <= -200)
{
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location, 5);
wpfMap.Height -= (-200);
Rectangle newplace = new Rectangle();
newplace.Width = 200;
newplace.Height = 200;
newplace.Fill = new SolidColorBrush(Colors.Azure);
RowDefinition newRow = new RowDefinition();
newRow.Height = new GridLength(200);
wpfMap.RowDefinitions.Add(newRow);
newplace.SetValue(Grid.ColumnProperty, wpfMap.ColumnDefinitions.Count-1);
newplace.SetValue(Grid.RowProperty, wpfMap.RowDefinitions.Count - 1);
wpfMap.Children.Add(newplace);
}
}
}
This code is when i am trying to "add more colums" to the grid.
my other idea was to move the grid to its original location but to change pics inside:
*plz note - there is a "bunnys" list - its an extra object, on top of the map
private void ImageCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (ImageCanvas.IsMouseCaptured)
{
End = e.GetPosition(wpfMap);
Delta.X = End.X - Start.X;
Delta.Y = End.Y - Start.Y;
brdrThikness.Top = wpfMap.Margin.Top + Delta.Y;
brdrThikness.Left = wpfMap.Margin.Left + Delta.X;
brdrThikness.Bottom = wpfMap.Margin.Bottom - Delta.Y;
brdrThikness.Right = wpfMap.Margin.Right - Delta.X;
wpfMap.Margin = brdrThikness;
panDiffX += Delta.X;
panDiffY += Delta.Y;
if (Math.Abs(panDiffX) > 200 )
{
pntCenter.X -= (panDiffX/2);
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location);
LoadImages(newSet);
brdrThikness.Left = -200 ;
brdrThikness.Right = -200 ;
wpfMap.Margin = brdrThikness;
panDiffX = 0;
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
MouseButtonEventArgs MouseUp = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, (MouseButton)e.LeftButton);
ImageCanvas_MouseUp(sender, MouseUp);
ImageCanvas_MouseDown(sender, MouseUp);
}
if (Math.Abs(panDiffY) >= 200)
{
pntCenter.Y -= (panDiffY / 2);
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location);
LoadImages(newSet);
brdrThikness.Bottom = -200;
brdrThikness.Top = -200 ;
wpfMap.Margin = brdrThikness;
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
panDiffY = 0;
MouseButtonEventArgs MouseUp = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, (MouseButton)e.LeftButton);
ImageCanvas_MouseUp(sender, MouseUp);
ImageCanvas_MouseDown(sender, MouseUp);
}
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
}
}
and "ImageCanves" is actually not a canvas, its a grid (as i said, test code :) )
there is an "ImageComposer" Class - its just a class that makes an "array" with image files
private void ImageCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (ImageCanvas.IsMouseCaptured)
{
End = e.GetPosition(wpfMap);
Delta.X = End.X - Start.X;
Delta.Y = End.Y - Start.Y;
panDiffX += Delta.X;
panDiffY += Delta.Y;
pntCenter.X -= (Delta.X);
pntCenter.Y -= (Delta.Y);
wpfMap.RenderTransform = new TranslateTransform(-1*(pntCenter.X - 500), -1*(pntCenter.Y - 500));
if (panDiffX <= -200 )
{
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location,5);
wpfMap.Width -= (-200);
Rectangle newplace = new Rectangle();
newplace.Width = 200;
newplace.Height = 200;
newplace.Fill = new SolidColorBrush(Colors.Azure);
ColumnDefinition newCol = new ColumnDefinition();
newCol.Width = new GridLength(200);
wpfMap.ColumnDefinitions.Add(newCol);
wpfMap.UpdateLayout();
newplace.SetValue(Grid.ColumnProperty, wpfMap.ColumnDefinitions.Count-1); //(Grid.ColumnProperty, 6);
newplace.SetValue(Grid.RowProperty, wpfMap.RowDefinitions.Count - 1);
wpfMap.Children.Add(newplace);
}
if (panDiffY <= -200)
{
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location, 5);
wpfMap.Height -= (-200);
Rectangle newplace = new Rectangle();
newplace.Width = 200;
newplace.Height = 200;
newplace.Fill = new SolidColorBrush(Colors.Azure);
RowDefinition newRow = new RowDefinition();
newRow.Height = new GridLength(200);
wpfMap.RowDefinitions.Add(newRow);
newplace.SetValue(Grid.ColumnProperty, wpfMap.ColumnDefinitions.Count-1);
newplace.SetValue(Grid.RowProperty, wpfMap.RowDefinitions.Count - 1);
wpfMap.Children.Add(newplace);
}
}
}
This code is when i am trying to "add more colums" to the grid.
my other idea was to move the grid to its original location but to change pics inside:
*plz note - there is a "bunnys" list - its an extra object, on top of the map
private void ImageCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (ImageCanvas.IsMouseCaptured)
{
End = e.GetPosition(wpfMap);
Delta.X = End.X - Start.X;
Delta.Y = End.Y - Start.Y;
brdrThikness.Top = wpfMap.Margin.Top + Delta.Y;
brdrThikness.Left = wpfMap.Margin.Left + Delta.X;
brdrThikness.Bottom = wpfMap.Margin.Bottom - Delta.Y;
brdrThikness.Right = wpfMap.Margin.Right - Delta.X;
wpfMap.Margin = brdrThikness;
panDiffX += Delta.X;
panDiffY += Delta.Y;
if (Math.Abs(panDiffX) > 200 )
{
pntCenter.X -= (panDiffX/2);
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location);
LoadImages(newSet);
brdrThikness.Left = -200 ;
brdrThikness.Right = -200 ;
wpfMap.Margin = brdrThikness;
panDiffX = 0;
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
MouseButtonEventArgs MouseUp = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, (MouseButton)e.LeftButton);
ImageCanvas_MouseUp(sender, MouseUp);
ImageCanvas_MouseDown(sender, MouseUp);
}
if (Math.Abs(panDiffY) >= 200)
{
pntCenter.Y -= (panDiffY / 2);
ImageComposer newSet = new ImageComposer(pntCenter, MapRow.Location);
LoadImages(newSet);
brdrThikness.Bottom = -200;
brdrThikness.Top = -200 ;
wpfMap.Margin = brdrThikness;
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
panDiffY = 0;
MouseButtonEventArgs MouseUp = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, (MouseButton)e.LeftButton);
ImageCanvas_MouseUp(sender, MouseUp);
ImageCanvas_MouseDown(sender, MouseUp);
}
foreach (TheObject bunny in bunnys)
{
bunny.ObjectImage.RenderTransform = new TranslateTransform(-1 * (pntCenter.X - panDiffX) + bunny.XLocation, -1 * (pntCenter.Y - panDiffY) + bunny.YLocation);
}
}
}
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










