bonjour à tous,
Je voudrais afficher des images composées elle mêmes d'autres images, la fonction suivante se charge de créé une Image et la retourne:
l'objet de type Image est retourné à la fonction qui elle se charge de l'afficher :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public Image ComputeImage(double width, double positionLeft, double positionTop) { Image myImage3 = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); bi3.UriSource = new Uri(@"H:\Documents\Visual Studio 2010\Projects\VisualReport\Images\count_bar_dark.png", UriKind.Absolute); bi3.CacheOption = BitmapCacheOption.OnLoad; bi3.EndInit(); myImage3.Stretch = Stretch.Fill; myImage3.Source = bi3; myImage3.Width = width; //change pas myImage3.Height = 8; // var mR = 300 - (width + positionLeft); System.Windows.Thickness oMargin = new Thickness(positionLeft, positionTop, mR, 0); myImage3.Margin = oMargin; return myImage3; }
Le switch permet d'envoyer l'image à la bonne fonction qui contient à chaque fois le nom du grid (il y en à 4) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public void MeasureImage() { double begin; double end; double width; int cpt=0; Image imageToDisplay=null; double totalDuration = (this.data.Timings.list[0].end - this.data.Timings.list[0].begin); double firstPointPosition=0; //Display the first image with a width of 300 int leftPosition = 0; int positionTop = 0; int totalWidth=300; ComputeImage(totalWidth,leftPosition,positionTop); //display the sub images based on the first image foreach (Timing time in this.data.Timings.list) { foreach (Timing sub_time in time.list) { positionTop += 20; end = sub_time.end; begin = sub_time.begin; width = ((end - begin) * 300) / totalDuration; firstPointPosition = ((sub_time.begin * totalWidth) / totalDuration); imageToDisplay= ComputeImage(width, firstPointPosition, positionTop); } switch(cpt) { case 0: displayImageGuess(imageToDisplay); break; case 1: displayImageCreate(imageToDisplay); break; case 2: displayImageBuild(imageToDisplay); break; case 3: displayImageApply(imageToDisplay); break; } cpt++; } }Au final rien ne s'affiche pourtant je pense que ma logique est correcte :s
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 private void displayImageGuess(Image image) { GuessTiming.Children.Add(image); } private void displayImageCreate(Image image) { CreateTiming.Children.Add(image); } private void displayImageBuild(Image image) { BuildTiming.Children.Add(image); } private void displayImageApply(Image image) { ApplyTiming.Children.Add(image); }
Je vous remercie d'avance pour votre aide





Répondre avec citation


c'est bien ce qu'il me semblait 
Partager