IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

[C#] Centrer une image sur des coordonnées précises


Sujet :

Windows Presentation Foundation

  1. #1
    Membre du Club
    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2011
    Messages
    46
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Novembre 2011
    Messages : 46
    Points : 43
    Points
    43
    Par défaut [C#] Centrer une image sur des coordonnées précises
    Bonjour,

    je fais une application WPF avec un canvas affichant une image de plan d'architecte et des routes et points par dessus.
    Tous ces éléments sont géoreférencés donc ont au moins 2 paires de coordonnées pixel et géographiques.

    Quand je charge les données d'une zone mon canvas s'ouvre par défaut en "visant" le centre du plan d'architecte, souvent bien plus grand que ma fenêtre.

    J'ai aussi fait un treeview qui me permet de savoir les éléments (points et routes) dessinés dans mon canvas.

    Je voudrais que quand je sélectionne par exemple le nom d'un point dans mon treeview ce point devienne le centre de mon canvas automatiquement. Et mon problème est que je ne sais pas trop quoi mettre dans mon événement de sélection du treeview. Les propriétés "HorizontalAlignment" et "VerticalAlignment" n'ont pas l'air d'accepter de coordonnées...

    Peut être le focus?... je sais pas! En tout cas mon code se présente comme cela

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <Border Name="Border_Map" BorderThickness="0" ClipToBounds="True" HorizontalAlignment="Stretch" Margin="0,0,0,23" VerticalAlignment="Stretch">
                        <Canvas Name="Canvas_Map" ClipToBounds="True" HorizontalAlignment="Center"  VerticalAlignment="Center"
                                MouseLeftButtonDown="Canvas_Map_MouseLeftButtonDown" MouseMove="Canvas_Map_MouseMove" MouseLeftButtonUp="Canvas_Map_MouseLeftButtonUp" MouseWheel="Canvas_Map_MouseWheel" Height="Auto" AllowDrop="True">
                            <Canvas.Background>
                                <ImageBrush x:Name="Image_Map"
                                            ImageSource="{Binding Path=Map, UpdateSourceTrigger=PropertyChanged}"
                                            Stretch="Uniform"
                                            Opacity="{Binding ElementName=Slider_Transparence, Path=Value, Converter={StaticResource sliderToOpacity}}"/>
                            </Canvas.Background>
                        </Canvas>
     </Border>

    Merci à vous Seigneurs et Reines du WPF!

  2. #2
    Expert confirmé
    Inscrit en
    Avril 2008
    Messages
    2 564
    Détails du profil
    Informations personnelles :
    Âge : 64

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 564
    Points : 4 441
    Points
    4 441
    Par défaut
    bonjour Towandaa...
    Modeste ,fideles seigneurs et barons de sa majeste plutot......
    Ceci d'abord .....

    J'ai aussi fait un treeview qui me permet de savoir les éléments (points et routes) dessinés dans mon canvas.
    Le TreeView n'est pas le seul choix quand on a un modele de donnees hierarchiques...et plutot inedequat dans ton cas ou tu souhaites synchroniser entre ce TreeView et ton canvas .
    Pourquoi?
    1/ le TreeView :la propriete SelectedValue
    -peut renvoyer un "List(of Point)" mais alors pas d'item racine (un "Point") si SelectedValuePath est sur "List(of Point)"....
    - il n' y a pas de "SelectedIndex" dans un TreeView
    2 /Le Canvas :
    -il n' a pas de prop ItemsSource.......
    Je te suggere :
    1 /Deux ListBox en maitre/detail parfaitement synchronises en lieu et place du "TreeView" qui s'adaptent "perfectly" à un modele hierarchique (-N- ListBox si tu veux ,et si ta hierarchie a une profondeur -N-)....
    En plus tu as en bonus:
    -SelectedIndex
    -SelectionMode="Multiple","Single"...
    2/Un ListBox (encore) avec un "itemsPanel" configure en "Canvas" ce qui :
    - fournit à notre canvas une prop ItemsSource....
    Je voudrais que quand je sélectionne par exemple le nom d'un point dans mon treeview ce point devienne le centre de mon canvas automatiquement. Et mon problème est que je ne sais pas trop quoi mettre dans mon événement de sélection du treeview.
    Cela suppose que ton canvas "defile" dans une "autre fenetre ou viewport" d'un autre controle ....qui ne peut etre qu'un "scrollviewer"....
    Le "scrollviewer" ,rendu "invisible" à l'user, peut scroller vers le point voulu par code sur l'event SelectionChanged du ListBox qui affiche le "point" selectionne ....
    De plus si on veut un recherche un point quelconque il faut pouvoir "panner" avec la souris...
    Bref voici le code qui explique mieux ce que je veux dire:

    code behind de la class data (Node ) de test:
    Code c# : 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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Windows.Shapes;
    using System.Windows;
    using System.Collections.ObjectModel;
     
    namespace WpfBringIntoViewCanvas
    {
     
       public  class Node : INotifyPropertyChanged
        {
            public Node()
            {
                this.X = 100;
                this.Y = 100; 
                this.Name = "Nothing";
     
            }
            public Node(int MyX, int MyY, string MyName)
            {
                this.X = MyX;
                this.Y = MyY; 
                this.Name = MyName;
            }
            private int m_X;
            public int X
            {
                get { return m_X; }
                set { m_X = value; OnPropertyChanged("X"); }
            }
            private int m_Y;
            public int Y
            {
                get { return m_Y; }
                set { m_Y = value; OnPropertyChanged("Y"); }
            }private string m_Name;
            public string Name
            {
                get { return m_Name; }
                set { m_Name = value; OnPropertyChanged("Name"); }
            }
     
            #region INotifyPropertyChanged Membres
     
            public event PropertyChangedEventHandler PropertyChanged;
            private void OnPropertyChanged(string propName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propName));
     
                }
            }
            #endregion
        }
        public class ListNode : ObservableCollection<Node>
        {
            public ListNode()
            {
            }
        }
        public class ZoneNode
        {
            private string _ZoneName;
            private ListNode _Nodes;
            public ZoneNode(string zname)
            {
                _ZoneName = zname;
                _Nodes = new ListNode();
            }
            public string ZoneName { get { return _ZoneName; } }
            public ListNode Nodes { get { return _Nodes; } }
        }
        public class ListZoneNode : ObservableCollection<ZoneNode>
        {
            private ZoneNode zn;
            private Node nd;
            private Random rnd;
            int mx;
            int my;
     
     
            public ListZoneNode()
            {
              CreateNewList();
            }
     
            private void CreateNewList()
            {
                rnd = new Random();
     
                // cree ZoneNode 1 avec 10 symboles graphiques  
     
                zn = new ZoneNode("Zone1");
                for (int i =0; i < 9; i++)
                {
                    mx = rnd.Next(0, 600);
                    my = rnd.Next(0, 600);
     
                    nd = new Node(mx, my, "grA" + i.ToString() + " :");
     
                    //add to Zone
                    zn.Nodes.Add(nd);
                }
     
     
                //add to ListZone
                this.Add(zn);
     
     
                // cree ZoneNode 2 avec 10 symboles graphiques  
     
                zn = new ZoneNode("Zone2");
                for (int i = 0; i < 9; i++)
                {
                    mx = rnd.Next(0,500);
                    my = rnd.Next(0,500);
     
                    nd = new Node(mx, my, "grB" + i.ToString() + " :");
     
                    //add to ZoneNode
                    zn.Nodes.Add(nd);
                }
     
                //add to ListZoneNode
                this.Add(zn);
     
            }
        }
    }
    code xaml du winform:
    Code xaml : 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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
     
    <Window x:Class="WpfBringIntoViewCanvas.WinItemsCanvasMaitreDetail"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:WpfBringIntoViewCanvas"
            Title="WinItemsCanvasMaitreDetail" 
            Height="300" Width="300">
        <Window.Resources>
            <!--notre Liste de base -->
            <Image 
                x:Key="MyMap" 
                Stretch="Uniform" 
                Source="Resources\Carte.jpg" 
                >
            </Image>
            <local:ListZoneNode
                x:Key="myDataSource" >
            </local:ListZoneNode>
     
            <!--DataTemplate du 1er ListBox sur ZoneNode -->
            <DataTemplate  
                x:Key="dtZoneNode"
                DataType="{x:Type local:ZoneNode}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock  
                        Margin="5,5,5,5"
                        Foreground="WhiteSmoke"
                        Background="Red"
                        FontWeight="Bold"
                        Text ="{Binding Path=ZoneName}" 
                        FontFamily="Times New Roman" 
                        FontSize="16" />
                </StackPanel>
            </DataTemplate>
     
            <!--DataTemplate du 2eme ListBox sur ListNode -->
            <DataTemplate  
                x:Key="dtListNode"
                DataType="{x:Type local:ListNode}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock   
                        Margin="5,5,5,5"
                        Foreground="Brown"
                        FontWeight="Bold"
                        FontFamily="Arial Rounded MT" 
                        FontSize="12"
                        TextAlignment="Center" 
                        Text ="{Binding Path=Name}" />
                    <TextBlock   
                        Margin="5,5,5,5"
                        Foreground="Brown"
                        FontWeight="Bold"
                        FontFamily="Arial Rounded MT" 
                        FontSize="12" 
                        TextAlignment="Center" 
                        Text="{Binding Path=X}" />
                    <TextBlock   
                        Margin="5,5,5,5"
                        Foreground="Brown"
                        FontWeight="Bold"
                        FontFamily="Arial Rounded MT" 
                        FontSize="12" 
                        TextAlignment="Center" 
                        Text="{Binding Path=Y}" />
                </StackPanel>
            </DataTemplate>
     
            <!--DataTemplate du ListBox alias "Canvas" sur le meme ListNode -->
            <!--mais aspect visuel different -->
            <DataTemplate 
                x:Key="dtZoneCanvas"
                DataType="{x:Type local:ListNode}" >
                <Grid>
                    <Rectangle
                        x:Name="rc"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        Width="80"
                        Height="50"
                        Stroke="Black"
                        StrokeThickness="1.0">
                    </Rectangle>
                    <TextBlock   
                        x:Name="tb"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        FontWeight="Bold"
                        FontFamily="Times New Roman" 
                        FontSize="16" 
                        FontStyle="Normal"
                        TextAlignment="Center" 
                        Margin="10"
                        TextWrapping="Wrap"
                        Text="{Binding Path=Name}" >
                    </TextBlock>
                </Grid>
            </DataTemplate>
            <!--un simple style pour ItemContainerStyle 
            necessaire pour gerer le canvas-->
            <Style x:Key="lbItemStyleCanvas" TargetType="ListBoxItem">
                <Setter Property="Canvas.Left" Value="{Binding Path=X}" />
                <Setter Property="Canvas.Top" Value="{Binding Path=Y}" />
                <Setter Property="Opacity" Value="1.0" />
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Trigger.Setters>
                            <Setter Property="Opacity" Value="0.6" />
                            <Setter Property="Background" Value="CornflowerBlue" />
                            <Setter Property="BorderBrush" Value="Fuchsia" />
                            <Setter Property="BorderThickness" Value="3.0" />
                        </Trigger.Setters>
                    </Trigger>
                </Style.Triggers>
     
            </Style>
        </Window.Resources>
        <!--note le DataContext du Grid sur la liste de base -->
        <Grid
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            DataContext="{Binding Source={StaticResource myDataSource}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="20"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.Resources>
     
            </Grid.Resources>
            <!--1 ListBox configure en canvas  -->
            <!--mettre : -SelectionMode="Single" &  IsSynchronizedWithCurrentItem="True" -->
            <Border 
                Grid.Row="1"
                Grid.Column="0" 
                Grid.ColumnSpan="2"
                Name="Border_Map" 
                BorderThickness="2" 
                BorderBrush="Blue"
                CornerRadius="5"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" >
                <ScrollViewer
                    Name="sv1" 
                    VerticalScrollBarVisibility="Hidden"
                    HorizontalScrollBarVisibility="Hidden"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Stretch">
                    <ListBox
                        x:Name="Canvas_Map" 
                        ClipToBounds="True" 
                        HorizontalAlignment="Center"  
                        VerticalAlignment="Center"   
                        Loaded="Canvas_Map_Loaded"
                        MouseLeftButtonDown="Canvas_Map_MouseLeftButtonDown" 
                        MouseMove="Canvas_Map_MouseMove" 
                        MouseLeftButtonUp="Canvas_Map_MouseLeftButtonUp" 
                        MouseWheel="Canvas_Map_MouseWheel" 
                        Height="638"
                        Width="1072"
                        AllowDrop="True"
                        SelectionMode="Single"
                        IsSynchronizedWithCurrentItem="True"
                        SelectionChanged="Canvas_Map_SelectionChanged"
                        ItemTemplate="{Binding Source={StaticResource dtZoneCanvas}}"
                        ItemsSource="{Binding  Path=Nodes}"
                        ItemContainerStyle="{Binding Source={StaticResource lbItemStyleCanvas}}">
                        <ListBox.Background>
                            <ImageBrush
                                x:Name="Image_Map"
                                ImageSource="{Binding Source={StaticResource MyMap},Path=Source}"
                                Opacity="0.8"
                                TileMode="None"
                                Stretch="Uniform" >
                            </ImageBrush>
                        </ListBox.Background>
                        <!--ItemsPanel en canvas-->
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <Canvas
                                    CacheMode="BitmapCache"
                                    VirtualizingStackPanel.IsVirtualizing="True"
                                    IsItemsHost="True" 
                                    >
                                </Canvas>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </ScrollViewer>
            </Border>
     
            <!--2 ListBox en maitre detail -->
            <!--mettre :-SelectionMode="Single"  & IsSynchronizedWithCurrentItem="True" -->
     
            <StackPanel
                x:Name="Zones" 
                Grid.Row="0"
                Grid.Column="0">
                <Label
                    Background="DarkBlue"
                    Foreground="WhiteSmoke"
                    FontSize="10"
                    FontWeight="Bold"
                    Content="Liste Zones">
                </Label>
                <ListBox 
                    x:Name="lbItemZone"
                    Height="200"
                    Background="WhiteSmoke"
                    SelectionMode="Single"
                    IsSynchronizedWithCurrentItem="True"
                    ItemTemplate="{Binding Source={StaticResource dtZoneNode}}"
                    ItemsSource="{Binding}">
                </ListBox>
            </StackPanel>
            <StackPanel  
                x:Name="Symbols"
                Grid.Row="0"
                Grid.Column="1">
                <Label
                   Background="DarkBlue"
                   Foreground="WhiteSmoke"
                   FontSize="10"
                   FontWeight="Bold"
                   Content="Liste  SymbolDataItems">
                </Label>
                <ListBox 
                    x:Name="lbSymbolDataItem"
                    Height="200"
                    Background="WhiteSmoke"
                    IsSynchronizedWithCurrentItem="True"
                    SelectionChanged="lbSymbolDataItem_SelectionChanged"
                    ItemTemplate="{Binding Source={StaticResource dtListNode}}"
                    ItemsSource="{Binding  Path=Nodes}">
                </ListBox>
            </StackPanel>
            <Button
                Grid.Row="2"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                x:Name="btnToCentreCanvas"
                Content="ToCentreCanvas"
                Click="btnToCentreCanvas_Click">
            </Button>
        </Grid>
    </Window>
    code-behind du winform:

    Code c# : 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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
     
    namespace WpfBringIntoViewCanvas
    {
        /// <summary>
        /// Logique d'interaction pour WinItemsCanvasMaitreDetail.xaml
        /// </summary>
        public partial class WinItemsCanvasMaitreDetail : Window
        {
            public WinItemsCanvasMaitreDetail()
            {
                InitializeComponent();
            }
     
            private void Canvas_Map_Loaded(object sender, RoutedEventArgs e)
            {
     
            }
            //"panning":  MouseDown,MouseMove et MouseUp
            // nb:cette methode est valable sur tout controle scrollable.....
            private Point pointDown = new Point(-1, -1);
            private Point pointMove = new Point(-1, -1);
            private Point currentOffset = new Point(-1, -1);
            private bool isDown  = false;
            private void Canvas_Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                pointDown = Mouse.GetPosition((ListBox)sender);
                if (pointDown != new Point(-1, -1))
                {
                    isDown = true ;
                    ((ListBox)sender).CaptureMouse();
                }
            }
            private void Canvas_Map_MouseMove(object sender, MouseEventArgs e)
            {
                pointMove = Mouse.GetPosition((ListBox)sender);
                if (isDown)
                {
                    Vector dragOffset = pointMove - pointDown;
     
                    this.currentOffset.X -= dragOffset.X;
                    this.currentOffset.Y -= dragOffset.Y;
                    sv1.ScrollToHorizontalOffset(this.currentOffset.X);
                    sv1.ScrollToVerticalOffset(this.currentOffset.Y);
                }
            }
     
            private void Canvas_Map_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                pointDown = new Point(-1, -1);
                currentOffset = new Point(-1, -1);
                isDown = false;
                ((ListBox)sender).ReleaseMouseCapture();
            }
     
            private void Canvas_Map_MouseWheel(object sender, MouseWheelEventArgs e)
            {
     
            }
     
            private void Canvas_Map_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
     
            }
     
            //  deplacer la fenetre "viewport" du scrollviewer
            //  vers le point souhaite
            private void lbSymbolDataItem_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                int ndx = this.lbSymbolDataItem.SelectedIndex;
                if (ndx != -1)
                {
                    Node nd = (Node)this.lbSymbolDataItem.Items[ndx];
                    sv1.ScrollToHorizontalOffset(nd.X);
                    sv1.ScrollToVerticalOffset(nd.Y);
     
                    // on peut aussi utiliser aussi ce bout de code qui amene  
                    // deplace la fenetre "viewport" du scrollviewer sur l'item ...... 
                    // ListBoxItem lbItemCanvas = (ListBoxItem)this.Canvas_Map.ItemContainerGenerator.ContainerFromIndex(ndx);
                    // if (lbItemCanvas != null)
                    // {
                    //   lbItemCanvas.BringIntoView();
                    // }
                }
            }
            //  deplacer la fenetre "viewport" du scrollviewer
            //  vers le centre du canvas
            private void btnToCentreCanvas_Click(object sender, RoutedEventArgs e)
            {
                    sv1.ScrollToHorizontalOffset(this.Canvas_Map.Width / 2- this.sv1.ViewportWidth/2);
                    sv1.ScrollToVerticalOffset(this.Canvas_Map.Height / 2 - this.sv1.ViewportHeight / 2);
     
            }
     
        }
    }
    bon code.............

Discussions similaires

  1. Réponses: 0
    Dernier message: 11/06/2013, 07h17
  2. Positionner une image selon des coordonnées
    Par abracadabra18 dans le forum Débuter
    Réponses: 12
    Dernier message: 18/06/2012, 12h32
  3. Découper une image selon des coordonnées
    Par Gloria_Im dans le forum Images
    Réponses: 2
    Dernier message: 20/04/2012, 12h54
  4. [HTML] Ouvrir une image avec des dimentions précises
    Par malabarbe dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 06/05/2008, 15h53
  5. Centrer une image sur la hauteur de la page
    Par koKoTis dans le forum Balisage (X)HTML et validation W3C
    Réponses: 7
    Dernier message: 09/01/2008, 20h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo