Example #1
0
        private NSerializationFilter GetSeriazliationFilter()
        {
            PersistencyFormat format = (PersistencyFormat)SerializationFormatComboBox.SelectedIndex;

            if (format.Equals(PersistencyFormat.Binary) || format.Equals(PersistencyFormat.XML) || format.Equals(PersistencyFormat.SOAP))
            {
                return(null);
            }

            NSerializationFilter filter = null;

            switch (SerializationContentComboBox.SelectedIndex)
            {
            case 0:                     // All
                filter = null;
                break;

            case 1:                     // Data
                filter = new NDataSerializationFilter();
                break;

            case 2:                     // Appearance
                filter = new NAppearanceSerializationFilter();
                break;
            }

            return(filter);
        }
Example #2
0
        private void LoadFromFileButton_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Binary(*.bin)|*.bin|XML(*.xml)|*.xml|All files (*.*)|*.*";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                NSerializationFilter filter = GetSeriazliationFilter();
                nChartControl1.Serializer.LoadControlStateFromFile(dlg.FileName, (PersistencyFormat)SerializationFormatComboBox.SelectedIndex, filter);

                // update form members
                if (nChartControl1.Charts.Count > 0)
                {
                    m_Chart = nChartControl1.Charts[0];

                    foreach (NSeriesBase series in m_Chart.Series)
                    {
                        if (series is NHighLowSeries)
                        {
                            m_HighLow = (NHighLowSeries)series;
                        }
                        else if (series is NLineSeries)
                        {
                            m_LineSMA = (NLineSeries)series;
                        }
                        else if (series is NStockSeries)
                        {
                            m_Stock = (NStockSeries)series;
                        }
                    }
                }

                nChartControl1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void SaveToFileButton_Click(object sender, System.EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "Binary(*.bin)|*.bin|XML(*.xml)|*.xml|All files (*.*)|*.*";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                NSerializationFilter filter = GetSeriazliationFilter();
                nChartControl1.Serializer.SaveControlStateToFile(dlg.FileName, (PersistencyFormat)SerializationFormatComboBox.SelectedIndex, filter);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void LoadSecondChartButton_Click(object sender, System.EventArgs e)
        {
//			MemoryStream stream = new MemoryStream();
            NSerializationFilter filter = null;

            switch (SerializationContentComboBox.SelectedIndex)
            {
            case 0:                     // All
                filter = null;
                break;

            case 1:                     // Data
                filter = new NDataSerializationFilter();
                break;

            case 2:                     // Appearance
                filter = new NAppearanceSerializationFilter();
                break;
            }

            if (m_Chart2 != null)
            {
                nChartControl1.Panels.Remove(m_Chart2);
            }

            // clone the first chart
            m_Chart2 = (NChart)(nChartControl1.Charts[0].CloneWithNewUniqueId(null));

            // filter elements
            m_Chart2          = (NChart)nChartControl1.Serializer.DeepClone(m_Chart2, filter);
            m_Chart2.Location = new NPointL(
                new NLength(10, NRelativeUnit.RootPercentage),
                new NLength(55, NRelativeUnit.RootPercentage));

            // add to panels collection
            nChartControl1.Panels.Add(m_Chart2);
            nChartControl1.Refresh();
        }