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


C# List.ElementAt方法代码示例

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


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

示例1: ZhenXinHua

 public ZhenXinHua()
 {
     InitializeComponent();
     this.LayoutRoot.Background = new ImageBrush() { ImageSource = new BitmapImage(new Uri("Bg/12.jpg", UriKind.Relative)) };
     db = new DataBase(DataBase.contectString);
     list = db.table1.Where(c => c.IsUse == true).ToList<Table1>();
     count = list.Count;
     int r1 = r.Next(0, count );
     int r2 = r.Next(0, count );
     int r3 = r.Next(0, count );
     content1.Text = list.ElementAt(r1).Content;
     content2.Text = list.ElementAt(r2).Content;
     content3.Text = list.ElementAt(r3).Content;
 }
开发者ID:Kelin-Hong,项目名称:Truth-or-Dare,代码行数:14,代码来源:ZhenXinHua.xaml.cs

示例2: PrepareWeekGrid

        private void PrepareWeekGrid()
        {

            for (int i = 0; i < 4; i++)//Creating listviews where we will display Timesatmps for rows
            {
                ListView list = new ListView();
                //Little bit of tinkering with properties to get desired result;
                list.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
                Label timelabel = new Label();//We will display timestamp on this label
                timelabel.Content = TimePeriodToString((timeperiod)i);//setting
                list.Items.Add(timelabel);//adding label to listview
                TimeStamps.Children.Add(list);//Adding listview to grid;
            }

            Label[] weekDayLabels = new Label[7];//Labels for dispaly weekday name
            List<DayOfWeek> customday = new List<DayOfWeek>();// reshuffling weekady enum to set monday as first day of week
            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek))
                              .OfType<DayOfWeek>()
                              .ToList()//monday is second day by default
                              .Skip(1))//so we skip sunday 
            {
                customday.Add(day);//adding 
            }
            customday.Add(DayOfWeek.Sunday);//and add sunday as last

            for (int i = 0; i < weekDayLabels.Length; i++)//Placing all the labels at grid;
            {
                weekDayLabels[i] = new Label();
                weekDayLabels[i].Background = Brushes.LightBlue;
                weekDayLabels[i].Content = customday.ElementAt(i).ToString();//With appropriate day name;(This will correspond to actual date-weekday)
                DayLabels.Children.Add(weekDayLabels[i]);

            }
        }
开发者ID:McArren,项目名称:GymApp,代码行数:34,代码来源:MainWindow.xaml.cs

示例3: DrawLine

        public static void DrawLine(DrawingContext dc, Point _Start, Point _End, double LineWidth, Brush LineColor, int LineStyle)
        {
            Pen lp = new Pen(LineColor, LineWidth);

            switch (LineStyle)
            {
                case LineStyle_StraightLine :
                    dc.DrawLine(lp, _Start, _End);
                    break;
                case LineStyle_MultipleSegment :
                    double dx = Math.Abs(_Start.X - _End.X);
                    double dy = Math.Abs(_Start.Y - _End.Y);
                    double d1 = Math.Pow(dx * dx + dy * dy, 0.5);
                    double d2 = Math.Pow(5 * 5 + 5 * 5, 0.5);
                    Vector v1 = new Vector(_End.X - _Start.X, _End.Y - _Start.Y);
                    Vector v2 = v1 / (d1 / d2);
                    int count = (int)(d1 / d2);
                    List<Point> S = new List<Point>();
                    List<Point> E = new List<Point>();
                    for (int i = 0; i < count; i += 2)
                    {
                        S.Add(_Start + v2 * i);
                        E.Add(_Start + v2 * i + v2);
                    }
                    for (int i = 0; i < S.Count; i++)
                    {
                        dc.DrawLine(lp, S.ElementAt(i), E.ElementAt(i));
                    }
                    break;
            }
        }
开发者ID:SAM33,项目名称:2016-OOP-UMLEditor,代码行数:31,代码来源:CoreDraw.cs

