2008年12月27日星期六

xmlspy 安装之后, xml 文件的打开方式和图标都变了

改回原来的方式,只要注册下C:\WINDOWS\system32
下的msxml3.dll
regsvr32 msxml3.dll

2008年10月26日星期日

openflashchart 2 .net添加了一个IHttpHandler

新添加的httphanlder,使得图形可以不再需要使用单独的数据文件。
使用方式,
1,web.config中添加
<httpHandlers>
<add verb="*" path="ofc_handler.ofc" type="OpenFlashChart.WebHandler.ofcHandler, OpenFlashChart"/>
</httpHandlers>
2,在数据生成的时候,把chart的示例赋予control中的Chart属性

具体见代码。

ArrayList data1 = new ArrayList();
Random rand = new Random(DateTime.Now.Millisecond);
for (double i = 0; i < temp =" rand.Next(30);"> 20)
data1.Add(new LineDotValue(temp, "#fe0"));
else
{
data1.Add(temp);
}
}

OpenFlashChart.LineHollow line1 = new LineHollow();
line1.Values = data1;
line1.HaloSize = 0;
line1.Width = 2;
line1.DotSize = 5;

line1.Tooltip = "提示:#val#";

chart.AddElement(line1);

chart.Title = new Title("line演示");
chart.Y_Axis.SetRange(0, 35, 5);
chart.Tooltip = new ToolTip("全局提示:#val#");
chart.Tooltip.Shadow = true;
chart.Tooltip.Colour = "#e43456";
chart.Tooltip.MouseStyle = ToolTipStyle.CLOSEST;
OpenFlashChartControl1.EnableCache = false;
OpenFlashChartControl1.Chart = chart;

2008年10月10日星期五

VS设计时问题

下面类似的错误,一般是由于自定义控件中出现。

The variable '****' is either undeclared or was never assigned.

Hide    Edit

at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

VS应该是(猜测?)通过InitializeComponent函数来初始化在设计时相关的变量,所以程序本身运行时不会有问题,不过却无法正常的显示设计的页面。
例如下面的代码(部分)
      ///
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        ///

        private void InitializeComponent()
        {
           
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(40, 86);
        
            ……
            this.ResumeLayout(false);

        }

        #endregion
      
        private System.Windows.Forms.Button button1= new System.Windows.Forms.Button();


button1变量在InitializeComponent函数外声明并初始化,虽然不会影响程序的正确性,不过再设计时无法确认button1是否初始化
因此,会给出错误(原则上说VS在这点上有点苛刻。),改为下面的可以消除设计时的错误。
private void InitializeComponent()
        {
            button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(40, 86);
            ……
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;//= new System.Windows.Forms.Button();

上面的错误的话,VS2008中还可以给出错误的行数(2005不可以),可以据此修改,不过下面一种可以引起的错误,VS2008
也没法给出。
比如我在自定义控件里定义一个属性(Property)
public string JustForTest
        {
            get
            {
                return ConfigurationManager.AppSettings["Test"]??string.Empty;
            }
            set
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings["Test"].Value = value;
                config.Save(ConfigurationSaveMode.Modified);
            }
        }

    这样的属性在运行时和设计时对这个控件来说也是没有问题的,不过在设计的时候,比如我把这个自定义的控件添加到了一个Form上,
这个Form就会出现问题。
VS会自动的初始化这个控件的Public属性值,
 this.userControl11.JustForTest = null;
而在设计时,这个属性是无法获取的,错误产生。

VS还需要继续在设计时的支持方面努力啊

2008年9月27日星期六

VSS branch ,share,merge 操作

首先不得不说,操作的方式给人的感觉很不好。
vss 的分支(branch)操作需要先进行share(分享)的操作,当然也可以在share的时候,选择branch after shared的复选框。
具体操作,
vss操作的不好之处,在与先选择目的地,然后才选择 需要共享的 工程目录
比如,现在我有一个项目,名称为 "动态用户控件应用框架",其中有两个工程,一个Framework工程,一个web站点。我想创建一个分支 ,分支与主项目共享同一个Framework工程,这样的话,任何一个项目中修改,都会反应到另一个项目中,同时我需要不同的web站点。
操作步骤,创建项目shared2

,然后选择 share to $ 的选项

然后选择第一个项目中的Framework工程。

同样的步骤创建web工程,不过要选择 Branch After share的复选框。

对share后的文件中的修改,会同时在各个项目中反应,对branch的文件的修改对各个项目中没有影响。
branch的文件可以执行merge操作。

2008年9月10日星期三

