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


C# List.IndexOf方法代码示例

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


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

示例1: OnBrowse

        private void OnBrowse(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            dialog.DefaultExt = "Image files (jpg, gif, png)";
            dialog.Filter = "Image files|*.jpg; *.jpeg; *.gif; *.png;";

            Nullable<bool> result = dialog.ShowDialog();

            if (result.Value == true)
            {
                string directory = System.IO.Path.GetDirectoryName(dialog.FileName);
                images = Directory.EnumerateFiles(directory).Where
                    (
                        filename => filename.EndsWith(".jpg")
                        || filename.EndsWith(".jpeg")
                        || filename.EndsWith(".gif")
                        || filename.EndsWith(".png")
                    )
                    .ToList<string>();

                OpenImage(images.IndexOf(dialog.FileName));
            }
        }
开发者ID:Pimple,项目名称:My-Coding-Misadventures-Documented,代码行数:25,代码来源:MainWindow.xaml.cs

示例2: DetectionButtonsControl

        public DetectionButtonsControl()
        {
            double imageWidth = 10;
            double imageHeight = 10;
            double buttonWidth;
            double smallDelimiter = 6 / 100 * imageWidth;
            double largeDelimiter = 8 / 100 * imageWidth;
            InitializeComponent();
            Button startButton = new Button();
            Button nextButton = new Button();
            Button backButton = new Button();
            Button stopButton = new Button();
            this.ButtonsStackPanel.Children.Add(startButton);
            this.ButtonsStackPanel.Children.Add(nextButton);
            this.ButtonsStackPanel.Children.Add(backButton);
            this.ButtonsStackPanel.Children.Add(stopButton);

            List<Button> buttons = new List<Button>();
            buttonWidth = (imageWidth - 2 * smallDelimiter - (buttons.Count - 1) * largeDelimiter) / buttons.Count;
            foreach (Button b in buttons)
            {

                if (buttons.IndexOf(b) == 1)
                {
                    //b.xPos = imageWidth + smallDelimiter;
                }
                else
                {
                    //b.xPos = imageWidth + largeDelimiter;
                }
            }
        }
开发者ID:kovacshuni,项目名称:slrt,代码行数:32,代码来源:DetectionButtonsControl.xaml.cs

示例3: ConvertTagsToHtml

        public IEnumerable<string> ConvertTagsToHtml(string[] lines)
        {
            var tables = new Dictionary<string, List<string>>();
            var lastLine = "";
            var tableCount = 0;

            var list = new List<string>();
            foreach (var line in lines)
            {

                if (line.StartsWith("<F>") && line.Length > 3)
                    list.Add(string.Format("<span>{0}</span>", line[3].ToString().PadLeft(lines.Max(x => x.Length), line[3])));
                if (line.StartsWith("<T>"))
                    list.Add(string.Format("<B>{0}</B>", RemoveTag(line)));
                if (line.StartsWith("<C") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<L") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<EB>"))
                    list.Add("<B>");
                if (line.StartsWith("<DB>"))
                    list.Add("</B>");

                if (line.StartsWith("<J") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                {
                    if (!lastLine.StartsWith("<J"))
                    {
                        tableCount++;
                        list.Add("tbl" + tableCount);
                    }

                    var tableName = "tbl" + tableCount;
                    if (!tables.ContainsKey(tableName))
                        tables.Add(tableName, new List<string>());
                    tables[tableName].Add(RemoveTag(line));
                }

                if (!line.Contains("<") && !string.IsNullOrEmpty(line.Trim()))
                    list.Add(line);

                lastLine = line;
            }

            foreach (var table in tables)
            {
                list.InsertRange(list.IndexOf(table.Key), GetTableLines(table.Value, Printer.CharsPerLine));
                list.Remove(table.Key);
            }

            for (int i = 0; i < list.Count; i++)
            {
                list[i] = list[i].TrimEnd();
                if ((!list[i].ToLower().EndsWith("<BR>") && RemoveTag(list[i]).Trim().Length > 0) || list[i].Trim().Length == 0)
                    list[i] += "<BR>";
                list[i] = list[i].Replace(" ", "&nbsp;");
            }

            return list;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:59,代码来源:HtmlPrinterJob.cs

示例4: SetComponentLinks

        internal void SetComponentLinks(IEnumerable<AbstractEndpoint.IAbstractComponentLink> componentLinks)
        {
            var links = new List<ComponentsOrderingViewModel>();

            var setOrder = new Action(() =>
                {
                    var worker = new BackgroundWorker();
                    worker.DoWork += (e, s) =>
                    {
                        foreach (var cl in links.AsEnumerable().Reverse())
                        {
                            cl.Link.Order = links.IndexOf(cl) + 1;
                        }
                    };
                    worker.RunWorkerAsync();
                });
            foreach (var cl in componentLinks.OrderBy(x => x.Order))
            {
                var vm = new ComponentsOrderingViewModel { Link = cl };
                links.Add(vm);
                vm.UpCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex - 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) > 0);
                vm.DownCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex + 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) < links.Count - 1);
            }
            this.ComponentList.ItemsSource = links;
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:45,代码来源:ComponentsOrderingView.xaml.cs

