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


C# List.Sort方法代码示例

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


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

示例1: GetSortedImagesFromDirectory

 static List<string> GetSortedImagesFromDirectory(string directory)
 {
     string[] filenameArray = Directory.GetFiles(directory, "*.tif", SearchOption.TopDirectoryOnly);
     List<string> filenameList = new List<string>(filenameArray);
     filenameList.Sort(StringComparer.InvariantCultureIgnoreCase);
     return filenameList;
 }
开发者ID:aupasana,项目名称:dli-viewer,代码行数:7,代码来源:pdf.cs

示例2: Slice

        /// <summary>
        /// Slices the WMF image per pool.
        /// </summary>
        /// <returns>Returns an array of string with the path of sliced images.</returns>
        public string[] Slice()
        {
            if (string.IsNullOrEmpty(this.wmfPath))
            {
                throw new InvalidOperationException(GlobalStringResource.IMAGE_PATH_NOT_SUPPLIED);
            }

            List<int> whites = new List<int>();
            int x = 0;
            int width = 0;
            int height = 0;
            using (Bitmap baseImage = (Bitmap)Bitmap.FromFile(this.wmfPath))
            {
                height = baseImage.Height;
                width = baseImage.Width;
                for (int i = 0; i < baseImage.Height; i++)
                {
                    System.Drawing.Color c = baseImage.GetPixel(x, i);
                    if (c.A == 255 && c.B == 255 && c.R == 255 && c.G == 255)
                    {
                        if (i == 0) { continue; }
                        whites.Add(i);
                    }

                }
            }
            whites.Sort();
            List<System.Drawing.Rectangle> rectangles = CreateCoordinates(whites, width, height);
            return CropAndSave(rectangles);
        }
开发者ID:meanprogrammer,项目名称:sawebreports_migrated,代码行数:34,代码来源:SubProcessSlicer.cs