看下google blog 对Title的中文翻译,;)

现在好像改掉了

2008年8月30日星期六

actionscript3 代码片段4 ――绘制3D bar

代码从openflashchart中取出

import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;

/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class Snippet3D_5 extends Sprite
{
private var col:Number = 0x3e4e4;// , 0x3ef43e];
public function Snippet3D_5()
{
var dropShadow:DropShadowFilter = new flash.filters.DropShadowFilter();
dropShadow.blurX = 5;
dropShadow.blurY = 5;
dropShadow.distance = 3;
dropShadow.angle = 45;
dropShadow.quality = 2;
dropShadow.alpha = 0.4;
this.filters = [dropShadow];
}
public function draw3Dbar(w:Number, h:Number,color:Number):void
{
this.col = color;
this.graphics.clear();
draw_top(w, h);
draw_front(w, h);
draw_side(w, h);
}
private function draw_top( w:Number, h:Number ):void {

this.graphics.lineStyle(0, 0, 0);
//set gradient fill

var lighter:Number = Lighten( this.col );

var colors:Array = [this.col,lighter];
var alphas:Array = [1,1];
var ratios:Array = [0,255];
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w + 12, 12, (270 / 180) * Math.PI );
this.graphics.beginGradientFill('linear' /*GradientType.Linear*/, colors, alphas, ratios, matrix, 'pad'/*SpreadMethod.PAD*/ );


var y:Number = 0;
if( h<0 )
y = h;

this.graphics.moveTo(0, y);
this.graphics.lineTo(w, y);
this.graphics.lineTo(w-12, y+12);
this.graphics.lineTo(-12, y+12);
this.graphics.endFill();
}

private function draw_front( w:Number, h:Number ):void {
//
var rad:Number = 7;

var lighter:Number = Lighten( this.col );

// Darken a light color
//var darker:Number = this.colour;
//darker &= 0x7F7F7F;

var colors:Array = [lighter,this.col];
var alphas:Array = [1,1];
var ratios:Array = [0, 127];

var matrix:Matrix = new Matrix();
matrix.createGradientBox(w - 12, h+12, (90 / 180) * Math.PI );
this.graphics.beginGradientFill('linear' /*GradientType.Linear*/, colors, alphas, ratios, matrix, 'pad'/*SpreadMethod.PAD*/ );

this.graphics.moveTo(-12, 12);
this.graphics.lineTo(-12, h+12);
this.graphics.lineTo(w-12, h+12);
this.graphics.lineTo(w-12, 12);
this.graphics.endFill();
}

private function draw_side( w:Number, h:Number ):void {
//
var rad:Number = 7;

var lighter:Number = Lighten( this.col );

var colors:Array = [this.col,lighter];
var alphas:Array = [1,1];
var ratios:Array = [0,255];
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w, h+12, (270 / 180) * Math.PI );
this.graphics.beginGradientFill('linear' /*GradientType.Linear*/, colors, alphas, ratios, matrix, 'pad'/*SpreadMethod.PAD*/ );


this.graphics.lineStyle(0, 0, 0);
this.graphics.moveTo(w, 0);
this.graphics.lineTo(w, h);
this.graphics.lineTo(w-12, h+12);
this.graphics.lineTo(w-12, 12);
this.graphics.endFill();
}
public function Lighten( col:Number ):Number {
var rgb:Number = col; //decimal value for a purple color
var red:Number = (rgb & 16711680) >> 16; //extacts the red channel
var green:Number = (rgb & 65280) >> 8; //extacts the green channel
var blue:Number = rgb & 255; //extacts the blue channel
var p:Number = 2;
red += red/p;
if( red > 255 )
red = 255;

green += green/p;
if( green > 255 )
green = 255;

blue += blue/p;
if( blue > 255 )
blue = 255;

return red << 16 | green << 8 | blue;
}
}

见: http://xiao-yifang.blogspot.com

2008年8月28日星期四

修改web.config,app.config

1,修改web.config
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
config.AppSettings.Settings["a1"].Value = "new value";
config.Save(ConfigurationSaveMode.Modified);

2,修改app.config

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["a1"].Value = "new value";
config.Save(ConfigurationSaveMode.Modified);

2008年8月27日星期三

actionscript3 代码片段3

默认滤镜:
分别对应Bevel,DropShadow,Blur


blogger不稳定,经常无法登陆


2008年8月26日星期二

actionscript3 代码片段2

1,pie切片

