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>

23
2015
04

若要再次显示该网页,Web浏览器需要重新发送您以前提交的消息

 


网页刷新的时候提示 :

若要再次显示该网页,Web浏览器需要重新发送您以前提交的消息


解决方法

1、提交完成后不要reload,而是location.href='这个页面的地址'
2、提交完成后后台直接Response.Redirect当前页面。
3、设置网页过期 可以试试在后台page_load里面用下面的代码

19
2015
04

asp.net页面中点击按钮传递给Silverlight,并且页面不刷新

转自http://blog.csdn.net/zdw_wym/article/details/7347548 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="test.Index" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="
http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
    <script src="Silverlight.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
        function onSilverlightError(sender, args) { 
            var appSource = ""; 
            if (sender != null && sender != 0) { 
                appSource = sender.getHost().Source; 
            } 
 
            var errorType = args.ErrorType; 
            var iErrorCode = args.ErrorCode; 
 
            if (errorType == "ImageError" || errorType == "MediaError") { 
                return; 
            } 
 
            var errMsg = "Silverlight 应用程序中未处理的错误 " + appSource + "\n"; 
 
            errMsg += "代码: " + iErrorCode + "    \n"; 
            errMsg += "类别: " + errorType + "       \n"; 
            errMsg += "消息: " + args.ErrorMessage + "     \n"; 
 
            if (errorType == "ParserError") { 
                errMsg += "文件: " + args.xamlFile + "     \n"; 
                errMsg += "行: " + args.lineNumber + "     \n"; 
                errMsg += "位置: " + args.charPosition + "     \n"; 
            } 
            else if (errorType == "RuntimeError") { 
                if (args.lineNumber != 0) { 
                    errMsg += "行: " + args.lineNumber + "     \n"; 
                    errMsg += "位置: " + args.charPosition + "     \n"; 
                } 
                errMsg += "方法名称: " + args.methodName + "     \n"; 
            } 
 
            引发新错误(errMsg); 
        } 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server"> 
        </asp:ScriptManager> 
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
            <ContentTemplate> 
                <input type="button" class="btn-search" value="查询" id="btnSearch" /> 
                <div style="width: 100%; height: 700px"> 
                    <object id="SL" data="data:application/x-silverlight-2," type="application/x-silverlight-2" 
                        width="100%" height="700px"> 
                        <param name="source" value="ClientBin/SL.xap" /> 
                        <param name="onError" value="onSilverlightError" /> 
                        <param name="background" value="white" /> 
                        <param name="minRuntimeVersion" value="4.0.60310.0" /> 
                        <param name="autoUpgrade" value="true" /> 
                        <param name="windowless" value="true" /> 
                        <a href="
http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0" style="text-decoration: none"> 
                            <img src="
http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" 
                                style="border-style: none" /> 
                        </a> 
                    </object> 
                </div> 
            </ContentTemplate> 
        </asp:UpdatePanel> 
    </div> 
    </form> 
</body> 
</html> 
<script type="text/javascript" language="javascript"> 
    $(document).ready(function () { 
        $("#btnSearch").click(function () { 
            getMess(); 
        }); 
    }); 
 
    function getMess() { 
        $.post("Index.aspx", { 
            "action": "search", 
            "param": "level" 
        }, function (data) { 
            setTimeout(function () { 
                var slHost = document.getElementById("SL"); 
                var page = slHost.Content.Page; 
                page.process(data); 
            }, 1000); 
        }); 
    } 
</script>