///<summary>初始化</summary> ///<param name="window">窗口</param> public void Initialize(IWindow window) { if (Graphs.IsReadOnly) { throw new InvalidOperationException(); } Graphs.IsReadOnly = true; var count = Graphs.Count; if (count > 0) { var graphs = new GraphProperties[count]; var index = 0; foreach (var graph in Graphs) { graph.Initialize(m_Core, (uint)index); graphs[index] = new GraphProperties { BaselineType = graph.BaselineType, GraphStyle = graph.GraphStyle, Foreground = ColorHelper.GetColor(graph.Foreground, 0xFF000000u), LineWidth = (uint)graph.LineWidth, Offset = graph.Offset, AutoTranslate = (float)graph.AutoTranslateOffset, IsEnabled = graph.IsGraphEnabled }; ++index; } var arg = new ConstructionParameters(window, ColorHelper.GetColor(ContentBackground, 0xFFFFFFFFu), (uint)DataLength, (float)Range, (float)ScaleX, (float)MaxScaleX, (float)ScaleY, (float)MaxScaleY, (uint)TranslateX, (uint)TranslateY, RefreshMode, ColorHelper.GetColor(AxisColor, 0xFF000000u), (uint)AxisLineWidth, (uint)AxisTicksCountX, (uint)AxisTicksCountY, (uint)AxisTickSizeX, (uint)AxisTickSizeY, (uint)AxisSizeX, (uint)AxisSizeY, AxisPlacementX, AxisPlacementY, graphs); m_Core.Initialize(ref arg); } }
///<summary>初始化</summary> ///<param name="window">窗口</param> public void Initialize(IWindow window) { if (IsFrozen) { throw new InvalidOperationException(); } m_IsFrozen = true; m_Graph.Initialize(m_Core, 0u); var arg = new ConstructionParameters(window, ColorHelper.GetColor(ContentBackground, 0xFFFFFFFFu), (uint)DataLength, (float)Range, (float)ScaleX, (float)MaxScaleX, (float)ScaleY, (float)MaxScaleY, (uint)TranslateX, (uint)TranslateY, RefreshMode, ColorHelper.GetColor(AxisColor, 0xFF000000u), (uint)AxisLineWidth, (uint)AxisTicksCountX, (uint)AxisTicksCountY, (uint)AxisTickSizeX, (uint)AxisTickSizeY, (uint)AxisSizeX, (uint)AxisSizeY, AxisPlacementX, AxisPlacementY, new GraphProperties[] { new GraphProperties { BaselineType = BaselineType, GraphStyle = GraphStyle, Foreground = ColorHelper.GetColor(GraphForeground, 0xFF000000u), LineWidth = (uint)LineWidth, Offset = Offset, AutoTranslate = (float)AutoTranslateOffset, IsEnabled = IsGraphEnabled } }); m_Core.Initialize(ref arg); }
///<summary>初始化</summary> ///<param name="arg">参数</param> public void Initialize(ref ConstructionParameters arg) { if (arg != null && m_IsUninitialized) { m_IsUninitialized = false; m_Core.Initialize(ref arg); var brush = Background as SolidColorBrush; var color = ColorHelper.ToColor(arg.Background); if (brush == null || brush.Color != color) { Background = new SolidColorBrush(color); } RefreshMode = arg.RefreshMode == Enum_RefreshMode.Scrolling; m_IsPropertyEnabled = true; } }
///<summary>创建示波器(多图形)</summary> ///<param name="arg">参数</param> public static IntPtr CreateOscilloscope(ref ConstructionParameters arg) { var length = (uint)arg.GraphProperties.Length; if (length == 0u) throw new ArgumentException(); fixed(ConstructionArgs *args = &arg.Args) { fixed(GraphProperties *array = arg.GraphProperties) { if (s_IsX64) { return(Dll64.CreateOscilloscope(arg.Oscilloscopes, arg.ControlHwnd, new IntPtr(args), new IntPtr(array), length)); } else { return(Dll86.CreateOscilloscope(arg.Oscilloscopes, arg.ControlHwnd, new IntPtr(args), new IntPtr(array), length)); } } } }
///<summary>初始化</summary> ///<param name="arg">参数</param> public void Initialize(ref ConstructionParameters arg) { if (arg != null && m_Oscilloscope == IntPtr.Zero && arg.Oscilloscopes != IntPtr.Zero) { arg.ControlHwnd = Handle; BackColor = ColorHelper.FromArgb(arg.Background); m_Oscilloscope = Dll.CreateOscilloscope(ref arg); m_IsUninitialized = m_Oscilloscope == IntPtr.Zero; if ((!m_IsUninitialized) && PropertyChanged != null) { PropertyChanged(Property.TranslateX_Limit, Dll.TranslateX_Limit(m_Oscilloscope)); PropertyChanged(Property.TranslateY_Limit, Dll.TranslateY_Limit(m_Oscilloscope)); PropertyChanged(Property.TranslateX, Dll.TranslateX(m_Oscilloscope)); PropertyChanged(Property.TranslateY, Dll.TranslateY(m_Oscilloscope)); PropertyChanged(Property.ScaleX, Dll.ScaleX(m_Oscilloscope)); PropertyChanged(Property.ScaleY, Dll.ScaleY(m_Oscilloscope)); PropertyChanged(Property.ScaleX_Limit, Dll.ScaleX_Limit(m_Oscilloscope)); PropertyChanged(Property.ScaleY_Limit, Dll.ScaleY_Limit(m_Oscilloscope)); } } }