var radius:Number = 100;
var TO_RADIANS:Number = Math.PI / 180;
graphics.clear();
graphics.lineStyle(2, 0x45ef98, 1);
graphics.beginFill(0xf0f0f0, 1);
graphics.moveTo(0, 0);
graphics.lineTo(radius, 0);

var angle:Number = 50;
var a:Number = Math.tan((angle/2)*TO_RADIANS);

var endx:Number;
var endy:Number;
var ax:Number;
var ay:Number;

endx = radius*Math.cos(angle*TO_RADIANS);
endy = radius*Math.sin(angle*TO_RADIANS);
ax = endx+radius*a*Math.cos((angle-90)*TO_RADIANS);
ay = endy+radius*a*Math.sin((angle-90)*TO_RADIANS);
graphics.curveTo(ax, ay, endx, endy);
graphics.endFill();
graphics.lineTo(0, 0);

2,donut,甜甜圈
var colors:Array = [0x87347e, 0x0000ef, 0x8D6433];
var alphas:Array = [100, 100, 100];
var ratios:Array = [0, 110, 255];
var matrix:Matrix = new Matrix();// { a:300, b:0, c:50, d:0, u:300, v:0, tx: -3, ty:3, w:1 };
graphics.beginGradientFill("radial", colors, alphas, ratios, matrix);
drawdonut(86, 36, 100, 94);
graphics.endFill();
其中drawdonut函数
public function drawdonut(r1:Number, r2:Number, x:Number, y:Number):void {
var TO_RADIANS:Number = Math.PI/180;
this.graphics.moveTo(0, 0);
this.graphics.lineTo(r1, 0);

// draw the 30-degree segments
var a:Number = 0.268; // tan(15)
var i:Number;
var endx:Number;
var endy:Number;
var ax:Number;
var ay:Number;
for ( i=0; i < 12; i++) {
endx = r1*Math.cos((i+1)*30*TO_RADIANS);
endy = r1*Math.sin((i+1)*30*TO_RADIANS);
ax = endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS);
ay = endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS);
this.graphics.curveTo(ax, ay, endx, endy);
}

// cut out middle (draw another circle before endFill applied)
this.graphics.moveTo(0, 0);
this.graphics.lineTo(r2, 0);

for ( i =0; i < 12; i++) {
endx = r2*Math.cos((i+1)*30*TO_RADIANS);
endy = r2*Math.sin((i+1)*30*TO_RADIANS);
ax = endx+r2*a*Math.cos(((i+1)*30-90)*TO_RADIANS);
ay = endy+r2*a*Math.sin(((i+1)*30-90)*TO_RADIANS);
this.graphics.curveTo(ax, ay, endx, endy);
}

this.x = x;
this.y = y;
}


效果:

2008年8月24日星期日

ActionScript3 代码片段1

1,自定义图形绘制填充
var param3:Number = 10;
var mapData:BitmapData = new BitmapData(param3, param3, true, 0);
var shape:Shape = new Shape;
shape.graphics.beginFill(0,0);
shape.graphics.lineStyle(1,0.5,1,true);
shape.graphics.moveTo(0, param3 / 2);
shape.graphics.lineTo(param3, param3 / 2);
shape.graphics.moveTo(param3 / 2, 0);
shape.graphics.lineTo(param3 / 2, param3);
shape.width = 10;
shape.height = 10;
shape.graphics.endFill();
mapData.draw(shape);
graphics.beginBitmapFill(mapData, new Matrix(), true);
graphics.lineStyle(1);
graphics.drawRect(100, 100, 400, 10);
graphics.endFill();

效果:


2,tweener 片段
使用的tweener为http://code.google.com/p/tweener/

public function Snippet2()
{
graphics.beginFill(0x777777);
graphics.lineStyle(2, 0x3efa0);
graphics.drawCircle(0, 0, 10);
graphics.endFill();
this.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
this.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
}
public function mouseOver(event:Event):void {
Tweener.addTween(this, { _scale:2, transition:Equations.easeOutElastic});
}

public function mouseOut(event:Event):void {
// stop the pulse, then fade in
Tweener.addTween(this, { _scale:1,alpha:0.33, transition:Equations.easeOutElastic } );
}

效果如下:

2008年8月23日星期六

ActionScript3 20分钟速览(不是教程)


对有其他编程经验的人。
1,变量
var 变量名:数据类型=值;

数据类型分基本数据类型和复杂数据类型
基本数据类型有Boolean,int,Number,String和unit,
复杂数据类型有Array,Date,Error,Function,RegExp,XML和自定义的类型。

声明方式如:

var i:int=2;
var name:String="name";

Array的赋值可以使用[],如var arr:Array=[1,"3",[5,6]]
Object的赋值可以使用{},使用上与javascript的类似

