月度归档: 2015 年 4 月

  • C#中根据Enum的值获取对应的名称

    C#中根据Enum的值获取对应的名称

    public enum OrderStateEnum
    {
        未发货 = 1 ,
        已发货 = 2 ,
        交易成功 = 3
    }

    意思就是,根据1,2,3获取对应的key(如”未发货”)

    代码如下:

    this.txtState.Text = Enum.Parse(typeof(OrderStateEnum), "1",  true).ToString();
  • WebForm写起来还是很带感的

    WebForm写起来还是很带感的。感觉是比较符合我的思想,以后就用WebForm了,至于MVC,看情况吧。 反正我现在是不太喜欢它。

  • 给软件加控制功能,可以随时中断使用

    给软件加控制功能,可以随时中断使用

    public void RemoteCtrl()
    {
        WebClient web = new WebClient();
        web.Encoding = Encoding.UTF8;
        string json = web.DownloadString("http://softapi.ilinshu.cn/softinfo/query/1" );
        SoftInfo si = JsonConvert.DeserializeObject<SoftInfo >(json);
        if (si.State != 0)
        {
            MessageBox.Show(si.ErrorMessage, "内部错误" , MessageBoxButtons .OK, MessageBoxIcon.Stop);
            Environment.Exit(0);
            return;
        }
    }

  • kindeditor获取不到内容的解决办法

    kindeditor获取不到内容的解决办法

    var editorMini = KindEditor.create('.editor-mini', {
        width: '98%',
        height: '450px',
        resizeType: 1,
        items: [
            'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
            'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
            'insertunorderedlist', '|', 'emoticons', 'link'],
            afterBlur: function() {
                this.sync();
            }
    });

    在 KindEditor.create中增加

    afterBlur: function() {
        this.sync();
    }

    this.sync()说明:这个函数就是同步 KindEditor 的值到 textarea文本框。

    官方解释:

    sync()
    将编辑器的内容设置到原来的textarea控件里。