当前位置: 首页>>代码示例>>C#>>正文


C# TextBlock.SetResourceReference方法代码示例

本文整理汇总了C#中TextBlock.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.SetResourceReference方法的具体用法?C# TextBlock.SetResourceReference怎么用?C# TextBlock.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextBlock的用法示例。


在下文中一共展示了TextBlock.SetResourceReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VersionsChanged

    protected void VersionsChanged(object sender, EventArgs e)
    {
        if (versions.Count == 0)
            return;
        for (int i = 0; i < _Versions.Count; i++)
        {
            ListViewItem item = _Versions[i];
            Mod mod = ((ModVersionViewModel)item.DataContext).mod;
            if (!versions.Values.Contains(mod))
            {
                _Versions.RemoveAt(i);
                i--;
            }
        }

        List<int> versionKeys = versions.Keys.ToList();
        versionKeys.Sort();
        versionKeys.Reverse();
        ListViewItem[] old = _Versions.ToArray();
        _Versions = new ObservableCollection<ListViewItem>();

        foreach (int n in versionKeys)
        {
            Mod mod = versions[n];
            bool add = true;
            /*foreach (ListViewItem item in _Versions)
            {
                if (item.DataContext == mod)
                {
                    add = false;
                    break;
                }
            }*/
            if (add)
            {
                ListViewItem newItem = new ListViewItem();
                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Vertical;
                newItem.DataContext = new ModVersionViewModel(mod);

                TextBlock label = new TextBlock();
                label.SetBinding(TextBlock.TextProperty, "Version");

                StackPanel panel2 = new StackPanel();
                panel2.Orientation = Orientation.Horizontal;
                TextBlock compatibleLabel = new TextBlock();
                compatibleLabel.SetResourceReference(TextBlock.TextProperty, "Lang.Mods.Labels.Compatible");
                compatibleLabel.FontSize = 14;

                compatibleLabel.Margin = new Thickness(0, 0, 5, 0);
                TextBlock label2 = new TextBlock();
                label2.SetBinding(TextBlock.TextProperty, "Compatible");
                label2.FontSize = 14;

                panel2.Children.Add(compatibleLabel);
                panel2.Children.Add(label2);

                panel.Children.Add(label);
                panel.Children.Add(panel2);

                newItem.Content = panel;
                _Versions.Add(newItem);
            }
        }

        OnPropertyChanged("Versions");

        if (_Initialized)
        {
            DontSaveVersion = true;
                int versionToPrefer = Configuration.GetInt("Mods." + versions[versions.Keys.ToArray()[0]].Game.GameConfiguration.ID + "." + versions[versions.Keys.ToArray()[0]].ID + ".Version");
                bool found = false;
                foreach (ListViewItem item in _Versions)
                {
                    Mod mod = ((ModVersionViewModel)item.DataContext).mod;
                    int build = Mod.Header.ParseModVersion(mod.header.GetVersion());
                    if (build == versionToPrefer)
                    {
                        SelectedVersion = item;
                        found = true;
                    }
                }
                if (!found)
                {
                    if (_Versions.Count > 0)
                        SelectedVersion = _Versions[0];
                    else
                        SelectedVersion = null;
                }
                DontSaveVersion = false;
                OnPropertyChanged("SelectedVersion");
                OnPropertyChanged("Name");
                OnPropertyChanged("Description");
                OnPropertyChanged("Version");
            }
    }
开发者ID:hamada147,项目名称:ModAPI,代码行数:96,代码来源:ModViewModel.cs

