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


C# Range.Select方法代码示例

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


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

示例1: GetResults

        public IEnumerable<IEnumerable<int>> GetResults(BooleanMatrix pairs, int count, ImmutableSequence<int> current)
        {
            int length = pairs.Width;

            int start;
            if (!current.HasValue)
            {
                start = 0;
            }
            else
            {
                start = current.First();
            }

            var results = new Range(start, length)
                .Where(i => current
                    .All(x => pairs[x, i]));

            if (count == 1)
            {
                return results
                    .Select(i => new ImmutableSequence<int>(i, current));
            }
            else
            {
                return results
                    .SelectMany(i => GetResults(pairs, count - 1, new ImmutableSequence<int>(i, current)));
            }
        }
开发者ID:ckknight,项目名称:ProjectEuler,代码行数:29,代码来源:Problem060.cs

示例2: CalculateResult

        public override object CalculateResult()
        {
            var range = new Range(1, 100, true);

            int sumOfSquares = range.Select(x => x * x).Sum();
            int sum = range.Sum();
            int squareOfSums = sum * sum;

            return squareOfSums - sumOfSquares;
        }
开发者ID:ckknight,项目名称:ProjectEuler,代码行数:10,代码来源:Problem006.cs

示例3: Run

        public long Run()
        {
            IEnumerable<long> range = new Range(m_max+1);

            return range.Sum() * range.Sum() - range.Select(n => n * n).Sum();
        }
开发者ID:bwillard,项目名称:ProjectEuler,代码行数:6,代码来源:Problem6.cs

示例4: SetStyle

        /// <summary>
        /// 虚线:XlBorderWeight=xlHairline
        /// </summary>
        public void SetStyle(Range range)
        {
            range.Select();
            range.HorizontalAlignment = xaLign;
            range.VerticalAlignment = XlHAlign.xlHAlignCenter;
            range.Borders.get_Item(XlBordersIndex.xlEdgeLeft).LineStyle = XlLineStyle.xlContinuous;
            range.Borders.get_Item(XlBordersIndex.xlEdgeRight).LineStyle = XlLineStyle.xlContinuous;
            range.Borders.get_Item(XlBordersIndex.xlEdgeTop).LineStyle = XlLineStyle.xlContinuous;
            range.Borders.get_Item(XlBordersIndex.xlEdgeBottom).LineStyle = XlLineStyle.xlContinuous;
            try
            {
                range.Borders.get_Item(XlBordersIndex.xlInsideHorizontal).LineStyle = XlLineStyle.xlContinuous;
                range.Borders.get_Item(XlBordersIndex.xlInsideVertical).LineStyle = XlLineStyle.xlContinuous;
                range.Borders.get_Item(XlBordersIndex.xlInsideHorizontal).Weight = this.BorderWeight;
                range.Borders.get_Item(XlBordersIndex.xlInsideVertical).Weight = this.BorderWeight;
            }
            catch
            {
            }

            range.Font.Bold = this.IsBold;

            if (this.FontColor.ToArgb() != Color.FromArgb(0, 0, 0, 0).ToArgb())
            {
                range.Font.Color = ColorTranslator.ToOle(this.FontColor);// string.Format("{0},{1},{2}", this.FontColor.R, this.FontColor.B, this.FontColor.G);

            }
            if (this.BgColor.ToArgb() != Color.FromArgb(0, 0, 0, 0).ToArgb())
            {
                range.Interior.Color = ColorTranslator.ToOle(this.BgColor);
            }
            range.Font.Size = this.fontSize;
        }
开发者ID:StephenYang1989,项目名称:AliSearchAnalysis,代码行数:36,代码来源:QItem.cs

示例5: UpdateRangeWithCardsToImport

 private void UpdateRangeWithCardsToImport(Range rangeThatFitsAllCards, string[,] cardsToImport)
 {
     rangeThatFitsAllCards.Value2 = cardsToImport;
     rangeThatFitsAllCards.Select();
     rangeThatFitsAllCards.Columns.AutoFit();
 }
开发者ID:nate250,项目名称:TrelloExcel,代码行数:6,代码来源:ImportCardsPresenter.cs

