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

Silverlight Discussion :

Comment réaliser une loupe en Silverlight


Sujet :

Silverlight

  1. #1
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut Comment réaliser une loupe en Silverlight
    Bonjour à tous.

    Je dois réaliser une loupe en silverlight (j'ai déjà trouvés des codes) pour que les pages du catalogue virtuel puissent-être lues avec le zoom.
    Les différents scripts que j'ai trouvé font un zoom sur des images, mais pas sur des objets graphique de type bouton. Dans mon cas les page du catalogue sont faites avec des boutons, comme cela dès que l'on clique sur une page, elle se tourne toute seule comme une grande .
    Si quelqu'un à une idée à me proposer, je suis preneur.

    Merci à tous.

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2008
    Messages : 121
    Par défaut
    Tu peux soit mettre ton bouton dans une ViewBox, ou plus propre à mon avis, appliquer un ScaleTransform

  3. #3
    Expert confirmé
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Par défaut
    En appliquant un ScaleTransform et en jouant avec les Clip.

    http://www.vectorlight.net/tutorials...ing_glass.aspx

  4. #4
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par Skyounet Voir le message
    En appliquant un ScaleTransform et en jouant avec les Clip.

    http://www.vectorlight.net/tutorials...ing_glass.aspx
    Le Clip'ping' est inévitable.

  5. #5
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut Merci pour les réponses
    J'ai déjà essayer le script proposé dans le lien. Cela fonctionne très bien quand je place un texte ou une image .
    Malheureusement, j'utilise un bouton pour faire mes pages de mon livre et le script ne s'applique pas dans ce cas de figure.

    Par contre je vais tenter d'utiliser le clipping coomme le signale Doc' house.

    Encore merci pour les informations.

    Ne maitrisant pas encore tout en Silverlight, vos conseils m'aident à progresser.

  6. #6
    Membre Expert
    Avatar de Samuel Blanchard
    Homme Profil pro
    Expert .NET
    Inscrit en
    Février 2010
    Messages
    1 504
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France

    Informations professionnelles :
    Activité : Expert .NET

    Informations forums :
    Inscription : Février 2010
    Messages : 1 504
    Par défaut
    J'ai déjà essayer le script proposé dans le lien. Cela fonctionne très bien quand je place un texte ou une image .
    Malheureusement, j'utilise un bouton pour faire mes pages de mon livre et le script ne s'applique pas dans ce cas de figure.
    Tu veux dire que c'est un problème de click ?

  7. #7
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Citation Envoyé par Skyounet Voir le message
    En appliquant un ScaleTransform et en jouant avec les Clip.

    http://www.vectorlight.net/tutorials...ing_glass.aspx
    Personnellement, j'ai déjà eu à faire un truc similaire et j'était passé par un Pixel Shader: plus hardcore mais ca marche

  8. #8
    Membre Expert
    Avatar de Samuel Blanchard
    Homme Profil pro
    Expert .NET
    Inscrit en
    Février 2010
    Messages
    1 504
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France

    Informations professionnelles :
    Activité : Expert .NET

    Informations forums :
    Inscription : Février 2010
    Messages : 1 504
    Par défaut
    Personnellement, j'ai déjà eu à faire un truc similaire et j'était passé par un Pixel Shader: plus hardcore mais ca marche
    Pas trop gourmand en CPU ?

  9. #9
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Citation Envoyé par Samoteph Voir le message
    Pas trop gourmand en CPU ?
    Non, justement: les Shaders passent par le GPU

  10. #10
    Membre Expert
    Avatar de Samuel Blanchard
    Homme Profil pro
    Expert .NET
    Inscrit en
    Février 2010
    Messages
    1 504
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France

    Informations professionnelles :
    Activité : Expert .NET

    Informations forums :
    Inscription : Février 2010
    Messages : 1 504
    Par défaut
    Non, justement: les Shaders passent par le GPU
    En WPF mais pas en Silverlight, il me semble

  11. #11
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Ah ou, bien vu

    Mais bon, avec l'accélération graphique possible depuis SL3, je suis sur que ca doit bien pouvoir passer par le GPU à un moment

  12. #12
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut
    Je vais tenter le PixelShader.

  13. #13
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Tiens nous au courant de ton avancement

  14. #14
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut
    Re-Bonjour,

    Je bloque complètement .

    J'ai essayer un nouveau script, la loupe fonctionne super bien sur des objets de type images, rectangles, bref sur tous les objets n'ayant aucune interaction avec l'utilisateur.
    Dans cette "loupe" chaque bouton devient invisible .

    J'ai honte de sécher lamentablement sur quelque chose comme cela .

  15. #15
    Expert confirmé
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Par défaut
    Montre nous ton code.

  16. #16
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut Les sources de mon code
    Voici mon code source (Désolé pour la longueur du texte ):

    Page.xaml (En pièce jointe elle se nomme Page.xml au lieu de Page.xaml)
    Code xml : 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
     
    <UserControl
        xmlns="http://schemas.microsoft.com/client/2007" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:SLMitsuControls;assembly=SLMitsuControls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="SLBookDemoApp.Page"
        Width="1024" Height="768" Loaded="UserControl_Loaded" HorizontalAlignment="Center" VerticalAlignment="Center">
        <UserControl.Resources>
            <Style x:Key="ButtonGlassOrbTemplate" TargetType="Button">
                <Setter Property="Background" Value="#FF1F3B53"/>
                <Setter Property="Foreground" Value="#FF000000"/>
                <Setter Property="Padding" Value="3"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9" Offset="0"/>
                            <GradientStop Color="#FF8399A9" Offset="0.375"/>
                            <GradientStop Color="#FF718597" Offset="0.375"/>
                            <GradientStop Color="#FF617584" Offset="1"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.15*"></ColumnDefinition>
                                    <ColumnDefinition Width="0.7*"></ColumnDefinition>
                                    <ColumnDefinition Width="0.15*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.04*"></RowDefinition>
                                    <RowDefinition Height="0.4*"></RowDefinition>
                                    <RowDefinition Height="0.56*"></RowDefinition>
                                </Grid.RowDefinitions>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                                                <ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                <ColorAnimation Duration="0" To="#CCFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                <ColorAnimation Duration="0" To="#7FFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" To="#FF6DBDD1" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Background"/>
                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                                                <ColorAnimation Duration="0" To="#D8FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                <ColorAnimation Duration="0" To="#C6FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                <ColorAnimation Duration="0" To="#8CFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                <ColorAnimation Duration="0" To="#3FFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="FocusStates">
                                        <VisualState x:Name="Focused"/>
                                        <VisualState x:Name="Unfocused"/>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White" CornerRadius="3">
                                    <Grid Background="{TemplateBinding Background}" Margin="1">
     
                                        <Border x:Name="BackgroundAnimation" Background="#FF448DCA" Opacity="0"/>
                                        <Rectangle x:Name="BackgroundGradient">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                    <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                                    <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                                                    <GradientStop Color="#C6FFFFFF" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                    </Grid>
                                </Border>
                                <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="ButtonGlassOrbTpl" TargetType="Button">
            	<Setter Property="Background" Value="#FF1F3B53"/>
            	<Setter Property="Foreground" Value="#FF000000"/>
            	<Setter Property="Padding" Value="3"/>
            	<Setter Property="BorderThickness" Value="1"/>
            	<Setter Property="BorderBrush">
            		<Setter.Value>
            			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            				<GradientStop Color="#FFA3AEB9" Offset="0"/>
            				<GradientStop Color="#FF8399A9" Offset="0.375"/>
            				<GradientStop Color="#FF718597" Offset="0.375"/>
            				<GradientStop Color="#FF617584" Offset="1"/>
            			</LinearGradientBrush>
            		</Setter.Value>
            	</Setter>
            	<Setter Property="Template">
            		<Setter.Value>
            			<ControlTemplate TargetType="Button">
            				<Grid>
            					<Grid.RowDefinitions>
            						<RowDefinition Height="0.04*"/>
            						<RowDefinition Height="0.4*"/>
            						<RowDefinition Height="0.56*"/>
            					</Grid.RowDefinitions>
            					<Grid.ColumnDefinitions>
            						<ColumnDefinition Width="0.15*"/>
            						<ColumnDefinition Width="0.7*"/>
            						<ColumnDefinition Width="0.15*"/>
            					</Grid.ColumnDefinitions>
            					<VisualStateManager.VisualStateGroups>
            						<VisualStateGroup x:Name="CommonStates">
            							<VisualState x:Name="Normal"/>
            							<VisualState x:Name="MouseOver"/>
            							<VisualState x:Name="Pressed"/>
            							<VisualState x:Name="Disabled"/>
            						</VisualStateGroup>
            						<VisualStateGroup x:Name="FocusStates">
            							<VisualState x:Name="Focused"/>
            							<VisualState x:Name="Unfocused"/>
            						</VisualStateGroup>
            					</VisualStateManager.VisualStateGroups>
            					<Ellipse x:Name="BackgroundEllipse" Grid.ColumnSpan="3" Grid.RowSpan="3" Fill="{TemplateBinding Background}"/>
    							<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Left" Margin="3,-4,0,0" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" OpacityMask="Black"/>
    							<Ellipse x:Name="VerticalGradientEllipse" Grid.Column="1" Margin="3,8,5,5" Grid.Row="1">
    								<Ellipse.Fill>
    									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    										<GradientStop Color="#3FFFFFFF" />
    										<GradientStop Color="#00787878" Offset="0.5"/>
    										<GradientStop Color="#99000000" Offset="1" />
    									</LinearGradientBrush>
    								</Ellipse.Fill>
    							</Ellipse>
            				</Grid>
            			</ControlTemplate>
            		</Setter.Value>
            	</Setter>
            </Style>
        </UserControl.Resources>
        <UserControl.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0.518" />
                <GradientStop Color="#FF00BA00" Offset="1" />
                <GradientStop Color="#FF00BA00" Offset="0.002" />
            </LinearGradientBrush>
        </UserControl.Background>
        <Grid Width="1024" Height="768" Background="#FF999999" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Canvas x:Name="RootCanvas" Width="800" Height="720" VerticalAlignment="Top" Background="Transparent" MouseLeftButtonDown="OnMouseLeftButtonDown" MouseMove="OnMouseMove" MouseLeftButtonUp="OnMouseLeftButtonUp">
                <Canvas x:Name="MainCanvas" Width="800" Height="700" Background="White" Canvas.Top="8">
                    <Canvas.Effect>
                        <DropShadowEffect Opacity="0.75"/>
                    </Canvas.Effect>
                    <Canvas Canvas.Left="0" Canvas.Top="20" Width="800" Height="550" Name="canvasCatalogue">
                        <local:UCBook x:Name="book" Canvas.Top="-76" Canvas.Left="-112" >
                        </local:UCBook>
                    </Canvas>
                    <Canvas x:Name="canvasBoutons" Canvas.Left="0" Canvas.Top="650" Width="800" Height="32">
                        <Rectangle Height="34" Canvas.Left="34" Canvas.Top="8" Width="732">
                            <Rectangle.Effect>
                                <DropShadowEffect Opacity="0.75"/>
                            </Rectangle.Effect>
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF001A51" Offset="1"/>
                                    <GradientStop Color="#FF006DAB"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Button Canvas.Left="405" Canvas.Top="13" Height="24" Name="btnNext" Width="24" Click="btnNext_Click" ToolTipService.ToolTip="Page suivante." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <ContentControl>
                                <Image Name="imgNext" Source="/SLBookDemoApp;component/Images/resultset_next.png" />
                            </ContentControl>
                        </Button>
                        <Button Name="bntPrevious" Width="24" Height="24" Canvas.Top="13" Canvas.Left="375" Click="bntPrevious_Click" ToolTipService.ToolTip="Page précédente." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <ContentControl>
                                <Image Name="imgPrevious" Source="/SLBookDemoApp;component/Images/resultset_previous.png" />
                            </ContentControl>
                        </Button>
                        <Button Canvas.Left="640" Canvas.Top="13" Height="24" Name="btnFicheCommunication" Width="24" Click="btnFicheCommunication_Click" ToolTipService.ToolTip="Voir les fiches Communication au format PDF." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <Image Name="imgCommunication" Source="/SLBookDemoApp;component/Images/television.png" />
                        </Button>
                        <Button Canvas.Left="610" Canvas.Top="13" Height="24" Name="btnPlaquette" Width="24" Click="btnPlaquette_Click" ToolTipService.ToolTip="Voir la plaquette au format PDF." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <Image Name="imgPlaquette" Source="/SLBookDemoApp;component/Images/report.png" />
                        </Button>
                        <Button Canvas.Left="670" Canvas.Top="13" Height="24" Name="btnAchat" Width="24" Click="btnAchat_Click" ToolTipService.ToolTip="Voir la fiche achat au format PDF." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <Image Name="imgAchat" Source="/SLBookDemoApp;component/Images/cart1.png" />
                        </Button>
                        <Button Canvas.Left="700" Canvas.Top="13" Height="24" Name="btnRH" Width="24" Click="btnRH_Click" ToolTipService.ToolTip="Voir la fiche Ressources humaines au format PDF." >
                        	<Button.Effect>
                        		<DropShadowEffect/>
                        	</Button.Effect>
                            <Image Name="imgRH" Source="/SLBookDemoApp;component/Images/group.png" />
                        </Button>
                    </Canvas>
                </Canvas>
            </Canvas>
        </Grid>
    </UserControl>

    Page.xaml.cs
    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
    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
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using SLMitsuControls;
    using System.Windows.Media.Imaging;
     
    using System.Windows.Browser;
    using System.ComponentModel;
    using System.Threading;
    using System.Windows.Threading;
     
    namespace SLBookDemoApp
    {
    	public partial class Page : UserControl, IDataProvider
    	{
    		private List<Button> pages;
    		private List<Image> images;
    		private List<Image> lstImg;
    		private Int32 temps = 500;
    		String strPDF;
    		String pdfPlaquette;
    		String pdfCommunication;
    		String pdfAchat;
    		String pdfRH;
    		private IDictionary<String, String> _parameters = null;
     
    		private bool _dragging = false;     // True when magnifying
    		private const double _scale = 4.0;  // Scale factor
    		private double _radius = 160.0;     // Radius of lens
    		private Image _image;               // Magnified image
    		private EllipseGeometry _lens;      // Clipping region
    		private EllipseGeometry _border;    // Lens border
    		private Path _path;                 // Path representing lens border
     
    		public Page(IDictionary<String, String> p)
    		{
    			this._parameters = p;
     
    			InitializeComponent();
     
    			pages = new List<Button>();
    			images = new List<Image>();
    			lstImg = new List<Image>();
     
    			Int32 nbParameter = _parameters.Count();
    			if (nbParameter != 0)
    			{
    				temps = Int32.Parse(_parameters["temps"].ToString());
     
    				pdfPlaquette = _parameters["pdf0"].ToString();
    				if (String.IsNullOrEmpty(pdfPlaquette))
    					btnPlaquette.Visibility = System.Windows.Visibility.Collapsed;
    				else
    					btnPlaquette.Visibility = System.Windows.Visibility.Visible;
     
    				pdfCommunication = _parameters["pdf1"].ToString();
    				if (String.IsNullOrEmpty(pdfCommunication))
    					btnFicheCommunication.Visibility = System.Windows.Visibility.Collapsed;
    				else
    					btnFicheCommunication.Visibility = System.Windows.Visibility.Visible;
     
    				pdfAchat = _parameters["pdf2"].ToString();
    				if (String.IsNullOrEmpty(pdfAchat))
    					btnAchat.Visibility = System.Windows.Visibility.Collapsed;
    				else
    					btnAchat.Visibility = System.Windows.Visibility.Visible;
     
    				pdfRH = _parameters["pdf3"].ToString();
    				if (String.IsNullOrEmpty(pdfRH))
    					btnRH.Visibility = System.Windows.Visibility.Collapsed;
    				else
    					btnRH.Visibility = System.Windows.Visibility.Visible;
     
    				Image img;
    				foreach (KeyValuePair<String, String> item in _parameters)
    				{
     
    					if (item.Key.Contains("page") == true)
    					{
    						//lblParametres.Text += item.Key + " => " + item.Value + "\r\n";
    						img = new Image();
    						BitmapImage bi3 = new BitmapImage();
    						bi3.UriSource = new Uri("http://www.monSite.fr/upload/plaquette/" + item.Value, UriKind.Absolute);
    						img.Stretch = Stretch.Fill;
    						img.Source = bi3;
    						lstImg.Add(img);
    					}
    				}
    			}
     
    			// Create a magnified image for zooming
    			_image = new Image();
    			_image.Width = MainCanvas.Width * _scale;
    			_image.Height = MainCanvas.Height * _scale;
    			_image.Visibility = Visibility.Collapsed;
     
    			// Render the main Canvas into the image at _scale times its nominal size
    			WriteableBitmap bitmap = new WriteableBitmap((int)_image.Width, (int)_image.Height);
    			ScaleTransform transform = new ScaleTransform();
    			transform.ScaleX = transform.ScaleY = _scale;
    			bitmap.Render(MainCanvas, transform);
    			bitmap.Invalidate();
    			_image.Source = bitmap;
     
    			// Apply a clipping region to the magnified image
    			_lens = new EllipseGeometry();
    			_lens.RadiusX = _lens.RadiusY = _radius;
    			_image.Clip = _lens;
     
    			// Add the magnified image to the XAML DOM
    			MainCanvas.Children.Add(_image);
     
    			// Create a Path to represent the edge of the lens
    			_border = new EllipseGeometry();
    			_border.RadiusX = _border.RadiusY = _radius;
     
    			_path = new Path();
    			_path.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x80, 0x80, 0x80));
    			_path.StrokeThickness = 1.0;
    			_path.Data = _border;
    			_path.Visibility = Visibility.Collapsed;
     
    			// Add the Path to the XAML DOM
    			MainCanvas.Children.Add(_path);
    		}
     
    		private void UserControl_Loaded(object sender, RoutedEventArgs e)
    		{
    			Button btn;
    			foreach (Image item in lstImg)
    			{
    				btn = new Button();
    				btn.Content = item;
    				pages.Add(btn);
    			}
     
    			int i = 0;
    			foreach (var b in pages)
    			{
    				if (i % 2 == 0)
    					b.Click += Button_Click;
    				else
    					b.Click += Button_Click_1;
    				i++;
    			}
     
    			book.SetData(this);
    		}
     
    		#region IDataProvider Members
     
    		public object GetItem(int index)
    		{
    			return pages[index];
    		}
     
    		public int GetCount()
    		{
    			return pages.Count;
    		}
     
    		#endregion
     
    		private void Button_Click(object sender, RoutedEventArgs e)
    		{
    			book.AnimateToNextPage(temps);
    		}
     
    		private void Button_Click_1(object sender, RoutedEventArgs e)
    		{
    			book.AnimateToPreviousPage(temps);
    		}
     
    		private void btnNext_Click(object sender, RoutedEventArgs e)
    		{
    			book.AnimateToNextPage(temps);
    		}
     
    		private void bntPrevious_Click(object sender, RoutedEventArgs e)
    		{
    			book.AnimateToPreviousPage(temps);
    		}
     
    		private void btnFicheCommunication_Click(object sender, RoutedEventArgs e)
    		{
    			HtmlPage.Window.Navigate(new Uri("http://www.monSite.fr/upload/plaquette/" + pdfCommunication), "_blank");
    		}
     
    		private void btnPlaquette_Click(object sender, RoutedEventArgs e)
    		{
    			HtmlPage.Window.Navigate(new Uri("http://www.monSite.fr/upload/plaquette/" + pdfPlaquette), "_blank");
    		}
     
    		private void btnAchat_Click(object sender, RoutedEventArgs e)
    		{
    			HtmlPage.Window.Navigate(new Uri("http://www.monSite.fr/upload/plaquette/" + pdfAchat), "_blank");
    		}
     
    		private void btnRH_Click(object sender, RoutedEventArgs e)
    		{
    			HtmlPage.Window.Navigate(new Uri("http://www.monSite.fr/upload/plaquette/" + pdfRH), "_blank");
    		}
     
    		private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    		{
    			double x = e.GetPosition(MainCanvas).X;
    			double y = e.GetPosition(MainCanvas).Y;
     
    			// Display the magnifying glass if the cursor is inside the Canvas
    			if (x > 0.0 || x < MainCanvas.Width || y > 0.0 || y < MainCanvas.Height)
    			{
    				PositionLens(x, y);
    				_image.Visibility = Visibility.Visible;
    				_path.Visibility = Visibility.Visible;
    				((FrameworkElement)sender).CaptureMouse();
    				_dragging = true;
    			}
    		}
     
    		private void OnMouseMove(object sender, MouseEventArgs e)
    		{
    			if (_dragging)
    			{
    				double x = e.GetPosition(MainCanvas).X;
    				double y = e.GetPosition(MainCanvas).Y;
     
    				// Hide the magnifying glass if the cursor has left the Canvas
    				if (x < 0.0 || x > MainCanvas.Width || y < 0.0 || y > MainCanvas.Height)
    				{
    					_image.Visibility = Visibility.Collapsed;
    					_path.Visibility = Visibility.Collapsed;
    					((FrameworkElement)sender).ReleaseMouseCapture();
    					_dragging = false;
    				}
    				else
    					PositionLens(x, y);
    			}
    		}
     
    		private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    		{
    			// Hide the magnifying glass when the mouse button is released
    			if (_dragging)
    			{
    				_image.Visibility = Visibility.Collapsed;
    				_path.Visibility = Visibility.Collapsed;
    				((FrameworkElement)sender).ReleaseMouseCapture();
    				_dragging = false;
    			}
    		}
     
    		private void PositionLens(double x, double y)
    		{
    			_lens.Center = new Point(x * _scale, y * _scale);
    			_border.Center = new Point(x, y);
    			_image.SetValue(Canvas.LeftProperty, (1 - _scale) * x);
    			_image.SetValue(Canvas.TopProperty, (1 - _scale) * y);
    		}
     
    	}
    }
    Fichiers attachés Fichiers attachés

  17. #17
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Je ne vois pas où tu utilises le PixelShader....

  18. #18
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut
    je n'ai pas encore eu le temps d'utiliser le pixel shadder, mais je suis en train de regarder cette voie en ce moment.

  19. #19
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut
    je viens de tenter avec le pixelshader, mais bon je n'y arrive pas.

    Par contre je réussi à faire un zoom (pas jolie, mais il cela zoom in/out) il me reste plus qu'a faire apparaitre les scrollbars verticale et horizontale et j'ai le principal, il me restera plus qu'a faire l'habillage.

  20. #20
    Membre averti
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2002
    Messages : 34
    Par défaut
    Sans vouloir abuser de votre temps,

    parce que là je ne comprends pas trop l'utilisation de l'objet scrollviewer:

    J'ai le morceau de code suivant:
    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
     
    ...
    <Grid Grid.Row="0" >
                <!---->  
                <ScrollViewer x:Name="scroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Background="White" Width="850" Height="650" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <ScrollViewer.Content>                    
                    <Canvas Name="canvasCatalogue">
                    	<Canvas.Effect>
                    		<DropShadowEffect/>
                    	</Canvas.Effect>
                        <Canvas.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform x:Name="scaleTransform" />
                                <SkewTransform  />
                            </TransformGroup>
                        </Canvas.RenderTransform>
                        <local:UCBook x:Name="book" Canvas.Left="-92" Canvas.Top="-65" ></local:UCBook>                 
                    </Canvas>
                    </ScrollViewer.Content>
                    <!---->
                </ScrollViewer>
            </Grid>
    ...
    Je trouve le résultat bizarre, j'ai bien mon zoom (in et out) mais le scrollviewer ne fait pas apparaître les scrollbars Verticale et horizontale.

    Si vous pouvez me dire là ou j'ai mal compris, se serai super cool.

    Encore merci pour les réponse

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Réponses: 12
    Dernier message: 23/01/2008, 09h17
  2. [SQL] Comment réaliser une fonction d'incrementation ?
    Par da_latifa dans le forum Langage SQL
    Réponses: 3
    Dernier message: 30/12/2005, 11h14
  3. Réponses: 4
    Dernier message: 25/12/2005, 18h46
  4. Réponses: 1
    Dernier message: 09/12/2005, 13h43
  5. [FLASH MX] Comment réaliser une forme dentelée
    Par celina5880 dans le forum Flash
    Réponses: 4
    Dernier message: 04/11/2004, 17h48

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