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


C# List.BinarySearch方法代码示例

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


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

示例1: InitializeEditor


//.........这里部分代码省略.........
              Grid.SetColumn(lineNum, 2 * i);
              grid.Children.Add(lineNum);
              lineNums[i].Add(lineNum);

              var text = new RichTextBox {
            Style = GetStyle("lineText"),
            HorizontalAlignment = HorizontalAlignment.Stretch
              };
              Panel.SetZIndex(text, 5);
              Grid.SetRow(text, 2 * j);
              Grid.SetColumn(text, 1 + 2 * i);
              var doc = new FlowDocument();
              var p = new Paragraph();
              doc.Blocks.Add(p);
              text.Document = doc;
              grid.Children.Add(text);
              lineTexts[i].Add(text);
            }
              }

              // Draw the actual text blocks.
              scrollNavBorders = new List<Border>();
              for (int side = 0; side < 2; side++) {
            int prevLine = 0;
            int lineNum = 1;
            lineNumBackgrounds[side] = new List<Border>();
            lineTextBackgrounds[side] = new List<Border>();
            for (int g = 0; g < content[side].Count; g++) {
              LineBlock lblock = content[side][g];
              for (int i = 0; i < lblock.lines.Count; i++) {
            Line line = lblock.lines[i];
            var p = (Paragraph)lineTexts[side][prevLine + i].Document.Blocks.First();
            foreach (Block b in line.blocks) {
              string text = b.text;
              if (text.EndsWith(SentenceFilter.SentenceDelim)) {
                text = text.Substring(0, text.Length - SentenceFilter.SentenceDelim.Length);
              }
              var run = new Run(text);
              if (b.type != BlockType.Normal) {
                if (lblock.type == BlockType.Conflict || lblock.type == BlockType.Edited) {
                  b.type = lblock.type;
                }
                run.Style = GetStyle("text" + b.type);
              }
              p.Inlines.Add(run);
            }
            lineNums[side][prevLine + i].Text = lineNum++.ToString();
              }

              var numBorder = new Border();
              Panel.SetZIndex(numBorder, 3);
              Grid.SetRow(numBorder, 2 * prevLine);
              Grid.SetColumn(numBorder, side * 2);
              Grid.SetRowSpan(numBorder, 2 * lineCount[g]);
              grid.Children.Add(numBorder);
              lineNumBackgrounds[side].Add(numBorder);

              var textBorder = new Border();
              Panel.SetZIndex(textBorder, 2);
              Grid.SetRow(textBorder, 2 * prevLine);
              Grid.SetColumn(textBorder, side * 2 + 1);
              Grid.SetRowSpan(textBorder, 2 * lineCount[g]);
              grid.Children.Add(textBorder);
              lineTextBackgrounds[side].Add(textBorder);

              if (lblock.type != BlockType.Normal) {
            numBorder.Style = GetStyle("numBackground" + lblock.type);
            textBorder.Style = GetStyle("textBackground" + lblock.type);
            int cIndex = conflictBlocks.BinarySearch(g);
            for (int line = 0; line < lineCount[g]; line++) {
              TextBlock num = lineNums[side][prevLine + line];
              RichTextBox text = lineTexts[side][prevLine + line];
              num.Style = GetStyle("lineNum" + lblock.type);
              text.Style = GetStyle("lineText" + lblock.type);
              if (cIndex >= 0) {
                int mySide = side; // for lambda scoping
                text.PreviewMouseLeftButtonUp += (o, e) => { ChooseConflict(cIndex, mySide); SelectConflict(cIndex, false); };
                text.PreviewMouseDoubleClick += (o, e) => EditConflict(cIndex, mySide);
                // text.ContextMenu = new ContextMenu();
                text.MouseEnter += (o, e) => HoverConflict(cIndex, mySide, true);
                text.MouseLeave += (o, e) => HoverConflict(cIndex, mySide, false);
              }
            }

            if (side == 0) {
              var scrollBorder = new Border();
              Grid.SetRow(scrollBorder, prevLine);
              Grid.SetRowSpan(scrollBorder, lineCount[g]);
              conflictNav.Children.Add(scrollBorder);
              scrollBorder.Style = GetStyle("scrollBorder" + (scrollNavBorders.Count == 0 ? "Active" : ""));
              scrollBorder.MouseUp += (o, e) => SelectConflict(cIndex);
              scrollBorder.ToolTip = String.Format("Conflict {0}/{1}", cIndex+1, conflictBlocks.Count);
              scrollNavBorders.Add(scrollBorder);
            }
              }

              prevLine += lineCount[g];
            }
              }
        }