示例4: Menus

        public Menus()
        {
            InitializeComponent();

            DateBox.FontSize = 40; //the name should be noticiably larger than the other 3 data feilds
            //DateBox.Margin = new Thickness(12, 12, 12, 12);
            List<String> Days = new List<string> { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
            DateBox.ItemsSource = Days;

            if (date3.DayOfWeek == DayOfWeek.Sunday)
                WhatToShow = 6;
            if (date3.DayOfWeek == DayOfWeek.Monday)
                WhatToShow = 0;
            if (date3.DayOfWeek == DayOfWeek.Tuesday)
                WhatToShow = 1;
            if (date3.DayOfWeek == DayOfWeek.Wednesday)
                WhatToShow = 2;
            if (date3.DayOfWeek == DayOfWeek.Thursday)
                WhatToShow = 3;
            if (date3.DayOfWeek == DayOfWeek.Friday)
                WhatToShow = 4;
            if (date3.DayOfWeek == DayOfWeek.Saturday)
                WhatToShow = 5;
            DateBox.SelectedItem = Days.ElementAt(WhatToShow);
        }
开发者ID:jasonkuster,项目名称:EECS-393,代码行数:25,代码来源:Menus.xaml.cs

示例5: SlideShow

 public SlideShow(List<string> SrcList, int CurrSrc, MainWindow MainImageWindow)
     : this()
 {
     this.SrcList = SrcList;
     this.CurrSrc = CurrSrc;
     this.MainImageWindow = MainImageWindow;
     ImageBox.Source = new BitmapImage(new Uri(SrcList.ElementAt(CurrSrc)));
     Timer.Start();
 }
开发者ID:dashkoalexander,项目名称:Image-Viewer,代码行数:9,代码来源:SlideShow.xaml.cs

示例6: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            List<Tower> towers = new List<Tower>();
            List<Phone> phones = new List<Phone>();
            List<ARenderObject> renderTowers = new List<ARenderObject>();
            List<ARenderObject> renderPhones = new List<ARenderObject>();

            towers.Add(new Tower(12));
            towers.Add(new Tower(15));
            towers.Add(new Tower(55));
            towers.Add(new Tower(55));
            towers.Add(new Tower(55));

            phones.Add(new Phone());
            phones.Add(new Phone());
            phones.Add(new Phone());

            phones.ElementAt(0).AddSubject(towers.ElementAt(0));
            foreach (Tower t in towers)
            {
                renderTowers.Add(new RenderTower(t, Carrier));
            }
            foreach (Phone p in phones)
            {
                renderPhones.Add(new RenderPhone(p, Carrier));
            }
            foreach (ARenderObject renderPhone in renderPhones)
            {
                RenderPhone rp = (RenderPhone)renderPhone;
                rp = new RenderLabelPhone(rp);
            }
            renderTowers.ElementAt(0).SetLocation(200, 20);
            renderTowers.ElementAt(1).SetLocation(20, 120);
            renderTowers.ElementAt(2).SetLocation(145, 205);
            renderTowers.ElementAt(3).SetLocation(30, 407);
            renderTowers.ElementAt(4).SetLocation(160, 500);
            renderPhones.ElementAt(0).SetLocation(19, 44);
            renderPhones.ElementAt(1).SetLocation(69, 224);
            renderPhones.ElementAt(2).SetLocation(269, 324);

            controlTower = new ControlTower(renderTowers, renderPhones);
        }
开发者ID:duoduo3369,项目名称:javaExercise,代码行数:43,代码来源:MainWindow.xaml.cs

示例7: Login_Click

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string s = "";
            //string fn = @"C:\Windows\Temp\user.txt";
            string path = Directory.GetCurrentDirectory();
            string file = path + @"account.txt";

            List<string> user = new List<string>();
            List<string> pass = new List<string>();
            try
            {
                using (StreamReader sr = new StreamReader(file, true))
                {
                    while (sr.EndOfStream == false)
                    {
                        s = sr.ReadLine();
                        string[] ss = s.Split(',');
                        user.Add(ss[0]);
                        pass.Add(ss[1]);
                    }
                }
            }
            catch (System.IO.DirectoryNotFoundException ex)
            {
                File.Create(file);
            }
            if(user.Contains(Username.Text))
            {
                for (int i = 0; i < user.Count; i++)
                {
                    if (Username.Text == user.ElementAt(i))
                    {
                        if (Password.Text == pass.ElementAt(i))
                        {
                            this.Hide();
                            Properties.Settings.Default.Save();
                            System.Windows.MessageBox.Show("Login Successful");
                            this.Show();
                        }
                        else
                        {
                            MessageBlock.Text = "Sorry wrong Password";
                        }
                    }
                }
            }
            else
            {
                MessageBlock.Text = "Sorry wrong Username";
            }
        }