示例6: CalculateResult

        public override object CalculateResult()
        {
            int[] values = GetText()
                .Split(',')
                .Select(x => int.Parse(x.Trim()))
                .ToArray();

            int[][] secretCodes = new Range('a', 'z', true)
                .SelectMany(a => new Range('a', 'z', true)
                    .SelectMany(b => new Range('a', 'z', true)
                        .Select(c => new[] { a, b, c })))
                .ToArray();

            string[] commonWords = new[] { "the", "of", "to", "and", "a", "in", "is", "it", "you", "that", "he", "was", "for", "on", "are", "with" };

            Regex punctuationRegex = new Regex(@"[^\w\s]+", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
            Regex whitespaceRegex = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
            var possibilities = secretCodes
                .Select(x => new {
                    Code = x,
                    Result = new string(values
                        .Select((c, i) => c ^ x[i % x.Length])
                        .Select(c => (char)c)
                        .ToArray())
                })
                .Select(x => new {
                    x.Code,
                    x.Result,
                    Words = whitespaceRegex.Split(punctuationRegex.Replace(x.Result, string.Empty))
                        .Where(w => w != string.Empty)
                        .ToMultiHashSet(StringComparer.InvariantCultureIgnoreCase),
                })
                .Select(x => new {
                    x.Code,
                    x.Result,
                    x.Words,
                    Value = commonWords
                        .Select(w => x.Words.GetCount(w))
                        .Sum()
                })
                .ToArray();

            var bestPossibility = possibilities
                .Aggregate((a, b) => a.Value > b.Value ? a : b);

            return bestPossibility
                .Result
                .Sum(c => (int)c);
        }
开发者ID:ckknight,项目名称:ProjectEuler,代码行数:49,代码来源:Problem059.cs

示例7: ToDocxImport

        /// <summary>
        /// Convert html to docx - import
        /// </summary>
        /// <param name="control"></param>
        /// <param name="html"></param>
        public void ToDocxImport(Range range, string html, int wiID, string wiField)
        {
            int actionCount = 0;

            string ra = Convert.ToChar(0x000D).ToString() + Convert.ToChar(0x0007).ToString(); // \r\a
            string folderName = Path.GetTempPath() + Guid.NewGuid().ToString(); // temp folder
            string fileName = folderName + "\\temp.docx"; // temp file

            Globals.ThisAddIn.Application.ScreenUpdating = false; // false to update screen

            Microsoft.Office.Interop.Word.Document doc = null;

            try
            {
                CreateTempDocument(html, folderName, fileName);

                // get range to insert
                doc = Globals.ThisAddIn.Application.Documents.Open(fileName, Visible: false, ReadOnly: true);
                Range insert = doc.Content;
                PrepareRange(ref range, ref insert);

                // delete old control
                Globals.ThisAddIn.Application.ActiveDocument.Range(range.Start - 1, range.End + 1).Select();
                Globals.ThisAddIn.Application.Selection.ClearFormatting(); actionCount++;

                // insert range
                range.FormattedText = insert.FormattedText; actionCount++;
                range.LanguageID = WdLanguageID.wdNoProofing;

                foreach (InlineShape image in range.InlineShapes)
                    image.LinkFormat.SavePictureWithDocument = true;

                range.Select();
                ExtendSelection();
                Globals.ThisAddIn.Application.ActiveDocument.Range(range.End, range.End + 1).Delete(); actionCount++;

                // add new control
                Globals.ThisAddIn.AddWIControl(wiID, wiField, range);
            }
            catch(Exception e)
            {
                if (actionCount > 0)
                    Globals.ThisAddIn.Application.ActiveDocument.Undo(actionCount);

                throw new Exception(e.Message);
            }
            finally
            {
                Globals.ThisAddIn.Application.Selection.Collapse();
                Globals.ThisAddIn.Application.ScreenUpdating = true;

                try
                {
                    ((_Document)doc).Close(SaveChanges: false);

                    if (Directory.Exists(folderName))
                        Directory.Delete(folderName, true);
                }
                catch { }
            }
        }
开发者ID:SoftServeInc,项目名称:SALMA,代码行数:66,代码来源:HtmlToDocx.cs

示例8: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            if (myArray == null)
            {
                MessageBox.Show("请先读取数据");
                return;
            }

            //開啟一個新的應用程式
            myExcel = new Excel.Application();
            //加入新的活頁簿
            myExcel.Workbooks.Add(true);
            //停用警告訊息
            myExcel.DisplayAlerts = true;
            //讓Excel文件可見
            myExcel.Visible = true;
            //引用第一個活頁簿
            myBook = myExcel.Workbooks[1];
            //設定活頁簿焦點
            myBook.Activate();
            //加入新的工作表在第1張工作表之後
            myBook.Sheets.Add(Type.Missing, myBook.Worksheets[1], 1, Type.Missing);
            //引用第一個工作表
            mySheet = (Worksheet)myBook.Worksheets[1];
            //命名工作表的名稱為 "Array"
            mySheet.Name = "Array";
            //設工作表焦點
            mySheet.Activate();
            int UpBound1 = myArray.GetUpperBound(0);//二維陣列數上限
            int UpBound2 = myArray.GetUpperBound(1);//二維陣列數上限
            //寫入報表名稱
            myExcel.Cells[1, 4] = "全自动生成報表";
            //設定範圍
            myRange = (Range)mySheet.Range[mySheet.Cells[2, 1], mySheet.Cells[UpBound1 + 2, UpBound2 + 1]];
            myRange.Select();
            //用陣列一次寫入資料
            myRange.Value2 = myArray;
            //設定儲存路徑
            string PathFile = Directory.GetCurrentDirectory() + @"\我的报表.xlsx";
            //另存活頁簿
            myBook.SaveAs(PathFile, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
                , XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            //關閉活頁簿
            //myBook.Close(false, Type.Missing, Type.Missing);
            ////關閉Excel
            //myExcel.Quit();
            ////釋放Excel資源
            //System.Runtime.InteropServices.Marshal.ReleaseComObject(myExcel);
            myBook = null;
            mySheet = null;
            myRange = null;
            myExcel = null;

            GC.Collect();
        }
开发者ID:yvceng,项目名称:OfficeMerger,代码行数:55,代码来源:Form1.cs


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