示例2: Get_e_24_Items

 private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_24_Items() {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_25 element
     TabItem e_25 = new TabItem();
     e_25.Name = "e_25";
     e_25.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     e_25.SetResourceReference(TabItem.HeaderProperty, "GameText");
     // e_26 element
     Grid e_26 = new Grid();
     e_25.Content = e_26;
     e_26.Name = "e_26";
     e_26.Margin = new Thickness(10F, 10F, 10F, 10F);
     RowDefinition row_e_26_0 = new RowDefinition();
     row_e_26_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_26.RowDefinitions.Add(row_e_26_0);
     RowDefinition row_e_26_1 = new RowDefinition();
     row_e_26_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_26.RowDefinitions.Add(row_e_26_1);
     RowDefinition row_e_26_2 = new RowDefinition();
     row_e_26_2.Height = new GridLength(1F, GridUnitType.Auto);
     e_26.RowDefinitions.Add(row_e_26_2);
     RowDefinition row_e_26_3 = new RowDefinition();
     row_e_26_3.Height = new GridLength(1F, GridUnitType.Auto);
     e_26.RowDefinitions.Add(row_e_26_3);
     RowDefinition row_e_26_4 = new RowDefinition();
     row_e_26_4.Height = new GridLength(1F, GridUnitType.Auto);
     e_26.RowDefinitions.Add(row_e_26_4);
     ColumnDefinition col_e_26_0 = new ColumnDefinition();
     col_e_26_0.Width = new GridLength(58F, GridUnitType.Star);
     e_26.ColumnDefinitions.Add(col_e_26_0);
     ColumnDefinition col_e_26_1 = new ColumnDefinition();
     col_e_26_1.Width = new GridLength(134F, GridUnitType.Star);
     e_26.ColumnDefinitions.Add(col_e_26_1);
     ColumnDefinition col_e_26_2 = new ColumnDefinition();
     col_e_26_2.Width = new GridLength(193F, GridUnitType.Star);
     e_26.ColumnDefinitions.Add(col_e_26_2);
     ColumnDefinition col_e_26_3 = new ColumnDefinition();
     col_e_26_3.Width = new GridLength(192F, GridUnitType.Star);
     e_26.ColumnDefinitions.Add(col_e_26_3);
     ColumnDefinition col_e_26_4 = new ColumnDefinition();
     col_e_26_4.Width = new GridLength(193F, GridUnitType.Star);
     e_26.ColumnDefinitions.Add(col_e_26_4);
     // e_27 element
     TextBlock e_27 = new TextBlock();
     e_26.Children.Add(e_27);
     e_27.Name = "e_27";
     e_27.Margin = new Thickness(0F, 6F, 0F, 5F);
     e_27.VerticalAlignment = VerticalAlignment.Center;
     e_27.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     Grid.SetColumnSpan(e_27, 2);
     e_27.SetResourceReference(TextBlock.TextProperty, "DifficultyText");
     // cbDifficulty element
     ComboBox cbDifficulty = new ComboBox();
     e_26.Children.Add(cbDifficulty);
     cbDifficulty.Name = "cbDifficulty";
     cbDifficulty.Margin = new Thickness(2F, 2F, 2F, 3F);
     cbDifficulty.VerticalAlignment = VerticalAlignment.Center;
     cbDifficulty.ItemsSource = Get_cbDifficulty_Items();
     Grid.SetColumn(cbDifficulty, 2);
     Binding binding_cbDifficulty_SelectedIndex = new Binding("Difficulty");
     cbDifficulty.SetBinding(ComboBox.SelectedIndexProperty, binding_cbDifficulty_SelectedIndex);
     // e_31 element
     TextBlock e_31 = new TextBlock();
     e_26.Children.Add(e_31);
     e_31.Name = "e_31";
     e_31.Margin = new Thickness(0F, 6F, 0F, 5F);
     e_31.VerticalAlignment = VerticalAlignment.Center;
     e_31.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     Grid.SetRow(e_31, 1);
     Grid.SetColumnSpan(e_31, 2);
     e_31.SetResourceReference(TextBlock.TextProperty, "LanguageText");
     // cbLanguage element
     ComboBox cbLanguage = new ComboBox();
     e_26.Children.Add(cbLanguage);
     cbLanguage.Name = "cbLanguage";
     cbLanguage.Margin = new Thickness(2F, 3F, 2F, 2F);
     cbLanguage.VerticalAlignment = VerticalAlignment.Center;
     cbLanguage.ItemsSource = Get_cbLanguage_Items();
     Grid.SetColumn(cbLanguage, 2);
     Grid.SetRow(cbLanguage, 1);
     Binding binding_cbLanguage_SelectedIndex = new Binding("Language");
     cbLanguage.SetBinding(ComboBox.SelectedIndexProperty, binding_cbLanguage_SelectedIndex);
     items.Add(e_25);
     // e_36 element
     TabItem e_36 = new TabItem();
     e_36.Name = "e_36";
     e_36.SetResourceReference(TabItem.HeaderProperty, "VideoText");
     // e_37 element
     Grid e_37 = new Grid();
     e_36.Content = e_37;
     e_37.Name = "e_37";
     e_37.Margin = new Thickness(10F, 10F, 10F, 10F);
     RowDefinition row_e_37_0 = new RowDefinition();
     row_e_37_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_37.RowDefinitions.Add(row_e_37_0);
     RowDefinition row_e_37_1 = new RowDefinition();
     row_e_37_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_37.RowDefinitions.Add(row_e_37_1);
     RowDefinition row_e_37_2 = new RowDefinition();
     row_e_37_2.Height = new GridLength(1F, GridUnitType.Auto);
//.........这里部分代码省略.........
开发者ID:charbean,项目名称:StrategyClean,代码行数:101,代码来源:Options.xaml.cs

示例3: AddLanguageButton

    protected void AddLanguageButton(string LangCode)
    {
        Button newButton = new Button();
        newButton.Style = Application.Current.FindResource("NormalButton") as Style;
        newButton.DataContext = LangCode;
        newButton.Click += RemoveLanguage;
        newButton.Margin = new Thickness(0, 0, 10, 0);

        StackPanel panel = new StackPanel();
        panel.Orientation = Orientation.Horizontal;
        Image image = new Image();
        image.Height = 20;
        BitmapImage source = new BitmapImage();
        source.BeginInit();
        source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_" + LangCode + ".png");
        source.EndInit();
        image.Source = source;
        image.Margin = new Thickness(0, 0, 5, 0);
        panel.Children.Add(image);

        Image image2 = new Image();
        image2.Height = 24;
        BitmapImage source2 = new BitmapImage();
        source2.BeginInit();
        source2.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Icon_Delete.png");
        source2.EndInit();
        image2.Source = source2;
        image2.Margin = new Thickness(5, 0, 0, 0);

        TextBlock label = new TextBlock();
        label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + LangCode);
        panel.Children.Add(label);
        panel.Children.Add(image2);

        newButton.Content = panel;
        _LanguageButtons.Add(newButton);
        _Languages.Add(LangCode);
    }
开发者ID:hamada147,项目名称:ModAPI,代码行数:38,代码来源:ModProjectViewModel.cs


注:本文中的TextBlock.SetResourceReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。