开发者ID:huytrinh93,项目名称:C-Sharp,代码行数:51,代码来源:MainWindow.xaml.cs

示例8: composeThingImageDetailPageUrlsArgument

 private String composeThingImageDetailPageUrlsArgument(List<String> thingAllImageDetailPageUrls)
 {
     StringBuilder argumentBuilder = new StringBuilder();
     int urlCount = thingAllImageDetailPageUrls.Count;
     for (int x = 0; x < urlCount; x++)
     {
         argumentBuilder.Append(thingAllImageDetailPageUrls.ElementAt(x));
         if (x < (urlCount - 1))
         {
             argumentBuilder.Append('|');
         }
     }
     return argumentBuilder.ToString();
 }
开发者ID:MarioBoehmer,项目名称:ThingiBrowse,代码行数:14,代码来源:DetailsPage.xaml.cs

示例9: setNetworks

        public void setNetworks(List<ZeroTierNetwork> networks)
        {
            this.wrapPanel.Children.Clear();
            if (networks == null)
            {
                return;
            }

            for (int i = 0; i < networks.Count; ++i)
            {
                this.wrapPanel.Children.Add(
                    new NetworkInfoView(
                        handler,
                        networks.ElementAt<ZeroTierNetwork>(i)));
            }
        }
开发者ID:asbjornenge,项目名称:ZeroTierOne,代码行数:16,代码来源:NetworksPage.xaml.cs

示例10: PanoramaDieta

 public PanoramaDieta()
 {
     InitializeComponent();
     ListaRefeicao = (Application.Current as App).ListaRefeicao;
     this.ItemCafe.DataContext = ListaRefeicao.ElementAt(0);
     this.itemLanche.DataContext = ListaRefeicao.ElementAt(1);
     this.itemAlmoco.DataContext = ListaRefeicao.ElementAt(2);
     this.itemLancheTarde.DataContext = ListaRefeicao.ElementAt(3);
     this.itemJanta.DataContext = ListaRefeicao.ElementAt(4);
     this.itemCeia.DataContext = ListaRefeicao.ElementAt(5);
     lerRefeicoes();
 }
开发者ID:CarlosMota,项目名称:Dieta,代码行数:12,代码来源:PanoramaDieta.xaml.cs

示例11: WordGenerator

        private void WordGenerator(int length)
        {
            List<string> neededwords = new List<string>();
            string pathtofile = @"../../words.txt";
            string[] allwords = File.ReadAllLines(pathtofile);

            for (int i = 0; i < allwords.Length; i++)
            {
                if (allwords[i].Length == length)
                {
                    neededwords.Add(allwords[i]);
                }
            }

            Random rand2 = new Random();
            int temp2 = rand2.Next(0, neededwords.Count + 1);
            hiddenword = neededwords.ElementAt(temp2);
        }
开发者ID:CreamyVinyl,项目名称:bulls_n_cows,代码行数:18,代码来源:Letters.xaml.cs

