/// <summary> /// 生成集合 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterDataSet(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { //var dataDataSet = from t in screenDef.Children // where t.MemberType == EMemberType.DataSet // select t; //if (dataDataSet != null && dataDataSet.ToList().Count() > 0) //{ // int index = 0; // foreach (var item in dataDataSet.ToList()) // { // if (index == 0) htmlWriter.WriteLine("{"); // else htmlWriter.WriteLine(",{"); // index++; // htmlWriter.WriteLine("RegType:\"Collection\","); // htmlWriter.WriteLine("RegValue:{"); // DataSet ds = (DataSet)item; // var entityName = (from t in compile.ProjectItems // where t.Value.DocumentType == 1 && t.Key == ds.EntityId // select t.Value.Name).FirstOrDefault(); // if (entityName != null) // { // htmlWriter.WriteLine("Name:\"" + item.Name + "\", Entity:\"" + entityName + "\""); // } // htmlWriter.WriteLine("}"); // if (index == dataDataSet.ToList().Count()) htmlWriter.WriteLine("},"); // else htmlWriter.WriteLine("}"); // } //} }
/// <summary> /// 生成逻辑 /// </summary> /// <param name="body">屏幕定义对象</param> public override string Build(object body) { try { var screenDefinition = body as ScreenDefinition; if (screenDefinition == null) { return(string.Empty); } ControlHost controlHost = screenDefinition.Root; using (var writer = new StringWriter()) { //根据屏幕生成HTML var xmlWriter = new HtmlTextWriter(writer); xmlWriter.AddAttribute("dojoType", "dojox/mvc/Group"); xmlWriter.AddAttribute("style", "width:100%;height:100%;"); xmlWriter.AddAttribute("class", "groupDiv"); xmlWriter.RenderBeginTag("div"); var builder = controlHost.GetBuilder(true, screenDefinition, null, null, null, xmlWriter); builder.Build(); xmlWriter.RenderEndTag(); return(writer.ToString().Replace(System.Environment.NewLine, "")); } } catch (Exception ex) { throw ex; } }
public void if_none_are_provided_check_for_value() { var source = new TextBox { Text = "the text" }; sourceNode.Stub(x => x.UIElement).Return(source); var defaults = Stub <IElementConvention>(); conventionManager.Expect(x => x.GetElementConvention(typeof(TextBox))) .Return(defaults); defaults.Expect(x => x.GetValue(source)).Return(source.Text); var message = new FakeMessage(); message.Initialize(sourceNode); var element = new ControlHost(); handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var requirements = new List <RequiredParameter> { new RequiredParameter("value", typeof(object)), }; var result = binder.DetermineParameters( message, requirements, handlingNode, null ); result.Length.ShouldBe(1); result.Contains(source.Text).ShouldBeTrue(); }
/// <summary> /// 生成DataGrid方法 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="htmlWriter">输出</param> private void GetDataSetDefaultMethod(ControlHost controlHost, HtmlTextWriter htmlWriter) { string typeName = controlHost.Content.GetType().Name; if (typeName == "DataGrid") { htmlWriter.WriteLine("{"); htmlWriter.WriteLine("RegType:\"Method\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("" + controlHost.Name + "_OnSelected: function (index, current) {"); htmlWriter.WriteLine("if(current === undefined){ current = this; }"); htmlWriter.WriteLine("var row = current.getItem(index);"); htmlWriter.WriteLine("if(row){ current.store.SetSelectItem(row); }"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("},"); htmlWriter.WriteLine("{"); htmlWriter.WriteLine("RegType:\"Method\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("" + controlHost.Name + "_OnApplyCellEdit: function (inValue, inRowIndex, inFieldIndex) {"); htmlWriter.WriteLine("screen.ViewModel." + controlHost.Name + "_OnSelected(inRowIndex, this);"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("},"); } foreach (var item in controlHost.Children) { GetDataSetDefaultMethod(item, htmlWriter); } }
/// <summary> /// 生成逻辑 /// </summary> /// <param name="body">屏幕定义对象</param> public override string Build(object body) { try { var screenDefinition = body as ScreenDefinition; if (screenDefinition == null) { return(string.Empty); } ControlHost controlHost = screenDefinition.Root; using (var writer = new StringWriter()) { //根据屏幕生成HTML var xmlWriter = new HtmlTextWriter(writer); var builder = controlHost.GetBuilder(true, screenDefinition, null, null, null, xmlWriter); builder.Build(); return(writer.ToString().Replace(System.Environment.NewLine, "")); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void ResetScaleSize(SIZE clientSize) { INativeBase native = Native; if (native != null) { ControlHost host = native.Host; SIZE nativeSize = native.DisplaySize; List <ControlA> controls = native.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { WindowFrameA frame = controls[i] as WindowFrameA; if (frame != null) { WindowEx window = frame.GetControls()[0] as WindowEx; if (window != null && !window.AnimateMoving) { POINT location = window.Location; if (location.x < 10 || location.x > nativeSize.cx - 10) { location.x = 0; } if (location.y < 30 || location.y > nativeSize.cy - 30) { location.y = 0; } window.Location = location; } } } native.ScaleSize = new SIZE((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.Update(); } }
/// <summary> /// 判断是否失败 /// </summary> /// <returns>是否失败</returns> private bool IsLose() { ControlHost host = Native.Host; SnakeBody body = m_bodys[0]; //蛇头是否撞墙 if (body.Left < 0 || body.Right > Width || body.Top < 0 || body.Bottom > Width) { return(true); } //蛇关节间是否碰撞 int bodySize = m_bodys.Count; for (int i = 0; i < bodySize; i++) { for (int j = i + 1; j < bodySize - i - 1; j++) { RECT tempRect = new RECT(); RECT iRect = m_bodys[i].Bounds; RECT jRect = m_bodys[j].Bounds; if (host.GetIntersectRect(ref tempRect, ref iRect, ref jRect) > 0) { return(true); } } } return(false); }
/// <summary> /// 获取生成器 /// </summary> /// <param name="control">控件对象</param> /// <returns>返回控件对应的生成器</returns> public static ControlBuildBase GetBuilder(this ControlHost controlHost, bool isPreview, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter) { //图表控件名字为空自动生成一个默认名字 var controlName = controlHost.Content.GetType().Name; if (controlName == "ChartPane" || controlName == "DropDownButton") { if (string.IsNullOrEmpty(controlHost.Name)) { controlHost.Name = controlName + ctlNumber++; } } if (!isPreview && doc != null && !string.IsNullOrEmpty(controlHost.Name)) { controlHost.Name = doc.Name + "_" + controlHost.Name; } if (controlHost.Content != null) { var assembly = Assembly.GetAssembly(typeof(ControlExtend)); string typeName = string.Format("Wilmar.Build.Core.Dojo.Default.Builders.{0}Build", controlHost.Content.GetType().Name); if (assembly.GetType(typeName) == null) { throw new Exception(string.Format("类型【{0}】没对应的生成器。", typeName)); } ControlBuildBase builder = Activator.CreateInstance(assembly.GetType(typeName), isPreview, controlHost, screenDef, compile, doc, permissionData, htmlWriter) as ControlBuildBase; return(builder); } else { return(null); } }
public void if_none_are_provided_check_for_dataContext() { var source = new Button { DataContext = new object() }; sourceNode.Stub(x => x.UIElement).Return(source); var message = new FakeMessage(); message.Initialize(sourceNode); var element = new ControlHost(); handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var requirements = new List <RequiredParameter> { new RequiredParameter("datacontext", typeof(object)), }; var result = binder.DetermineParameters( message, requirements, handlingNode, null ); result.Length.ShouldBe(1); result.Contains(source.DataContext).ShouldBeTrue(); }
/// <summary> /// 生成属性 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterProperty(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { var dataProperty = from t in screenDef.Children where t.MemberType == EMemberType.Property select t; if (dataProperty != null && dataProperty.ToList().Count > 0) { int index = 0; foreach (var item in dataProperty.ToList()) { if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } htmlWriter.WriteLine("RegType:\"Property\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("Name:\"" + item.Name + "\""); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); index++; } } }
/// <summary> /// 生成属性数据 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterPropertyMetaData(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { var dataProperty = from t in screenDef.Children where t.MemberType == EMemberType.Property select t; if (dataProperty != null && dataProperty.ToList().Count > 0) { int index = 0; foreach (var item in dataProperty.ToList()) { var property = item as Property; var content = property.Content; dynamic type = content; if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } htmlWriter.WriteLine("RegType:\"Property\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("Name:\"" + item.Name + "\","); if (content.GetType().GetProperty("Title") != null) { htmlWriter.WriteLine("Title:\"" + type.Title + "\","); } if (content.GetType().GetProperty("IsRequired") != null) { htmlWriter.WriteLine("IsRequired:\"" + property.IsRequired.ToString().ToLower() + "\","); } if (content.GetType().GetProperty("IsCollection") != null) { htmlWriter.WriteLine("IsCollection:\"" + property.IsCollection.ToString().ToLower() + "\","); } if (content.GetType().GetProperty("DefaultValue") != null) { htmlWriter.WriteLine("DefaultValue:\"" + type.DefaultValue + "\","); } if (content.GetType().GetProperty("MaxLength") != null) { htmlWriter.WriteLine("MaxLength:\"" + type.MaxLength + "\","); } if (content.GetType().GetProperty("MinLength") != null) { htmlWriter.WriteLine("MinLength:\"" + type.MinLength + "\""); } htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); index++; } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="isPreview">是否预览</param> /// <param name="controlHost">控件</param> /// <param name="compile">编译器对象</param> /// <param name="htmlWriter">htmlWriter</param> public ControlBuildBase(bool isPreview, ControlHost controlHost, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter) { this.IsPreview = isPreview; this.ControlHost = controlHost; this.ScreenDefinition = screenDef; this.Compile = compile; this.ProjectDocument = doc; this.PermissionData = permissionData; this.HtmlWriter = htmlWriter; }
/// <summary> /// 按键方法 /// </summary> /// <param name="key">按键</param> public override void OnKeyDown(char key) { base.OnKeyDown(key); ControlHost host = Native.Host; if (!host.IsKeyPress(0x10) && !host.IsKeyPress(0x11) && !host.IsKeyPress(0x12)) { if (m_play.GameState == GameState.Playing) { int bodySize = m_bodys.Count; if (bodySize > 0) { switch ((int)key) { //向左 case 37: if (m_bodys[0].Direction != SnakeDirection.Right) { m_bodys[0].Direction = SnakeDirection.Left; } break; //向上 case 38: if (m_bodys[0].Direction != SnakeDirection.Down) { m_bodys[0].Direction = SnakeDirection.Up; } break; //向右 case 39: if (m_bodys[0].Direction != SnakeDirection.Left) { m_bodys[0].Direction = SnakeDirection.Right; } break; //向下 case 40: if (m_bodys[0].Direction != SnakeDirection.Up) { m_bodys[0].Direction = SnakeDirection.Down; } break; } } } //回车 if (key == 13) { ChangeState(); } } }
protected override void given_the_context_of() { factory = new DefaultMethodFactory(); conventionManager = Mock<IConventionManager>(); binder = new DefaultMessageBinder(conventionManager); handlingNode = Stub<IInteractionNode>(); sourceNode = Stub<IInteractionNode>(); host = new ControlHost(); sourceNode.Stub(x => x.UIElement).Return(host).Repeat.Any(); }
protected override void given_the_context_of() { factory = new DefaultMethodFactory(); conventionManager = Mock <IConventionManager>(); binder = new DefaultMessageBinder(conventionManager); handlingNode = Stub <IInteractionNode>(); sourceNode = Stub <IInteractionNode>(); host = new ControlHost(); sourceNode.Stub(x => x.UIElement).Return(host).Repeat.Any(); }
/// <summary> /// 生成逻辑 /// </summary> /// <param name="compile">DOJO编译器</param> /// <param name="doc">文档对象模型</param> public override void Build(CompileBase compile, ProjectDocument doc) { var docBody = compile.GetDocumentBody(doc); var screenDefinition = docBody as ScreenDefinition; if (screenDefinition != null) { ControlHost controlHost = screenDefinition.Root; BuildHtml(doc.Name, controlHost, compile, screenDefinition, doc); } }
private void ArticleBrowserAddIn_Startup(object sender, EventArgs e) { // Load the WPF ControlHost to be the design surface for WPF UI _host = new ControlHost(); _host.Form1_Load(this, EventArgs.Empty); // Add the name of the plugin _myTaskPane = CustomTaskPanes.Add(_host, "ArticleBrowser"); _myTaskPane.Visible = true; // Bring the control to front, so drag n drop element work _myTaskPane.Control.BringToFront(); }
/// <summary> /// 以动画形式隐藏 /// </summary> public void AnimateHide() { m_animateType = 1; INativeBase native = Native; ControlHost host = native.Host; m_animateDirection = m_rd.Next(0, 4); StartTimer(m_timerID, 10); m_animateMoving = true; host.AllowOperate = false; }
private void RegisterToViewModel(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { this.RegGridEvent(controlHost, htmlWriter); htmlWriter.WriteLine("screen.RegToViewModel(["); this.RegisterMethod(controlHost, screenDef, htmlWriter); this.RegisterDataSet(controlHost, screenDef, htmlWriter); this.RegisterProperty(controlHost, screenDef, htmlWriter); htmlWriter.WriteLine("]);"); }
/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void ResetScaleSize(SIZE clientSize) { INativeBase native = Native; if (native != null) { ControlHost host = native.Host; SIZE nativeSize = native.DisplaySize; native.ScaleSize = new SIZE((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.Update(); } }
/// <summary> /// 生成DataGrid方法注册 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="htmlWriter">输出</param> private void RegGridEvent(ControlHost controlHost, HtmlTextWriter htmlWriter) { string typeName = controlHost.Content.GetType().Name; if (typeName == "DataGrid") { htmlWriter.WriteLine("screen.RegGridEvent('" + controlHost.Name + "_event', " + controlHost.Name + ");"); } foreach (var item in controlHost.Children) { RegGridEvent(item, htmlWriter); } }
/// <summary> /// 添加食物 /// </summary> private void AddFood() { Food food = new Food(); food.Size = new SIZE(SNAKE_SIZE, SNAKE_SIZE); ControlHost host = Native.Host; while (true) { //获取随机数 int num = m_random.Next(0, Width / SNAKE_SIZE - 1); int num2 = m_random.Next(0, Height / SNAKE_SIZE - 1); //设置位置 food.Location = new POINT(num * SNAKE_SIZE, num2 * SNAKE_SIZE); bool reset = false; RECT fRect = food.Bounds; int bodySize = m_bodys.Count; for (int j = 0; j < bodySize; j++) { //如果与关节重合,需要重新设置位置 RECT tempRect = new RECT(); RECT bRect = m_bodys[j].Bounds; if (host.GetIntersectRect(ref tempRect, ref bRect, ref fRect) > 0) { reset = true; } } int foodSize = m_foods.Count; for (int j = 0; j < foodSize; j++) { RECT fiRect = m_foods[j].Bounds; RECT tempRect = new RECT(); //如果与食物重合,需要重新设置位置 if (host.GetIntersectRect(ref tempRect, ref fiRect, ref fRect) > 0) { reset = true; } } if (!reset) { break; } } AddControl(food); m_foods.Add(food); food.BringToFront(); }
/// <summary> /// 拖动中方法 /// </summary> public override void OnDragging() { base.OnDragging(); ControlA parent = Parent; ControlHost host = Native.Host; RECT tempRect = new RECT(); RECT bounds = Bounds; List <ControlA> controls = parent.m_controls; int controlsSize = controls.Count; int thisIndex = -1; for (int i = 0; i < controlsSize; i++) { ControlA iControl = controls[i]; if (iControl == this) { thisIndex = i; break; } } int mx = bounds.left + (bounds.right - bounds.left) / 2; int my = bounds.top + (bounds.bottom - bounds.top) / 2; for (int i = 0; i < controlsSize; i++) { ControlA iCell = controls[i]; if (iCell != this && !(iCell is ScrollBarA)) { RECT iBounds = iCell.Bounds; if (host.GetIntersectRect(ref tempRect, ref bounds, ref iBounds) > 0) { if (mx >= iBounds.left && mx <= iBounds.right && my >= iBounds.top && my <= iBounds.bottom) { controls[thisIndex] = iCell; controls[i] = this; RECT oldBounds = iCell.Bounds; iCell.Bounds = m_paintRect; m_paintRect = oldBounds; parent.Invalidate(); break; } } } } }
/// <summary> /// 设置Prosps /// </summary> /// <returns></returns> private string GetDataGridProsps(ControlHost controlHost) { string result = string.Empty, controlName = controlHost.Content.GetType().Name; if (controlName == "Menu") { Menu control = controlHost.Content as Menu; StringBuilder returnContent = new StringBuilder(); result = control.BuildControlProps(this.ScreenDefinition, this.IsPreview, this.PermissionData, returnContent); } else if (controlName == "MenuItem") { MenuItem control = controlHost.Content as MenuItem; StringBuilder returnContent = new StringBuilder(); result = control.BuildControlProps(this.ScreenDefinition, this.IsPreview, this.PermissionData, returnContent); } return(result); }
/// <summary> /// 以动画形式显示 /// </summary> /// <param name="showDialog">是否对话框打开</param> public void AnimateShow(bool showDialog) { m_animateType = 0; INativeBase native = Native; ControlHost host = native.Host; SIZE nativeSize = native.DisplaySize; int width = Width, height = Height, mx = (nativeSize.cx - width) / 2, my = (nativeSize.cy - height) / 2, x = mx, y = my; m_animateDirection = m_rd.Next(0, 4); switch (m_animateDirection) { case 0: x = -width; break; case 1: x = nativeSize.cx; break; case 2: y = -height; break; case 3: y = nativeSize.cy; break; } POINT location = new POINT(x, y); Location = location; if (showDialog) { ShowDialog(); } else { Show(); } Update(); StartTimer(m_timerID, 10); m_animateMoving = true; host.AllowOperate = false; }
/// <summary> /// 生成列内容 /// </summary> /// <param name="content"></param> /// <param name="child"></param> /// <returns></returns> private string BuildCell(DataGrid content, ControlHost child) { StringBuilder result = new StringBuilder(); ControlBase control = child.Content; string controlName = control.GetType().Name; //列分组 if (controlName.ToLower() == "datagridheader") { StringBuilder cellGroup = new StringBuilder(); StringBuilder cellString = new StringBuilder(); cellGroup.Append("["); var dgHeader = child.Content as DataGridHeader; foreach (var header in child.Children) { string cellContent = this.BuildCellContent(content, header, true); if (cellContent.ToString().Length > 0) { cellString.Append("{" + cellContent.ToString().Substring(0, cellContent.ToString().Length - 1) + "},"); } } if (cellString.ToString().Length > 0) { cellGroup.Append(cellString.ToString().Substring(0, cellString.ToString().Length - 1)); } cellGroup.Append("]"); if (cellGroup.ToString().Length > 0) { result.Append(cellGroup.ToString() + ","); } } else { string cellContent = this.BuildCellContent(content, child, false); if (cellContent.ToString().Length > 0) { result.Append("{" + cellContent.ToString().Substring(0, cellContent.ToString().Length - 1) + "},"); } } return(result.ToString()); }
public void if_none_are_provided_should_search_the_UI() { const int param1 = 56; const double param2 = 34.0; var element = new ControlHost(); element.SetParam1(param1); element.SetParam2(param2); handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var defaults = Mock <IElementConvention>(); conventionManager.Expect(x => x.GetElementConvention(typeof(TextBox))) .Return(defaults).Repeat.Twice(); var stack = new Stack <object>(); stack.Push(param1); stack.Push(param2); defaults.Expect(x => x.GetValue(Arg <DependencyObject> .Is.Anything)).Return(param1).Repeat.Once(); defaults.Expect(x => x.GetValue(Arg <DependencyObject> .Is.Anything)).Return(param2).Repeat.Once(); var message = new FakeMessage(); message.Initialize(sourceNode); var requirements = new List <RequiredParameter> { new RequiredParameter("param1", typeof(string)), new RequiredParameter("param2", typeof(int)) }; var result = binder.DetermineParameters( message, requirements, handlingNode, null ); result.Length.ShouldBe(2); result.Contains(param1.ToString()).ShouldBeTrue(); result.Contains(Convert.ToInt32(param2)).ShouldBeTrue(); }
private string GetReportProsps(ControlHost controlHost) { string result = string.Empty; ReportViewer control = controlHost.Content as ReportViewer; if (!this.IsPreview && control.Bindings.Count > 0) { Dictionary <string, string> dictProperty = control.GetPropertyBindValue(); foreach (var item in control.Bindings) { string bindPath = item.Path == null ? "" : item.Path; string bindProperty = item.Property == null ? "" : item.Property; if (bindProperty.ToLower() == "value" && !string.IsNullOrEmpty(bindPath)) { result = string.Format("at('rel:','{0}').direction(1)", bindPath); break; } } } return(result); }
/// <summary> /// 生成方法 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterMethod(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { this.GetDataSetDefaultMethod(controlHost, htmlWriter); var dataMethod = from t in screenDef.Children where t.MemberType == EMemberType.Method select t; if (dataMethod != null && dataMethod.ToList().Count > 0) { int index = 0; foreach (var item in dataMethod.ToList()) { if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } index++; htmlWriter.WriteLine("RegType:\"Method\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("" + item.Name + ":function(e){"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); if (index == dataMethod.ToList().Count()) { htmlWriter.WriteLine("},"); } else { htmlWriter.WriteLine("}"); } } } }
/// <summary> /// 单元格拖动方法 /// </summary> /// <param name="cell">单元格</param> public void OnCellDragging(UserSecurityCellT2 cell) { ControlHost host = Native.Host; RECT tempRect = new RECT(); RECT bounds = cell.Bounds; int cellsSize = m_cells.Count; int thisIndex = -1; for (int i = 0; i < cellsSize; i++) { UserSecurityCellT2 iCell = m_cells[i]; if (iCell == cell) { thisIndex = i; break; } } int mx = bounds.left + (bounds.right - bounds.left) / 2; int my = bounds.top + (bounds.bottom - bounds.top) / 2; for (int i = 0; i < cellsSize; i++) { UserSecurityCellT2 iCell = m_cells[i]; if (iCell != cell) { RECT iBounds = iCell.PaintRect; if (host.GetIntersectRect(ref tempRect, ref bounds, ref iBounds) > 0) { if (mx >= iBounds.left && mx <= iBounds.right && my >= iBounds.top && my <= iBounds.bottom) { m_cells[thisIndex] = iCell; m_cells[i] = cell; Update(); break; } } } } }
private void BuildDataGridCell(ref StringBuilder result, DataGrid content, ControlHost child) { ControlBase control = child.Content; string controlName = control.GetType().Name; if (controlName.ToLower() == "datagridheader") { string cellContent = this.BuildCellContent(content, child, true); result.Append("{" + cellContent.ToString().Substring(0, cellContent.ToString().Length - 1) + ""); if (child.Children.Count > 0) { result.Append(",children:["); foreach (var header in child.Children) { if (header.Content.GetType().Name.ToLower() == "datagridheader") { BuildDataGridCell(ref result, content, header); } else { string cellChildContent = this.BuildCellContent(content, header, true); result.Append("{" + cellChildContent.ToString().Substring(0, cellChildContent.ToString().Length - 1) + "},"); } } result = new StringBuilder(result.ToString().Substring(0, result.ToString().Length - 1)); result.Append("]"); } result.Append("},"); } else { string cellContent = this.BuildCellContent(content, child, false); if (cellContent.ToString().Length > 0) { result.Append("{" + cellContent.ToString().Substring(0, cellContent.ToString().Length - 1) + "},"); } } }
public void if_none_are_provided_should_search_the_UI() { const int param1 = 56; const double param2 = 34.0; var element = new ControlHost(); element.SetParam1(param1); element.SetParam2(param2); _handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var defaults = Mock<IElementConvention>(); _conventionManager.Expect(x => x.GetElementConvention(typeof(TextBox))) .Return(defaults).Repeat.Twice(); defaults.Expect(x => x.GetValue(Arg<DependencyObject>.Is.Anything)).Return(param1); defaults.Expect(x => x.GetValue(Arg<DependencyObject>.Is.Anything)).Return(param2); var message = new FakeMessage(); message.Initialize(_sourceNode); var requirements = new List<RequiredParameter> { new RequiredParameter("param1", typeof(string)), new RequiredParameter("param2", typeof(int)) }; var result = _binder.DetermineParameters( message, requirements, _handlingNode, null ); Assert.That(result, Has.Length(2)); Assert.That(result, Has.Member(param1.ToString())); Assert.That(result, Has.Member(Convert.ToInt32(param2))); }
public void if_none_are_provided_check_for_eventArgs() { var context = EventArgs.Empty; var message = new FakeMessage(); message.Initialize(_sourceNode); var element = new ControlHost(); _handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var requirements = new List<RequiredParameter> { new RequiredParameter("eventArgs", typeof(EventArgs)), }; var result = _binder.DetermineParameters( message, requirements, _handlingNode, context ); Assert.That(result, Has.Length(1)); Assert.That(result, Has.Member(context)); }
public void if_none_are_provided_check_for_value() { var source = new TextBox { Text = "the text" }; _sourceNode.Stub(x => x.UIElement).Return(source); var defaults = Stub<IElementConvention>(); _conventionManager.Expect(x => x.GetElementConvention(typeof(TextBox))) .Return(defaults); defaults.Expect(x => x.GetValue(source)).Return(source.Text); var message = new FakeMessage(); message.Initialize(_sourceNode); var element = new ControlHost(); _handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var requirements = new List<RequiredParameter> { new RequiredParameter("value", typeof(object)), }; var result = _binder.DetermineParameters( message, requirements, _handlingNode, null ); Assert.That(result, Has.Length(1)); Assert.That(result, Has.Member(source.Text)); }
public void if_none_are_provided_check_for_dataContext() { var source = new Button { DataContext = new object() }; _sourceNode.Stub(x => x.UIElement).Return(source); var message = new FakeMessage(); message.Initialize(_sourceNode); var element = new ControlHost(); _handlingNode.Stub(x => x.UIElement).Return(element).Repeat.Twice(); var requirements = new List<RequiredParameter> { new RequiredParameter("datacontext", typeof(object)), }; var result = _binder.DetermineParameters( message, requirements, _handlingNode, null ); Assert.That(result, Has.Length(1)); Assert.That(result, Has.Member(source.DataContext)); }