2,运算符,表达式
如其他语言的相同,除了部分细节方面的处理不一样,不影响第一次使用
3,流程控制
if else,switch,while,do while,for ,return,break
for多了用法 for each ,for in,对第一此使用的人,可以先不管。
4,函数定义
function 函数名 (参数1:参数类型,参数2:参数类型):返回值
{
函数体
}
5,类
class,类及接口的继承方式
其他诸如命名空间,包导入之类可以调过,不影响使用。
6,事件

掌握以上应该就可以进行基本的编码了。


2008年8月22日星期五

图表组件

用以绘制直线,饼状,柱状之类的2D,3D图形的一些软件列表
1,SharpGraph.net
可视化设计支持比较好。
2,dotnetcharting
非常专业,从图表数量和质量来说。
3,ComponentArt WebChart
几个flash相关的
4,AnyChart
5,ampie
6,NetAdvantage中的Chart控件
7,DevExpress中的Chart控件

.net 平台 行为测试框架 ,Rhino Mocks ,

2008年8月19日星期二

asp.net网页动态生成图形



//1,生成Graphics对象

Bitmap newBitmap = new Bitmap(200, 200, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(newBitmap);
//2,图形绘制



//3,输出到页面
MemoryStream tempStream = new MemoryStream();
newBitmap.Save(tempStream, ImageFormat.Png);
Response.ClearContent();
Response.ContentType = "image/png";
Response.BinaryWrite(tempStream.ToArray());
Response.Flush();

2008年8月9日星期六

兔子爱上猫(There She is 3)


http://www.sambakza.net/amalloc/amalloc_frameset.htm

2008年8月3日星期日

清理一下不常用的组件

1,ZipForge.NET
解压缩
2.cpSphereLicense
授权
3.Mentalis Security
加解密
4.Mentalis IniReader
ini文件读写
5.PDFLIB
PDF文件创建
6.Garbe.Sound
声音文件处理
7.Mentalis Multimedia
多媒体文件处理
8..NET Communication Library
通讯处理,邮件
9.BossWare SMTPClient
邮件类,不过.net 2.0中有同功能类。
10.cpSphere.Mail
邮件处理
11.FTPComponent
FTP封装类
12.Mentalis ICMP
13.Mentalis ProxySocket
代理类,允许穿越防火墙
14.ScandPortal
根据IP查询国家
15.Whois
16.FreeTextBox
在线多功能编辑器
17.PieChart Component
asp.net 图表
18.SourceGrid
自定义Grid
19.Lumisoft UI Controls
UI控件
20.XSChart
21.TreeGrid control

2008年8月1日星期五

2008年7月29日星期二

2008年7月28日星期一

如何使用openflashchartV2 dot net library 中的asp.net 控件。

在工具栏上右键,选择项,添加openflashchart.dll,

工具栏上会多出控件openflashchartcontrol


然后就是按照正常的控件使用。

控件中内置了swfobject2.0和相应的open-flash-chart.swf.
所以程序中不在需要这两个文件,不过依然提供了两个属性,方便用户添加外来文件。
为以后使用新版本的swf和swfobject做预留。

2008年7月26日星期六

2008年7月19日星期六

openflashchart V2 .net 新版本

http://openflashchart.svn.sourceforge.net/viewvc/openflashchart/version-2/dot-net-library/written-by-xiao-yifang.tar.gz?view=tar


tor 软件

知道的人不用说,不知道的google search   .

2008年7月16日星期三

openflashchart2 .net实现 五

可以到
sourceforge的站点下载
http://openflashchart.svn.sourceforge.net/viewvc/openflashchart/version-2/dot-net-library/written-by-xiao-yifang/

openflashchart的原作者把它放到了svn上。

2008年7月15日星期二

有趣的问题, 称球

大学时一个老师所做的研究中的一部分。
曾经给我们出过一个题是:
13个球中有1个不知轻重的球,用天平3次称出。
抽象为一般问题是,n次最多可以称出多少球(球中有一个未知轻重的球)

重新做一下。
为了方便说明,规定图例为

第一次4,4称,如果相等的话,
可以得到8个标准的球和5个不知轻重的球。还剩两次机会,简单,不讨论。
如果不相等的话,不妨讨论大于的情况
第一次大于的话,可以得到4个可能重的球,4个可能轻的球,和5个标准球。



称第二次,如下分配:




第二次如果相等的话,在剩下的球中一个可能重的球,2个可能轻的球中,那么第三次的话,在轻重各取一个,与标准的两个球称,如果相等,则剩余的为轻球,大于的话,为参与称重的球中的重球,小于的话,为参与称重的球中的轻球。

第二次如果大于的话,说明存在于左侧的两个可能重球和右侧的一个可能轻球里面。同上。
第二次如果小于的话,说明存在与左侧的可能轻球和右侧的可能重球里面,第三次,取一个与标准球称。


2008年7月14日星期一

openflashchartV2 .net的实现四

实现了一个.net版本

上面的版本中JSON序列化所用的组件需要.net framework 3.5的支持,
对这个项目来说,本身有点太过复杂了,以后修改为支持.net framework 2.0
如果你使用上面的程序,希望可以发一个生成的图片给我,最好包括你们公司的地址:-)
我可以列在下面,谢谢。

