Inheritance: IDisposable
Exemple #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.LanguagesSelectionDialog = ((MetroDemo.ExampleWindows.LanguagesDialog)(target));

            #line 21 "..\..\..\..\Windows\Information.xaml"
                this.LanguagesSelectionDialog.Loaded += new System.Windows.RoutedEventHandler(this.LanguagesDialog_OnLoaded);

            #line default
            #line hidden
                return;

            case 2:
                this.LanguageList = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 3:
                this.OkButton = ((System.Windows.Controls.Button)(target));

            #line 79 "..\..\..\..\Windows\Information.xaml"
                this.OkButton.Click += new System.Windows.RoutedEventHandler(this.OkButton_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.CancelButton = ((System.Windows.Controls.Button)(target));

            #line 80 "..\..\..\..\Windows\Information.xaml"
                this.CancelButton.Click += new System.Windows.RoutedEventHandler(this.CancelButton_OnClick);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.LanguagesSelectionDialog = ((MetroDemo.ExampleWindows.LanguagesDialog)(target));
     
     #line 26 "..\..\..\..\Windows\Languages.xaml"
     this.LanguagesSelectionDialog.Loaded += new System.Windows.RoutedEventHandler(this.LanguagesDialog_OnLoaded);
     
     #line default
     #line hidden
     return;
     case 2:
     this.LanguageList = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 3:
     this.OkButton = ((System.Windows.Controls.Button)(target));
     
     #line 92 "..\..\..\..\Windows\Languages.xaml"
     this.OkButton.Click += new System.Windows.RoutedEventHandler(this.OkButton_Click);
     
     #line default
     #line hidden
     return;
     case 4:
     this.CancelButton = ((System.Windows.Controls.Button)(target));
     
     #line 93 "..\..\..\..\Windows\Languages.xaml"
     this.CancelButton.Click += new System.Windows.RoutedEventHandler(this.CancelButton_OnClick);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
        private void LaunchLanguageDialog()
        {
            try
            {
                if (languagesDialog == null)
                {
                    var currentItems1 = (List<Language>)LanguageList.ItemsSource ?? new List<Language>();

                    var languageList = GlobalObjects.ViewModel.Languages.ToList();
                    foreach (var language in currentItems1)
                    {
                        languageList.Remove(language);
                    }

                    languagesDialog = new LanguagesDialog
                    {
                        LanguageSource = languageList
                    };
                    languagesDialog.Closed += (o, args) =>
                    {
                        languagesDialog = null;
                    };
                    languagesDialog.Closing += (o, args) =>
                    {
                        var currentItems2 = (List<Language>)LanguageList.ItemsSource ?? new List<Language>();

                        if (languagesDialog.SelectedItems?.Count > 0)
                        {
                            currentItems2.AddRange(languagesDialog.SelectedItems);
                        }

                        var selectedLangs = FormatLanguage(currentItems2.Distinct().ToList()).ToList();

                        var selectProductId = GetSelectedProduct();

                        foreach (var languages in selectedLangs)
                        {
                            languages.ProductId = selectProductId;
                        }

                        GlobalObjects.ViewModel.AddLanguages(selectProductId, selectedLangs);

                        foreach (var language in selectedLangs)
                        {
                            GlobalObjects.ViewModel.RemoveAddRemovedLanguage(selectProductId, language); 
                        }
                        
                        LanguageList.ItemsSource = null;
                        LanguageList.ItemsSource = selectedLangs;

                        UpdateXml();
                    };
                }
                languagesDialog.Launch();

            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
        }