Esempio n. 1
0
        public void OnSetFlawLegend(List<FlawLegend> legend)
        {
            ConfigHelper ch = new ConfigHelper();
            Config configFile = ch.GetConfigFile();
            Config newConfig = new Config() { Legends = new List<NMap.Model.Legend>() };

            List<NMap.Model.Legend> mcsLegends = new List<NMap.Model.Legend>();
            foreach (var item in legend)
            {
                NMap.Model.Legend l = new NMap.Model.Legend();
                l.ClassID = item.ClassID.ToString();
                l.Color = String.Format("#{0:X2}{1:X2}{2:X2}",
                              ColorTranslator.FromWin32((int)item.Color).R,
                              ColorTranslator.FromWin32((int)item.Color).G,
                              ColorTranslator.FromWin32((int)item.Color).B);
                l.Shape = "Circle";
                l.Name = item.Name;
                l.OriginLegend = item;
                mcsLegends.Add(l);
            }

            // Compare legends in config file and mcs file
            if (configFile.Legends.Count() != 0)
            {
                if (configFile.Legends.Count() == mcsLegends.Count())
                {
                    int i = 0;
                    foreach (var item in mcsLegends)
                    {
                        configFile.Legends[i].ClassID = item.ClassID;
                        configFile.Legends[i].Name = item.Name;
                        i++;
                    }
                }
                else if (configFile.Legends.Count() > mcsLegends.Count())
                {
                    int i = 0;
                    foreach (var item in mcsLegends)
                    {
                        configFile.Legends[i].ClassID = item.ClassID;
                        configFile.Legends[i].Name = item.Name;
                        i++;
                    }
                    configFile.Legends.RemoveRange(i, configFile.Legends.Count() - i);
                }
                else
                {
                    int i = 0;
                    int legendQuantity = configFile.Legends.Count();
                    foreach (var item in mcsLegends)
                    {
                        if (legendQuantity > i)
                        {
                            configFile.Legends[i].ClassID = item.ClassID;
                            configFile.Legends[i].Name = item.Name;
                        }
                        else
                        {
                            configFile.Legends.Add(item);
                        }
                        i++;
                    }
                }
            }
            else
            {
                configFile.Legends = mcsLegends;
            }

            // Reset config
            ch.CreateConfigFile(configFile);
        }
Esempio n. 2
0
        /// <summary>
        /// 開啟設定視窗 設定 Map 相關參數
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetting_Click(object sender, EventArgs e)
        {
            // Read XML
            ConfigHelper ch = new ConfigHelper();
            _config = ch.GetConfigFile();

            Settings setting = new Settings(_config);
            setting.ShowDialog();

            if (chartControl.Series.Count > 0)
            {
                chartControl.Series.Clear();
                // Add each legend to chart
                foreach (var legend in _config.Legends)
                {
                    Series series = new Series(legend.Name, ViewType.Point);
                    series.ArgumentScaleType = ScaleType.Numerical;
                    series.ArgumentDataMember = "CD";
                    series.ValueScaleType = ScaleType.Numerical;
                    series.ValueDataMembers.AddRange(new string[] { "MD" });
                    series.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;

                    PointSeriesView seriesView = (PointSeriesView)series.View;
                    seriesView.PointMarkerOptions.Size = 15;
                    seriesView.PointMarkerOptions.Kind = _dicSeriesShape[legend.Shape];
                    seriesView.Color = System.Drawing.ColorTranslator.FromHtml(legend.Color);

                    chartControl.Series.Add(series);
                }

                foreach (Series series in chartControl.Series)
                {
                    series.DataSource = QueryDataTable(_flawData, "FlawClass = '" + series.Name + "'", ""); ;
                }

                SetScrollingRange();
            }
        }
Esempio n. 3
0
        public void OnJobStarted(int jobKey)
        {
            //btnSetting.Enabled = false;
            JobHelper.JobKey = jobKey;

            // Get config from xml file
            ConfigHelper ch = new ConfigHelper();
            _config = ch.GetConfigFile();
            InitialChart();

            // Add each legend to chart
            foreach (var legend in _config.Legends)
            {
                Series series = new Series(legend.Name, ViewType.Point);
                series.ArgumentScaleType = ScaleType.Numerical;
                series.ArgumentDataMember = "CD";
                series.ValueScaleType = ScaleType.Numerical;
                series.ValueDataMembers.AddRange(new string[] { "MD" });
                series.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;

                PointSeriesView seriesView = (PointSeriesView)series.View;
                seriesView.PointMarkerOptions.Size = 15;
                seriesView.PointMarkerOptions.Kind = _dicSeriesShape[legend.Shape];
                seriesView.Color = System.Drawing.ColorTranslator.FromHtml(legend.Color);

                chartControl.Series.Add(series);
            }
        }