07
2015
08

js 中function $ (id)冲突问题

 


//获取id
function $ (id)
{
 return typeof id === "string" ? document.getElementById(id) : id;
}

页面中存在上面的JS代码。加上后原来的 下拉菜单不起作用, 检查后发现是JS代码冲突问题、

 

 

 

$(id)是js document.getElementById(id)的简写,定义了这个方法以后调用的时候就可以直接用类似于jquery中那样的$(“img-icon”).onclick简单封装。

07
2015
08

Win server 2003 上的IIS网站出现Out of memory.内存溢出问题

 

 

部署在IIS6 上的网站经常出现内存溢出问题,给IIS 设置内存回收机制后能有效的解决这个问题。

 

 

 

 

打开应用程序池属性,设置里面的内存回收选项, 设置最大虚拟内存和最大使用内存 即可。

05
2015
08

Telerik的ChartView 关于空值Empty Value的处理

 

Telerik 曲线控件关于空值的处理, 如果整个图表都没有数据,可以自定义显示信息。

 

            <telerik:RadCartesianChart.EmptyContentTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock  FontSize="16" Text="该参数没有支持的曲线数据,请更改参数重新查询!"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadCartesianChart.EmptyContentTemplate>

04
2015
08

Telerik 图标控件RadLegend添加CheckBox

 

    <Application.Resources>

        <ResourceDictionary>
            <telerik:VisibilityToBooleanConverter x:Key="visibilityToBooleanConverter" />
            <DataTemplate x:Key="legendTemplate">
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding Presenter.Visibility, Mode=TwoWay, Converter={StaticResource visibilityToBooleanConverter}}"
                            
                           BorderBrush="{Binding MarkerFill}" BorderThickness="5" />
                    <TextBlock Text="{Binding Title}" />
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
       
    </Application.Resources>

11
2015
07

C#图片切割

 