关于openflashchart的介绍见
http://teethgrinder.co.uk/open-flash-chart-2/

2008年7月13日星期日

openflashchart2 .net实现 三

如何使用?
有很多种方式,可以在页面上使用openflashchart的图形,此处只演示一种

显示页面,比如叫 Pie.aspx

内容
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Pie.aspx.cs" Inherits="Pie" %>

<!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 type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "550", "500",
"9.0.0", "expressInstall.swf",
{"data-file":"datafile/Pie.aspx"}
);
</script>

</head>
<body>
<form id="form1" runat="server">
<div id="my_chart">
</div>
</form>
</body>
</html>

数据由datafile目录下的Pie.aspx生成,Pie.aspx.cs中Page_Load函数的内容为
OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
chart.Title = new Title("Pie Chart");

OpenFlashChart.Pie pie = new OpenFlashChart.Pie();
Random random = new Random();

List<PieValue> values = new List<PieValue>();
List<string> labels = new List<string>();
for (int i = 0; i < 12; i++)
{
values.Add(new PieValue(random.NextDouble(),"Pie"+i));
labels.Add(i.ToString());
}
pie.Values = values;
//pie.Colour = "#fff";
pie.Colours = new string[]{"#04f","#1ff","#6ef","#f30"};
chart.AddElement(pie);
string s = chart.ToString();
Response.Clear();
Response.CacheControl = "no-cache";
Response.Write(s);
Response.End();

最后的图形为:

openflashchart2 .net实现二

一些图形具有的值具有特定的格式。
如Pie的节点值,可以同时具有 (value值,color颜色),也可以只含有值,不包括颜色,
所以对于Pie来说 ,形如 {12,{12,"#ef0"},3}之类的数组是可以接受的。
对于.net来说,数组中的值只允许一种类型,表示这种值有困难。
实现的时候,先只实现如下格式{{12,null},{12,"#ef0"},{3,null}}保证类型的统一。


为了同时利用已有的代码,抽象出一个泛型类,如图。

openflashchart2 .net 实现的类设计

到目前为止,已经有人用perl ,php实现了openflashchart2的数据层。
此处参考php的实现,来实现.net的结构。不过类的层次继承关系重新组织

以AreaHollow图形为例。
以设计来说,你尽可以做的面面俱到。此处只给出简单的实现,做不得标准:-),另外此处只是实现过程中的设计,或许在实现的过程中会更改:-).
因为此时,我还没有完全实现在.net下的版本。




openflashchart有很多图形,所以给出一个图形的基类ChartBase,方便后面添加多个图形的时候方便。
Title,Legend,都具有Text(名称),Style(样式),此处也让他们共用一个基类。

坐标轴也有一个基类。 OpenflashChart负责整体的控制。


此处的实现,关键的地方是把类转化为相应的JSON结构。采用JSON.net的实现。

最后生成AreaHollow的图像的数据层,将会是这样。
OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
chart.Title=new Title("AreaHollow");

AreaHollow area = new AreaHollow();
Random random=new Random();
area.Colour = "#0fe";
area.DotSize = 2;
area.Fillalpha = 0.4;
area.Text = "Test";
area.Width = 2;
area.Fontsize = 10;
IList<double> values = new List<double>();
for (int i = 0; i < 12; i++)
values.Add(random.Next(i, i*2));
area.Values = values;
chart.AddElement(area);
XAxis xaxis=new XAxis();
// xaxis.Labels = new AxisLabel("text","#ef0",10,"vertical");
xaxis.Steps = 1;
xaxis.SetRange(0,12);
chart.X_Axis = xaxis;
YAxis yaxis = new YAxis();
yaxis.Steps = 4;
yaxis.SetRange(0,20);
chart.Y_Axis = yaxis;
string s = chart.ToString();
Response.Clear();
Response.CacheControl = "no-cache";
Response.Write(s);
Response.End();