示例12: LearningWindow

        public LearningWindow(String style, int type, ListBox list, ComboBox choosenType)
        {
            InitializeComponent();
            selectedStyle.Content = style;
            ts = DateTime.Now;
            this.type = type;
            this.selectedType = choosenType.SelectedIndex;
            foreach(object ob in list.SelectedItems)
                selectedGroups.Add((Group)ob);
            if(selectedGroups.Count==1)
                basicLanguage.KeyDown += new KeyEventHandler(basicLanguage_KeyDown);
            else if (selectedGroups.Count > 1)
            {
                foreach (Group p in selectedGroups)
                    groupsWithResult.Add(p, new Result());
                basicLanguage.KeyDown += new KeyEventHandler(basicLanguageMultiple_KeyDown);
            }
            SqlAccess sql = new SqlAccess();

            if (this.type == 1) {

                Random random = new Random();
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                if(selectedType==0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;

            }
            else if (this.type == 2)
            {

                Random random = new Random();
                //int randomNumber = random.Next(0, 100);
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                if (selectedType == 0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;

            }
            else if (this.type == 3) {
                label5.Visibility = Visibility.Visible;

                Random random = new Random();
                //int randomNumber = random.Next(0, 100);
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                label5.MouseDown += new MouseButtonEventHandler(label5_MouseDown );
                if (selectedType == 0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;
            }
        }
开发者ID:kajzur,项目名称:language-worker,代码行数:69,代码来源:LearningWindow.xaml.cs

示例13: setSelectedProgramme

        private void setSelectedProgramme()
        {
            List<CourseProgrammePart> programmeParts = DatabaseConnection.readCourseProgrammePart(departmentWindow.selectedProgramme);

            // Clear tree before repopulating
            //
            treeView.Items.Clear();

            // Count the number of parts of the programme
            //
            List<String> listOfParts = new List<String>();
            foreach(CourseProgrammePart courseProgrammePart in programmeParts)
            {
                bool isPartFound = false;
                foreach(String part in listOfParts)
                {
                    if (courseProgrammePart.part == part)
                    {
                        isPartFound = true;
                        break;
                    }
                }

                if (!isPartFound)
                {
                    listOfParts.Add(courseProgrammePart.part);
                }
            }

            TreeViewItem[] partItems = new TreeViewItem[listOfParts.Count];
            for (int i = 0; i < partItems.Length; i++)
            {
                if (partItems[i] == null)
                {
                    partItems[i] = new TreeViewItem();
                }

                partItems[i].IsExpanded = false;

                // Create stack panel
                //
                StackPanel stack = new StackPanel();
                stack.Orientation = Orientation.Horizontal;
                var background = new SolidColorBrush(Colors.White);
                stack.Background = background;
                background.Opacity = 100;

                // Create Image
                //
                //Image image = new Image();
                //image.Source = new BitmapImage(new Uri(BasicManipulation.Properties.Resources.programmeIcon));

                // Part Label
                //
                Label partLabel = new Label();
                partLabel.Content = "PART " + listOfParts.ElementAt(i);

                List<Course> programmeCourses = DatabaseConnection.readCoursesUsingProgrammePart(departmentWindow.selectedProgramme, listOfParts.ElementAt(i));
                foreach(Course programmeCourse in programmeCourses)
                {
                    TreeViewItem programmeCourseItem = new TreeViewItem();

                    programmeCourseItem.IsExpanded = false;

                    createCourseListButton(programmeCourseItem, BasicManipulation.Properties.Resources.programmeIcon, programmeCourse.id);

                    partItems[i].Items.Add(programmeCourseItem);
                }

                // Add into stack
                //stack.Children.Add(image);
                stack.Children.Add(partLabel);

                // assign stack to header
                partItems[i].Header = stack;

                treeView.Items.Add(partItems[i]);
            }
        }
开发者ID:ebaguia,项目名称:CareerPath,代码行数:79,代码来源:ProgrammeWindow.xaml.cs

示例14: createMovie

 /** Metoda care se foloseste de bibliotecile AviManager pentru a
  * crea un stream video dintr-o lista de imagini format bitmap.
  **/
 private void createMovie(String fileName, List<Bitmap> images)
 {
     AviManager aviManager = new AviManager(fileName, false);
     VideoStream videoStream = aviManager.AddVideoStream(false, 30, images.ElementAt(0));
     foreach (var image in images)
     {
         if (finalFrames.IndexOf(image) != 0)
         {
             videoStream.AddFrame(image);
         }
     }
     aviManager.Close();
 }
开发者ID:pickachumcm,项目名称:KinectMovie,代码行数:16,代码来源:MainWindow.xaml.cs

示例15: updateMemberList

 private void updateMemberList(List<string> ms)
 {
     this.dispatcher.Invoke((Action)(() =>
     {
         members_textBlock.Text = "";
         for (int i = 1; i <= ms.Count; i++) 
         {
             members_textBlock.Text += "  "+i +" : "+ ms.ElementAt(i-1) + "\n";
         }
     }));
 }
开发者ID:jianfeipan,项目名称:visualstudio_.NET,代码行数:11,代码来源:MainWindow.xaml.cs


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