开发者ID:SciGit,项目名称:scigit-client,代码行数:101,代码来源:TextMergeViewer.cs

示例2: ReloadReserveViewItem


//.........这里部分代码省略.........
                        {
                            viewItem.Height = Settings.Instance.MinHeight;
                        }
                        viewItem.Width = 150;
                        viewItem.LeftPos = leftPos;

                        foreach (ReserveViewItem addItem in tunerAddList)
                        {
                            ReserveData addInfo = addItem.ReserveInfo;
                            Int32 durationAdd = (Int32)addInfo.DurationSecond;
                            DateTime startTimeAdd = addInfo.StartTime;
                            if (addInfo.RecSetting.UseMargineFlag == 1)
                            {
                                if (addInfo.RecSetting.StartMargine < 0)
                                {
                                    startTimeAdd = addInfo.StartTime.AddSeconds(addInfo.RecSetting.StartMargine*-1);
                                    durationAdd += addInfo.RecSetting.StartMargine;
                                }
                                if (addInfo.RecSetting.EndMargine < 0)
                                {
                                    durationAdd += addInfo.RecSetting.EndMargine;
                                }
                            }
                            DateTime endTimeAdd;
                            endTimeAdd = startTimeAdd.AddSeconds(durationAdd);

                            if ((startTimeAdd <= startTime && startTime < endTimeAdd) ||
                                (startTimeAdd < EndTime && EndTime <= endTimeAdd) || 
                                (startTime <= startTimeAdd && startTimeAdd < EndTime) ||
                                (startTime < endTimeAdd && endTimeAdd <= EndTime)
                                )
                            {
                                if (addItem.LeftPos >= viewItem.LeftPos)
                                {
                                    viewItem.LeftPos += 150;
                                    if (viewItem.LeftPos - leftPos >= width)
                                    {
                                        width += 150;
                                    }
                                }
                            }
                        }

                        reserveList.Add(viewItem);
                        tunerAddList.Add(viewItem);

                        //必要時間リストの構築

                        DateTime chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        while (chkStartTime <= EndTime)
                        {
                            int index = timeList.BinarySearch(chkStartTime);
                            if (index < 0)
                            {
                                timeList.Insert(~index, chkStartTime);
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }

                    }
                    tunerInfo.Width = width;
                    leftPos += width;
                }

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    DateTime startTime = item.ReserveInfo.StartTime;
                    if (item.ReserveInfo.RecSetting.UseMargineFlag == 1)
                    {
                        if (item.ReserveInfo.RecSetting.StartMargine < 0)
                        {
                            startTime = item.ReserveInfo.StartTime.AddSeconds(item.ReserveInfo.RecSetting.StartMargine*-1);
                        }
                    }

                    DateTime chkStartTime = new DateTime(startTime.Year,
                        startTime.Month,
                        startTime.Day,
                        startTime.Hour,
                        0,
                        0);
                    int index = timeList.BinarySearch(chkStartTime);
                    if (index >= 0)
                    {
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                    }
                }

                tunerReserveTimeView.SetTime(timeList, true);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                    leftPos,
                    timeList.Count * 60 * Settings.Instance.MinHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:lokippc,项目名称:EDCB,代码行数:101,代码来源:TunerReserveMainView.xaml.cs


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