示例5: Save

 public int Save(Score score)
 {
     TheScores.Add(score);
     TheScores = TheScores.OrderBy(s => s.ElapsedTime).ToList();
     var position = TheScores.IndexOf(score) + 1;
     File.WriteAllText(scoresPath, JsonConvert.SerializeObject(TheScores), Encoding.UTF8);
     WriteLeaderBoard(position);
     return position;
 }
开发者ID:andmos,项目名称:NDC2015,代码行数:9,代码来源:Scores.cs

示例6: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            newItem = GlobalVars.item;
            GlobalVars.item = null;
            Item item = Database_Functions.GetItem(newItem.Item_ID);
            this.item_name.Text = item.Title;
            this.textBlock_description.Text = item.Description;
            textBlock_total.Text = Database_Functions.GetItemCost(item.ID).ToString("c");
            IList<Transaction> transactions = Database_Functions.GetItemTransactions(item.ID);
            IList<TextBlock> names = new List<TextBlock>();
            IList<TextBlock> amounts = new List<TextBlock>();
            IList<string> names_only = new List<string>();
            IList<Decimal> amounts_only = new List<Decimal>();
            int index = -1;

            foreach (Transaction t in transactions)
            {
                TextBlock name = new TextBlock();
                name.FontSize = 20;
                name.Margin = new Thickness(9, 64, 0, 0);
                name.Text = Database_Functions.GetMember((int)t.MemberID).Name;
                TextBlock amount = new TextBlock();
                amount.FontSize = 28;
                amount.Margin = new Thickness(9, 0, 0, 0);
                amounts_only.Add(t.Amount);
                if (t.Amount < 0)
                    amount.Text = "-" + (t.Amount * -1).ToString("c");
                else
                    amount.Text = t.Amount.ToString("c");
                if (!names_only.Contains(name.Text))
                {
                    names_only.Add(name.Text);
                    names.Add(name);
                    ContentPanel.Children.Add(name);
                    amounts.Add(amount);
                    ContentPanel.Children.Add(amount);
                }
                else
                {
                    index = names_only.IndexOf(name.Text);
                    Decimal temp = amounts_only[index] + t.Amount;
                    if (temp < 0)
                        amounts[index].Text = "-" + (temp * -1).ToString("c");
                    else
                        amounts[index].Text = temp.ToString("c");
                }
            }
        }
开发者ID:UWbadgers16,项目名称:BillSync,代码行数:50,代码来源:ItemDetails.xaml.cs

示例7: Classement

 public Classement(List<Joueur> classement)
 {
     InitializeComponent();
     int i = 0;
     int k = 1;
     foreach (Joueur j in classement)
     {
         classementPanel.Children.Add(new JoueurClassement(j,i+1));
         int index = classement.IndexOf(j);
         if (index+1 < classement.Count && classement[index + 1].Points < j.Points)
             i=k;
         k++;
     }
 }
开发者ID:BenjBoug,项目名称:INSA-SmallWorld,代码行数:14,代码来源:Classement.xaml.cs

示例8: Messages

        public Messages()
        {
            _messages = CMClient.Instance().LastDisplayContext.Messages;

            Message message = _messages.FirstOrDefault(item => item.Id == CMClient.Instance().LastDisplayContext.InitialMessageId);
            if(message != null)
            {
                _currentMessage = _messages.IndexOf(message);
            }

            DataContext = this;
            InitializeComponent();

            ShowMessage();
        }
开发者ID:clyngmobile,项目名称:wp,代码行数:15,代码来源:Messages.xaml.cs

示例9: AddListRessultNode

 private List<Models.ResultListNode> AddListRessultNode(List<HtmlNode> listNode)
 {
     List<Models.ResultListNode> list = new List<Models.ResultListNode>();
     try
     {
         foreach (var item in listNode)
         {
             list.Add(new Models.ResultListNode { NameNode = "[" + listNode.IndexOf(item) + "] " + item.Name, InerText = item.InnerText, InerHtml = item.OuterHtml, Items = AddListRessultNode(item.ChildNodes.ToList()) });
             AddListRessultNode(item.ChildNodes.ToList());
         }
     }
     catch
     {
     
     }
    
     return list;
 }
开发者ID:Tuanna123,项目名称:GetValueChirdNode,代码行数:18,代码来源:MainWindow.xaml.cs