openflashchart 2 在asp.net中使用

openflashchart 2 中重新设计了数据的格式,从1.0中的参数式的格式,改为了基于JSON格式的表示
现在的图形,全部采用JSON的结构式表示,如AreaHollow图形,会表示成。
{
"title": {
"text": "Area Chart"
},
"elements": [
{
"type": "area_hollow",
"fill-alpha": 0.35,
"values": [
0,
0.37747172851062,
0.73989485038644,
1.0728206994506
//省略
],
"width": 1
}
],
"y_axis": {
"min": -2,
"max": 2,
"steps": 2,
"labels": null,
"offset": 0
},
"x_axis": {
"labels": {
"steps": 4,
"rotate": "vertical"
},
"steps": 2
}
}

像以前一样,展现层依然与数据的生成分离。也就是只要最后的数据格式符合JSON的这种形式,
及openflashchart的字段定义。
就可以。所以可以用任何语言实现它的数据层。
幸运的是,目前已经在.net下有多种JSON的实现,用以把数据对象转换成JSON的格式。
下面将会有一系列的文章,来说明openflashchart的.net实现。

2008年7月12日星期六

2008年7月11日星期五

2008年7月8日星期二

.net 3.5 大整数 big integer 支持

System.core.dll中的System.Numberic 命名空间
BigInteger 


2008年7月7日星期一

比较好的一些开源项目

1,mootools
javascript 的framework
个人认为,功能强大,使用简单,速度快。
2,subsonic
处理数据库相关的操作,可以生成代码,它的口号是,All your database belong to us.
3.wix
或许会代替windows install shield ,微软的一些产品的如Office 2007 就是用它做的安装程序。


Resharper 卸载后 Visual Studio 的快捷键和智能提示消失

Resharper的快捷键覆盖了Visual Studio的设置。如果要恢复Visual Studio的快捷键,需要在工具->导入导出配置->重置所有键     就可以了。

2008年7月6日星期日

google blog首字下沉

同样是修改模板中的
css样式,添加
div .entry-content:first-letter{font-size:3em;float:left;}

google,blog的自定义功能实在是很方便啊,与msn space比起来。

设置blog spot使用Google Analytics

google的blog中可以自定义模板,
只要在布局里面的选择修改HTML,然后把Google Analytics的跟踪代码放进去就可以了。
很简单。

piwik 请求


http://dev.piwik.org/trac/wiki/MainSequenceDiagram

2008年7月4日星期五

强大的搜索引擎

google的搜索引擎做的更出众了
自己的帖子写完之后,半小时左右就可以用google搜出来。
速度更新很快。
baidu好像死了。

google treasure hunt -----network 网络寻址

