Exemplo n.º 1
0
        public void ReadXml(TextReader reader, bool AssignCanvas)
        {
            CreateSerializer();
            ObjectManager om = (ObjectManager)xsReadWrite.Deserialize(reader);

            objects.Clear();
            foreach (BaseObject bo in om.objects)
            {
                objects.Add(bo);
            }
            this.symbol           = om.symbol;
            this.startTime        = om.startTime;
            this.endTime          = om.endTime;
            this.maxPrice         = om.maxPrice;
            this.minPrice         = om.minPrice;
            this.latestTime       = om.latestTime;
            this.stockRenderType  = om.stockRenderType;
            this.indicators       = om.indicators;
            this.areaPercent      = om.areaPercent;
            this.skin             = om.skin;
            this.currentDataCycle = om.currentDataCycle;
            this.width            = om.width;
            this.height           = om.height;

            if (AssignCanvas)
            {
                SetCanvas(Canvas);
                RebuildTree();
                Invalidate();
            }
        }
Exemplo n.º 2
0
        public void WriteXml(TextWriter writer)
        {
            if (Canvas != null && Canvas.Chart != null)
            {
                FormulaChart  fc  = Canvas.Chart;
                IDataProvider idp = fc.DataProvider;
                if (idp != null)
                {
                    symbol           = idp.GetStringData("Code");
                    currentDataCycle = idp.DataCycle.ToString();
                    startTime        = fc.StartTime.ToOADate();
                    endTime          = fc.EndTime.ToOADate();
                    areaPercent      = fc.GetAreaPercent();
                    indicators       = string.Join(";", fc.AreaToStrings());
                    stickRenderType  = fc.StickRenderType;

                    width  = fc.Rect.Width;
                    height = fc.Rect.Height;

                    if (Canvas.DesignerControl is ChartWinControl)
                    {
                        skin = ((ChartWinControl)Canvas.DesignerControl).Skin;
                    }

                    if (fc.MainArea != null)
                    {
                        maxPrice        = fc.MainArea.AxisY.MaxY;
                        minPrice        = fc.MainArea.AxisY.MinY;
                        stockRenderType = fc.MainArea.StockRenderType;
                    }

                    double[] dd = idp["DATE"];
                    if (dd.Length > 0)
                    {
                        latestTime = dd[dd.Length - 1];
                    }
                }
            }

            CreateSerializer();
            xsReadWrite.Serialize(writer, this,
                                  new XmlSerializerNamespaces(
                                      new XmlQualifiedName[] { new XmlQualifiedName("EasyChart", "http://finance.easychart.net") }));
            Changed = false;
        }