示例10: fill

 public void fill()
 {
     LocalList.ItemsSource = null;
     if ((Application.Current as App).estado == Estado.accepted && (Application.Current as App).state == WatcherState.active)
     {
         geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
         loc = loc.OrderBy(i => geolist.IndexOf(new GeoCoordinate() { Latitude = i.latLocal, Longitude = i.longLocal })).ToList();
         for (int i = 0; i < geolist.ToArray().Length; i++)
         {
             loc.ToArray()[i].distance = "~" + Math.Round((geolist.ToArray()[i].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
         }
         LocalList.ItemsSource = loc;
     }
     else
     {
         LocalList.ItemsSource = loc;
     }
 }
开发者ID:Asfiroth,项目名称:MovistApp,代码行数:18,代码来源:MainPage.xaml.cs

示例11: UploadImages

 private void UploadImages()
 {
     List<int> delImage = new List<int>();
     ListingManager listManager = new ListingManager();
     for(int i = 0; i<imageSource.Count; i++)
     {
         if (imageSource[i] == " " || imageSource[i] == "")
         {
             delImage.Add(i);
             listManager.EditListingImage(imageID[i],imageCaptions[i]);
         }
     }
     for (int i = delImage.Count - 1; i >= 0; i--)
     {
         if (delImage.IndexOf(i) != -1)
         {
             imageSource.RemoveAt(i);
             imageCaptions.RemoveAt(i);
         }
     }
         for (int i = 0; i < imageSource.Count; i++)
         {
             Console.WriteLine(i + " New " + imageID[i] + " - " + imageSource[i] + " with " + imageCaptions[i] + " of " + imageSource.Count);
         }
     Overlays.Listings.LoadingOverlay uploadImages = new Overlays.Listings.LoadingOverlay(propertyID, imageSource, imageCaptions);
     uploadImages.Owner = Framework.UI.Controls.Window.GetWindow(this);
     uploadImages.Show();
     (this.Tag as AgentWindow).HideEditListingView();
     (this.Tag as AgentWindow).ShowListingsView();
     ClearView();
 }
开发者ID:gpdiemelkman,项目名称:REII422_DesktopApp,代码行数:31,代码来源:EditListingView.xaml.cs

示例12: splitter_DragDelta

        /// <summary>
        /// This method is called by a splitter when it is dragged
        /// </summary>
        /// <param name="splitter">Dragged splitter</param>
        /// <param name="delta"></param>
        void splitter_DragDelta(object sender, DragDeltaEventArgs e)
        {
            ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter;
            int i = 0;

            //Compute the list of visible children
            List<FrameworkElement> visibleChildren = new List<FrameworkElement>();
            for (i = 0; i < VisualChildrenCount; i++)
            {
                FrameworkElement child = GetVisualChild(i) as FrameworkElement;

                IDockableControl dockableControl = child as IDockableControl;
                if (dockableControl != null &&
                    !dockableControl.IsDocked)
                {
                    if (i == VisualChildrenCount - 1 &&
                        i > 0)
                    {
                        //remove the last splitter added
                        if (visibleChildren.Count > 0 &&
                            visibleChildren.Last<FrameworkElement>() is ResizingPanelSplitter)
                            visibleChildren.RemoveAt(visibleChildren.Count - 1);
                    }
                    else if (i < VisualChildrenCount - 1)
                    {
                        //discard the next splitter
                        i++;
                    }

                    continue;
                }

                visibleChildren.Add(child);
            }

            if (visibleChildren.Count == 0)
                return;

            if (visibleChildren.Last<FrameworkElement>() is ResizingPanelSplitter)
                visibleChildren.RemoveAt(visibleChildren.Count - 1);

            Size[] currentSizes = new Size[visibleChildren.Count];
            double delta = Orientation == Orientation.Horizontal ? e.HorizontalChange : e.VerticalChange;

            if (_childrenFinalSizes == null)
                return;

            _childrenFinalSizes.CopyTo(currentSizes, 0);

            int iSplitter = visibleChildren.IndexOf(splitter);

            Debug.Assert(iSplitter > -1);

            List<FrameworkElement> prevChildren = new List<FrameworkElement>();
            for (i = iSplitter - 1; i >= 0; i--)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is ResizingPanelSplitter)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (prevChildren.Count == 0)
                    {
                        prevChildren.Add(child);
                    }
                    break;
                }
                if (child.IsStar())
                {
                    prevChildren.Add(child);
                }
            }

            List<FrameworkElement> nextChildren = new List<FrameworkElement>();

            for (i = iSplitter + 1; i < visibleChildren.Count; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is ResizingPanelSplitter)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (nextChildren.Count == 0)
                        nextChildren.Add(child);
                    break;
                }
                if (child.IsStar())
                {
                    nextChildren.Add(child);
                }
            }


            double prevMinSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
            double nextMinSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
