protected voID Page_Load(object sender,EventArgs e) { if (Request.queryString["ID"] != null && Request.queryString["ID"].Length > 0) { .................. } else if (Request.queryString["transform"] != null) { int index; string column; ResolveParams(Request.queryString["transform"], out index,out column); if (index != -1) { Employee data = GetData(index); MemoryStream ms = Resolvetransform(data,column); if (ms != null) { Response.Clear(); Response.BufferOutput = true; Response.ContentType = "image/bmp"; Response.OutputStream.Write(ms.GetBuffer(),(int)ms.Length); ms.dispose(); Response.Flush(); Response.End(); } else Response.End(); } } } private voID ResolveParams(string transformParams,out int index,out string column) { string[] p = Request.queryString["transform"].Split('*'); index = -1; column = string.Empty; if (p.Length == 2) { index = int.Parse(p[0]); column = p[1]; } } private MemoryStream Resolvetransform(object data,string column) { PropertyInfo pi = data.GetType().GetProperty(column); if (pi != null) return GetDBCSJpestream(pi.GetValue(data,null).ToString(), new Font("PMingliU",11,FontStyle.Bold),color.Black,color.White,280,24); return null; } private MemoryStream GetDBCSJpestream(string str,Font Font,color forecolor, color background,int wIDth,int height) { Bitmap bmp = new Bitmap(wIDth,height); Graphics g = Graphics.FromImage(bmp); Brush bFore = new SolIDBrush(forecolor); Brush bBack = new SolIDBrush(background); g.Clear(color.transparent); g.DrawString(str,Font,bFore,2,2); bFore.dispose(); bBack.dispose(); MemoryStream ms = new MemoryStream(); bmp.Save(ms,System.Drawing.Imaging.ImageFormat.Png); bmp.dispose(); ms.position = 0; return ms; } |
< Canvas xmlns = "http://schemas.microsoft.com/clIEnt/2007" ................... < Image name = "imgLastname"Tag="BindingFIEld:Lastname;BindingProperty:Source;Format:Default.aspx?transform={INDEX}*{BindingFIEld}"WIDth="300"Height="24"Canvas.left="500"Canvas.top="23" /> </ Canvas > |
///////////////////////////////////////////////////////////////////////// // Silverlight Data Binding Helper 0.1 ///////////////////////////////////////////////////////////////////////// if (!window.SilverlightBinding) window.SilverlightBinding = {}; SilverlightBinding.BindingData = function(ctrl,bindingExpression,context) { var bindings = bindingExpression.split(';'); this.bindingComplete = false; this.ctrl = ctrl; this.context = context; for(var i = 0; i < bindings.length; i++) { var temp = bindings[i].split(':'); if(temp.length != 2) { this.bindingComplete = false; return; } if(temp[0] == 'BindingFIEld') this.bindingFIEld = temp[1]; else if(temp[0] == 'BindingProperty') this.bindingProperty = temp[1]; else if(temp[0] == 'Format') this.format = temp[1]; } this.bindingComplete = true; } SilverlightBinding.BindingData.prototype = { updateValue : function(dataItem) { if(this.bindingComplete) { if(this.format) { var str = eval("this.format.replace('{0}',dataItem."+this.bindingFIEld+');'); if(this.format.indexOf("INDEX") != -1) str = str.replace("{INDEX}",this.context.currentDataIndex); if(this.format.indexOf("BindingFIEld") != -1) str = str.replace("{BindingFIEld}",this.bindingFIEld); eval('this.ctrl.'+this.bindingProperty+" = str;"); } else eval('this.ctrl.'+this.bindingProperty+' = dataItem.'+this.bindingFIEld+';'); } } } SilverlightBinding.BindingContext = function(bindingContainer) { var parseBindings = bindingContainer.tag.split(';'); this.bindingComplete = false; this.bindingContainer = bindingContainer; this.bindingControls = new Array(); this.currentDataIndex = 0; this.recordCount = 0; for(var i = 0; i < parseBindings.length; i++) { var parseBinding = parseBindings[i].split(':'); if(parseBinding[0] == "BindingContext") { var bindingMethods = parseBinding[1].split(','); if(bindingMethods.length == 2) { this.bindingMethod = bindingMethods[0]; this.bindingCountMethod = bindingMethods[1]; this.bindingComplete = true; } } } if(!this.bindingComplete) alert('ERROR,Binding Failed.'); } SilverlightBinding.BindingContext.prototype = { _chilDWorker : function(parent,parseParent) { if(parent.tag && parent.tag != '') { if(parseParent) { var bindingData = new SilverlightBinding.BindingData(parent,parent.tag,this); if(bindingData.bindingComplete) { this.bindingControls.length++; this.bindingControls[this.bindingControls.length-1] = bindingData; } else delete bindingData; } try { var temp = parent.children; } catch(err) { return; } for(var i = 0; i < parent.children.count; i++) this._chilDWorker(parent.children.getItem(i),true); } }, initialize:function() { this._chilDWorker(this.bindingContainer,false); this._receiveCount(); this._receiveData(0); }, OnSucceeded: function(result,userContext,methodname) { if (methodname == userContext.bindingMethod) { for(var i = 0; i < userContext.bindingControls.length; i++) userContext.bindingControls[i].updateValue(result); } else if(methodname == userContext.bindingCountMethod) userContext.recordCount = result; }, OnFailed:function(error,methodname) { if(error !== null) { alert(error.get_message()); } }, _receiveData: function(index) { eval('PageMethods.'+this.bindingMethod+'(index,this.OnSucceeded,this.OnFailed,this);'); }, _receiveCount: function() { eval('PageMethods.'+this.bindingCountMethod+'(this.OnSucceeded, next:function() { if(this.currentDataIndex+1 >= this.recordCount) return; this._receiveData(++this.currentDataIndex); }, prev:function() { if(this.currentDataIndex -1 < 0) return; this._receiveData(--this.currentDataIndex); } } |
以上是内存溢出为你收集整理的另類的Silverlight中文解法全部内容,希望文章能够帮你解决另類的Silverlight中文解法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)