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 :

Index was outside the bounds of the array


Sujet :

Windows Presentation Foundation

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut Index was outside the bounds of the array
    Bonjour

    " Tour d'un coup" je me retrouve avec une erreur (dans le error list de visual studio) concernant mon fichier XAML.
    Cette erreure est
    Index was outside the bounds of the array
    Mais lorsque je clique dessus, cela me souligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            <ObjectDataProvider x:Key="odpComboBoxLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
    Je ne voit pas ou est l'erreur dans mon code XAML
    - Cela ne m'empêche pas de compiler mais du coup je n'accède plus aux méthodes des mes ObjectDataProvider.
    - Et le designer refuse de se charger tant que je n'ai pas résolu cette erreur.
    Voicis le contenu de ma page XAML.

    Merci pour votre aide

    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
    <UserControl x:Class="ADManagementIHM.Tabs.UGMTab"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ODP="clr-namespace:ADManagementIHM.ODP"
        xmlns:Styles="clr-namespace:ADManagementIHM.Styles"
        xmlns:Commons="clr-namespace:ADManagementIHM.Common">
        <UserControl.Resources>
            <ObjectDataProvider x:Key="odpComboBoxLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpComboBoxRight"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmUserGroupsLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmUserGroupsRight"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpOrganizationalUnits"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <Styles:UgmStyle x:Key="ugmStyleSelector"/>
            <Styles:UgmImgConverter x:Key="UgmImgConverter"/>
        </UserControl.Resources>
        <Grid Width="671.63" Height="517.298">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="261*" />
                <ColumnDefinition Width="155*" />
                <ColumnDefinition Width="256*" />
            </Grid.ColumnDefinitions>
            <!--Top Radio Buttons-->
            <RadioButton Name="rbUserMode" Height="16" Margin="0,21.671,96.686,0"  VerticalAlignment="Top"  GroupName="UGMMode" Click="rbMode_Checked" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="105.698">User Mode</RadioButton>
            <RadioButton Name="rbGroupMode" Height="16" Margin="35.007,21.671,10.002,0"  VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1">Group Mode</RadioButton>
            <RadioButton Name="rbTemplateMode" Height="16" Margin="125.025,21.671,186.704,0" VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1" Grid.ColumnSpan="2">Template Mode</RadioButton>
     
            <!--OU Comboboxes-->
     
            <ComboBox Name="cbRightOu" 
                      ItemsSource="{Binding}"
                      Margin="0,55.011,0,0"
                      DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      VerticalAlignment="Top"
                      Grid.Column="2" 
                      SelectionChanged="LoadComboBox" Height="21.277" HorizontalAlignment="Left" Width="255.859" />
     
            <ComboBox Name="cbLeftOu"
                      SelectionChanged="LoadComboBox"
                      ItemsSource="{Binding}" DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      Margin="0,55.011,0,0"  VerticalAlignment="Top"
                      />
     
     
            <!--Object Searched Comboboxes-->
            <ComboBox Name="cbListLeft" Height="23" Margin="0,87.769,0,0"
                      Focusable="true"  VerticalAlignment="Top" IsEditable="true"
                      IsReadOnly="False" IsTextSearchEnabled="True" DisplayMemberPath="Cn"
                      ItemsSource="{Binding}"
                      TextBoxBase.TextChanged="cbListLeft_TextChangedEventArgs"
                      DropDownClosed="cbListLeft_DropDownClosed" />
     
            <ComboBox Name="cbListRight" Height="23" Margin="0,87.769,0,0" 
                      VerticalAlignment="Top" Grid.Column="2"
                      IsEditable="True" DropDownClosed="cbListRight_DropDownClosed"
                      IsReadOnly="False" IsTextSearchEnabled="True"
                      DisplayMemberPath="Cn" ItemsSource="{Binding}"
                      SelectionChanged="cbList_SelectionChanged" />
     
     
            <!--Listviews-->
            <ListView Name="lvListLeft" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvLeft">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
     
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvLeft}" />
                        <GridViewColumn  Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvLeft" Click="lvLeftSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox  IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <ListView Name="lvListRight" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}"
                      Grid.Column="2">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvRight">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvRight}" />
                        <GridViewColumn   Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvRight" Click="lvRightSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <!--Actions Buttons-->
            <Button Name="btCompare" Grid.Column="1" Height="23" Margin="35.006,175.035,27.992,0"  VerticalAlignment="Top" Click="btCompare_Click">&lt;&lt; Compare &gt;&gt;</Button>
            <Button Name="btMoveToLeft" Grid.Column="1" Margin="35.007,0,27.992,175.035"  Click="btMoveToLeft_Click"  Height="22.199" VerticalAlignment="Bottom">&lt;&lt;</Button>
            <Button Name="btMoveToRight" Margin="35.007,0,27.992,223.75"  Grid.Column="1" Height="22.199" VerticalAlignment="Bottom" Click="btMoveToRight_Click">&gt;&gt;</Button>
            <Button Name="btHide" Height="23" Margin="35.006,223.378,27.992,0" VerticalAlignment="Top" Grid.Column="1" Click="btHide_Click" Tag="hide">Hide similar</Button>
            <Button Name="btRemSelect" Grid.Column="1" Height="23" Margin="35.006,0,27.993,53.344"  VerticalAlignment="Bottom" Click="btRemSelect_Click">Remove Selected</Button>
        </Grid>
     
    </UserControl>

  2. #2
    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
    C'est quoi le code de UgmProvider ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello
    Merci pour la réponse. Suite à celle-ci j'ai fait un peu de ménage dans mon UGM Provider (code ci dessous). Maintenant l'erreur reste au même endroit mais est devenue.
    Type Not Found In config file
    Mais je n'ai pas d'autres indications et le projet compile toujours
    Merci pour ton aide.

    UGM Provider
    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
     
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using Rcb.ActiveDirectory;
    using Rcb.ActiveDirectory.Objects;
    using System.DirectoryServices;
    using ADManagementRemotInterface;
    using ADManagementIHM.Common;
    using System.Runtime.Remoting.Lifetime;
    using System.Runtime.Remoting;
     
     
    namespace ADManagementIHM.ODP
    {
        public class UgmProvider : ObservableCollection<ADObject>
        {
            private IADMADSearcher _remoteADSearcher;
            static Dictionary<string, ObservableCollection<ADObject>> _lstCbUserResult;
            static Dictionary<string, ObservableCollection<ADObject>> _lstCbUserGroupsResult;
            private ObservableCollection<ADOrganizationalUnit> _CbOuResult;
            //Constructor
            public UgmProvider()
            {            
                //_remoteADSearcher.Hub = ADManagementIHM.Properties.Settings.Default.HubName;
                _remoteADSearcher = (IADMADSearcher)ADMRemoting.GetRemoteObject(typeof(IADMADSearcher));
                _remoteADSearcher.Module = "Ugm";
     
                //This dictionnary is  shared . It avoids to  request the AD Everytime we switch The OU
                if (_lstCbUserResult == null) 
                    _lstCbUserResult = new Dictionary<string, ObservableCollection<ADObject>>();
                if (_lstCbUserGroupsResult == null)
                    _lstCbUserGroupsResult = new Dictionary<string, ObservableCollection<ADObject>>();
     
                _CbOuResult = new ObservableCollection<ADOrganizationalUnit>();
            }
     
            //Method to populate the combobox after "Mode" and the "OU" have been selected
            public ObservableCollection<ADObject> GetDirectoryEntryAdObject(string subOUName, DirectoryEntry entry, Type objectTypeSearched)
            {
     
                    if (objectTypeSearched == typeof(ADUser))
                    {
                        //To avoid reloading the content of the combobox for a specified OU we put the result in a shared list.
                        if (!(_lstCbUserResult.Keys.Contains(subOUName)))
                        {
                            _lstCbUserResult.Add(subOUName, new ObservableCollection<ADObject>());
                            foreach (ADObject adObj in _remoteADSearcher.GetUsers(entry.Path))
                            {
                                _lstCbUserResult[subOUName].Add(adObj);
                            }
                        }
                            return _lstCbUserResult[subOUName];
                    }
     
     
                    if (objectTypeSearched == typeof(ADUserGroup))
                    {
     
                        if (!(_lstCbUserGroupsResult.Keys.Contains(subOUName)))
                        {
                            _lstCbUserGroupsResult.Add(subOUName, new ObservableCollection<ADObject>());
                            foreach (ADObject adObj in _remoteADSearcher.GetUsersGroups(entry.Path))
                            {
                                _lstCbUserGroupsResult[subOUName].Add(adObj);
                            }
                        }
     
                        return _lstCbUserGroupsResult[subOUName];
                    }
                    return null;
            }
     
     
     
            //Overloaded for a list of DirectoryEntries
            public ObservableCollection<ADObject> GetDirectoryEntryAdObject(string subOUName, List<DirectoryEntry> lstEntry, Type objectTypeSearched)
            {
                foreach (DirectoryEntry entry in lstEntry) { GetDirectoryEntryAdObject(subOUName, entry, objectTypeSearched); };
                // Based ont he type searched, We return the corresponding list (ADUser or ADUserGroup)
                if (objectTypeSearched == typeof(ADUser))
                    return _lstCbUserResult[subOUName];
                else if (objectTypeSearched == typeof(ADUserGroup))
                    return _lstCbUserGroupsResult[subOUName];
                else return null;
            }
     
            //Methode to retreive the memberOf the Object selected in the combobox
            public ObservableCollection<ADObject> GetObjectMemberOf(DirectoryEntry entry, ADObject adObj)
            {
                ObservableCollection<ADObject> colResults = new ObservableCollection<ADObject>();
                // If the adObj is an UserGroup we have to retreived the potential users members as well
                if (adObj.IsUserGroup())
                {
                    ADUserGroup castedAdUserGroup = (ADUserGroup)adObj;
                    foreach (ADObject user in _remoteADSearcher.GetUsers(castedAdUserGroup))
                        colResults.Add(user);
     
                    foreach (ADObject group in _remoteADSearcher.GetGroups(castedAdUserGroup))
                        colResults.Add(group);
                }
     
     
     
                // If the adObj is an user we have to retreived the groups he's memberOf
                if (adObj.IsUser())
                {
                    ADUser castedUser = (ADUser)adObj;
                    foreach (ADObject user in _remoteADSearcher.GetGroups(castedUser))
                        colResults.Add(user);
                }
                return colResults;
            }
     
            //Methode of the objectDataProvider to retreive a list of UserGroups to populate the listbox
            public ObservableCollection<ADOrganizationalUnit> GetAllOU()
            {
                ObservableCollection<ADOrganizationalUnit> colResults = new ObservableCollection<ADOrganizationalUnit>();
                foreach (ADOrganizationalUnit obj in _remoteADSearcher.GetAllOU())
                    colResults.Add(obj);
                return colResults;
            }
     
     
            //Method to retreived the Template Groups
            public ObservableCollection<ADUserGroup> GetTemplateGroups()
            {
                ObservableCollection<ADUserGroup> colResults = new ObservableCollection<ADUserGroup>();
                foreach (ADUserGroup obj in _remoteADSearcher.GetUgmTemplateGroups())
                    colResults.Add(obj);
                return colResults;
            }
     
        }
    }

  4. #4
    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
    Cela viendrait de cette ligne là que cela ne m'étonnerais pas:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    _remoteADSearcher = (IADMADSearcher)ADMRemoting.GetRemoteObject(typeof(IADMADSearcher));
    C'est quoi ces objets:
    - ADMRemoting.GetRemoteObject
    - IADMADSearcher

    ?

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello
    Bien IADMADSearcher c'est une interface.
    Vu que mon projet utilise le .Net remoting, j'utilise cette IADMADSearcher pour me connecter à mon serveur qui me crée un objet proxy. Ce qui me permet ensuite d'instancier mes méthodes.
    Cependant j'utilisai déjà cet objet avant que cela plante.

  6. #6
    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
    Et si tu met le code qui est dans le constructeur en commentaire ?

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello

    Merci, effectivement l'erreur est partie........ mais m'en a apporté une autre ;-)
    je l'ai mise en pièce jointe. C'est ce que j'obtiens quand je charge le designer

    et voicis ci dessous le code du converter pour lequel l'exception est jeté.
    Aurais tu une idée ?

    Merci d'avance !

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Data;
    using System.Windows.Media.Imaging;
    using Rcb.ActiveDirectory.Objects;
    using System.Windows;
    using System.IO;
     
    namespace ADManagementIHM.Styles
    {
        public class UgmImgConverter : IValueConverter
        {
            #region IValueConverter Members
     
            public object Convert(object value, Type targetType,
                object parameter, System.Globalization.CultureInfo culture)
            {
                string resourcesPath = null;
                ADObject objRetreived = (ADObject)value;
                if (objRetreived.IsUser())
                    resourcesPath = ADManagementIHM.Properties.Settings.Default.UserIconPath;
                if (objRetreived.IsUserGroup())
                    resourcesPath = ADManagementIHM.Properties.Settings.Default.UserGroupIconPath;
     
                Uri uri = new Uri(resourcesPath, UriKind.RelativeOrAbsolute);
                BitmapFrame source = BitmapFrame.Create(uri);
                return source;
     
            }
     
            public object ConvertBack(object value, Type targetType,
                object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
     
            #endregion
     
        }
    }
    Images attachées Images attachées  

  8. #8
    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
    Ca doit venir de cette ligne:

    ADObject objRetreived = (ADObject)value;


    Essaye de jouer avec ca: http://msdn.microsoft.com/en-us/libr...esignmode.aspx

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello

    Effectivement le problème vient de là. lorsque je supprime mon ADObject , cela fonctionne. Cependant en regardant l'erreur c'est bizarre ca dit que y'a pas de référence de fait
    . Pourtant j'ai essayé d'initialiser mon objet
    ADObject objRetreived = null;
    et je ne peut pas faire de new car c'est une classe abstract.
    Effectivement le pb doit venir du fait que le designer ne "connait" pas ce type d'objet nativement et n'arrive pas à l'instancier. Y'aurait il une solution ?
    Merci d'avance.

  10. #10
    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
    Commeje te l'ai dit, utilise ca pour faire le test et savoir si tu es en mode design:

    http://msdn.microsoft.com/en-us/libr...esignmode.aspx

    Si t'es en design mode, tu ne fais rien sinon, tu appelles ton code

  11. #11
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Oups, Désolé j'avais pa vu.

    Cependant je me retrouve toujours avec l'erreur type not found in config file

    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
     
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Data;
    using System.Windows.Media.Imaging;
    using Rcb.ActiveDirectory.Objects;
    using System.Windows;
    using System.IO;
    using System.ComponentModel;
     
    namespace ADManagementIHM.Styles
    {
        public class UgmImgConverter : IValueConverter
        {
            #region IValueConverter Members
            public bool IsInDesignMode { get { return DesignerProperties.GetIsInDesignMode(new DependencyObject()); } } 
     
            public object Convert(object value, Type targetType,
                object parameter, System.Globalization.CultureInfo culture)
            {
                //Necessary for the design mode to not throw exception
                if (!(IsInDesignMode))
                {
                string resourcesPath = null;
                ADObject objRetreived = null;
                objRetreived = (ADObject)value;
                if (objRetreived.IsUser())
                    resourcesPath = ADManagementIHM.Properties.Settings.Default.UserIconPath;
                if (objRetreived.IsUserGroup())
                    resourcesPath = ADManagementIHM.Properties.Settings.Default.UserGroupIconPath;
     
                Uri uri = new Uri(resourcesPath, UriKind.RelativeOrAbsolute);
                BitmapFrame source = BitmapFrame.Create(uri);
                return source;
                }
                return null;
     
            }
     
            public object ConvertBack(object value, Type targetType,
                object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
     
            #endregion
     
        }
    }

  12. #12
    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
    Même avec une recompilation ? Quelle est l'erreur exacte ?

  13. #13
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Je t'ais mis la capture d'écran en copie.
    Le reload ne change rien.

    Nom : error2.JPG
Affichages : 463
Taille : 109,5 Ko

  14. #14
    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
    Tu peux me montrer le code de UHMTab.xaml.cs ?

  15. #15
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Oui
    Voici ci dessous
    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
    <UserControl x:Class="ADManagementIHM.Tabs.UGMTab"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ODP="clr-namespace:ADManagementIHM.ODP"
        xmlns:Styles="clr-namespace:ADManagementIHM.Styles"
        xmlns:Commons="clr-namespace:ADManagementIHM.Common">
        <UserControl.Resources>
            <ObjectDataProvider x:Key="odpUgmAdObjLeftCb"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmAdObjRightCb"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmLeftLv"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmRightLv"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpOrganizationalUnits"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <Styles:UgmStyle x:Key="ugmStyleSelector"/>
            <Styles:UgmImgConverter x:Key="UgmImgConverter"/>
        </UserControl.Resources>
        <Grid Width="671.63" Height="517.298">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="261*" />
                <ColumnDefinition Width="155*" />
                <ColumnDefinition Width="256*" />
            </Grid.ColumnDefinitions>
            <!--Top Radio Buttons-->
            <RadioButton Name="rbUserMode" Height="16" Margin="0,21.671,96.686,0"  VerticalAlignment="Top"  GroupName="UGMMode" Click="rbMode_Checked" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="105.698">User Mode</RadioButton>
            <RadioButton Name="rbGroupMode" Height="16" Margin="35.007,21.671,10.002,0"  VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1">Group Mode</RadioButton>
            <RadioButton Name="rbTemplateMode" Height="16" Margin="125.025,21.671,186.704,0" VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1" Grid.ColumnSpan="2">Template Mode</RadioButton>
     
            <!--OU Comboboxes-->
     
            <ComboBox Name="cbRightOu" 
                      ItemsSource="{Binding}"
                      Margin="0,55.011,0,0"
                      DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      VerticalAlignment="Top"
                      Grid.Column="2" 
                      SelectionChanged="LoadComboBox" Height="21.277" HorizontalAlignment="Left" Width="255.859" />
     
            <ComboBox Name="cbLeftOu"
                      SelectionChanged="LoadComboBox"
                      ItemsSource="{Binding}" DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      Margin="0,55.011,0,0"  VerticalAlignment="Top"
                      />
     
     
            <!--Object Searched Comboboxes-->
            <ComboBox Name="cbListLeft" Height="23" Margin="0,87.769,0,0"
                      Focusable="true"  VerticalAlignment="Top" IsEditable="true"
                      IsReadOnly="False" IsTextSearchEnabled="True" DisplayMemberPath="Cn"
                      ItemsSource="{Binding}"
                      TextBoxBase.TextChanged="combo_TextChangedEventArgs"
                      DropDownClosed="combo_DropDownClosed" />
     
            <ComboBox Name="cbListRight" Height="23" Margin="0,87.769,0,0" 
                      VerticalAlignment="Top" Grid.Column="2"
                      IsEditable="True" DropDownClosed="cbListRight_DropDownClosed"
                      IsReadOnly="False" IsTextSearchEnabled="True"
                      DisplayMemberPath="Cn" ItemsSource="{Binding}"
                      TextBoxBase.TextChanged="combo_TextChangedEventArgs"
                      SelectionChanged="combo_DropDownClosed" />
     
     
            <!--Listviews-->
            <ListView Name="lvListLeft" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvLeft">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
     
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvLeft}" />
                        <GridViewColumn  Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvLeft" Click="lvLeftSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox  IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <ListView Name="lvListRight" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}"
                      Grid.Column="2">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvRight">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvRight}" />
                        <GridViewColumn   Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvRight" Click="lvRightSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <!--Actions Buttons-->
            <Button Name="btCompare" Grid.Column="1" Height="23" Margin="35.006,175.035,27.992,0"  VerticalAlignment="Top" Click="btCompare_Click">&lt;&lt; Compare &gt;&gt;</Button>
            <Button Name="btMoveToLeft" Grid.Column="1" Margin="35.007,0,27.992,175.035"  Click="btMoveToLeft_Click"  Height="22.199" VerticalAlignment="Bottom">&lt;&lt;</Button>
            <Button Name="btMoveToRight" Margin="35.007,0,27.992,223.75"  Grid.Column="1" Height="22.199" VerticalAlignment="Bottom" Click="btMoveToRight_Click">&gt;&gt;</Button>
            <Button Name="btHide" Height="23" Margin="35.006,223.378,27.992,0" VerticalAlignment="Top" Grid.Column="1" Click="btHide_Click" Tag="hide">Hide similar</Button>
            <Button Name="btRemSelect" Grid.Column="1" Height="23" Margin="35.006,0,27.993,53.344"  VerticalAlignment="Bottom" Click="btRemSelect_Click">Remove Selected</Button>
        </Grid>
     
    </UserControl>

  16. #16
    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
    Essaye d'utiliser aussi IsInDesignMode dans le constructeur de UgmProvider.

  17. #17
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Ahhhhh cool ca marche !

    Merci beaucoup.


+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] index was outside of the bounds of the array
    Par labib23dz dans le forum C#
    Réponses: 1
    Dernier message: 09/04/2012, 12h53
  2. Réponses: 0
    Dernier message: 25/01/2012, 15h34
  3. Réponses: 1
    Dernier message: 22/04/2010, 12h24
  4. ERREUR : Index was outside the bounds of the array
    Par maxwel56 dans le forum Linq
    Réponses: 1
    Dernier message: 06/02/2010, 10h40
  5. [VB.NET] Tableau "index was outside of bound array"
    Par guillaume1998 dans le forum VB.NET
    Réponses: 1
    Dernier message: 11/11/2005, 14h07

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