Use of FastCopy PEvset
1// This example builds upon the basic CreateSimpleGraph '000' example chart //2CreateSimpleGraph(Pego1);3 4int o, p, s;5 6// Repass the data, this time with FastCopyFrom / PEvset call //7 8float[] MyYData = new float[48]; // 4 * 12 = 48 // Create an array/block of memory.9 10// ProEssentials is a native c++ component and low-level draws directly via Direct2D and Direct3D to a Windows hDC and/or the windows display memory.11// ProEssentials handles data via c++ where it passes data via memcpy (PEvset uses memcpy) using basic blocks/buffers/arrays of memory.12// ProEssentials can optionally be told where your app blocks are located and ProEssentials will use/read your memory location instead of13// passing and storing a copy of your data. See example 144.14 15// ChatGpt/Gemini/Claude/CoPilot are very good at writing code to help form/refactor any state of app data into a basic c# array or arrays,16// This means using FastCopyFrom / PEvset to pass, or optionally tell ProEssentials where your data exists and not pass, is a clear and clean method17// of handling your data. One will always have a basic view of the data via the app arrays and ProEssentials simply charts this same data.18// This helps clarify data passing logic and improves the debugging ability related to passing data.19 20GCHandle hMyYData = GCHandle.Alloc(MyYData, GCHandleType.Pinned); // freeze memory location21 22// Note that .net's memory manager will not move arrays/blocks by changing its location when the array is more than 85,000 bytes.23// This is often the case when using FastCopyFrom / PEvset as its advantages are most noticable for larger data sets.24// The above pinning logic is not necessary if the size of your array/block is more than 85,000 bytes.25 26for (s=0; s<4; s++)27{28 for(p=0; p<12; p++)29 {30 o = (s * 12) + p; // 12 = Points property31 MyYData[o] = 5 + ((float)(Rand_Num.NextDouble()) * 10);32 }33}34Pego1.PeData.Y.FastCopyFrom(MyYData);35// this is same as calling Api.PEvsetW(Pego1.PeSpecial.HObject, DllProperties.YData, MyYData, 48);36 37// Un-pin the pinned memory when finished using the memory //38if (hMyYData.IsAllocated) { hMyYData.Free(); } // un-freeze memory location39 40Pego1.PeFunction.ReinitializeResetImage();41Pego1.Invalidate();42// Optionally call Pego1.Refresh() if you are not seeing changes immediatelyPego1.PeData.Y[s, p]Click underlined properties to view documentation