//.........这里部分代码省略.........
开发者ID:mousetwentytwo,项目名称:test,代码行数:101,代码来源:ResizingPanel.cs

示例13: populatePreBoxFields

        public void populatePreBoxFields()
        {
            type = Treatment.GetTreatmentTypes();
            List<Employee> allEmployees = Employee.GetEmployees();
            wards = Ward.GetWards();
            doctors = new List<string>();
            employeeIDs = new List<int>();

            foreach (Employee employee in allEmployees)
            {
                if (employee.Employee_type == "Doctor")
                {
                    doctors.Add(employee.Lname + ", " + employee.Fname);
                    employeeIDs.Add(employee.Eid);
                }
            }

            boxDoctors.DataContext = doctors;
            boxDoctors.SelectedIndex = employeeIDs.IndexOf(treatment.Doctor);
            boxTreatmentType.DataContext = type;
            boxWard.DataContext = wards;
            boxWard.DisplayMemberPath = "WardName";
            boxWard.SelectedValuePath = "SlugName";
            boxDoctors.Items.Refresh();
            boxTreatmentType.Items.Refresh();
            patient.Select();
            lblName.Content = patient.LastName + ", " + patient.FirstName;
        }
开发者ID:trbielec,项目名称:hospipal,代码行数:28,代码来源:AddTreatment.xaml.cs

示例14: cardView_OnDragging

        void cardView_OnDragging(object sender, EventArgs e)
        {
            lock (cardArrangeLock)
            {
                // First, find the two stacks that the card is hovering above.
                var relevantStacks = new List<CardStack>();
                var yOverlap = new List<double>();
                CardStack resultDeckStack = null;
                double maxOverlap = 0;
                double resultOverlap = 0;

                foreach (var stack in _allCardStacks)
                {
                    Rect rect = stack.BoundingBox;
                    rect.Intersect(new Rect(InteractingCard.Position, new Size(InteractingCard.Width, InteractingCard.Height)));
                    if (rect.Size.Height > 0)
                    {
                        if (stack.Parent != _resultPanel)
                        {
                            relevantStacks.Add(stack);
                            yOverlap.Add(rect.Size.Height);
                        }
                        else if (rect.Size.Width > maxOverlap)
                        {
                            resultDeckStack = stack;
                            maxOverlap = rect.Size.Width;
                            resultOverlap = rect.Size.Height;
                        }
                    }
                }

                if (resultDeckStack != null)
                {
                    relevantStacks.Add(resultDeckStack);
                    yOverlap.Add(resultOverlap);
                }
                Trace.Assert(relevantStacks.Count <= 2 && yOverlap.Count == relevantStacks.Count);

                // Second, set the interacting card of all card stacks accordingly
                foreach (var stack in _allCardStacks)
                {
                    CardInteraction status;
                    if (relevantStacks.Contains(stack) || stack == _sourceDeck)
                    {
                        stack.InteractingCard = InteractingCard;
                        status = CardInteraction.Drag;
                    }
                    else
                    {
                        stack.InteractingCard = null;
                        status = CardInteraction.None;
                    }
                    if (status != stack.CardStatus || status == CardInteraction.Drag)
                    {
                        stack.CardStatus = status;
                        stack.RearrangeCards();
                    }
                }

                // Finally, in the stack with greatest overlapping y-distance, highlight the slot.
                _ResetHighlightSlot();

                if (relevantStacks.Count == 0)
                {
                    _highlightedStack = null;
                }
                else
                {
                    _highlightedStack = relevantStacks[yOverlap.IndexOf(yOverlap.Max())];
                    var highlightedSlot = _stackToSlot[_highlightedStack];
                    if (highlightedSlot.Cards.Count > 0)
                    {
                        int index = Math.Min(_highlightedStack.InteractingCardIndex, highlightedSlot.Cards.Count - 1);
                        _highlightedCardSlot = highlightedSlot.Cards[index];
                        _highlightedCardSlot.CardModel.IsFaded = true;
                    }
                }
            }
        }
开发者ID:pxoylngx,项目名称:sgs,代码行数:79,代码来源:CardArrangeBox.xaml.cs

示例15: watcher_PositionChanged

 void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
 {
     geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
     loc = loc.OrderBy(i => geolist.IndexOf(new GeoCoordinate() { Latitude = i.latLocal, Longitude = i.longLocal })).ToList();
     for (int i = 0; i < geolist.ToArray().Length; i++)
     {
         loc.ToArray()[i].distance = "~" + Math.Round((geolist.ToArray()[i].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
     }
     LocalList.ItemsSource = loc;
 }
开发者ID:Asfiroth,项目名称:MovistApp,代码行数:10,代码来源:MainPage.xaml.cs


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