09
2015
11

Silverlight 中颜色和字符的互相转化

 

     public static Color ToColor(string colorName)
        {
            if (colorName.StartsWith("#"))
                colorName = colorName.Replace("#", string.Empty);
            int v = int.Parse(colorName, System.Globalization.NumberStyles.HexNumber);
            return new Color()
            {
                A = Convert.ToByte((v >> 24) & 255),
                R = Convert.ToByte((v >> 16) & 255),
                G = Convert.ToByte((v >> 8) & 255),
                B = Convert.ToByte((v >> 0) & 255)
            };
        }

24
2015
10

“System.BadImageFormatException”类型的未经处理的异常在 System.Windows.Forms.dll 中发生

 “System.BadImageFormatException”类型的未经处理的异常在 System.Windows.Forms.dll 中发生



C#调用VC dll 出现“System.BadImageFormatException”,编写vc dll时用的是x86平台,即32位,而编译C#时用的x64, 即64位

将C#切换到x86平台编译,编译通过

20
2015
10

C# 获取插入的U盘的盘符信息

 

using System.IO;

 

DriveInfo[] allDrives = DriveInfo.GetDrives();

foreach (DriveInfo d in allDrives)
{
    Console.WriteLine("Drive {0}", d.Name);
    Console.WriteLine("  File type: {0}", d.DriveType);
}

16
2015
10

telerik 的 RadDiagram控件 铅笔和钢笔工具默认不填充形状内的背景色

 

 

用铅笔和钢笔工具画图的时候, 形状默认会填充颜色, 如果是画形状还好,如果是画线的话就没必要填充颜色了, 设置如下:

 

首先要引用

xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Diagrams.Primitives;assembly=Telerik.Windows.Controls.Diagrams"

 

16
2015
10

Crop that pdf page horizontaly into 4 pieces and create a new pdf for each piece

 

  

Crop that pdf page horizontaly into 4 pieces and create a new pdf for each piece


 

Document document = new Document("D:\\AP Data\\copy.pdf");
 
//Create the Copy of the page
document.Pages.Insert(2, document.Pages[1]);
document.Pages.Insert(3, document.Pages[1]);
document.Pages.Insert(4, document.Pages[1]);
 
double segment = (document.Pages[1].Rect.Height / 4);
double half = (document.Pages[1].Rect.Height / 2);
double width = document.Pages[1].Rect.Width;
double height = document.Pages[1].Rect.Height;
 
//Create Crops
Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(0,  height - segment,width , height);
document.Pages[1].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, height - half, width, height - segment);
document.Pages[2].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, height - half, width, (height - half) - segment);
document.Pages[3].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, 0, width, half - segment);
document.Pages[4].CropBox = pageRect;
 
document.Save("D:\\AP Data\\test_Crop.pdf");

16
2015
10

Crop Pdf from each edge

 

public void TrimPdf(string sourceFilePath, string outputFilePath)
  {
        PdfReader pdfReader = new PdfReader(sourceFilePath);
        float widthTo_Trim =         iTextSharp.text.Utilities.MillimetersToPoints(5);

16
2015
10

C# Crop PDF File

 

   static void cropiTxtSharp()
   {
        string file ="C:\\testpdf.pdf";
        string oldchar = "testpdf.pdf";
        string repChar = "test.pdf";
        PdfReader reader = new PdfReader(file);
        PdfDictionary pageDict;
        PdfRectangle rect = new PdfRectangle(0, 1000, 600, 115);
        pageDict = reader.GetPageN(1);
        pageDict.Put(PdfName.CROPBOX, rect);
        PdfStamper stamper = new PdfStamper(reader, new FileStream(file.Replace(oldchar, repChar), FileMode.Create, FileAccess.Write));
        stamper.Close();
        reader.Close();
    }

15
2015
10

js 点击按钮实现“隐藏,稍后弹出提示”的功能

 

右下角的信息弹出后,点击按钮实现 隐藏,稍后提示功能


        //隐藏, 稍后提示
        function hidelater(divId) {
            document.getElementById(divId).style.display = "none";
            setTimeout(function () { document.getElementById(divId).style.display = "block"; }, 10000);
        }

15
2015
10

js 获取 Request传递的值

 



 // js 获取 Request传递的值
        function request(strParame) {
            var args = new Object();
            var query = location.search.substring(1);

14
2015
10

art.dialog.close 关掉指定弹窗

 


在弹窗前,先给定义一个ID 例如:id='abc'