public class ImageManager
    {
        /// <summary>
        /// 图像切割
        /// </summary>
        /// <param name="url">图像文件名称</param>
        /// <param name="width">切割后图像宽度</param>
        /// <param name="height">切割后图像高度</param>
        /// <param name="savePath">切割后图像文件保存路径</param>
        /// <param name="fileExt">切割后图像文件扩展名</param>
        public static void Cut(string url, int width, int height,string savePath,string fileExt,string logofile)
        {
            Bitmap bitmap = new Bitmap(url);
            Decimal MaxRow = Math.Ceiling((Decimal)bitmap.Height / height);
            Decimal MaxColumn = Math.Ceiling((decimal)bitmap.Width / width);
            for (decimal i = 0; i < MaxRow; i++)
            {
                for (decimal j = 0; j < MaxColumn; j++)
                {
                    string filename = i.ToString() + "," + j.ToString() + "." + fileExt;
                    Bitmap bmp = new Bitmap(width, height);
                  
                    for (int offsetX = 0; offsetX < width; offsetX++)
                    {
                        for (int offsetY = 0; offsetY < height; offsetY++)
                        {
                            if (((j * width + offsetX) < bitmap.Width) && ((i * height + offsetY) < bitmap.Height))
                            {
                                bmp.SetPixel(offsetX, offsetY, bitmap.GetPixel((int)(j * width + offsetX), (int)(i * height + offsetY)));
                            }
                        }
                    }                   
                    Graphics g = Graphics.FromImage(bmp);
                    g.DrawString("哲慧科技", new Font("黑体", 20), new SolidBrush(Color.FromArgb(70, Color.WhiteSmoke)), 60, height/2);//加水印
                    ImageFormat format = ImageFormat.Png;                  
                    switch (fileExt.ToLower())
                    {
                        case "png":
                            format = ImageFormat.Png;
                            break;
                        case "bmp":
                            format = ImageFormat.Bmp;
                            break;
                        case "gif":
                            format = ImageFormat.Gif;
                            break;                        

11
2015
07

C#图片分割

 

   Bitmap image = new Bitmap(textBox1.Text);//从TextBox里获得图像的路径
    int Height = image.Height;//图像高度
    int Width = image.Width;//图像宽度
    int x = Convert.ToInt32(comboBox1.Text);//横切x份
    int y = Convert.ToInt32(comboBox2.Text);//纵切y份

11
2015
07

c#分割图片代码

 

public static class ImageSplitTool
    {
        public static ImageSource[] SplitImage(BitmapSource source, int tileWidth, int tileHeight)
        {
            var colCount = source.PixelWidth / tileWidth;
            var rowCount = source.PixelHeight / tileHeight;
            var results = new ImageSource[rowCount * colCount];
            var stride = tileWidth * ((source.Format.BitsPerPixel + 7) / 8);
            var pixelsCount = tileWidth * tileHeight;
            var tileRect = new Int32Rect(0, 0, tileWidth, tileHeight);

11
2015
07

C#图片切割,图片压缩,缩略图的生成代码

 

**//// <summary>
    /// 图片切割函数
    /// </summary>
    /// <param name="sourceFile">原始图片文件</param>
    /// <param name="xNum">在X轴上的切割数量</param>
    /// <param name="yNum">在Y轴上的切割数量</param>
    /// <param name="quality">质量压缩比</param>
    /// <param name="outputFile">输出文件名,不带后缀</param>
    /// <returns>成功返回true,失败则返回false</returns>
    public static bool imageCut(String sourceFile, int xNum, int yNum, long quality, String outputFile)
    {
        try
        {
            long imageQuality                        =    quality;
            Bitmap sourceImage                       =    new Bitmap(sourceFile);
            ImageCodecInfo myImageCodecInfo          =    GetEncoderInfo("image/jpeg");
            Encoder myEncoder                        =    Encoder.Quality;
            EncoderParameters myEncoderParameters    =    new EncoderParameters(1);
            EncoderParameter myEncoderParameter      =    new EncoderParameter(myEncoder, imageQuality);
            myEncoderParameters.Param[0]             =    myEncoderParameter;
            float xWidth                             =    sourceImage.Width / xNum;
            float yWidth                             =    sourceImage.Height / yNum;
            String outputImage                       =    "";
           
            for (int countY = 0; countY < yNum; countY++)
                for (int countX = 0; countX < xNum; countX++)
                {

08
2015
06

telerik的RadGrid控件列合并的方法

 

方法1 : 采用  GridTemplateColumn 添加 HeaderTemplate

 

<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AutoGenerateColumns="false">
  <MasterTableView>
    <Columns>
      <telerik:GridBoundColumn HeaderText="ContactName" DataField="ContactName" UniqueName="ContactName">
      </telerik:GridBoundColumn>
      <telerik:GridTemplateColumn UniqueName="TemplateColumn">
        <HeaderTemplate>
          <table id="Table1" cellspacing="1" cellpadding="1" width="300" border="1">
            <tr>
              <td colspan="2" align="center">
                <b>Address</b>
              </td>
            </tr>
            <tr>
              <td width="50%">
                <b>City</b>
              </td>
              <td width="50%">
                <b>Postal code</b>
              </td>
            </tr>
          </table>
        </HeaderTemplate>
        <ItemTemplate>
          <table id="Table2" cellspacing="1" cellpadding="1" width="300" border="1">
            <tr>
              <td width="50%">
                <%# DataBinder.Eval(Container.DataItem"City") %>
              </td>
              <td width="50%">
                <%# DataBinder.Eval(Container.DataItem"PostalCode") %>
              </td>
            </tr>
          </table>
        </ItemTemplate>
      </telerik:GridTemplateColumn>
    </Columns>
  </MasterTableView>
</telerik:RadGrid> 

30
2015
05

telerik控件RadGrid分组后无法折叠问题

 一个页面里面放了 一个 telerik 的 RadComboBox ,并且是复选模式;

        <telerik:RadComboBox ID="cbxState" AutoPostBack="true" Enabled="true" CheckedItemsTexts="DisplayAllInInput" DropDownAutoWidth="Disabled" MaxHeight="300"
                                        Localization-CheckAllString="全选" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Width="160px" OnSelectedIndexChanged="ddlMine_SelectedIndexChanged">
       </telerik:RadComboBox>