这个自己看吧,本人对网络外行:-(

Question

Below is a diagram of a computer network. The nodes are hosts on the network, and the lines between them are links. A packet is sent out from host F with a destination of 74.1.70.230. Which nodes does the packet pass through on its way to the destination? (include start and final node in your answer)

Network

Here is a network routing table you'll need to determine the path taken:
Node Ip address Routing table entry Routing table entry Routing table entry Default route
A 11.207.188.140 174.179.20.151 => 118.51.156.14 107.254.82.100 => 115.32.2.165 74.1.70.0/24 => 102.41.84.235 104.173.164.71
B 118.51.156.14 74.1.70.230 => 104.173.164.71 115.32.2.165 => 11.207.188.140 102.208.9.0/24 => 115.32.2.165 107.254.82.100
C 107.254.82.100 54.91.191.110 => 102.41.84.235 118.51.156.14 => 26.153.160.156 74.1.70.0/24 => 118.51.156.14 74.1.70.230
D 174.179.20.151 253.172.13.172 => 107.254.82.100 22.245.173.210 => 22.245.173.210 38.202.188.0/24 => 54.91.191.110 74.1.70.230
E 102.208.9.150 174.179.20.151 => 47.198.81.165 108.85.16.8 => 253.172.13.172 26.153.160.0/24 => 108.85.16.8 174.179.20.151
F 253.172.13.172 253.172.13.172 => 38.202.188.8 26.153.160.156 => 47.198.81.165 102.208.9.0/24 => 102.208.9.150 108.85.16.8
G 38.202.188.8 74.1.70.230 => 54.91.191.110 38.202.188.8 => 22.245.173.210 11.207.188.0/24 => 174.179.20.151 253.172.13.172
H 22.245.173.210 11.207.188.140 => 108.85.16.8 38.202.188.8 => 174.179.20.151 107.254.82.0/24 => 54.91.191.110 38.202.188.8
I 108.85.16.8 22.245.173.210 => 102.208.9.150 118.51.156.14 => 253.172.13.172 74.1.70.0/24 => 22.245.173.210 47.198.81.165
J 47.198.81.165 38.202.188.8 => 102.208.9.150 102.208.9.150 => 108.85.16.8 11.207.188.0/24 => 54.91.191.110 253.172.13.172
K 54.91.191.110 115.32.2.165 => 38.202.188.8 118.51.156.14 => 174.179.20.151 38.202.188.0/24 => 22.245.173.210 107.254.82.100
L 74.1.70.230 115.32.2.165 => 102.41.84.235 107.254.82.100 => 104.173.164.71 11.207.188.0/24 => 54.91.191.110 107.254.82.100
M 104.173.164.71 54.91.191.110 => 115.32.2.165 118.51.156.14 => 74.1.70.230 102.41.84.0/24 => 118.51.156.14 11.207.188.140
N 115.32.2.165 22.245.173.210 => 118.51.156.14 47.198.81.165 => 26.153.160.156 38.202.188.0/24 => 11.207.188.140 104.173.164.71
O 26.153.160.156 174.179.20.151 => 74.1.70.230 74.1.70.230 => 102.41.84.235 102.208.9.0/24 => 115.32.2.165 107.254.82.100
P 102.41.84.235 107.254.82.100 => 26.153.160.156 22.245.173.210 => 107.254.82.100 74.1.70.0/24 => 74.1.70.230 11.207.188.140

Enter the nodes the packet passes through below
(Note: Answer must start with F, end with the destination node name, and contain only node names.)

google treasure hunt ----zip

问题:

统计下面zip文件夹中满足下面条件的数据,并把它们的乘积返回。
所有文件名或文件路径中包含foo,且以.txt结尾的文件中的第4行的总数
所有文件名或文件路径中包含EFG ,且以.js结尾的文件中的第5行的总数
提示:如果相应的行不存在,不统计



Question

Here is a random zip archive for you to download:
GoogleTreasureHunt08_18057390569245304937.zip

Unzip the archive, then process the resulting files to obtain a numeric result. You'll be taking the sum of lines from files matching a certain description, and multiplying those sums together to obtain a final result. Note that files have many different extensions, like '.pdf' and '.js', but all are plain text files containing a small number of lines of text.

Sum of line 4 for all files with path or name containing foo and ending in .txt
Sum of line 5 for all files with path or name containing EFG and ending in .js
Hint: If the requested line does not exist, do not increment the sum.

Multiply all the above sums together and enter the product below.
(Note: Answer must be an exact, decimal representation of the number.)


程序:



static Int64 sum(string folder, string ext, string foundstring, Int64 linenum)
{
Int64 result=0;
string[] files = Directory.GetFiles(folder, ext, SearchOption.AllDirectories);
foreach (string file in files)
{
if (file.ToLower().Contains(foundstring))
using (StreamReader reader = new StreamReader(file))
{
Int64 count = 0;
string line;
while ((line=reader.ReadLine())!=null)
{
count++;
if (count == linenum)
{
Int64 temp = Convert.ToInt64(line);
result+=temp;
break;
}
}
}

}
return result;


}

google tresure hunt 机器人

有一个机器人在36x36的格子上的左上角,移动到右下角,每次只能向下,或向右移动一步。

共有多少条路径?

这个问题很简单,组合数学中的问题。


Question

A robot is located at the top-left corner of a 36 x 36 grid (marked 'Start' in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

Note: The grid below is 7x3, and is used to illustrate the problem. It is not drawn to scale.

Robot

*Image not to scale.

How many possible unique paths are there?
(Note: Answer must be an exact, decimal representation of the number.)



解法:对于n x m的格子,路径数为组合中 n+m-2个数中n-1的组合数,

分析,机器人共需要走n+m-2步到达目的地。这些步中有n-1步是需要向右的。正好是组合数学中的组合定义。

数目可能比较大,会超出整形的最大值。编程的话,需要大数的支持。

有开源的一些项目可以使用。.net的话,可以用IntX codeplex上的项目。

2008年7月3日星期四

google寻宝 google treasure hunt prime 素数问题

偶然看见的题目,很有意思,一时技痒,试着解决一下:-)
题目翻译如下:
找一个最小的素数,使其满足一下条件:
分别可以表示成连续11,37,347,1157个素数之和。

如41是满足下面条件的最小素数:
同时满足连续3个,和6个的素数之和。
11 + 13 + 17 = 41,
2 + 3 + 5 + 7 + 11 + 13 = 41

题目中的数字是动态生成的。这是给我生成的题目。解法都一样。

Question:

Find the smallest number that can be expressed as
the sum of 11 consecutive prime numbers,
the sum of 37 consecutive prime numbers,
the sum of 347 consecutive prime numbers,
the sum of 1157 consecutive prime numbers,
and is itself a prime number.

For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).



