Beispiel #1
0
        private void Button_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            cm.Items.Clear();

            List <OneLanguage> langs = languagesManager.GetAllOneLanguages();

            StackPanel sp            = null;
            TextBlock  tbName        = null;
            TextBlock  tbCultureName = null;
            CheckBox   cb            = null;

            foreach (var lang in langs)
            {
                sp                   = new StackPanel();
                sp.Orientation       = Orientation.Horizontal;
                sp.Tag               = lang;
                sp.PreviewMouseDown += new MouseButtonEventHandler(sp_PreviewMouseDown);
                tbName               = new TextBlock();
                tbName.Text          = lang.Name;
                cb                   = new CheckBox();
                cb.IsEnabled         = false;

                if (lang.Name == languagesManager.CurrLanguage.Name)
                {
                    cb.IsChecked = true; //this.t
                }
                else
                {
                    cb.IsChecked = false;
                }
                sp.Children.Add(cb);
                sp.Children.Add(tbName);

                if (lang.Culture != null)
                {
                    tbCultureName      = new TextBlock();
                    tbCultureName.Text = " - " + lang.Culture.DisplayName;
                    sp.Children.Add(tbCultureName);
                }

                cm.Items.Add(sp);
            }

            sp = new StackPanel();
            sp.PreviewMouseDown += new MouseButtonEventHandler(sp_PreviewMouseDown);
            tbName      = new TextBlock();
            tbName.Text = "Hide";
            sp.Children.Add(tbName);
            cm.Items.Add(sp);

            //this.Content = Properties.Settings.Default.CurrLang;
        }
        /// <summary>
        /// Обновить список языков
        /// </summary>
        private void RefreshLanguages()
        {
            LanguagesManager lm = new LanguagesManager();

            languages = lm.GetAllOneLanguages();

            SelectedLanguage = lm.CurrLanguage;
        }