using System;
using System.Drawing;
using System.Text;
using System.Runtime.InteropServices;

namespace Chart_CSharp
{
    public partial class XYChart : ChartBase
    {
        public XYChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 0);
        }
        public int AddCurve()
        {
            return ChartAncestor.AddCurve(0);
        }
        public int AddCurve(double[] pX, double[] pY, int nLen)
        {
            return ChartAncestor.AddCurve(pX, pY, nLen, 0);
        }
        public int AddPoint(double x, double y, int nCurveIndex)
        {
            return ChartAncestor.AddPoint2D(x, y, nCurveIndex, 0);
        }
        public int UpdateCurve(int nCurveIndex, double[] pX, double[] pY, int nLen)
        {
            return ChartAncestor.UpdateCurve(nCurveIndex, pX, pY, nLen, 0);
        }
        
    }
    public partial class SplitChart : MultiChartBase
    {
        public SplitChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 8);
        }
    }
    public partial class ShareXChart : MultiChartBase
    {
        public ShareXChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 9);
        }
    }
    public partial class LayeredChart : MultiChartBase
    {
        public LayeredChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 10);
        }
    }
    public partial class PieChart : ChartBase
    {
        public PieChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 1);
        }
        public int AddPie(double val)
        {
            return ChartAncestor.AddPie(val);
        }
        public int AddPie(double val, string pieTitle)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(pieTitle);
            return ChartAncestor.AddPie(val, sb);
        }
        public void SetPieTitle(string pieTitle, int whichPie)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(pieTitle);
            ChartAncestor.SetPieTitle(sb, whichPie);
        }
    }
    public partial class StemChart : ChartBase
    {
        public StemChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 2);
        }
        public int AddStems(double []pData, int nLen)
        {
            return ChartAncestor.AddStems(pData, nLen);
        }
        public int AddStems(double[] pData, int nLen, string stemTitle)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(stemTitle);
            return ChartAncestor.AddStems(pData, nLen, sb);
        }
        public void SetStemLabel(string label, int whichStem)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(label);
            ChartAncestor.SetStemLabel(sb, whichStem);
        }
        public void SetStemTitle(string stemTitle, int nDataIndex)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(stemTitle);
            ChartAncestor.SetStemTitle(sb, nDataIndex);
        }
    }
    public partial class ContourLineChart : ChartBase
    {
        public ContourLineChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 4);
        }
        public void SetContourLineNum(int num)
        {
            ChartAncestor.SetContourLineNum(num);
        }
        public void SetContourPrecision(int n)
        {
            ChartAncestor.SetContourPrecision(n);
        }
    }
    public partial class ContourMapChart : ContourChartBase
    {
        public ContourMapChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 5);
        }
    }
    public partial class ContourChart : ContourChartBase
    {
        public ContourChart(IntPtr hWnd)
        {
            ChartAncestor.Attach(hWnd, 6);
        }
        public void SetContourLineNum(int num)
        {
            ChartAncestor.SetContourLineNum(num);
        }
        public void SetContourPrecision(int n)
        {
            ChartAncestor.SetContourPrecision(n);
        }
    }
    // Base class
    public partial class ChartBase : ChartAncestor
    {
        public ChartBase()
        {
            CreateChart();
        }
        ~ChartBase()
        {
            DestroyChart();
        }
        public void SetTitle(String title)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(title);
            ChartAncestor.SetTitle(sb);
        }

        public static int ColorToCOLORREF(Color color)
        {
            return ((color.R | (color.G << 8)) | (color.B << 0x10));
        }

        public static Color COLORREFToColor(int colorRef)
        {
            byte[] _IntByte = BitConverter.GetBytes(colorRef);
            return Color.FromArgb(_IntByte[0], _IntByte[1], _IntByte[2]);
        }
        public void ReDraw()
        {
            ChartAncestor.ReDraw();
        }
    }
    public partial class MultiChartBase : ChartBase
    {
        public int GetSubPlotsCount()
        {
            return ChartAncestor.GetSubPlotsCount();
        }
        public int AddLayers()
        {
            return ChartAncestor.AddLayer();
        }
        public void ResizePlots(int nLayers)
        {
            ChartAncestor.ResizePlots(nLayers);
        }
        public void ResizePlots(int mode, int nRows, int nCols)
        {
            ChartAncestor.ResizePlots(mode, nRows, nCols);
        }
        public int AddCurve(double[] pX, double[] pY, int nLen, int nPlotIndex)
        {
            return ChartAncestor.AddCurve(pX, pY, nLen, nPlotIndex);
        }
        public int AddPoint(double x, double y, int nCurveIndex, int nPlotIndex)
        {
            return ChartAncestor.AddPoint2D(x, y, nCurveIndex, nPlotIndex);
        }
        public int UpdateCurve(int nCurveIndex, double[] pX, double[] pY, int nLen, int nPlotIndex)
        {
            return ChartAncestor.UpdateCurve(nCurveIndex, pX, pY, nLen, nPlotIndex);
        }
    }
    public partial class ContourChartBase : ChartBase
    {
        public void SetFieldFunction(DelegateFieldFunction func)
        {
            ChartAncestor.SetFieldFcn(func);
        }
        public void SetPlotRange(double[] xRange, double[] yRange)
        {
            ChartAncestor.SetPlotRange(xRange, yRange);
        }
        public void SetPlotRange(double x1, double x2, double y1, double y2)
        {
            ChartAncestor.SetPlotRange(x1, x2, y1, y2);
        }
    }
    // The following class ChartAncestor is mainly Getting the function entry from the Dll file.
    public partial class ChartAncestor
    {
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?CreateChart@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void CreateChart();
        [DllImport(@"CChartu.dll", EntryPoint = "?DestroyChart@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void DestroyChart();
        [DllImport(@"CChartu.dll", EntryPoint = "?Attach@Classless@@YAHPAUHWND__@@@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int Attach(IntPtr hWnd);
        [DllImport(@"CChartu.dll", EntryPoint = "?Attach@Classless@@YAHPAUHWND__@@H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int Attach(IntPtr hWnd, int nType);
        [DllImport(@"CChartu.dll", EntryPoint = "?Attach@Classless@@YAHPAUHWND__@@UtagRECT@@H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static bool Attach(IntPtr hWnd, Rectangle rtClient, int nType);
        [DllImport(@"CChartu.dll", EntryPoint = "?AttachDlg@Classless@@YAHPAUHWND__@@0H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static bool AttachDlg(IntPtr hDlg, IntPtr hCtrl, int nType);
        [DllImport(@"CChartu.dll", EntryPoint = "?AttachDlg@Classless@@YAHPAUHWND__@@IH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static bool AttachDlg(IntPtr hDlg, uint nCtrlID, int nType);
    }
    partial class ChartAncestor
    {
        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
        public delegate double DelegateFieldFunction(double a, double b);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetFieldFcn@Classless@@YAXP6ANNN@Z@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetFieldFcn(DelegateFieldFunction funcField);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?AddCurve@Classless@@YAHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddCurve(int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?AddCurve@Classless@@YAHPAN0HH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddCurve(double[] pX, double[] pY, int nLen, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?AddPoint2D@Classless@@YAHNNHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddPoint2D(double x, double y, int nCurveIndex, int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?AddCurve@Classless@@YAHPAN0NHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddCurve(double[] pX, double[] pY, double z, int nLen, int nPlotIndex);
        
        [DllImport(@"CChartu.dll", EntryPoint = "?AddCurve@Classless@@YAHPAN00H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddCurve(double[] pX, double[] pY, double[] pZ, int nLen);
        [DllImport(@"CChartu.dll", EntryPoint = "?AddPoint3D@Classless@@YAHNNNH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddPoint3D(double x, double y, double z, int nCurveIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?UpdateCurve@Classless@@YAHHPAN0HH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int UpdateCurve(int nDataIndex, double[] pX, double[] pY, int nLen, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?UpdateCurveByID@Classless@@YAHHPAN0HH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int UpdateCurveByID(int nDataID, double[] pX, double[] pY, int nLen, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetTitle@Classless@@YAXPB_W@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetTitle(StringBuilder title);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetTitle@Classless@@YAXPB_WH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetTitle(StringBuilder title, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?AddPie@Classless@@YAHN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddPie(double value);
        [DllImport(@"CChartu.dll", EntryPoint = "?AddPie@Classless@@YAHNPAG@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddPie(double value, StringBuilder name);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetPieTitle@Classless@@YAXPBGH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetPieTitle(StringBuilder title, int which);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetPieColor@Classless@@YAXKH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetPieColor(int color, int which);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?AddStems@Classless@@YAHPANH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddStems(double[] pData, int nLen);
        [DllImport(@"CChartu.dll", EntryPoint = "?AddStems@Classless@@YAHPANHPAG@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddStems(double[] pData, int nLen, StringBuilder title);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetStemLabel@Classless@@YAXPBGH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetStemLabel(StringBuilder label, int which);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetStemTitle@Classless@@YAXPBGH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetStemTitle(StringBuilder title, int nDataIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?ClrAllData@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ClrAllData();
        [DllImport(@"CChartu.dll", EntryPoint = "?ClrPlotData@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ClrPlotData(int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?ClrSingleData@Classless@@YAXHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ClrSingleData(int nDataIndex, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?AddLayer@Classless@@YAHXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int AddLayer();
        [DllImport(@"CChartu.dll", EntryPoint = "?ResizePlots@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ResizePlots(int nLayers);
        [DllImport(@"CChartu.dll", EntryPoint = "?ResizePlots@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ResizePlots(int mode, int nRows, int nCols);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataTitle@Classless@@YAXPBGHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataTitle(StringBuilder title, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataColor@Classless@@YAXKHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataColor(int color, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataLineSize@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataLineSize(int nSize, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataLineStyle@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataLineStyle(int nStyle, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetPlotType@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetPlotType(int nType, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetMarkerShow@Classless@@YAX_NHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetMarkerShow(bool bShow, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetMarkerFill@Classless@@YAX_NHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetMarkerFill(bool bFill, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetMarkerType@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetMarkerType(int nType, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetMarkerSize@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetMarkerSize(int nSize, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetMarkerFreq@Classless@@YAXHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetMarkerFreq(int nFreq, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataFillColor@Classless@@YAX_NKHHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataFillColor(bool bFill, int color, int nOpaque, int nFillMode, int nDataIndex, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetDataBarMode@Classless@@YAX_NHHHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetDataBarMode(bool bShowBar, int nBarBase, int nBarSize, int nDataIndex, int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetScatter@Classless@@YAXHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetScatter(int nDataIndex, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?AddAxis@Classless@@YAXHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void AddAxis(int location, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetAxisTitle@Classless@@YAXPBGH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetAxisTitle(StringBuilder title, int location);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetAxisTitle@Classless@@YAXPBGHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetAxisTitle(StringBuilder title, int location, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetAxisLabelShow@Classless@@YAX_NH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetAxisLabelShow(bool bShow, int location);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetAxisLabelShow@Classless@@YAX_NHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetAxisLabelShow(bool bShow, int location, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetUseLegend@Classless@@YAX_NH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetUseLegend(bool bUse, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetLegendMaxRows@Classless@@YAXHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetLegendMaxRows(int nRows, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetLegendMaxCols@Classless@@YAXHH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetLegendMaxCols(int nCols, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?GetSubPlotsCount@Classless@@YAHXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static int GetSubPlotsCount();
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetPlotRange@Classless@@YAXQAN0@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetPlotRange(double[] xRange, double[] yRange);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetPlotRange@Classless@@YAXNNNN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetPlotRange(double x1, double x2, double y1, double y2);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetXRange@Classless@@YAXNN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetXRange(double low, double high);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetXRange@Classless@@YAXNNH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetXRange(double low, double high, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetYRange@Classless@@YAXNN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetYRange(double low, double high);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetYRange@Classless@@YAXNNH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetYRange(double low, double high, int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetExactXRange@Classless@@YAX_NH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetExactXRange(bool bExact, int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetExactYRange@Classless@@YAX_NH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetExactYRange(bool bExact, int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetEqualXYAxis@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetEqualXYAxis(bool bEqual);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetEqualXYRange@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetEqualXYRange(bool bEqual);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetEqualXYScale@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetEqualXYScale(bool bEqual);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetGridBindLayer@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetGridBindLayer(int nPlotIndex);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetGridLine@Classless@@YAX_N000@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetGridLine(bool MajorH, bool MajorV, bool MinorH, bool MinorV);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetGridLine@Classless@@YAX_N000H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetGridLine(bool MajorH, bool MajorV, bool MinorH, bool MinorV, int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetBkgndColor@Classless@@YAXK@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetBkgndColor(int color);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetBkgndColor@Classless@@YAXKH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetBkgndColor(int color, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetContourLineNum@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetContourLineNum(int num);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetContourPrecision@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetContourPrecision(int n);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetContourMapColor1@Classless@@YAXK@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetContourMapColor1(int cr);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetContourMapColor2@Classless@@YAXK@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetContourMapColor2(int cr);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetZoomMode@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetZoomMode(bool zoom);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetZoomFactorX@Classless@@YAXN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetZoomFactorX(double fact);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetZoomFactorY@Classless@@YAXN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetZoomFactorY(double fact);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetZoomFactor@Classless@@YAXN@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetZoomFactor(double fact);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetZoomCenterMode@Classless@@YAXH@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetZoomCenterMode(int center);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowXYMajorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowXYMajorGrid(bool show);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowYZMajorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowYZMajorGrid(bool show);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowZXMajorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowZXMajorGrid(bool show);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowXYMinorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowXYMinorGrid(bool show);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowYZMinorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowYZMinorGrid(bool show);
        [DllImport(@"CChartu.dll", EntryPoint = "?SetShowZXMinorGrid@Classless@@YAX_N@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetShowZXMinorGrid(bool show);

        [DllImport(@"CChartu.dll", EntryPoint = "?SetGridLine@Classless@@YAX_N00000@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetGridLine(bool MajorXY, bool MinorXY, bool MajorYZ, bool MinorYZ, bool MajorZX, bool MinorZX);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?SetLRAxis@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetLRAxis();
        [DllImport(@"CChartu.dll", EntryPoint = "?SetTBAxis@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void SetTBAxis();

        [DllImport(@"CChartu.dll", EntryPoint = "?GetPlotRect@Classless@@YA?AUtagRECT@@XZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static Rectangle GetPlotRect();
        [DllImport(@"CChartu.dll", EntryPoint = "?GetPlotRect@Classless@@YA?AUtagRECT@@H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static Rectangle GetPlotRect(int nPlotIndex);

        [DllImport(@"CChartu.dll", EntryPoint = "?GetPlotRange@Classless@@YAXQAN0H@Z", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void GetPlotRange(out double[] xRange, out double[] yRange, int nPlotIndex);
    }
    partial class ChartAncestor
    {
        [DllImport(@"CChartu.dll", EntryPoint = "?ReDraw@Classless@@YAXXZ", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        protected extern static void ReDraw();
    }
}

