यह निश्चित रूप से संभव है। मैंने कुछ ऐसा किया है और यह बहुत अच्छा काम करता है। निम्न उदाहरण एक क्लिक की गई छवि के लिए विशिष्ट जानकारी दिखाएगा। यदि आप माउसओवर पर जानकारी को प्रेषित करना चाहते हैं, क्लिक करें, या ज़ूम किए जाने पर भी आप इसे संशोधित कर सकते हैं। यह पूरी तरह से आप पर निर्भर है।
<TextBlock X:Name="tbInfo" />
:
सबसे पहले, एक MultiScaleImage अपने कैनवास को, कैनवास पर कहीं और जोड़ने ...
<MultiScaleImage x:Name="deepZoomObject" Source="/GeneratedImages/dzc_output.xml" />
... और एक TextBlock जोड़ने जानकारी प्रदर्शित करने के लिए इस्तेमाल किया जा
इसके बाद, प्रत्येक "टाइल" के लिए जानकारी धारण करने के लिए एक वर्ग बनाने के कुछ डमी जानकारी जोड़ने, और एक सूची के लिए टाइल का एक समूह जोड़ें:
public class TileDetail {
public int Index { get; set; }
public string TileName { get; set; }
}
//The Index is the zero based index of the images. It depends on the index created by DeepZoomComposer. This is the one piece of information that you absolutely need to know. I believe the index is based on the order that the images are added to DeepZoomComposer but test to make sure.
List<TileDetail> TileDetailsList = new List<TileDetail>();
TitleDetail td1 = new TileDetail();
td1.Index = 0;
td1.TileName = "Tile #1";
TileDetailsList.Add(td1);
TitleDetail td21 = new TileDetail();
td2.Index = 1;
td2.TileName = "Tile #2";
TileDetailsList.Add(td2);
//Repeat the above for your remaining tiles always incrementing the Index. If you're loading information from a DB then you'll need to make sure to have a way to connect the image to its index from DeepZoomComposer.
अब जब सूची टाइल जानकारी से भरी हुई है, तो हमें माउसलेफ्टबटन डाउन इवेंट हैंडलर को वायरस करने की आवश्यकता है ताकि यह पता लगाया जा सके कि कोई छवि कब क्लिक की जाती है और आखिरकार क्लिक की गई छवि के सूचकांक को निर्धारित करने के लिए। इंडेक्स के साथ हमें केवल उचित टाइल विवरण के लिए हमारी सूची खोजनी होगी और फिर कैनवास पर प्रदर्शित करना होगा।
अपने में कोड-पीछे, निम्नलिखित जगह:
deepZoomObject.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
{
//Get the index of the image
int index = GetIndexOfSubImage(e.GetPosition(deepZoomObject));
//Find the image in the list of images
TileDetail td = TileDetailsList.FirstOrDefault(t => t.Index == index);
//Display image info
tbInfo.Text = td.TileName;
};
निम्नलिखित "गुप्त सॉस" है। इसे क्लिक की गई छवि का सूचकांक मिलेगा।
private int GetIndexOfSubImage(Point point)
{
// Test each subimage to find the image where the mouse is within
for (int i = deepZoomObject.SubImages.Count - 1; i >= 0; i--)
{
MultiScaleSubImage image = deepZoomObject.SubImages[i];
double width = deepZoomObject.ActualWidth/(deepZoomObject.ViewportWidth * image.ViewportWidth);
double height = deepZoomObject.ActualWidth/(deepZoomObject.ViewportWidth * image.ViewportWidth * image.AspectRatio);
Point pos = deepZoomObject.LogicalToElementPoint(new Point(image.ViewportOrigin.X/image.ViewportWidth, -image.ViewportOrigin.Y/image.ViewportWidth));
Rect rect = new Rect(pos.X, pos.Y, width, height);
if (rect.Contains(point))
{
// Return the image index
return i;
}
}
return -1; //if there is no corresponding subimage
}
और यही वह है। जब तक आपकी छवि अनुक्रमणिका में आपकी सूची में कोई संबंधित छवि हो, तब तक मल्टीस्केले इमेज ऑब्जेक्ट के अंदर एक छवि पर क्लिक करने से छवि की जानकारी प्रदर्शित हो जाएगी।
क्या आप कृपया एक रनिंग कोड पोस्ट कर सकते हैं ताकि मैं इसे आजमा सकूं? मैंने इसे कार्यान्वित करने की कोशिश की लेकिन माउस लेफ्टबटन डाउन ट्रिगर नहीं किया गया है। धन्यवाद – xscape
आपने MouseLeftButtonDown ईवेंट को बाध्य करने के लिए कोड कहां रखा? –
मैं इसे मल्टीस्केले इमेज – xscape