/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmCommon_Load(object sender, EventArgs e) { try { ComClient = new EPortalService.CommonClient(); DataTransformer = new DataTransform(); ComClient.SetCurUsrInfo(CurUsrID, CurUsrName); //设置行序号列的宽度 this.View_Common1.IndicatorWidth = 36; this.View_Common2.IndicatorWidth = 36; this.View_Common3.IndicatorWidth = 36; //注册自动计算行号事件 this.View_Common1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.View_Common1_CustomDrawRowIndicator); this.View_Common2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.View_Common2_CustomDrawRowIndicator); this.View_Common3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.View_Common3_CustomDrawRowIndicator); //设置当前选择页签 //Tab_Common1.SelectedTabPage = Page_Preview; //失效详细信息页签上的控件 EDabDtControls(EDabType.Disable); Grip_Common2.DataSource = InitGridData("0"); AssiValue(); ExpandoObject EObject = (ExpandoObject)View_Common2.GetFocusedRow(); ShowData(Grip_Common3, GetDataByFocRow(EObject, "Panel6"), GetDataByPKToChCol("Panel6"), View_Common3, "Panel6"); ShowData(Grip_Common1, GetDataByFocRow(EObject, "Panel3"), GetDataByPKToChCol("Panel3"), View_Common1, "Panel3"); } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
public DataSourceChangedEventArgs(SourceTileServer tileSource, DataTransform dataTransform, EStatus status, string statusMessage = "SUCCESS") { TileSource = tileSource; DataTransform = dataTransform; Status = status; StatusMessage = statusMessage; }
private void OnDestroy() { if (GameData.PlayerDataTransform.GetInstanceID() == DataTransform.GetInstanceID()) { GameData.PlayerDataTransform = null; } }
// check if a query stage / data transform has all of its inputs & outputs hooked up internal static void DataWired <T1, T2>(DataTransform <T1, T2> dt) { Assert.NotNull(dt.WorkingIndices); Assert.NotNull(dt.Input1); Assert.NotNull(dt.Output); Assert.NotNull(dt.Process); }
public DataTransformReader(DataTransform dataTransform) { // Initialize the object. this.dataTransform = dataTransform; this.lexicon = new Lexicon(); this.xmlNamespaceManager = new XmlNamespaceManager(new NameTable()); this.stateStack = new System.Collections.Generic.Stack <NodeState>(); }
public DataTransform getTransform() { if (dataTransform == null) { dataTransform = new DataTransform(); } return(dataTransform); }
public override void Activate() { base.Activate(); _dataTransform = Entity.Get <DataTransform>(); var dataHealth = Entity.Get <DataHealth>(); dataHealth.Health.Where(health => health >= 0f).Subscribe(SetScale); }
internal static void DataWired <T1, T2, T3, T4, T5, T6>(DataTransform <T1, T2, T3, T4, T5, T6> dt) { Assert.NotNull(dt.WorkingIndices); Assert.NotNull(dt.Input1); Assert.NotNull(dt.Input2); Assert.NotNull(dt.Input3); Assert.NotNull(dt.Input4); Assert.NotNull(dt.Input5); Assert.NotNull(dt.Output); Assert.NotNull(dt.Process); }
/// <summary> /// Creates a writer to translate an incoming XSL stylesheet into a data structure. /// </summary> public XmlDataTransformWriter(DataTransform dataTransform) { // Initialize the object; this.dataTransform = dataTransform; // This determines how to handle each of the incoming tokens parsed out of the XML stream. this.tokenHandlerDictionary = new Dictionary <Token, TokenHandler>(); // This stack holds the current state of parsing the XSL language elements. It is needed to build a tree of these // structures that is roughly the same as the incoming XSL document. The stack structure is required because the // parsing can recursively dig down into the data structures, the unwind back up the tree before reading more child // elements. The stack structure keeps track of how far down into the tree the parsing has gone. this.nodeStack = new Stack <Node>(); this.nodeStack.Push(new RootNode()); // This will create a lexical analyzer for the XSL DataTransforms and installs handlers for each of the tokens read from // the XML stream as it parses the stylesheet. this.lexicon = new Lexicon(); this.tokenHandlerDictionary.Add(Token.Animation, new TokenHandler(ParseAnimation)); this.tokenHandlerDictionary.Add(Token.ApplyTemplate, new TokenHandler(ParseApplyTemplate)); this.tokenHandlerDictionary.Add(Token.BottomBorder, new TokenHandler(ParseBottomBorder)); this.tokenHandlerDictionary.Add(Token.LeftBorder, new TokenHandler(ParseLeftBorder)); this.tokenHandlerDictionary.Add(Token.RightBorder, new TokenHandler(ParseRightBorder)); this.tokenHandlerDictionary.Add(Token.TopBorder, new TokenHandler(ParseTopBorder)); this.tokenHandlerDictionary.Add(Token.Tile, new TokenHandler(ParseTile)); this.tokenHandlerDictionary.Add(Token.Column, new TokenHandler(ParseColumn)); this.tokenHandlerDictionary.Add(Token.Columns, new TokenHandler(ParseColumns)); this.tokenHandlerDictionary.Add(Token.ColumnReference, new TokenHandler(ParseColumnReference)); this.tokenHandlerDictionary.Add(Token.Data, new TokenHandler(ParseData)); this.tokenHandlerDictionary.Add(Token.DataTransform, new TokenHandler(ParseDataTransform)); this.tokenHandlerDictionary.Add(Token.View, new TokenHandler(ParseView)); this.tokenHandlerDictionary.Add(Token.Filter, new TokenHandler(ParseFilter)); this.tokenHandlerDictionary.Add(Token.Font, new TokenHandler(ParseFont)); this.tokenHandlerDictionary.Add(Token.FontBrush, new TokenHandler(ParseFontBrush)); this.tokenHandlerDictionary.Add(Token.Image, new TokenHandler(ParseImage)); this.tokenHandlerDictionary.Add(Token.InteriorBrush, new TokenHandler(ParseInteriorBrush)); this.tokenHandlerDictionary.Add(Token.Locks, new TokenHandler(ParseLocks)); this.tokenHandlerDictionary.Add(Token.Lock, new TokenHandler(ParseLock)); this.tokenHandlerDictionary.Add(Token.NumberFormat, new TokenHandler(ParseNumberFormat)); this.tokenHandlerDictionary.Add(Token.Protection, new TokenHandler(ParseProtection)); this.tokenHandlerDictionary.Add(Token.Row, new TokenHandler(ParseRow)); this.tokenHandlerDictionary.Add(Token.Style, new TokenHandler(ParseStyle)); this.tokenHandlerDictionary.Add(Token.StyleId, new TokenHandler(ParseStyleId)); this.tokenHandlerDictionary.Add(Token.Styles, new TokenHandler(ParseStyles)); this.tokenHandlerDictionary.Add(Token.Template, new TokenHandler(ParseTemplate)); this.tokenHandlerDictionary.Add(Token.Scale, new TokenHandler(ParseScale)); this.tokenHandlerDictionary.Add(Token.Split, new TokenHandler(ParseSplit)); this.tokenHandlerDictionary.Add(Token.Scratch, new TokenHandler(ParseScratch)); this.tokenHandlerDictionary.Add(Token.StringFormat, new TokenHandler(ParseStringFormat)); this.tokenHandlerDictionary.Add(Token.Sort, new TokenHandler(ParseSort)); this.tokenHandlerDictionary.Add(Token.SortColumn, new TokenHandler(ParseSortColumn)); this.tokenHandlerDictionary.Add(Token.Source, new TokenHandler(ParseSource)); this.tokenHandlerDictionary.Add(Token.Variable, new TokenHandler(ParseVariable)); }
public void TestRoundTripeEmpty() { const string TestString = ""; CertificateHelper.InvokeWithDummyCert( (fingerprint) => { var encrypted = DataTransform.Encrypt(fingerprint, TestString); var decrypted = DataTransform.Decrypt(encrypted); Assert.AreEqual(decrypted, TestString); }); }
//------------------------------------------------------------------------- // Called when the map is panned private void Viewport_EndPanning(object sender, EventArgs e) { if (Model != null) { Point centre = new Point(Visible.CenterX, Visible.CenterY); if (DataTransform != null) { centre = DataTransform.ViewportToData(centre); } Model.OnViewChanged(centre.Y, centre.X, Visible.Size.Width, Visible.Size.Height); } }
public void TestRoundTrip2() { const string TestString = "asdfasdfas;dlffkjpowQYB93YRY7982UO1HQW AHAUI FACPWUH F CAHGUIWEA RY93QRCHWEFCS;DHFVOAWGOSE7R HAE"; CertificateHelper.InvokeWithDummyCert( (fingerprint) => { var encrypted = DataTransform.Encrypt(fingerprint, TestString); var decrypted = DataTransform.Decrypt(encrypted); Assert.AreEqual(decrypted, TestString); }); }
//------------------------------------------------------------------------- public void ChangeServer(SourceTileServer server, DataTransform dataTransform) { Application.Current.Dispatcher.Invoke(() => { try { RaiseDataSourceChangedEvent(new DataSourceChangedEventArgs(server, dataTransform, DataSourceChangedEventArgs.EStatus.SUCCESS)); OnPropertyChanged(nameof(MapTransform)); OnPropertyChanged(nameof(CoordinateTransform)); } catch (Exception ex) { RaiseDataSourceChangedEvent(new DataSourceChangedEventArgs(null, null, DataSourceChangedEventArgs.EStatus.FAIL, ex.Message)); } }); }
//------------------------------------------------------------------------- // Centres the map on the given point and sets the view width and height public void ChangeView(double centreLatDeg, double centreLonDeg, double widthDeg, double heightDeg) { Point a = new Point(centreLonDeg - widthDeg / 2, centreLatDeg - heightDeg / 2); Point b = new Point(centreLonDeg + widthDeg / 2, centreLatDeg + heightDeg / 2); if (DataTransform != null) { a = DataTransform.DataToViewport(a); b = DataTransform.DataToViewport(b); } Dispatcher.Invoke(() => { Visible = new DataRect(a, b); }); }
static void Main(string[] args) { try { Console.WriteLine("Started to transform ......"); DataTransform.TransFile("../../../TestData/Input1.csv", FileType.AccountFormat1, true); DataTransform.TransFile("../../../TestData/Input2.csv", FileType.AccountFormat2, false, new string[] { "Name", "Type", "Currency", "Custodian Code" }); Console.WriteLine("Finished, Check the log files to see if there are errors."); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press ENTER Key to exit."); Console.ReadLine(); }
public static double[] Transform(double[] data, DataTransform func) { if (data == null || func == null) { return(null); } double[] retData = new double[data.Length]; for (int i = 0; i < data.Length; i++) { retData[i] = func(i, data[i]); } return(retData); }
//------------------------------------------------------------------------- // Centres the map on the given point without changing the zoom level/width/height public void CentreOn(double latDeg, double lonDeg) { if (latDeg.IsNaN() || lonDeg.IsNaN()) { return; } var centre = new Point(lonDeg, latDeg); if (DataTransform != null) { centre = DataTransform.DataToViewport(centre); } centre.X -= (Visible.Size.Width / 2); centre.Y -= (Visible.Size.Height / 2); Visible = new DataRect(centre, Visible.Size); }
/// <summary> /// This will create the namespace that contains the all the types used to generate the C# code. /// </summary> /// <param name="dataTransform">A data structure containing the description of the view.</param> public DataTransformNamespace(DataTransform dataTransform) { //namespace MarkThree.UnitTest //{ // using MarkThree.Forms; // using System; // using System.Collections.Generic; // using System.Data; // using System.Drawing; // using System.Text; // using System.Windows.Forms; // this.Name = dataTransform.TargetNamespace; this.Imports.Add(new CodeNamespaceImport("MarkThree.Forms")); this.Imports.Add(new CodeNamespaceImport("System")); this.Imports.Add(new CodeNamespaceImport("System.Collections.Generic")); this.Imports.Add(new CodeNamespaceImport("System.Data")); this.Imports.Add(new CodeNamespaceImport("System.Drawing")); this.Imports.Add(new CodeNamespaceImport("System.IO")); this.Imports.Add(new CodeNamespaceImport("System.Text")); this.Imports.Add(new CodeNamespaceImport("System.Windows.Forms")); // This will create a class that will transform a data model into a human readable report. this.Types.Add(new DataTransformClass(dataTransform)); // These classes are used to sort the various rows generated by the transform. foreach (DataTransform.TemplateNode templateNode in dataTransform.Templates) { foreach (DataTransform.RowNode rowNode in templateNode.Rows) { foreach (DataTransform.ApplyTemplateNode applyTemplateNode in rowNode.ApplyTemplates) { if (applyTemplateNode.Sorts.Count != 0) { this.Types.Add(new SortClass(applyTemplateNode)); } } } } }
/// <summary> /// Create a form for selecting and ordering the columns in a document viewer. /// </summary> /// <param name="dataTransform">The description of how the document is constructed.</param> public ColumnSelector(DataTransform dataTransform) { // IDE Maintained Components. InitializeComponent(); // Initialize the object. this.DataTransform = dataTransform; // These lists contain the available (currently invisible) columns and the displayed columns. this.availableList = new DataTransform.ColumnsNode(); this.displayedList = new DataTransform.ViewNode(); // The available columns are the ones that are not currently part of the view. This basically selects all the columns // that are not in the view. foreach (DataTransform.ColumnNode column in this.DataTransform.Columns) { bool isFound = false; foreach (DataTransform.ColumnReferenceNode columnReferenceNode in this.DataTransform.View) { if (column.ColumnId == columnReferenceNode.ColumnId) { isFound = true; break; } } if (!isFound) { availableList.Add(column); } } // The items in the 'Display' list are the ones already in the view. foreach (DataTransform.ColumnReferenceNode columnReferenceNode in this.DataTransform.View) { displayedList.Add(columnReferenceNode.Column); } // This will synchronize the form with the two lists. DrawListBoxes(); }
public void SaveFltSlt1(OperType operType, string StrXML, string TabName, string KeyWords, SqlCommand Cmd) { try { DataTransform DataTransformer = new DataTransform(); //1.获取增加方案SQL语句 string SQL = ""; List <ExpandoObject> List_EObj = DataTransformer.LoadData(GetTabStrc(TabName, "DiousEPortal.FrmFilter", operType, KeyWords, "Pal_FlCtner")); foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } //2.保存数据 SaveData1(StrXML, SQL, Cmd); } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
//----------------------------------------------------------------------- public EPSG_Converter(string epsgCode, DataTransform dataTransform) { EPSGCode = epsgCode; DataTransform = dataTransform; }
//----------------------------------------------------------------------- public EPSG_Converter(string epsgCode) { EPSGCode = epsgCode; DataTransform = null; }
/// <summary> /// 保存过滤方案数据 /// </summary> /// <param name="operType">操作类型</param> /// <param name="StrXML">序列化后的List<DTSerializer<string, object>>对象字符串</param> /// <param name="KeyWords">Where查询关键字(删除方案数据用)</param> public void SaveFltSlt(OperType operType, string StrXML, string TabName, string KeyWords) { try { DataTransform DataTransformer = new DataTransform(); //1.获取增加方案SQL语句 string SQL = ""; List <ExpandoObject> List_EObj = DataTransformer.LoadData(GetTabStrc(TabName, "DiousEPortal.FrmFilter", operType, KeyWords, "Pal_FlCtner")); foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } //2.保存数据 SaveData(StrXML, SQL, operType); } catch (Exception Ex) { //如果增加方案明细时报错,则回滚删除方案名称 if ((operType == OperType.AddSave || operType == OperType.Delete) && TabName == "t_ADMM_FltSltforDtl") { List <ExpandoObject> List_EObj1 = Serializer.DeserializeXMLToEObject(StrXML); string FSltID = ""; foreach (dynamic EObj in List_EObj1) { FSltID = EObj.FSltID; break; } DataTransform DataTransformer = new DataTransform(); string SQL = ""; List <ExpandoObject> List_EObj2; if (operType != OperType.Delete) { List_EObj2 = DataTransformer.LoadData(GetTabStrc("t_ADMM_FltSltList", "DiousEPortal.FrmFilter", OperType.Delete, " FSltID='" + FSltID + "'", "Pal_FlCtner")); foreach (ExpandoObject EObj in List_EObj2) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } //如果删除方案明细时报错,则回滚删除方案名称 else { List_EObj2 = DataTransformer.LoadData(GetTabStrc("t_ADMM_FltSltList", "DiousEPortal.FrmFilter", OperType.Delete, KeyWords, "Pal_FlCtner")); foreach (ExpandoObject EObj in List_EObj2) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } SaveData("", SQL, OperType.Delete); } Common.ShowMsg(Ex.Message); } }
/// <summary> /// 加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmFilter_Load(object sender, EventArgs e) { try { if (CurOperType == OperType.InitFilter) { UsrContr_Filter2.CtrContainer = Pal_FlCtner; DataTransformer = new DataTransform(); InitLkUp(this.UsrContr_Filter2); //新建树菜单列 DevExpress.XtraTreeList.Columns.TreeListColumn Col_FSltID = new DevExpress.XtraTreeList.Columns.TreeListColumn(); Col_FSltID.Name = "FSltID"; Col_FSltID.FieldName = "FSltID"; Col_FSltID.Caption = "FSltID"; DevExpress.XtraTreeList.Columns.TreeListColumn Col_FParentID = new DevExpress.XtraTreeList.Columns.TreeListColumn(); Col_FParentID.Name = "FParentID"; Col_FParentID.Caption = "FParentID"; Col_FParentID.FieldName = "FParentID"; DevExpress.XtraTreeList.Columns.TreeListColumn Col_FSltName = new DevExpress.XtraTreeList.Columns.TreeListColumn(); Col_FSltName.Name = "FSltName"; Col_FSltName.Caption = "FSltName"; Col_FSltName.FieldName = "FSltName"; Col_FSltName.Visible = true; Col_FSltName.VisibleIndex = 2; DevExpress.XtraTreeList.Columns.TreeListColumn Col_FFrmName = new DevExpress.XtraTreeList.Columns.TreeListColumn(); Col_FFrmName.Name = "FFrmName"; Col_FFrmName.Caption = "FFrmName"; Col_FFrmName.FieldName = "FFrmName"; //将列添加到树菜单 TrList_FltSlt.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { Col_FSltID, Col_FParentID, Col_FSltName, Col_FFrmName } ); TrList_FltSlt.KeyFieldName = "FSltID"; TrList_FltSlt.ParentFieldName = "FParentID"; TrList_FltSlt.OptionsView.ShowColumns = false; TrList_FltSlt.OptionsBehavior.Editable = false; //设置树菜单节点竖向边框不显示 TrList_FltSlt.OptionsView.ShowVertLines = false; //设置树菜单节点横向边框不显示 TrList_FltSlt.OptionsView.ShowHorzLines = false; //设置树菜单节点的字体大小 TrList_FltSlt.Appearance.Row.Font = new System.Drawing.Font("Tahoma", 10F); Pal_FltSlt.Controls.Add(TrList_FltSlt); //将过滤方案反序列化成Datatable TrList_FltSlt.DataSource = Serializer.DeserializeXMLToDT(ComClient.GetFltSlt(CurUsrID, FrmNam)); TrList_FltSlt.ExpandAll(); } } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
unsafe void Flush(bool rebatch) { if (batch.VertexCount == 0) { if (!rebatch) { batch.EndBatch(); } return; } // We flush the buffer, first end batch. batch.EndBatch(); // We update vertex constants. vertexConstants.Map(MapOptions.Write); try { DataTransform vtransform = positionTransforms.Peek(); if (!vtransform.ProcessCPU) { vertexConstants.SetConstant("PositionTransform", Matrix4x4f.CreateTranslate(new Vector3f(-unitSize.X, -unitSize.Y, 0)) * Matrix4x4f.CreateScale(new Vector3f(2.0f, 2.0f, 2.0f)) * vtransform.Transform.RuntimeForm); } else { vertexConstants.SetConstant("PositionTransform", Matrix4x4f.Identity); } DataTransform ttransform = textureTransforms.Peek(); if (!ttransform.ProcessCPU) { vertexConstants.SetConstant("TextureTransform", ttransform.Transform.RuntimeForm); } else { vertexConstants.SetConstant("TextureTransform", Matrix4x4f.Identity); } } finally { vertexConstants.UnMap(); } // Vertex Shader: FixedShaderParameters vparams = vertexShaderCode.FixedParameters; vparams.AddLayout(0, vertexConstants.Layout); VShader vshader = vertexShaderCode.Compile(device, vparams) as VShader; // Pixel Shaders: FixedShaderParameters pparams = pixelShaderCode.FixedParameters; // We set interfaces. pparams.SetInterfaceArray("Fills", fills); // We now set per parameter data. ConstantBufferLayoutBuilder builder = new ConstantBufferLayoutBuilder(); List <TextureView> textures = new List <TextureView>(); List <SamplerState> samplers = new List <SamplerState>(); // We add per-fill data. for (int i = 0; i < fills.Count; i++) { IFill fill = fills[i]; string prefix = string.Format("Fills[{0}]", i); InterfaceHelper.ApplyInterfaceConstants(prefix, fill, builder, pparams, textures, samplers, fill.ParameterValues); } // We create view and fill data. ConstantBufferLayout layout = builder.CreateLayout(); ConstantBufferView pixelConstantsView = pixelConstants.CreateConstantBuffer(layout); pparams.AddLayout(0, layout); // TODO: this may not be needed for optimized setting. pixelConstantsView.Map(MapOptions.Write); try { for (int i = 0; i < fills.Count; i++) { IFill fill = fills[i]; string prefix = string.Format("Fills[{0}]", i); InterfaceHelper.FillInterfaceConstants(prefix, fill, pixelConstantsView, fill.ParameterValues); } } finally { pixelConstantsView.UnMap(); } // Finally compile. PShader pshader = pixelShaderCode.Compile(device, pparams) as PShader; using (DeviceLock devLock = device.Lock()) { // We now draw using data, set all states. device.SetBlendState(blendState, Colour.Black, 0xFFFFFFFF); device.SetDepthStencilState(depthStencilState, 0); device.SetRasterizationState(rasterizationState); if (viewport.Width == viewport.Height && viewport.Height == 0) { device.Viewport = new Region2i(new Vector2i(0, 0), new Vector2i((int)renderTarget.Width, (int)renderTarget.Height)); } else { device.Viewport = viewport; } // We bind stages. device.SetVertexShader(vshader, batch, null, null, new ConstantBufferView[] { vertexConstants }); device.SetPixelShader(pshader, samplers.ToArray(), textures.ToArray(), new ConstantBufferView[] { pixelConstantsView }, new RenderTargetView[] { renderTarget }, null); device.SetGeometryShader(null, null, null, null, null); // We now draw. device.DrawIndexed(0, batch.IndexCount, 0); // We clear state. device.SetVertexShader(null, null, null, null, null); device.SetPixelShader(null, null, null, null, null, null); } pixelConstantsView.Dispose(); // Fills and data is irrelavant. fills.Clear(); // We rebatch if not completelly ended. if (rebatch) { batch.BeginBatch(); } }
/// <summary> /// Creates the method that is the starting point for the document creation. /// </summary> /// <param name="dataTransform">Describes how to create a document from an abstract data model.</param> public DataTransformInitializeViewMethod(DataTransform dataTransform) { // /// <summary> // /// Builds the styles used to display data in the document. // /// </summary> // public override void InitializeView(List<ViewerCommand> viewerCommands) // { this.Comments.Add(new CodeCommentStatement("<summary>", true)); this.Comments.Add(new CodeCommentStatement("Builds the styles used to display data in the document.", true)); this.Comments.Add(new CodeCommentStatement("</summary>", true)); this.Attributes = MemberAttributes.Public | MemberAttributes.Override; this.ReturnType = new CodeTypeReference(typeof(void)); this.Name = "InitializeView"; // // Split the screen into quadrants. // this.documentViewer.ViewerCommandQueue.Enqueue(new MarkThree.Forms.ViewerCommand(new MarkThree.Forms.ViewerSplit(new System.Drawing.SizeF(54F, 55F)), new MarkThree.Forms.ViewerCommandDelegate(this.documentViewer.SetSplit))); SizeF splitSize = dataTransform.SplitSize; if (splitSize != SizeF.Empty) { this.Statements.Add(new CodeCommentStatement("Split the screen into quadrants.")); this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "ViewerCommandQueue"), "Enqueue", new CodeObjectCreateExpression(typeof(ViewerCommand), new CodeObjectCreateExpression(typeof(ViewerSplit), new CodeObjectCreateExpression(typeof(SizeF), new CodePrimitiveExpression(splitSize.Width), new CodePrimitiveExpression(splitSize.Height))), new CodeObjectCreateExpression(typeof(ViewerCommandDelegate), new CodeMethodReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "SetSplit"))))); } // // Set the magnification factor. // this.documentViewer.ViewerCommandQueue.Enqueue(new MarkThree.Forms.ViewerCommand(new MarkThree.Forms.ViewerScale(1.25F), new MarkThree.Forms.ViewerCommandDelegate(this.documentViewer.SetScale))); float scaleFactor = dataTransform.ScaleFactor; if (scaleFactor != DefaultDocument.ScaleFactor) { this.Statements.Add(new CodeCommentStatement("Set the magnification factor.")); this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "ViewerCommandQueue"), "Enqueue", new CodeObjectCreateExpression(typeof(ViewerCommand), new CodeObjectCreateExpression(typeof(ViewerScale), new CodePrimitiveExpression(scaleFactor)), new CodeObjectCreateExpression(typeof(ViewerCommandDelegate), new CodeMethodReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "SetScale"))))); } // This will generate each of the styles in turn and add them to the range of styles that is sent to the viewer. // The viewer will then use these styles to match up the incoming tiles to instructions to present them in the // document. foreach (DataTransform.StyleNode styleNode in dataTransform.Styles) { // // Header Style // MarkThree.Forms.ViewerStyle headerStyle = this.documentViewer.GetStyle("Default"); // if (("Default" != headerStyle.ParentId)) // { // headerStyle.ParentId = "Default"; // headerStyle.IsModified = true; // } // headerStyle.Attributes.Add(new MarkThree.Forms.ViewerBottomBorder(System.Drawing.Color.DarkGray, 1F)); // headerStyle.Attributes.Add(new MarkThree.Forms.ViewerRightBorder(System.Drawing.Color.DarkGray, 1F)); // headerStyle.Attributes.Add(new MarkThree.Forms.ViewerInteriorBrush(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Control))); // headerStyle.Attributes.Add(new MarkThree.Forms.ViewerImage(this.documentViewer.Variables["GreenCheckImage"])); this.Statements.Add(new CodeCommentStatement(string.Format("{0} Style", styleNode.StyleId))); string variableName = string.Format("{0}Style", CamelCase.Convert(styleNode.StyleId)); this.Statements.Add(new CodeVariableDeclarationStatement(typeof(ViewerStyle), variableName, new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "GetStyle", new CodePrimitiveExpression(styleNode.StyleId)))); if (styleNode.ParentStyle != null) { CodeStatement[] trueStatements0 = new CodeStatement[2]; trueStatements0[0] = new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "ParentId"), new CodePrimitiveExpression(styleNode.ParentStyle.StyleId)); trueStatements0[1] = new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "IsModified"), new CodePrimitiveExpression(true)); this.Statements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(new CodePrimitiveExpression(styleNode.ParentStyle.StyleId), CodeBinaryOperatorType.IdentityInequality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "ParentId")), trueStatements0)); } if (styleNode.HasAnimation) { if (styleNode.Animation.Effect == Effect.Fade) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerFadeAnimation), CodeSnippet.Convert(styleNode.Animation.Up), CodeSnippet.Convert(styleNode.Animation.Down), CodeSnippet.Convert(styleNode.Animation.Same), new CodePrimitiveExpression(styleNode.Animation.Steps)))); } if (styleNode.Animation.Effect == Effect.Flash) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerFlashAnimation), CodeSnippet.Convert(styleNode.Animation.Foreground), CodeSnippet.Convert(styleNode.Animation.Background), new CodePrimitiveExpression(styleNode.Animation.On), new CodePrimitiveExpression(styleNode.Animation.Off), new CodePrimitiveExpression(styleNode.Animation.Repeat)))); } } if (styleNode.HasBottomBorder) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerBottomBorder), CodeSnippet.Convert(styleNode.BottomBorder.Color), new CodePrimitiveExpression(styleNode.BottomBorder.Width)))); } if (styleNode.HasLeftBorder) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerLeftBorder), CodeSnippet.Convert(styleNode.LeftBorder.Color), new CodePrimitiveExpression(styleNode.LeftBorder.Width)))); } if (styleNode.HasRightBorder) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerRightBorder), CodeSnippet.Convert(styleNode.RightBorder.Color), new CodePrimitiveExpression(styleNode.RightBorder.Width)))); } if (styleNode.HasTopBorder) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerTopBorder), CodeSnippet.Convert(styleNode.TopBorder.Color), new CodePrimitiveExpression(styleNode.TopBorder.Width)))); } if (styleNode.HasFont) { if (styleNode.Font.Style == FontStyle.Regular) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerFont), CodeSnippet.Convert(styleNode.Font.FontFamily), new CodePrimitiveExpression(styleNode.Font.Size)))); } else { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerFont), CodeSnippet.Convert(styleNode.Font.FontFamily), new CodePrimitiveExpression(styleNode.Font.Size), CodeSnippet.Convert(styleNode.Font.Style)))); } } if (styleNode.HasFontBrush) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerFontBrush), CodeSnippet.Convert(styleNode.ForeColor)))); } if (styleNode.HasStringFormat) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerStringFormat), CodeSnippet.Convert(styleNode.StringFormat.Alignment), CodeSnippet.Convert(styleNode.StringFormat.LineAlignment)))); } if (styleNode.HasNumberFormat) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerNumberFormat), new CodePrimitiveExpression(styleNode.NumberFormat)))); } if (styleNode.HasInterior) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerInteriorBrush), CodeSnippet.Convert(styleNode.BackColor)))); } if (styleNode.HasImage) { this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(variableName), "Attributes"), "Add", new CodeObjectCreateExpression(typeof(ViewerImage), new CodeCastExpression(typeof(Image), new CodeIndexerExpression(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "documentViewer"), "Variables"), new CodePrimitiveExpression(styleNode.Image)))))); } } }
public void FillShape(IFill fill, TriangleSoup2f mesh, IMapper mapper) { if (mapper == null) { mapper = new PositionMapper(); } // We first find "apropriate id" for instance independant fills uint fillID = uint.MaxValue; if (!fill.IsInstanceDependant) { for (int i = 0; i < fills.Count; i++) { if (fills[i].GetType() == fill.GetType()) { fillID = (uint)i; break; } } } else { int i; // We try to find exact (reference) match. for (i = 0; i < fills.Count; i++) { if (fills[i] == fill) { fillID = (uint)i; break; } } // If we found it. if (i >= fills.Count) { // We try to find compare match. for (int j = 0; j < fills.Count; j++) { if (fills[j].Equals(fills)) { fillID = (uint)j; break; } } } } // We now insert fill if no appropriate was found. if (fillID == uint.MaxValue) { // We add it and save id. fillID = (uint)fills.Count; fills.Add(fill); } // We extract indices and vertices. List <Vector2f> vertices = mesh.Vertices; List <uint> indices = mesh.Indices; // We go for each triangle. int vertexCount = vertices.Count; VertexData[] triangleData = new VertexData[vertices.Count]; // We prepare vertices. for (int i = 0; i < vertexCount; i++) { // We fill data. if (fill.CustomAttributeCount >= 1) { triangleData[i].CustomAttribute0 = fill.CalcCustomAttribute(0, mesh, vertices[i]); if (fill.CustomAttributeCount >= 2) { throw new NotSupportedException("Too many attributes."); } } else { triangleData[i].CustomAttribute0 = Vector3f.Zero; } // Fill ID. triangleData[i].FillID = fillID; // Positions. triangleData[i].Position = vertices[i]; } // We generate them. Vector2f[] mappingCoord = mapper.Generate(mesh, vertices.ToArray()); DataTransform ttransform = textureTransforms.Peek(); // We do preprocessing. if (ttransform.Transform.NeedsPreprocess) { mappingCoord = (Vector2f[])ttransform.Transform.Preprocess( PreprocessDataType.TextureCoordinates, mappingCoord); } if (ttransform.ProcessCPU) { Matrix4x4f matrix = ttransform.Transform.RuntimeForm; // We write them. for (int i = 0; i < vertexCount; i++) { triangleData[i].TexCoord0 = (matrix * mappingCoord[i].Vec3).Vec2; } } else { // We write them. for (int i = 0; i < vertexCount; i++) { triangleData[i].TexCoord0 = mappingCoord[i]; } } // We may need to transform. DataTransform vtransform = positionTransforms.Peek(); if (vtransform.ProcessCPU) { // We create matrix. Matrix4x4f matrix = Matrix4x4f.CreateTranslate(new Vector3f(-unitSize.X, -unitSize.Y, 0)) * Matrix4x4f.CreateScale(new Vector3f(2.0f, 2.0f, 2.0f)) * vtransform.Transform.RuntimeForm; // We transform all points. for (int i = 0; i < triangleData.Length; i++) { triangleData[i].Position = (matrix * new Vector4f(triangleData[i].Position.X, triangleData[i].Position.Y, 0, 1)).Vec2; } } // Send data to batch. ulong r = batch.AddVertices(triangleData); // If we cannot draw it, we flush and try again. // FIXME: this is far from optimal. if (r != (ulong)triangleData.LongLength) { Flush(true); if (batch.AddVertices(triangleData) != (ulong)triangleData.LongLength) { throw new NotSupportedException("Big vertex chunks not supported, consider creating bigger buffers."); } batch.AddVertices(triangleData); } // We now prepare indices. uint[] transIndices = new uint[indices.Count]; uint offset = (uint)batch.VertexCount - (uint)triangleData.Length; int indexCount = indices.Count; for (int i = 0; i < indexCount; i++) { transIndices[i] = indices[i] + offset; } batch.AddIndices(transIndices); }
/// <summary> /// Generates the class that transforms a data model into a human read-able document. /// </summary> /// <param name="dataTransform">Describes how to transform abstract data into a document.</param> public DataTransformClass(DataTransform dataTransform) { // /// <summary> // /// Transforms a data model into a document. // /// </summary> // public class PrototypeView : DocumentView // { this.Comments.Add(new CodeCommentStatement("<summary>", true)); this.Comments.Add(new CodeCommentStatement("Transforms a data model into a document.", true)); this.Comments.Add(new CodeCommentStatement("</summary>", true)); this.Name = dataTransform.DataTransformId; this.BaseTypes.Add("DocumentView"); // The Column Index (Absolute Order) Constants // // Constant Column Indices // internal const int workingStatusImageIndex = 0; // internal const int submittedStatusImageIndex = 1; // internal const int recordIdIndex = 2; bool isFirstColumnIndexConstant = true; for (int columnIndex = 0; columnIndex < dataTransform.Columns.Count; columnIndex++) { DataTransform.ColumnNode columnNode = dataTransform.Columns[columnIndex]; string constantName = CamelCase.Convert(columnNode.ColumnId) + "Index"; CodeMemberField codeMemberField = new CodeMemberField(typeof(Int32), constantName); if (isFirstColumnIndexConstant) { isFirstColumnIndexConstant = false; codeMemberField.Comments.Add(new CodeCommentStatement("Constant Column Indices (Column Order)")); } codeMemberField.Attributes = MemberAttributes.Const | MemberAttributes.Assembly; codeMemberField.InitExpression = new CodePrimitiveExpression(columnIndex); this.Members.Add(codeMemberField); } // The Column Ordinal (Viewer Order) Constants // // Constant Column Indices // internal const int workingStatusImageOrdinal = 0; // internal const int submittedStatusImageOrdinal = 1; // internal const int recordIdOrdinal = 2; bool isFirstColumnOrdinalConstant = true; for (int columnOrdinal = 0; columnOrdinal < dataTransform.View.Count; columnOrdinal++) { DataTransform.ColumnNode columnNode = dataTransform.View[columnOrdinal].Column; string constantName = CamelCase.Convert(columnNode.ColumnId) + "Ordinal"; CodeMemberField codeMemberField = new CodeMemberField(typeof(Int32), constantName); if (isFirstColumnOrdinalConstant) { isFirstColumnOrdinalConstant = false; codeMemberField.Comments.Add(new CodeCommentStatement("Constant Column Ordinals (Viewer Order)")); } codeMemberField.Attributes = MemberAttributes.Const | MemberAttributes.Assembly; codeMemberField.InitExpression = new CodePrimitiveExpression(columnOrdinal); this.Members.Add(codeMemberField); } // The Row Height Constants. // // Constant Row Heights // private const float headerRowHeight = 40F; // private const float workingOrderRowHeight = 20F; // private const float sourceOrderRowHeight = 20F; // private const float destinationOrderRowHeight = 20F; // private const float executionRowHeight = 20F; bool isFirstRowHeightConstant = true; foreach (DataTransform.TemplateNode templateNode in dataTransform.Templates) { foreach (DataTransform.RowNode rowNode in templateNode.Rows) { string constantName = CamelCase.Convert(rowNode.RowId) + "Height"; CodeMemberField codeMemberField = new CodeMemberField(typeof(Single), constantName); if (isFirstRowHeightConstant) { isFirstRowHeightConstant = false; codeMemberField.Comments.Add(new CodeCommentStatement("Constant Row Heights")); } codeMemberField.Attributes = MemberAttributes.Const | MemberAttributes.Private; codeMemberField.InitExpression = new CodePrimitiveExpression(rowNode.Height); this.Members.Add(codeMemberField); } } // The Row Width Constants. // // Constant Row Widths // private const float headerRowHeight = 745F; // private const float workingOrderRowHeight = 745F; // private const float sourceOrderRowHeight = 745F; // private const float destinationOrderRowHeight = 745F; // private const float executionRowHeight = 745F; bool isFirstRowWidthConstant = true; foreach (DataTransform.TemplateNode templateNode in dataTransform.Templates) { foreach (DataTransform.RowNode rowNode in templateNode.Rows) { string constantName = CamelCase.Convert(rowNode.RowId) + "Width"; CodeMemberField codeMemberField = new CodeMemberField(typeof(Single), constantName); if (isFirstRowWidthConstant) { isFirstRowWidthConstant = false; codeMemberField.Comments.Add(new CodeCommentStatement("Constant Row Widths")); } codeMemberField.Attributes = MemberAttributes.Const | MemberAttributes.Private; float rowWidth = 0.0f; foreach (DataTransform.ColumnReferenceNode columnReferenceNode in dataTransform.View) { rowWidth += columnReferenceNode.Column.Width; } codeMemberField.InitExpression = new CodePrimitiveExpression(rowWidth); this.Members.Add(codeMemberField); } } // The Column Width Constants. // // Constant Column Widths // private const float askPriceWidth = 53F; // private const float availableQuantityWidth = 56F; // private const float bidPriceWidth = 53F; // private const float destinationOrderQuantityWidth = 56F; bool isFirstColumnWidthConstant = true; foreach (DataTransform.ColumnNode columnNode in dataTransform.Columns) { string constantName = CamelCase.Convert(columnNode.ColumnId) + "Width"; CodeMemberField codeMemberField = new CodeMemberField(typeof(Single), constantName); if (isFirstColumnWidthConstant) { isFirstColumnWidthConstant = false; codeMemberField.Comments.Add(new CodeCommentStatement("Constant Column Widths")); } codeMemberField.Attributes = MemberAttributes.Const | MemberAttributes.Private; codeMemberField.InitExpression = new CodePrimitiveExpression(columnNode.Width); this.Members.Add(codeMemberField); } // The Comparers // // Comparers // private System.Collections.Generic.IComparer<MarkThree.Forms.ViewerRow> workingOrderRowComparer; // private System.Collections.Generic.IComparer<MarkThree.Forms.ViewerRow> sourceOrderRowComparer; // private System.Collections.Generic.IComparer<MarkThree.Forms.ViewerRow> destinationOrderRowComparer; bool isFirstComparer = true; foreach (DataTransform.TemplateNode templateNode in dataTransform.Templates) { foreach (DataTransform.RowNode rowNode in templateNode.Rows) { foreach (DataTransform.ApplyTemplateNode applyTemplateNode in rowNode.ApplyTemplates) { if (applyTemplateNode.Sorts.Count != 0) { string comparerName = CamelCase.Convert(applyTemplateNode.Select) + "RowComparer"; CodeMemberField codeMemberField = new CodeMemberField(typeof(IComparer <ViewerRow>), comparerName); if (isFirstComparer) { isFirstComparer = false; codeMemberField.Comments.Add(new CodeCommentStatement("Comparers")); } codeMemberField.Attributes = MemberAttributes.Private; this.Members.Add(codeMemberField); } } } } // Add the constructor to the namespace. this.Members.Add(new DataTransformConstructor(dataTransform)); // Add the Build method used to construct the styles. this.Members.Add(new DataTransformInitializeViewMethod(dataTransform)); // Add the Build method used to construct the document. this.Members.Add(new DataTransformBuildViewMethod(dataTransform)); // Add the code for all the template handlers. foreach (DataTransform.TemplateNode templateNode in dataTransform.Templates) { this.Members.Add(new DataTransformTemplateMethod(templateNode)); } }
/// <summary> /// Creates a CodeDOM method to compare two rows of a document for the purpose of sorting. /// </summary> /// <param name="templateNode">Contains the specification for the template.</param> public SortCompareMethod(DataTransform.ApplyTemplateNode applyTemplateNode) { // The sort works very efficiently by examining the tiles using the column ordinals as indices into the row. The View // class defines these ordinals as public constants. DataTransform dataTransform = applyTemplateNode.TopLevelNode as DataTransform; // #region IComparer<ViewerRow> Members this.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "IComparer<ViewerRow> Members")); // // <summary> // // Compares a row with another row using the column values to determine the order. // // </summary> // // <param name="x">The first row to be compared.</param> // // <param name="y">The second row to be compared.</param> // // <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> // public virtual int Compare(MarkThree.Forms.ViewerRow x, MarkThree.Forms.ViewerRow y) // { this.Comments.Add(new CodeCommentStatement(@"<summary>")); this.Comments.Add(new CodeCommentStatement(@"Compares a row with another row using the column values to determine the order.")); this.Comments.Add(new CodeCommentStatement(@"</summary>")); this.Comments.Add(new CodeCommentStatement(@"<param name=""x"">The first row to be compared.</param>")); this.Comments.Add(new CodeCommentStatement(@"<param name=""y"">The second row to be compared.</param>")); this.Comments.Add(new CodeCommentStatement(@"<returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>")); this.Attributes = MemberAttributes.Public; this.ReturnType = new CodeTypeReference(typeof(int)); this.Name = "Compare"; this.Parameters.Add(new CodeParameterDeclarationExpression(typeof(ViewerRow), "x")); this.Parameters.Add(new CodeParameterDeclarationExpression(typeof(ViewerRow), "y")); // // The order of the comparison determines whether the rows are sorted in ascending order or descending. If the values // // compared in one set of tiles is equal, then the next set of tiles in the sort order will be compared. // MarkThree.Forms.ViewerTile xTile0 = ((MarkThree.Forms.ViewerTile)(x.Tile[PrototypeView.symbolIndex])); // MarkThree.Forms.ViewerTile yTile0 = ((MarkThree.Forms.ViewerTile)(y.Tile[PrototypeView.symbolIndex])); // int compare0 = xTile0.CompareTo(yTile0); // if ((compare0 != 0)) // { // return compare0; // } // return ((IComparable)y.Data[PrototypeView.sourceOrderQuantityIndex]).CompareTo(x.Data[PrototypeView.sourceOrderQuantityIndex]); this.Statements.Add(new CodeCommentStatement("The order of the comparison determines whether the rows are sorted in ascending order or descending. If the values")); this.Statements.Add(new CodeCommentStatement("compared in one set of tiles is equal, then the next set of tiles in the sort order will be compared.")); for (int index = 0; index < applyTemplateNode.Sorts.Count; index++) { DataTransform.SortNode sortNode = applyTemplateNode.Sorts[index]; string columnReference = string.Format("{0}Index", CamelCase.Convert(sortNode.Column.ColumnId)); string operand1 = sortNode.Direction == SortOrder.Ascending ? "x" : "y"; string operand2 = sortNode.Direction == SortOrder.Ascending ? "y" : "x"; if (index != applyTemplateNode.Sorts.Count - 1) { string compareVariableName = string.Format("compare{0}", index); this.Statements.Add(new CodeVariableDeclarationStatement(typeof(int), compareVariableName, new CodeMethodInvokeExpression(new CodeCastExpression(typeof(IComparable), new CodeIndexerExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(operand1), "Data"), new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataTransform.DataTransformId), columnReference))), "CompareTo", new CodeIndexerExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(operand2), "Data"), new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataTransform.DataTransformId), columnReference))))); this.Statements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression(compareVariableName), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(0)), new CodeMethodReturnStatement(new CodeVariableReferenceExpression(compareVariableName)))); } else { this.Statements.Add(new CodeMethodReturnStatement(new CodeMethodInvokeExpression(new CodeCastExpression(typeof(IComparable), new CodeIndexerExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(operand1), "Data"), new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataTransform.DataTransformId), columnReference))), "CompareTo", new CodeIndexerExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(operand2), "Data"), new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataTransform.DataTransformId), columnReference))))); } } // #endregion this.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty)); }
/// <summary> /// Read the image data from ExchangeElement, subject to the transform, i.e., reSize, downsampling, etc. /// specified by the parameters. /// </summary> /// <param name="exEl">element in DataExchange</param> /// <returns></returns> private INumArray <double> GetData(ExchangeElement exEl) { INumArray <double> data; int nHeight = exEl.Height; int nWidth = exEl.Width; int i, j; int ipx = 0; if (m_bResize) { //if m_bResize=true, resize the data to certain size char[] charArr = new char[exEl.ByteData.GetLength(0)]; for (i = 0; i < exEl.ByteData.GetLength(0); i++) { charArr[i] = Convert.ToChar(exEl.ByteData[i]); } Dpu.ImageProcessing.Image dpuImgData = new Dpu.ImageProcessing.Image(charArr, nWidth, nHeight); Dpu.ImageProcessing.Image rstImgData = new Dpu.ImageProcessing.Image(m_iReSizeWidth, m_iReSizeHeight); Dpu.ImageProcessing.Image.BilinearResample(dpuImgData, rstImgData); data = ArrFactory.DoubleArray(m_iReSizeHeight, m_iReSizeWidth); float[] pixelData = rstImgData.Pixels; ipx = 0; for (i = 0; i < m_iReSizeHeight; i++) { for (j = 0; j < m_iReSizeWidth; j++) { data[i, j] = Convert.ToDouble(pixelData[ipx]); ipx += 1; } } } else { if (m_bDownSample) { data = ArrFactory.DoubleArray(nHeight / 2, nWidth / 2); ipx = 0; Byte[] imData = exEl.ByteData; for (i = 0; i < nHeight; i++) { for (j = 0; j < nWidth; j++) { data[i, j] = Convert.ToDouble(imData[ipx]); ipx += 2; } } } else { data = ArrFactory.DoubleArray(exEl.DoubleDataMatrix); } } if (m_bGlocalTrans) { data = DataTransform.GlocalTransform(data, _localWidth, _localHeight); } return(data); }