此题的答案是:9778121

程序:

        static bool isPrime(Int64 num)
{
if ((num == 2) || (num == 3))
return true;
Int64 sqrti = (Int64)Math.Sqrt(num) + 1;
for (Int64 i = 2; i < sqrti; i++)
{
if (num % i == 0)
return false;
}

return true;
}
static void Main(string[] args)
{
Int64 result = 0;
bool found = false;
Int64 endprime;
Int64 startprime = 2;
Int64 sumtotal = sum(startprime, 1157, out endprime);
Console.WriteLine(sumtotal);
Console.WriteLine(endprime);
while (!found)
{
while (!isPrime(sumtotal))
{
sumtotal = sumtotal + endprime - startprime;
startprime = findPrimeAfter(startprime);
endprime = findPrimeAfter(endprime);

}
Console.WriteLine("find temp prime sum:" + sumtotal);
if (splitprime(sumtotal, 11) && splitprime(sumtotal, 37) && splitprime(sumtotal, 347))
{
result = sumtotal;
found = true;
}
else
{
sumtotal = sumtotal + endprime - startprime;
startprime = findPrimeAfter(startprime);
endprime = findPrimeAfter(endprime);
}

}

Console.WriteLine("result:" + result);


}
static bool splitprime(Int64 prime, Int64 slicenum)
{
Int64 average = prime / slicenum;
Int64 lowprime = findPrimeBefore(average, slicenum);
// Int64 highprime = findPrimeAfter(average, slicenum);
Int64 startprime = lowprime;
Int64 endprime;
Int64 slicetotalnum = sum(startprime, slicenum, out endprime);
while ((startprime < average) && (slicetotalnum <= prime))
{
if (slicetotalnum == prime)
{
Int64 temp = startprime;
Console.Write(prime+"=");
while (slicenum-- > 0)
{
Console.Write(temp + "+");
temp = findPrimeAfter(temp);
}
Console.WriteLine();
return true;
}
slicetotalnum = slicetotalnum + endprime - startprime;
startprime = findPrimeAfter(startprime);
endprime = findPrimeAfter(endprime);

}
return false;
}
static Int64 sum(Int64 startprimenum, Int64 primenum, out Int64 endprimenum)
{
Int64 total = 0;
Int64 prime = startprimenum;
for (int i = 0; i < primenum; i++)
{
total += prime;
prime = findPrimeAfter(prime);
}
endprimenum = prime;
return total;
}
static Int64 findPrimeBefore(Int64 prime)
{
if (prime == 2)
return 2;
if (prime == 3)
return 2;
if (prime % 2 == 0)
prime = prime - 1;
else
{
prime = prime - 2;
}
while (!isPrime(prime) && prime > 0)
{
prime = prime - 2;
}
return prime;
}
static Int64 findPrimeBefore(Int64 prime, Int64 before)
{
while (before-- > 0 && prime > 0)
prime = findPrimeBefore(prime);
return prime;
}
static Int64 findPrimeAfter(Int64 prime, Int64 after)
{
while (after-- > 0)
prime = findPrimeAfter(prime);
return prime;
}
static Int64 findPrimeAfter(Int64 prime)
{
if (prime == 2)
return 3;
if ((prime & 1) == 1)
prime = prime + 2;
else
{
prime = prime + 1;
}
while (!isPrime(prime) && prime > 0)
{
prime = prime + 2;
}
return prime;
}

2008年7月1日星期二

VS2005/2008 字体设置

新发现了一个VS 2005的Theme,
http://www.codinghorror.com/blog/archives/000682.html

效果不错:

2008年6月30日星期一

C# sql 事务的问题

在使用ado.net的事务机制的时候,
如果对一个表先进行了更新,然后在请求同一个表中的被更新的数据的时候会造成死锁。
如果需要即查询数据,又要更新的话,需要谨慎的处理操作的顺序。
比如在查询完了之后,才更新数据。或者在更新数据后,提交事务。

不知道是否有设置读取脏数据的设置?再查。

2008年6月29日星期日

有创意的网站错误页面

1,http://github.com/


2.tudou

3,emule