示例3: ToPdf

        /** 
         * Overriding standard PdfObject.ToPdf because we need sorted PdfDictionaries.
         */
        private static void ToPdf(PdfObject @object, PdfWriter writer, ByteBuffer os) {
            if (@object is PdfDictionary) {
                os.Append('<');
                os.Append('<');

                List<PdfName> keys = new List<PdfName>(((PdfDictionary) @object).Keys);
                keys.Sort();

                foreach (PdfName key in keys) {
                    ToPdf(key, writer, os);
                    PdfObject value = ((PdfDictionary) @object).Get(key);
                    int type = value.Type;

                    if (type != PdfObject.ARRAY && type != PdfObject.DICTIONARY && type != PdfObject.NAME &&
                            type != PdfObject.STRING) {
                        os.Append(' ');
                    }

                    ToPdf(value, writer, os);
                }

                os.Append('>');
                os.Append('>');
            } else {
                @object.ToPdf(writer, os);
            }
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:30,代码来源:PdfCleanUpContentOperator.cs

示例4: InitializeComboBox

        private void InitializeComboBox()
        {
            LiteCConfig cfg = new LiteCConfig(/*xmlDynamicDirectory +*/ "Instruments.xml");
            InstrumentComboBox.Items.Clear();

            //Using temp List<> for easy sorting
            List<string> temp = new List<string>();
            foreach (LiteCParameter x in cfg.Read()) { temp.Add(x.Value); }
            temp.Sort();
            foreach (string x in temp) { InstrumentComboBox.Items.Add(x); }
        }
开发者ID:Raxo94,项目名称:QCView,代码行数:11,代码来源:Form1.cs

示例5: loadFilesFromFolderToolStripMenuItem_Click

        private void loadFilesFromFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.statusListView.BeginUpdate();
            this.statusListView.Items.Clear();

            if (!System.IO.Directory.Exists(this.outputFolderLabel.Text))
            {
                MessageBox.Show("Unable to find directory", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string[] inputFilenames;
            
            inputFilenames = Directory.GetFiles(this.outputFolderLabel.Text, "*.tif", SearchOption.TopDirectoryOnly);
            if (inputFilenames.Length == 0)
            {
                inputFilenames = Directory.GetFiles(this.outputFolderLabel.Text, "*.png", SearchOption.TopDirectoryOnly);
            }

            List<string> fileNamesSortList = new List<string>(inputFilenames);
            fileNamesSortList.Sort(StringComparer.CurrentCultureIgnoreCase);

            foreach (string file in fileNamesSortList)
            {
                ListViewItem item = new ListViewItem(file);
                this.statusListView.Items.Add(item);
            }

            this.statusListView.EndUpdate();
        }
开发者ID:aupasana,项目名称:dli-viewer,代码行数:30,代码来源:MainForm.cs

示例6: GeneratePDF

        void GeneratePDF(object argumentsObject)
        {
            try
            {
                GeneratePDFArguments arguments = argumentsObject as GeneratePDFArguments;

                FileStream outputStream = new FileStream(arguments.OutputFilename, FileMode.Create);

                List<string> fileNamesSortList = new List<string>(arguments.InputFilenames);
                fileNamesSortList.Sort(StringComparer.CurrentCultureIgnoreCase);
                arguments.InputFilenames = fileNamesSortList.ToArray();

                int totalNmberOfFiles = arguments.InputFilenames.Length;
                int numberOfFilesProcessed = 0;

                Document document = new Document();
                PdfWriter writer = PdfWriter.GetInstance(document, outputStream);
                writer.SetPdfVersion(PdfWriter.PDF_VERSION_1_5);
                writer.CompressionLevel = PdfStream.BEST_COMPRESSION;

                document.Open();
                PdfContentByte content = writer.DirectContent;
                
                foreach (string file in arguments.InputFilenames)
                {
                    string dliName = String.Empty;

                    try
                    {
                        FileInfo info = new FileInfo(file);
                        string name = info.Name.Split(new char[] { '.' })[0];
                        string formatString = string.Empty;

                        if (System.IO.File.Exists(outputFolderLabel.Text + @"\formatString.txt"))
                        {
                            formatString = System.IO.File.ReadAllText(outputFolderLabel.Text + @"\formatString.txt");
                        }
                        dliName = string.Format(formatString, name);
                    }
                    catch
                    {
                    }

                    try
                    {
                        iTextSharp.text.Image image;

                        if (arguments.useOriginalImages)
                        {
                            image = iTextSharp.text.Image.GetInstance(file);
                        }
                        else
                        {
                            image = iTextSharp.text.Image.GetInstance(ConvertImage(file, arguments.imageScaleFactor, arguments.imageQuality));
                        }

                        // scale image to fit either the 8.5 or 11 inch margins
                        // default dpi is 72

                        float scaleFactor = 1f;
                        if (image.Height > 11*72f)
                        {
                            scaleFactor = 11f / (image.Height/72f);
                        }
                        if (image.Width > 8.5*72f)
                        {
                            float widthScaleFactor = 8.5f / (image.Width/72f);
                            if (widthScaleFactor > scaleFactor)
                            {
                                scaleFactor = widthScaleFactor;
                            }
                        }

                        if (scaleFactor != 1f)
                        {
                            image.ScalePercent(scaleFactor * (float)100.0);
                        }

                        document.SetPageSize(new iTextSharp.text.Rectangle(image.Width*scaleFactor, image.Height*scaleFactor));
                        document.NewPage();

                        image.SetAbsolutePosition(0, 0);
                        content.AddImage(image);

                        if (this.AddWatermarktoPDF && !string.IsNullOrEmpty(dliName))
                        {
                            BaseFont baseFont = FontFactory.GetFont(FontFactory.COURIER).GetCalculatedBaseFont(false);
                                
                            content.BeginText();
                            content.SetFontAndSize(baseFont, 35);
                            content.ShowTextAligned(PdfContentByte.ALIGN_CENTER, dliName, image.Width / 2, 35, 0);
                            content.EndText();
                        }

                        int progress = this.CalculatePercentage(++numberOfFilesProcessed, totalNmberOfFiles);
                        this.progressBarBook.Invoke(new SetInt(SetBookProgress), progress);
                        this.statusListView.Invoke(new AddStatusItemDelegate(AddStatusItem), new object[] { file, "Added" });
                    }
                    catch (ThreadAbortException)
                    {
//.........这里部分代码省略.........
开发者ID:aupasana,项目名称:dli-viewer,代码行数:101,代码来源:MainForm.cs

示例7: getAllDepManagers

        public ActionResult getAllDepManagers()
        {
            var m = from e in db.EmployeeRoles
                    where e.Role.RoleName == "Department Manager"
                    select e.Employee;

            List<Employee> list = new List<Employee>();
            list = m.ToList();
            list.Sort((x, y) => string.Compare(x.EmployeeName, y.EmployeeName));
            return Json(m.ToList(), JsonRequestBehavior.AllowGet);
        }
开发者ID:Besermenji,项目名称:LeaveManager,代码行数:11,代码来源:EmployeeLeaveRequestViewModelsController.cs

示例8: demographicfield

 public String demographicfield(int fieldID,int pollID,String [] items)
 {
     var result = "";
     var poll = pollRepository.GetPollByID(pollID);
     List<string> values = new List<string>();
     IList<ParticipantFieldValue> valued = participantRepository.GetParticipantFieldByID(fieldID).fieldValues.Where(valu => (!valu.value.Equals(""))).ToList();
     if (poll.isGroup) valued = valued.Where(v => v.groupd != null).ToList();
     else valued = valued.Where(v => v.participant != null).ToList();
     values = (from v in valued select v.value).Distinct().ToList();
     bool num = true;
     int number;
     if (values.Any(v => (!int.TryParse(v, out number)))) num = false;
     if (num == false)
     {
         values.Sort((x, y) => string.Compare(x, y));
         foreach (String value in values)
         {
             if (items != null && items.Contains(value))
                 result = result + "<label><input type=\"checkbox\" name=\"items\" checked=\"yes\" value=\"" + value + "\"/>" + value + "</label><br />";
             else result = result + "<label><input type=\"checkbox\" name=\"items\" value=\"" + value + "\"/>" + value + "</label><br />";
         }
     }
     else
     {
         List<int> intvalues = values.ConvertAll<int>(delegate(String i) { return int.Parse(i); });
         intvalues.Sort();
         foreach (int value in intvalues)
         {
             if (items != null && items.Contains(value.ToString()))
                 result = result + "<label><input type=\"checkbox\" name=\"items\" checked=\"yes\" value=\"" + value + "\"/>" + value + "</label><br />";
             else result = result + "<label><input type=\"checkbox\" name=\"items\" value=\"" + value + "\"/>" + value + "</label><br />";
         }
     }
     return result;
 }
开发者ID:thebinarysearchtree,项目名称:dbPoll,代码行数:35,代码来源:PollController.cs

示例9: AnalyzeFile

        protected void AnalyzeFile()
        {
            analyzeFailed = false;
            this.SetStatusText("Analyzing...");
            SetPictureVisible(ref imgError, false);
            SetPictureVisible(ref imgOK, false);

            if (radRadioButton2.IsChecked && txtPageNumbers.Text.Trim().Length > 0)
            {
                try
                {
                    String[] pages = txtPageNumbers.Text.Trim().Replace(" ", "").Split(',');
                    foreach (string s in pages)
                    {
                        if (s.Contains('-'))
                        {
                            String[] pageRange = s.Split('-');
                            if (Convert.ToInt32(pageRange[0]) >= Convert.ToInt32(pageRange[1]))
                            {
                                MessageBox.Show("Cannot count pages backwards. Please correct your page range.", "Invalid Page Range", MessageBoxButtons.OK);
                                analyzeFailed = true;
                                SetButtonEnabled(ref btnSourcePDF, true);
                                SetButtonEnabled(ref btnDestinationPDF, true);
                                SetPictureVisible(ref imgError, true);
                                SetGroupBoxEnabled(ref radGroupBox1, true);
                                this.SetStatusText("Invalid Page Range");
                                this.SetProgressBar(ref progressStatus, false, 100);
                                this.SetProgressPanelVisible(false);
                                analyzeThread.Abort();
                                return;
                            } else if (pageRange.Length > 2)
                            {
                                MessageBox.Show("Invalid page range entered. Please correct your entry and try again", "Invalid Page Range", MessageBoxButtons.OK);
                                analyzeFailed = true;
                                SetButtonEnabled(ref btnSourcePDF, true);
                                SetButtonEnabled(ref btnDestinationPDF, true);
                                SetGroupBoxEnabled(ref radGroupBox1, true);
                                SetPictureVisible(ref imgError, true);
                                this.SetStatusText("Invalid Page Range");
                                this.SetProgressBar(ref progressStatus, false, 100);
                                this.SetProgressPanelVisible(false);
                                analyzeThread.Abort();
                                return;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    analyzeFailed = true;
                    SetButtonEnabled(ref btnSourcePDF, true);
                    SetButtonEnabled(ref btnDestinationPDF, true);
                    SetPictureVisible(ref imgError, true);
                    SetGroupBoxEnabled(ref radGroupBox1, true);
                    this.SetStatusText("Invalid Page Range");
                    this.SetProgressBar(ref progressStatus, false, 100);
                    this.SetProgressPanelVisible(false);
                    analyzeThread.Abort();
                    return;
                }
            }

            PdfReader pdfDocument = new PdfReader(lblSourcePDF.Text);
            PdfDictionary document = new PdfDictionary( );
            SortPagesProvider sortPagesProvider = new SortPagesProvider();
            int page_number = 0;

            if (radRadioButton1.IsChecked) {
                bookMarkReferences = new List<BookMarkReference>();
                IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(pdfDocument);

                if (bookmarks != null) {
                    int i = 0;
                    this.SetProgressBar(ref progressStatus, true, bookmarks.Count);
                    foreach (Dictionary<string, object> bk in bookmarks)
                    {
                        foreach (KeyValuePair<string, object> kvr in bk)
                        {
                            if (kvr.Key == "Page" || kvr.Key == "page")
                                page_number = Convert.ToInt32(Regex.Match(kvr.Value.ToString(), "[0-9]+").Value);
                        }

                        bookMarkReferences.Add(new BookMarkReference(bookmarks[i].Values.ToArray().GetValue(0).ToString(), page_number));
                        this.AddTreeNode(radTreeView1, bookmarks[i].Values.ToArray().GetValue(0).ToString() + " (Page: " + page_number.ToString() + ")");
                        this.SetStatusText(string.Format("Analyzing, {0}...", bookmarks[i].Values.ToArray().GetValue(0).ToString()));
                        this.SetProgressBarValue(ref progressStatus, i);
                        Thread.Sleep(500);
                        i++;

                    }

                    bookMarkReferences.Sort(sortPagesProvider);
                    SetButtonEnabled(ref btnSourcePDF, true);
                    SetButtonEnabled(ref btnDestinationPDF, true);
                    SetPictureVisible(ref imgOK, true);
                    SetGroupBoxEnabled(ref radGroupBox1, true);
                    this.SetStatusText("Done.");
                    this.SetProgressBar(ref progressStatus, false, 100);
                    this.SetProgressPanelVisible(false);
                } else {
//.........这里部分代码省略.........
开发者ID:Dolemite1347,项目名称:PDFSplitIT,代码行数:101,代码来源:frmMain.cs

示例10: Generate

        public void Generate(string fn)
        {
            //MessageBox.Show(fn);

            //List<UniqueWords> wordstoiterate = new List<UniqueWords>(wordstoprint);
            //sorting words of list in alphabetical order

            wordstoprint.Sort((x, y) => string.Compare(x.Term, y.Term));

            List<string> lines = new List<string>();
            lines.Add("<html>");
            lines.Add("<head>");
            lines.Add("<style>");
            lines.Add(".divleft{width:50%;float:left;}");
            lines.Add(".divright{width:50%;float:right;}");

            lines.Add("</style>");
            lines.Add("</head>");
            lines.Add("<body>");

            int n = wordstoprint.Count;
               // int incr = (n/2) - 1;
            int count = 0;
            while (count<n)
            {
                lines.Add("<hr />");
                lines.Add("<div class=\"divleft\">");

                int end = count + 25;

                for (; count <= end;count++ )
                {

                    try
                    {
                        lines.Add(wordstoprint[count].Term);
                    }
                    catch (ArgumentOutOfRangeException aore)
                    {

                        break;
                    }
                        int[] pagenos = wordstoprint[count].PagenoWithFrequency.Keys.ToArray();
                        List<int> pagenostosort = new List<int>();

                        foreach (var pno in pagenos)
                        {

                            pagenostosort.Add(pno);

                        }

                        //sorting page nos
                        pagenostosort.Sort();

                        foreach (var i in pagenostosort)
                        {
                            lines.Add("(" + i.ToString() + ")" + "&nbsp");
                        }

                    lines.Add("<br />");
                }
                lines.Add("</div>");

                lines.Add("<div class=\"divright\">");

                int end1 = count + 25;
                for (; count <= end1; count++)
                {

                    try
                    {
                        lines.Add(wordstoprint[count].Term);
                    }
                    catch (ArgumentOutOfRangeException aore)
                    {

                        break;
                    }

                    int[] pagenos = wordstoprint[count].PagenoWithFrequency.Keys.ToArray();
                    List<int> pagenostosort = new List<int>();

                    foreach (var pno in pagenos)
                    {

                        pagenostosort.Add(pno);

                    }

                    //sorting page nos
                    pagenostosort.Sort();

                    foreach (var i in pagenostosort)
                    {
                        lines.Add("(" + i.ToString() + ")" + "&nbsp");
                    }

                    lines.Add("<br />");

//.........这里部分代码省略.........
开发者ID:hemtros,项目名称:BackOfThebookIndexing,代码行数:101,代码来源:IndexDocumentGenerator.cs


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