原文《Install Mplayer and Multimedia Codecs (libdvdcss2,w32codecs,w64codecs) in Ubuntu 10.04 (Lucid Lynx)》
Mplayer 是一个功能强大的媒体播放器。支持的编码方式有:MPEG 1/2/4、DivX 3/4/5、Windows Media 7/8/9、RealAudio/Video(9以下)、Quicktime 5/6 以及 Vivo 1/2。它支持很多针对MX/SSE (2)/3Dnow(Ex)优化的视频/音频编码……(以下略)
在Ubuntu 10.04 (Lucid) 里安装 Mplayer。
首先在软件源的设置里启用“社区维护的开源软件(universe)”和“有版权和合法性问题的软件(multiverse)”
然后刷新软件源:
sudo apt-get update
用下面这行命令安装:
sudo aptitude install mplayer-gui
或者点击下面的链接:
apt://mplayer
现在您可以在 应用程序⇒影音 里找到 Mplayer Movie Player
在Ubuntu 10.04 (Lucid)里安装 w32codecs 和 libdvdcss2
w32codecs 用于支持WMV、RealMedia和一些其他格式。但是由于版权和法律方面的原因,这个软件包没有包含在Ubuntu的软件仓库里。而libdvdcss2 软件包在播放加密的DVD的时候是必须的。
下面的命令将把 Medibuntu 的软件仓库添加到 Ubuntu,并同时把 Medibuntu 的 GPG 密钥添加到您的密码环,以便于验证 Medibuntu 软件包。
sudo wget http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list --output-document=/etc/apt/sources.list.d/medibuntu.list
sudo apt-get -q update
sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring
sudo apt-get -q update
i386 用户用下面这条命令安装 Codecs:
sudo apt-get install w32codecs libdvdcss2
amd64 用户用下面这条命令安装 Codecs:
sudo apt-get install w64codecs libdvdcss2
上面这个下载地址可用于安装大多数适用于 ubuntu 的解码器包。
htmlAttributes可用“对象初始化器”来创建,如引用一个CSS类,new { @class = "myClass" },因为class为C#关键字,前加@就可以拿来做自己变量的名字,也可以把@class直接写成Class,C#区分大小写,Class不为C#关键字,
new { Class= "myClass" },
实例:
.myClass
{
color:Red;
}
<%= Html.TextBox("DLID", item.DLID, new { @class = "myClass" })%>
当然你也可以设置其它任何有效的htmlAttributes的值。如
new {style="color:red",width="12px",height="10px"}。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/loveyou128144/archive/2009/07/09/4336227.aspx
本日志由 hooperzao 于 2010-06-28 15:24:36 发表到 ASP.NET MVC 中,目前已经被浏览 122 次,评论 0 次;
在表单中写:<input id="cbx" type="checkbox" />
脚本判断选中还是没选中。
- <script type="text/javascript">
- $(document).ready(function() {
- $("input[type='checkbox']").attr("checked", false)
- });
- $("#cbx").click(function()
- {
- if ($("#cbx").attr("checked"))
- {
- $("input[type='checkbox']").attr("checked",true)
- }
- else
- {
- $("input[type='checkbox']").attr("checked", false)
- }
- });
- var strid = "";
- </script>
- function delMeetingNotice(action) {
- var strDocumentid = "";
- var selectNum = $("input[type='checkbox'][id!='cbx']").size();
- var selectedNum = $("input[type='checkbox'][id!='cbx'][checked=true]").size();
- if (selectedNum == 0) {
- alert("请选择删除项!");
- return false;
- }
- for (var i = 0; i < selectNum; i++)
- {
- if ($("input[type='checkbox'][id!='cbx']").eq(i).attr("checked")) {
- strDocumentid = strDocumentid + $("input[type='checkbox'][id!='cbx']").next().eq(i).val() + ",";
- }
- }
- switch (action) {
- case "delete":
- return confirm('您真的要删除选中信息吗?') ? doaction('<%=Url.Action(MVC.Oa.MeetingNotice.Delete()) %>', 'Delete', strDocumentid) : false;
- break;
- case "remove":
- return confirm('您真的要删除选中信息吗?') ? doaction('<%=Url.Action(MVC.Oa.MeetingNotice.Remove())%>', 'Post', strDocumentid) : false;
- }
本日志由 hooperzao 于 2010-06-25 17:11:31 发表到 ASP.NET MVC 中,目前已经被浏览 155 次,评论 0 次;
在安装TFS2010时遇到以下错误:
[ Reporting ] TF255455: SQL Server Reporting Services is configured to require a secure connection. However, no HTTPS URL is configured with a valid certificate. Use the Reporting Services Configuration Manager to configure or remove HTTPS support. For more information see http://go.microsoft.com/fwlink/?LinkId=179982
解决的方法是:
编辑以下文件:
C:\Program Files\Microsoft SQL Server\MSRS10.<ServerInstance>\Reporting Services\ReportServer\rsreportserver.config
修改
<Add Key="SecureConnectionLevel" Value="2"/> (将值修改为0)
3:最安全的,使用SSL的绝对一切。
2:安全,使用SSL的渲染和方法,通过证书,但不坚持它为所有的SOAP调用。
1:基本安全,接受HTTP,但拒绝在任何可能涉及的凭据传递调用。
0:最不安全的,不使用SSL。
转自 http://social.msdn.microsoft.com/Forums/zh-TW/tfssetup/thread/494a0753-c128-49a0-967d-32e27de5bb87
XP下使用2003的“管理工具”中的“远程桌面”
方法一:
安装2003中的adminpak.msi,远程桌面可用了,但是附带也安装了一大堆的管理工具;
方法二:
1、从Windows Server 2003 %systemroot%\system32\下拷贝 mstsmmc.dll 和 mstsmhst.dll 到 Windows XP System32目录下;
2、在Windows XP 上运行: Regsvr32 mstsmmc.dll 和 Regsvr32 mstsmhst.dll,确认注册DLL文件成功;
3、在Windows XP 上运行 MMC,然后添加“远程桌面”管理单元即可使用,可以保存MSC文件以备后用。
方法三:
用远程桌面连接输入了完全的信息和设置后,你可以将其另存为rdp文件,然后用记事本或者其他文本编辑程序直接打开该rdp程序,修改rdp文件,将头部几行替换为
screen mode id:i:1
desktopwidth:i:1000
desktopheight:i:700
session bpp:i:15
winposstr:s:0,1,1,11,9999,9999
保存后,然后打开这个rdp文件就能够直接连接到服务器,并且用自己指定长宽度,像这个信息里面就是让远程桌面连接窗口为1000*700,这样在1024*768的桌面环境上,打开一堆1000*700的窗口还是挺方便切换的
注意上文中“远程桌面”和“远程桌面连接”是两个不同的工具。
Win7下使用2003的“管理工具”中的“远程桌面”
1.去MS中国下载“Windows 7 远程服务器管理工具”,KB958850,200多M,下载地址 http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d
2.安装完成后依次打开“控制面板”-“程序和功能”-“打开或关闭Windows功能”-“远程服务器管理工具”-“角色管理工具”,勾选下面的“远程桌面服务工具”;
3.此时重新打开MMC控制台,添加管理单元时就可以选择并添加“远程桌面”管理单元了。
- <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="生成实体类。" ResponseEncoding="UTF-8" %>
- <%@ Property Name="EntityName" Type="System.String" Category="Context" Description="实体名称。" %>
- <%@ Property Name="NameSpace" Type="System.String" Category="Context" Description="命名空间。" %>
- <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="数据表。" %>
- <%@ Property Name="ProjectName" Type="System.String" Category="Context" Description="项目名称。" %>
- <%@ Assembly Name="SchemaExplorer" %>
- <%@ Assembly Name="System.Data" %>
- <%@ Import Namespace="SchemaExplorer" %>
- <%@ Import Namespace="System.Data" %>
- using System;
- using System.Collections.Generic;
- namespace <%=NameSpace%>
- {
- /// <summary>
- /// 实体类:<%=EntityName%>。
- ///</summary>
- [Serializable]
- public class En<%= GetClassName(SourceTable) %>
- {
- #region 存储字段。
- <% foreach (ColumnSchema column in SourceTable.Columns) { %>
- private <%= GetCSharpVariableType(column) %> <%=GetCamelCaseName(column.Name)%>;
- <% } %>
- #endregion
- #region 初始化 En<%= GetClassName(SourceTable) %> 类的新实例。
- /// <summary>
- /// 初始化 <see cref="En<%= GetClassName(SourceTable) %>" /> 类的新实例。
- ///</summary>
- public En<%= GetClassName(SourceTable) %>()
- {
- <% foreach (ColumnSchema column in SourceTable.Columns) { %>
- <%=GetCamelCaseName(column.Name)%> = En<%=ProjectName%>.Base<%= GetBaseType(GetCSharpVariableType(column)) %>;
- <% } %>
- }
- #endregion
- <% foreach (ColumnSchema column in SourceTable.Columns) { %>
- #region 获取或设置<%=column.Description%>
- ///<summary>
- ///获取或设置<%=column.Description%>
- ///</summary>
- ///<value><%=column.Description%></value>
- public <%= GetCSharpVariableType(column) %> <%=column.Name%>
- {
- get { return <%=GetCamelCaseName(column.Name)%>; }
- set { <%=GetCamelCaseName(column.Name)%> = value; }
- }
- #endregion
- <% } %>
- }
- /// <summary>
- /// 实体类:<%=EntityName%>集合。
- ///</summary>
- [Serializable]
- public class En<%= GetClassName(SourceTable) %>List
- {
- #region 存储字段。
- private List<En<%= GetClassName(SourceTable) %>> <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%>;
- #endregion
- #region 初始化 En<%= GetClassName(SourceTable) %>List 类的新实例。
- /// <summary>
- /// 初始化 <see cref="En<%= GetClassName(SourceTable) %>List" /> 类的新实例。
- ///</summary>
- public En<%= GetClassName(SourceTable) %>List()
- {
- <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%> = new List<En<%= GetClassName(SourceTable) %>>();
- }
- #endregion
- #region 获取或设置<%=EntityName%>集合。
- ///<summary>
- ///获取或设置<%=EntityName%>集合。
- ///</summary>
- ///<value><%=EntityName%>集合。</value>
- public List<En<%= GetClassName(SourceTable) %>> <%= GetClassName(SourceTable) %>s
- {
- get { return <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%>; }
- set { <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%> = value; }
- }
- #endregion
- }
- }
- <script runat="template">
- // 获取私有字段名称。
- public string GetCamelCaseName(string value)
- {
- return "_" + value.Substring(0, 1).ToLower() + value.Substring(1);
- }
- // 获取基本类型。
- public string GetBaseType(string value)
- {
- return value.Substring(0,1).ToUpper() + value.Substring(1);
- }
- // 获取CS数据类型名称。
- public string GetCSharpVariableType(ColumnSchema column)
- {
- if (column.Name.EndsWith("TypeCode")) return column.Name;
- switch (column.DataType)
- {
- case DbType.AnsiString: return "string";
- case DbType.AnsiStringFixedLength: return "string";
- case DbType.Binary: return "byte[]";
- case DbType.Boolean: return "bool";
- case DbType.Byte: return "byte";
- case DbType.Currency: return "decimal";
- case DbType.Date: return "DateTime";
- case DbType.DateTime: return "DateTime";
- case DbType.Decimal: return "decimal";
- case DbType.Double: return "double";
- case DbType.Guid: return "Guid";
- case DbType.Int16: return "short";
- case DbType.Int32: return "int";
- case DbType.Int64: return "long";
- case DbType.Object: return "object";
- case DbType.SByte: return "sbyte";
- case DbType.Single: return "float";
- case DbType.String: return "string";
- case DbType.StringFixedLength: return "string";
- case DbType.Time: return "TimeSpan";
- case DbType.UInt16: return "ushort";
- case DbType.UInt32: return "uint";
- case DbType.UInt64: return "ulong";
- case DbType.VarNumeric: return "decimal";
- default:
- {
- return "__UNKNOWN__" + column.NativeType;
- }
- }
- }
- // 获取表名称。
- public string GetClassName(TableSchema table)
- {
- if (table.Name.EndsWith("s"))
- {
- return table.Name.Substring(0, table.Name.Length - 1);
- }
- else
- {
- return table.Name;
- }
- }
- </script>
//模板的基础知识
//任何模板都需要的第一句,用来指定模板编辑语言是什么,目标语言是什么:
- <%@ CodeTemplate Language="C#" TargetLanguage="T-SQL" Description="Generates a update stored procedure." %>
//接下来写模板需要从外界引入的参数
- <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="Database" %>
//在模板里面用到了codesmith的函数和方法,需要引入对应的包,一般是
- <%@ Assembly Name="SchemaExplorer" %>
- <%@ Import Namespace="SchemaExplorer" %>
我理解assembly 是引入dll,import 是引入dll里面的命名空间,这些dll有的是codesmith自己带的,对于vs.net提供的dll,都可以引入使用。
//所有codesmith函数都在script标签里面定义,包括变量
- <script runat="template">
- private string _outputDirectory = String.Empty;
- </script>
调用用<% %> 括起来,一般有一个主函数来执行整个模板的函数
- <%
- this.Go();
- %>
将生成的变量插入到模板的任何需要动态生成的地方,直接用asp.net的写法就可以了,例如
- namespace <%=DALNameSpace%>.SqlClient
//一般模板的函数和用法
- /// <summary>
- /// 拷贝指定文件
- /// </summary>
- public void SafeCopyFile(string path, string destination)
- {
- FileInfo file1 = new FileInfo(path);
- file1.CopyTo(destination, true);
- }
- /// <summary>
- /// 创建指定目录
- /// </summary>
- public void SafeCreateDirectory(string path)
- {
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- }
- /// <summary>
- /// 根据指定模板生成指定文件
- /// </summary>
- public void RenderToFile(string templateName, string path, bool overwrite)
- {
- this._CurrentFileName = path;
- this.GetTemplate(templateName).RenderToFile(path, overwrite);
- this._counter++;
- }
- /// <summary>
- /// 打开文件目录,[Editor]标签表示调用指定的编辑器;category表示参数所属目录;Descript表示对参数的描述;defaultvalue表示缺省值CodeTemplateProperty表示该参数是可选还是必须的,CodeTemplatePropertyOption.Optional是可选,CodeTemplatePropertyOption.Required是必须
- /// </summary>
- private string _outputDirectory = String.Empty;
- [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
- [CodeTemplateProperty(CodeTemplatePropertyOption.Optional)]
- [Category("General")]
- [Description("The directory to output the results to.")]
- [DefaultValue("")]
- public string OutputDirectory
- {
- get
- {
- if (_outputDirectory.Length == 0)
- {
- return @"c:\NetTiers\Output");
- }
- else
- {
- return _outputDirectory;
- }
- }
- set
- {
- if (value.EndsWith("\\")) value = value.Substring(0, value.Length - 1);
- _outputDirectory = value;
- }
- }
- //获取当前打开模板所在路径
- this.CodeTemplateInfo.DirectoryName
- //对于模板,当前打开的模板可以用codeTemplateInfo访问,其他的子模板需要先根据文件名和路径载入,然后编辑模板,最后赋予参数,生成文件。
- //设定模板路径
- private string[] _templatesFileNames = new string[] {
- "vsnet2003.project.cst",
- "vsnet2005.project.cst",
- "vsnet2003.solution.cst",
- "vsnet2005.solution.cst",
- "ASP.Net\\2.0\\Entty_aspx_resx.cst"
- };
- //设定编辑好的子模板保存的hashtable,在hashtable里面,key是文件名,所以全套模板不能有重复的文件名
- // Compile and load all them in a collection
- private System.Collections.Hashtable _CodeTemplates = new System.Collections.Hashtable();
- //载入模板
- // load all the templates and put them into an hashtable
- public void LoadTemplates()
- {
- foreach(string _templatesFileName in _templatesFileNames)
- {
- string key = System.IO.Path.GetFileName(_templatesFileName);
- if (_CodeTemplates.Contains(key))
- {
- continue;
- }
- _CodeTemplates.Add(key, this.CompileTemplate(this.CodeTemplateInfo.DirectoryName + _templatesFileName));
- // Set the properties that all the commonsqlcode inherited templates should set
- // TODO : use reflection to check that the templates inherits from commonsql
- try
- {
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("EntityFormat", EntityFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("CollectionFormat",
- CollectionFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("ProviderFormat", ProviderFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("InterfaceFormat", InterfaceFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("BaseClassFormat", BaseClassFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("EnumFormat", EnumFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("ManyToManyFormat", ManyToManyFormat);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("AliasFilePath", AliasFilePath);
- ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("StrippedTablePrefixes", StrippedTablePrefixes);
- }
- catch(Exception) {}
- }
- }
- //载入的时候都需要编译模板
- public CodeTemplate CompileTemplate(string templateName)
- {
- this._CurrentFileName = templateName;
- CodeTemplateCompiler compiler = new CodeTemplateCompiler(templateName);
- compiler.Compile();
- if (compiler.Errors.Count == 0)
- {
- return compiler.CreateInstance();
- }
- else
- {
- for (int i = 0; i < compiler.Errors.Count; i++)
- {
- Response.WriteLine(compiler.Errors[i].ToString());
- }
- return null;
- }
- }
- //获取模板
- public CodeTemplate GetTemplate(string templateType)
- {
- return (CodeSmith.Engine.CodeTemplate)_CodeTemplates[templateType];
- }
- //给模板赋值
- this.GetTemplate("EntityProviderBase.cst").SetProperty("SourceTable", SourceTable);
- //数据库属性
- <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Optional="False" Category="DataSource" Description="Database that the stored procedures should be based on." %>
- //遍历数据库里面的所有数据表
- private TableSchemaCollection _sourceTables;
- private ViewSchemaCollection _sourceViews;
- for (int i=0; i < SourceDatabase.Tables.Count; i++)
- {
- _sourceTables.Add(SourceDatabase.Tables[i]);
- }
- //遍历数据库里面的所有视图
- for (int i=0; i < SourceDatabase.Views.Count; i++)
- {
- _sourceViews.Add(SourceDatabase.Views[i]);
- }
- //获取表格名
- SourceTables[i].Name
- //遍历表的结构
- for (int i=0; i< SourceTable.Columns.Count; i++) {
- Response.Write("\""+ SourceTable.Columns[i].Name + "\""); }
- //指定打开哪个或者哪几个表
- [Category("DataSource")]
- [Description("The tables to generate.")]
- [CodeTemplateProperty(CodeTemplatePropertyOption.Optional)]
- public TableSchemaCollection SourceTables
- {
- get
- {
- if (this._sourceTables != null && this._sourceTables.Count > 0 )
- return this._sourceTables;
- else
- return null;
- }
- set
- {
- this._sourceTables = value;
- }
- }
- //关于遍历文件夹和拷贝文件夹里面所有文件是我自己写的,在nettiers里面没有用例:
- //拷贝目录
- public void CopyDirectory(string path)
- {
- SafeCreateDirectory(OutputDirectory+path);
- DirectoryInfo dir = new DirectoryInfo(this.CodeTemplateInfo.DirectoryName+path);
- FileInfo[] fileList = dir.GetFiles();
- foreach (FileInfo sourceFile in fileList)
- {
- sourceFile.CopyTo(OutputDirectory + path+"\\"+sourceFile.Name, true);
- Response.WriteLine("Copy file: " + sourceFile.Name);
- }
- }
- //遍历文件夹:先打开目录,然后载入目录下的文件,这个操作完全是用c#代码来写的,更多功能可以参考msdn
- DirectoryInfo dir = new DirectoryInfo(this.CodeTemplateInfo.DirectoryName+path);
- FileInfo[] fileList = dir.GetFiles();
- foreach (FileInfo sourceFile in fileList)
- {
- sourceFile.CopyTo(OutputDirectory + path+"\\"+sourceFile.Name, true);
- Response.WriteLine("Copy file: " + sourceFile.Name);
- }
- using System;
- using System.IO;
- using System.Text;
- using System.Security.Cryptography;
- using System.Web;
- namespace Test.Com
- {
- /// <summary>
- /// DESEncryptor 的摘要说明。
- /// </summary>
- public class DESEncryptor
- {
- #region 私有成员
- /// <summary>
- /// 输入字符串
- /// </summary>
- private string inputString=null;
- /// <summary>
- /// 输出字符串
- /// </summary>
- private string outString=null;
- /// <summary>
- /// 输入文件路径
- /// </summary>
- private string inputFilePath=null;
- /// <summary>
- /// 输出文件路径
- /// </summary>
- private string outFilePath=null;
- /// <summary>
- /// 加密密钥
- /// </summary>
- private string encryptKey=null;
- /// <summary>
- /// 解密密钥
- /// </summary>
- private string decryptKey=null;
- /// <summary>
- /// 提示信息
- /// </summary>
- private string noteMessage=null;
- #endregion
- #region 公共属性
- /// <summary>
- /// 输入字符串
- /// </summary>
- public string InputString
- {
- get{return inputString;}
- set{inputString=value;}
- }
- /// <summary>
- /// 输出字符串
- /// </summary>
- public string OutString
- {
- get{return outString;}
- set{outString=value;}
- }
- /// <summary>
- /// 输入文件路径
- /// </summary>
- public string InputFilePath
- {
- get{return inputFilePath;}
- set{inputFilePath=value;}
- }
- /// <summary>
- /// 输出文件路径
- /// </summary>
- public string OutFilePath
- {
- get{return outFilePath;}
- set{outFilePath=value;}
- }
- /// <summary>
- /// 加密密钥
- /// </summary>
- public string EncryptKey
- {
- get{return encryptKey;}
- set{encryptKey=value;}
- }
- /// <summary>
- /// 解密密钥
- /// </summary>
- public string DecryptKey
- {
- get{return decryptKey;}
- set{decryptKey=value;}
- }
- /// <summary>
- /// 错误信息
- /// </summary>
- public string NoteMessage
- {
- get{return noteMessage;}
- set{noteMessage=value;}
- }
- #endregion
- #region 构造函数
- public DESEncryptor()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- #endregion
- #region DES加密字符串
- /// <summary>
- /// 加密字符串
- /// 注意:密钥必须为8位
- /// </summary>
- /// <param name="strText">字符串</param>
- /// <param name="encryptKey">密钥</param>
- public void DesEncrypt()
- {
- byte[] byKey=null;
- byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
- try
- {
- byKey = System.Text.Encoding.UTF8.GetBytes(this.encryptKey.Substring(0,8));
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
- byte[] inputByteArray = Encoding.UTF8.GetBytes(this.inputString);
- MemoryStream ms = new MemoryStream();
- CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) ;
- cs.Write(inputByteArray, 0, inputByteArray.Length);
- cs.FlushFinalBlock();
- this.outString=Convert.ToBase64String(ms.ToArray());
- }
- catch(System.Exception error)
- {
- this.noteMessage=error.Message;
- }
- }
- #endregion
- #region DES解密字符串
- /// <summary>
- /// 解密字符串
- /// </summary>
- /// <param name="this.inputString">加了密的字符串</param>
- /// <param name="decryptKey">密钥</param>
- public void DesDecrypt()
- {
- byte[] byKey = null;
- byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
- byte[] inputByteArray = new Byte[this.inputString.Length];
- try
- {
- byKey = System.Text.Encoding.UTF8.GetBytes(decryptKey.Substring(0,8));
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
- inputByteArray = Convert.FromBase64String(this.inputString);
- MemoryStream ms = new MemoryStream();
- CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
- cs.Write(inputByteArray, 0, inputByteArray.Length);
- cs.FlushFinalBlock();
- System.Text.Encoding encoding = new System.Text.UTF8Encoding();
- this.outString=encoding.GetString(ms.ToArray());
- }
- catch(System.Exception error)
- {
- this.noteMessage=error.Message;
- }
- }
- #endregion
- #region DES加密文件
- /// <summary>
- /// DES加密文件
- /// </summary>
- /// <param name="this.inputFilePath">源文件路径</param>
- /// <param name="this.outFilePath">输出文件路径</param>
- /// <param name="encryptKey">密钥</param>
- public void FileDesEncrypt()
- {
- byte[] byKey=null;
- byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
- try
- {
- byKey = System.Text.Encoding.UTF8.GetBytes(this.encryptKey.Substring(0,8));
- FileStream fin = new FileStream(this.inputFilePath, FileMode.Open, FileAccess.Read);
- FileStream fout = new FileStream(this.outFilePath, FileMode.OpenOrCreate, FileAccess.Write);
- fout.SetLength(0);
- //Create variables to help with read and write.
- byte[] bin = new byte[100]; //This is intermediate storage for the encryption.
- long rdlen = 0; //This is the total number of bytes written.
- long totlen = fin.Length; //This is the total length of the input file.
- int len; //This is the number of bytes to be written at a time.
- DES des = new DESCryptoServiceProvider();
- CryptoStream encStream = new CryptoStream(fout, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
- //Read from the input file, then encrypt and write to the output file.
- while(rdlen < totlen)
- {
- len = fin.Read(bin, 0, 100);
- encStream.Write(bin, 0, len);
- rdlen = rdlen + len;
- }
- encStream.Close();
- fout.Close();
- fin.Close();
- }
- catch(System.Exception error)
- {
- this.noteMessage=error.Message.ToString();
- }
- }
- #endregion
- #region DES解密文件
- /// <summary>
- /// 解密文件
- /// </summary>
- /// <param name="this.inputFilePath">加密了的文件路径</param>
- /// <param name="this.outFilePath">输出文件路径</param>
- /// <param name="decryptKey">密钥</param>
- public void FileDesDecrypt()
- {
- byte[] byKey = null;
- byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
- try
- {
- byKey = System.Text.Encoding.UTF8.GetBytes(decryptKey.Substring(0,8));
- FileStream fin = new FileStream(this.inputFilePath, FileMode.Open, FileAccess.Read);
- FileStream fout = new FileStream(this.outFilePath, FileMode.OpenOrCreate, FileAccess.Write);
- fout.SetLength(0);
- //Create variables to help with read and write.
- byte[] bin = new byte[100]; //This is intermediate storage for the encryption.
- long rdlen = 0; //This is the total number of bytes written.
- long totlen = fin.Length; //This is the total length of the input file.
- int len; //This is the number of bytes to be written at a time.
- DES des = new DESCryptoServiceProvider();
- CryptoStream encStream = new CryptoStream(fout, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
- //Read from the input file, then encrypt and write to the output file.
- while(rdlen < totlen)
- {
- len = fin.Read(bin, 0, 100);
- encStream.Write(bin, 0, len);
- rdlen = rdlen + len;
- }
- encStream.Close();
- fout.Close();
- fin.Close();
- }
- catch(System.Exception error)
- {
- this.noteMessage=error.Message.ToString();
- }
- }
- #endregion
- #region MD5
- /// <summary>
- /// MD5 Encrypt
- /// </summary>
- /// <param name="strText">text</param>
- /// <returns>md5 Encrypt string</returns>
- public void MD5Encrypt()
- {
- MD5 md5 = new MD5CryptoServiceProvider();
- byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(this.inputString));
- this.outString=System.Text.Encoding.Default.GetString(result);
- }
- #endregion
- }
- }
本文来自CSDN博客:http://blog.csdn.net/cooljazz/archive/2006/05/31/766660.aspx
- /**********************Created by Chen*****************
- *出处以及原创作者email:aishen944-sohu.com
- ***********************************************************/
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.IO;
- namespace ImageDrawing
- {
- /// <summary>
- /// 图片修改类,主要是用来保护图片版权的
- /// </summary>
- public class ImageModification
- {
- #region "member fields"
- private string modifyImagePath=null;
- private string drawedImagePath=null;
- private int rightSpace;
- private int bottoamSpace;
- private int lucencyPercent=70;
- private string outPath=null;
- #endregion
- public ImageModification()
- {
- }
- #region "propertys"
- /// <summary>
- /// 获取或设置要修改的图像路径
- /// </summary>
- public string ModifyImagePath
- {
- get{return this.modifyImagePath;}
- set{this.modifyImagePath=value;}
- }
- /// <summary>
- /// 获取或设置在画的图片路径(水印图片)
- /// </summary>
- public string DrawedImagePath
- {
- get{return this.drawedImagePath;}
- set{this.drawedImagePath=value;}
- }
- /// <summary>
- /// 获取或设置水印在修改图片中的右边距
- /// </summary>
- public int RightSpace
- {
- get{return this.rightSpace;}
- set{this.rightSpace=value;}
- }
- //获取或设置水印在修改图片中距底部的高度
- public int BottoamSpace
- {
- get{return this.bottoamSpace;}
- set{this.bottoamSpace=value;}
- }
- /// <summary>
- /// 获取或设置要绘制水印的透明度,注意是原来图片透明度的百分比
- /// </summary>
- public int LucencyPercent
- {
- get{return this.lucencyPercent;}
- set
- {
- if(value>=0&&value<=100)
- this.lucencyPercent=value;
- }
- }
- /// <summary>
- /// 获取或设置要输出图像的路径
- /// </summary>
- public string OutPath
- {
- get{return this.outPath;}
- set{this.outPath=value;}
- }
- #endregion
- #region "methods"
- /// <summary>
- /// 开始绘制水印
- /// </summary>
- public void DrawImage()
- {
- Image modifyImage=null;
- Image drawedImage=null;
- Graphics g=null;
- try
- {
- //建立图形对象
- modifyImage=Image.FromFile(this.ModifyImagePath);
- drawedImage=Image.FromFile(this.DrawedImagePath);
- g=Graphics.FromImage(modifyImage);
- //获取要绘制图形坐标
- int x=modifyImage.Width-this.rightSpace;
- int y=modifyImage.Height-this.BottoamSpace;
- //设置颜色矩阵
- float[][] matrixItems ={
- new float[] {1, 0, 0, 0, 0},
- new float[] {0, 1, 0, 0, 0},
- new float[] {0, 0, 1, 0, 0},
- new float[] {0, 0, 0, (float)this.LucencyPercent/100f, 0},
- new float[] {0, 0, 0, 0, 1}};
- ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
- ImageAttributes imgAttr=new ImageAttributes();
- imgAttr.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
- //绘制阴影图像
- g.DrawImage(
- drawedImage,
- new Rectangle(x,y,drawedImage.Width,drawedImage.Height),
- 0,0,drawedImage.Width,drawedImage.Height,
- GraphicsUnit.Pixel,imgAttr);
- //保存文件
- string[] allowImageType={".jpg",".gif",".png",".bmp",".tiff",".wmf",".ico"};
- FileInfo file=new FileInfo(this.ModifyImagePath);
- ImageFormat imageType=ImageFormat.Gif;
- switch(file.Extension.ToLower())
- {
- case ".jpg":
- imageType=ImageFormat.Jpeg;
- break;
- case ".gif":
- imageType=ImageFormat.Gif;
- break;
- case ".png":
- imageType=ImageFormat.Png;
- break;
- case ".bmp":
- imageType=ImageFormat.Bmp;
- break;
- case ".tif":
- imageType=ImageFormat.Tiff;
- break;
- case ".wmf":
- imageType=ImageFormat.Wmf;
- break;
- case ".ico":
- imageType=ImageFormat.Icon;
- break;
- default:
- break;
- }
- MemoryStream ms=new MemoryStream();
- modifyImage.Save(ms,imageType);
- byte[] imgData=ms.ToArray();
- modifyImage.Dispose();
- drawedImage.Dispose();
- g.Dispose();
- FileStream fs=null;
- if(this.OutPath==null || this.OutPath=="")
- {
- File.Delete(this.ModifyImagePath);
- fs=new FileStream(this.ModifyImagePath,FileMode.Create,FileAccess.Write);
- }
- else
- {
- fs=new FileStream(this.OutPath,FileMode.Create,FileAccess.Write);
- }
- if(fs!=null)
- {
- fs.Write(imgData,0,imgData.Length);
- fs.Close();
- }
- }
- finally
- {
- try
- {
- drawedImage.Dispose();
- modifyImage.Dispose();
- g.Dispose();
- }
- catch{;}
- }
- }
- #endregion
- }
- }
本文来自CSDN博客:http://blog.csdn.net/sunkangta/archive/2005/05/23/378534.aspx
- using System;
- namespace Test.Com
- {
- /// <summary>
- /// 功能:字符串处理函数集
- /// </summary>
- public class DealString
- {
- #region 私有成员
- /// <summary>
- /// 输入字符串
- /// </summary>
- private string inputString=null;
- /// <summary>
- /// 输出字符串
- /// </summary>
- private string outString=null;
- /// <summary>
- /// 提示信息
- /// </summary>
- private string noteMessage=null;
- #endregion
- #region 公共属性
- /// <summary>
- /// 输入字符串
- /// </summary>
- public string InputString
- {
- get{return inputString;}
- set{inputString=value;}
- }
- /// <summary>
- /// 输出字符串
- /// </summary>
- public string OutString
- {
- get{return outString;}
- set{outString=value;}
- }
- /// <summary>
- /// 提示信息
- /// </summary>
- public string NoteMessage
- {
- get{return noteMessage;}
- set{noteMessage=value;}
- }
- #endregion
- #region 构造函数
- public DealString()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- #endregion
- #region 公共方法
- public void ConvertToChineseNum()
- {
- string numList="零壹贰叁肆伍陆柒捌玖";
- string rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万";
- double number=0;
- string tempOutString=null;
- try
- {
- number=double.Parse(this.inputString);
- }
- catch
- {
- this.noteMessage="传入参数非数字!";
- return;
- }
- if(number>9999999999999.99)
- this.noteMessage="超出范围的人民币值";
- //将小数转化为整数字符串
- string tempNumberString=Convert.ToInt64(number*100).ToString();
- int tempNmberLength=tempNumberString.Length;
- int i=0;
- while(i<tempNmberLength)
- {
- int oneNumber=Int32.Parse(tempNumberString.Substring(i,1));
- string oneNumberChar=numList.Substring(oneNumber,1);
- string oneNumberUnit=rmbList.Substring(tempNmberLength-i-1,1);
- if(oneNumberChar!="零")
- tempOutString+=oneNumberChar+oneNumberUnit;
- else
- {
- if(oneNumberUnit=="亿"||oneNumberUnit=="万"||oneNumberUnit=="元"||oneNumberUnit=="零")
- {
- while (tempOutString.EndsWith("零"))
- {
- tempOutString=tempOutString.Substring(0,tempOutString.Length-1);
- }
- }
- if(oneNumberUnit=="亿"||(oneNumberUnit=="万"&&!tempOutString.EndsWith("亿"))||oneNumberUnit=="元")
- {
- tempOutString+=oneNumberUnit;
- }
- else
- {
- bool tempEnd=tempOutString.EndsWith("亿");
- bool zeroEnd=tempOutString.EndsWith("零");
- if(tempOutString.Length>1)
- {
- bool zeroStart=tempOutString.Substring(tempOutString.Length-2,2).StartsWith("零");
- if(!zeroEnd&&(zeroStart||!tempEnd))
- tempOutString+=oneNumberChar;
- }
- else
- {
- if(!zeroEnd&&!tempEnd)
- tempOutString+=oneNumberChar;
- }
- }
- }
- i+=1;
- }
- while (tempOutString.EndsWith("零"))
- {
- tempOutString=tempOutString.Substring(0,tempOutString.Length-1);
- }
- while(tempOutString.EndsWith("元"))
- {
- tempOutString=tempOutString+"整";
- }
- this.outString=tempOutString;
- }
- #endregion
- }
本文来自CSDN博客:http://blog.csdn.net/rexsp/archive/2004/03/30/14170.aspx
Powered by Bitrac, Designed by Loveyuki, Icon by Led Icon Set. 鲁ICP备09053129号