16,017,297 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10838492 (Top 11 by date)
Member 10838492
7-Jul-14 1:23am
View
really great links
Member 10838492
2-Jul-14 3:24am
View
hey Hi
its not the solution yaar, its just a part of my code, I have by mistake posted here
Member 10838492
1-Jul-14 1:03am
View
hiThe problem is i have a images on the canvas and i want to select the images on click and drag... for the same purpose i have used two canvas...
1. the canvas on which images are there (.png format)
2. the canvas which is used for click and drag.
here i s the code for the same
////////////////////////////////////////////////////////////////Code///////////////////////////
XAML;
MouseDown="Grid_MouseDown"
MouseUp="Grid_MouseUp"
MouseMove="Grid_MouseMove"
Background="Transparent"
> <!---->
<canvas name="myCanvas" horizontalalignment="Center" verticalalignment="Stretch" allowdrop="True" drop="DropImage" mouserightbuttondown="myCanvas_MouseRightButtonDown_1" width="648" margin="9,9,9,7" grid.column="1" grid.row="3">
<!---->
<image margin="2,0,0,10" name="imgPhoto" mouseleftbuttondown="DragImage" allowdrop="True" mouserightbuttondown="Image_MouseRightButtonDown_1">
Stretch="Fill" Grid.Row="1" Grid.ColumnSpan="4" Grid.Column="1" Grid.RowSpan="2" />
<canvas.contextmenu>
</canvas.contextmenu>
<!---->
<!---->
<canvas>
<!-- This canvas is overlaid over the previous canvas and is used to
place the rectangle that implements the drag selection box. -->
x:Name="selectionBox"
Visibility="Collapsed"
Stroke="Black"
StrokeThickness="1"
/>
</canvas>
<!---->
XAML.cs
bool mouseDown = false; // Set to 'true' when mouse is held down.
Point mouseDownPos; // The point where the mouse button was clicked down.
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
// Capture and track the mouse.
mouseDown = true;
mouseDownPos = e.GetPosition(theGrid);
theGrid.CaptureMouse();
// Initial placement of the drag selection box.
Canvas.SetLeft(selectionBox, mouseDownPos.X);
Canvas.SetTop(selectionBox, mouseDownPos.Y);
selectionBox.Width = 0;
selectionBox.Height = 0;
// Make the drag selection box visible.
selectionBox.Visibility = Visibility.Visible;
myCanvas.Children.Contains(selectedElement);
}
private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
{
// Release the mouse capture and stop tracking it.
mouseDown = false;
theGrid.ReleaseMouseCapture();
// Hide the drag selection box.
selectionBox.Visibility = Visibility.Collapsed;
Point mouseUpPos = e.GetPosition(theGrid);
}
private void Grid_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (mouseDown)
{
// When the mouse is held down, reposition the drag selection box.
Point mousePos = e.GetPosition(theGrid);
if (mouseDownPos.X < mousePos.X)
{
Canvas.SetLeft(selectionBox, mouseDownPos.X);
selectionBox.Width = mousePos.X - mouseDownPos.X;
}
else
{
Canvas.SetLeft(selectionBox, mousePos.X);
selectionBox.Width = mouseDownPos.X - mousePos.X;
}
if (mouseDownPos.Y < mousePos.Y)
{
Canvas.SetTop(selectionBox, mouseDownPos.Y);
selectionBox.Height = mousePos.Y - mouseDownPos.Y;
}
else
{
Canvas.SetTop(selectionBox, mousePos.Y);
selectionBox.Height = mouseDownPos.Y - mousePos.Y;
}
myCanvas.Children.Contains(selectedElement);
if (selected)
{
selected = false;
if (selectedElement != null)
{
// Remove the adorner from the selected element
//<<i have justifed it after adding the delete button becasue of adorner layer issue>>
aLayer.Remove(aLayer.GetAdorners(selectedElement)[0]);
selectedElement = null;
}
}
if (e.Source != myCanvas)
{
_isDown = true;
_startPoint = e.GetPosition(myCanvas);
selectedElement = e.Source as UIElement;
_originalLeft = Canvas.GetLeft(selectedElement);
_originalTop = Canvas.GetTop(selectedElement);
aLayer = AdornerLayer.GetAdornerLayer(selectedElement);
aLayer.Add(new ResizingAdorner(selectedElement));
selected = true;
e.Handled = true;
}
}
}
Member 10838492
1-Jul-14 0:56am
View
Deleted
select the images
Member 10838492
1-Jul-14 0:56am
View
I have updated the code and the issue, please do have a look at it :)
Member 10838492
1-Jul-14 0:53am
View
yes
I am not able to select, when i do that the whole canvas gets selected instead of the images on canvas
Member 10838492
26-Jun-14 0:29am
View
please help me regarding the issue..
Member 10838492
26-Jun-14 0:28am
View
hey hi
thanks for the reply.
The problems is how to create an xml file. And yes once i load the XML file, I should be in a position to alter the images on canvas. Please do help me.
Member 10838492
26-Jun-14 0:26am
View
hmm sorry
Member 10838492
10-Jun-14 7:00am
View
Dear fadi Halboni
I did not get what you were trying to tell, can you please elaborate. and thanks for the help
Member 10838492
29-May-14 0:58am
View
well the thing is, I want to browse a folder from my desktop and get all the images from that folder into my list box, once I get those images in the list I should be able to drag and drop the selected images from the listbox onto the canvas.
Show More