Exemple #1
1
        /// <summary>
        /// �޸Ļ�վ��Ϣ����ͼ��Դ�ļ�
        /// </summary>
        /// <param name="f"></param>
        /// <param name="pointCode"></param>
        /// <param name="iType"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pointname"></param>
        private void ModifyPoint(Feature f, string pointCode, int iType, double x, double y, string pointname, bool IsBusy)
        {
            MapInfo.Geometry.Point g = new MapInfo.Geometry.Point(GetCoordSys(), x, y);
            SimpleVectorPointStyle vs = null;
            MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(strTempMapPointTable);
            //vs = new SimpleVectorPointStyle(34, System.Drawing.Color.Red, 12);

            //��ȡ��վ��ʾЧ��
            vs = GetSimpleVectorPointStyleByiType(iType);

            SimpleLineStyle ls = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 1, System.Drawing.Color.Red);
            SimpleInterior si = new SimpleInterior(1, System.Drawing.Color.Red, System.Drawing.Color.Red);
            AreaStyle a = new AreaStyle(ls, si);
            CompositeStyle cs = new CompositeStyle(a, null, null, vs);
            cs = GetCompositeStyleByIsBusy(IsBusy, iType);

            //Columns cols = new Columns();
            //cols.Add(MapInfo.Data.ColumnFactory.CreateStringColumn("Caption", 50));
            //Feature f = new Feature(g, cs, cols);

            f["Obj"] = g;
            f["MI_Style"] = cs;
            f["ID"] = pointCode;
            f["Caption"] = pointname;
            table.UpdateFeature(f);

            MapInfo.Data.TableInfo tableInfo = table.TableInfo;
            tableInfo.WriteTabFile(); //����Ϊ.tab�ļ�
        }
Exemple #2
0
 public SimpleLineSymbolDef(Color color, SimpleLineStyle style,
                            double width)
 {
     Color = color;
     Style = style;
     Width = width;
 }
Exemple #3
0
 public SimpleLineSymbolDef(Color color, SimpleLineStyle style,
     double width)
 {
     Color = color;
     Style = style;
     Width = width;
 }
Exemple #4
0
 //刷新区域查车显示
 private void RefreshRegionQuery()
 {
     if (queryPtList.Count > 1)
     {
         try
         {
             DPoint[] dpt = { queryPtList[queryPtList.Count - 1], queryPtList[queryPtList.Count - 2] };
             Feature  ftr = new Feature(tableTemp.TableInfo.Columns);
             MapInfo.Styles.SimpleLineStyle ss = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 2);
             ftr.Geometry = new MapInfo.Geometry.MultiCurve(mapControl.Map.GetDisplayCoordSys(), MapInfo.Geometry.CurveSegmentType.Linear, dpt);
             ftr.Style    = ss;
             tableTemp.InsertFeature(ftr);
             tableTemp.Refresh();
         }
         catch { }
     }
 }
Exemple #5
0
        void Map_ViewChangedEvent(object sender, MapInfo.Mapping.ViewChangedEventArgs e)
        {
            // Display the zoom level
            Double dblZoom = System.Convert.ToDouble(String.Format("{0:E2}", mapControl1.Map.Zoom.Value));

            if (statusStrip1.Items.Count > 0)
            {
                statusStrip1.Items[0].Text = "缩放: " + dblZoom.ToString() + " " + MapInfo.Geometry.CoordSys.DistanceUnitAbbreviation(mapControl1.Map.Zoom.Unit);
            }

            if (Session.Current.Catalog.GetTable("EagleEyeTemp") == null)
            {
                loadEagleLayer();
            }
            Table tblTemp = Session.Current.Catalog.GetTable("EagleEyeTemp");

            try
            {
                (tblTemp as ITableFeatureCollection).Clear();
            }
            catch (Exception)
            { }

            try
            {
                // 主地图发生改变是对鹰眼地图进行相应的画框操作
                if (mapControl2.Map.Layers["MyEagleEye"] != null)
                {
                    mapControl2.Map.Layers.Remove(eagleEye);
                }
                DRect           rect   = mapControl1.Map.Bounds;
                FeatureGeometry fg     = new MapInfo.Geometry.Rectangle(mapControl1.Map.GetDisplayCoordSys(), rect);
                SimpleLineStyle vLine  = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), 2, Color.Red);
                SimpleInterior  vInter = new SimpleInterior(9, Color.Yellow, Color.Yellow, true);
                CompositeStyle  cStyle = new CompositeStyle(new AreaStyle(vLine, vInter), null, null, null);
                fRec = new Feature(fg, cStyle);
                tblTemp.InsertFeature(fRec);
                eagleEye = new FeatureLayer(tblTemp, "EagleEye ", "MyEagleEye");
                mapControl2.Map.Layers.Insert(0, eagleEye);
            }
            catch (Exception)
            { }
        }
Exemple #6
0
 //刷新测距显示
 private void RefreshDistance()
 {
     if (disPtList.Count > 1)
     {
         try
         {
             DPoint[] dpt =
             {
                 GetCoordPt(disPtList[disPtList.Count - 1].X, disPtList[disPtList.Count - 1].Y),
                 GetCoordPt(disPtList[disPtList.Count - 2].X, disPtList[disPtList.Count - 2].Y)
             };
             Feature ftr = new Feature(tableDisLine.TableInfo.Columns);
             MapInfo.Styles.SimpleLineStyle ss = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 2);
             ftr.Geometry = new MapInfo.Geometry.MultiCurve(mapControl.Map.GetDisplayCoordSys(), MapInfo.Geometry.CurveSegmentType.Linear, dpt);
             ftr.Style    = ss;
             tableDisLine.InsertFeature(ftr);
             tableDisLine.Refresh();
         }
         catch { }
     }
 }
Exemple #7
0
        // Disable other LabelLayers if we demo a new LabelLayer with theme or modifier sample.
        // so User could see theme/modifier label layer clearly.
//		public static void HandleLabelLayerVisibleStatus(Map map)
//		{
//			if(map == null) return;
//			for(int index=0; index < map.Layers.Count; index++)
//			{
//				IMapLayer lyr = map.Layers[index];
//				if(lyr is LabelLayer)
//				{
//					LabelLayer ll = lyr as LabelLayer;
//					if(map.Layers[SampleConstants.NewLabelLayerAlias] != null
//						&& ll.Alias != SampleConstants.NewLabelLayerAlias)
//					{
//						ll.Enabled = false;
//					}
//					else
//					{
//						ll.Enabled = true;
//					}
//				}
//			}
//		}

        // Create all MapXtreme.Net themes and modifiers for the bound data
        // and add them into the corresponding Map object.
        private void CreateThemeOrModifier(string themeName)
        {
            Map myMap = GetMapObj();

            if (myMap == null)
            {
                return;
            }
            // Clean up all temp themes or modifiers from the Map object.
            this.CleanUp(myMap);

            FeatureLayer          fLyr      = myMap.Layers[SampleConstants.ThemeLayerAlias] as FeatureLayer;
            ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName);

            string alias = ConstructThemeAlias(themeType);

            switch (themeType)
            {
            case ThemeAndModifierTypes.RangedTheme:
                RangedTheme rt = new RangedTheme(fLyr, GetThemeOrModifierExpression(), alias, 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
                fLyr.Modifiers.Append(rt);
                break;

            case ThemeAndModifierTypes.DotDensityTheme:
                DotDensityTheme ddt = new DotDensityTheme(fLyr, GetThemeOrModifierExpression(), alias, Color.Purple, DotDensitySize.Large);
                ddt.ValuePerDot = 2000000d;
                fLyr.Modifiers.Append(ddt);
                break;

            case ThemeAndModifierTypes.IndividualValueTheme:
                IndividualValueTheme ivt = new IndividualValueTheme(fLyr, GetThemeOrModifierExpression(), alias);
                fLyr.Modifiers.Append(ivt);
                break;

            case ThemeAndModifierTypes.PieTheme:
                PieTheme         pt    = new PieTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                ObjectThemeLayer otlPt = new ObjectThemeLayer("PieTheme", alias, pt);
                GetTheGroupLayer().Insert(0, otlPt);
                break;

            case ThemeAndModifierTypes.BarTheme:
                BarTheme bt = new BarTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                bt.DataValueAtSize = 10000000;
                bt.Size            = new MapInfo.Engine.PaperSize(0.1, 0.1, MapInfo.Geometry.PaperUnit.Inch);
                bt.Width           = new MapInfo.Engine.PaperSize(0.1, MapInfo.Geometry.PaperUnit.Inch);
                ObjectThemeLayer otlBt = new ObjectThemeLayer("BarTheme", alias, bt);

                GetTheGroupLayer().Insert(0, otlBt);
                break;

            case ThemeAndModifierTypes.GraduatedSymbolTheme:
                GraduatedSymbolTheme gst    = new GraduatedSymbolTheme(fLyr.Table, GetThemeOrModifierExpression());
                ObjectThemeLayer     otlGst = new ObjectThemeLayer("GraduatedSymbolTheme", alias, gst);
                GetTheGroupLayer().Insert(0, otlGst);
                break;

            case ThemeAndModifierTypes.FeatureOverrideStyleModifier:
                FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("OverrideTheme", alias);

                SimpleInterior fs = new SimpleInterior((SimpleInterior.MaxFillPattern - SimpleInterior.MinFillPattern) / 2, Color.FromArgb(10, 23, 90), Color.FromArgb(33, 35, 35), false);
                fs.SetApplyAll();
                SimpleLineStyle lineStyle = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), (SimpleLineStyle.MaxLinePattern - SimpleLineStyle.MinLinePattern) / 2);
                lineStyle.Color       = Color.FromArgb(111, 150, 230);
                lineStyle.Interleaved = false;
                lineStyle.SetApplyAll();

                fosm.Style.AreaStyle = new AreaStyle(lineStyle, fs);
                fLyr.Modifiers.Append(fosm);
                break;

            case ThemeAndModifierTypes.Label_IndividualValueLabelTheme:
                IndividualValueLabelTheme ivlt = new IndividualValueLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias);
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(ivlt);
                break;

            case ThemeAndModifierTypes.Label_RangedLabelTheme:
                RangedLabelTheme rlt = new RangedLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias, 5, DistributionMethod.EqualCountPerRange);
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(rlt);
                break;

            case ThemeAndModifierTypes.Label_OverrideLabelModifier:
                OverrideLabelModifier olm  = new OverrideLabelModifier(alias, "OverrideLabelModifier");
                MapInfo.Styles.Font   font = new MapInfo.Styles.Font("Arial", 24, Color.Red, Color.Yellow, FontFaceStyle.Italic,
                                                                     FontWeight.Bold, TextEffect.Halo, TextDecoration.All, TextCase.AllCaps, true, true);

                font.Attributes = StyleAttributes.FontAttributes.All;

                olm.Properties.Style   = new TextStyle(font);
                olm.Properties.Caption = GetThemeOrModifierExpression();
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(olm);
                break;

            default:
                break;
            }
        }
        // Create all MapXtreme.Net themes and modifiers for the bound data
        // and add them into the corresponding Map object.
        private void CreateThemeOrModifier(string themeName)
        {
            Map myMap = GetMapObj();
            if(myMap == null)return;
            // Clean up all temp themes or modifiers from the Map object.
            this.CleanUp(myMap);

            FeatureLayer fLyr = myMap.Layers[SampleConstants.ThemeLayerAlias] as FeatureLayer;
            ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName);

            string alias = ConstructThemeAlias(themeType);
            switch(themeType)
            {
                case ThemeAndModifierTypes.RangedTheme:
                    RangedTheme rt = new RangedTheme(fLyr, GetThemeOrModifierExpression(), alias, 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
                    fLyr.Modifiers.Append(rt);
                    break;
                case ThemeAndModifierTypes.DotDensityTheme:
                    DotDensityTheme ddt = new DotDensityTheme(fLyr, GetThemeOrModifierExpression(), alias, Color.Purple, DotDensitySize.Large);
                    ddt.ValuePerDot = 2000000d;
                    fLyr.Modifiers.Append(ddt);
                    break;
                case ThemeAndModifierTypes.IndividualValueTheme:
                    IndividualValueTheme ivt = new IndividualValueTheme(fLyr, GetThemeOrModifierExpression(), alias);
                    fLyr.Modifiers.Append(ivt);
                    break;
                case ThemeAndModifierTypes.PieTheme:
                    PieTheme pt = new PieTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                    ObjectThemeLayer otlPt = new ObjectThemeLayer("PieTheme", alias, pt);
                    GetTheGroupLayer().Insert(0, otlPt);
                    break;
                case ThemeAndModifierTypes.BarTheme:
                    BarTheme bt = new BarTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                    bt.DataValueAtSize = 10000000;
                    bt.Size = new MapInfo.Engine.PaperSize(0.1, 0.1, MapInfo.Geometry.PaperUnit.Inch);
                    bt.Width = new MapInfo.Engine.PaperSize(0.1, MapInfo.Geometry.PaperUnit.Inch);
                    ObjectThemeLayer otlBt = new ObjectThemeLayer("BarTheme", alias, bt);
                    GetTheGroupLayer().Insert(0, otlBt);
                    break;
                case ThemeAndModifierTypes.GraduatedSymbolTheme:
                    GraduatedSymbolTheme gst = new GraduatedSymbolTheme(fLyr.Table, GetThemeOrModifierExpression());
                    ObjectThemeLayer otlGst = new ObjectThemeLayer("GraduatedSymbolTheme", alias, gst);
                    GetTheGroupLayer().Insert(0, otlGst);
                    break;
                case ThemeAndModifierTypes.FeatureOverrideStyleModifier:
                    FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("OverrideTheme", alias);

                    SimpleInterior fs = new SimpleInterior((SimpleInterior.MaxFillPattern - SimpleInterior.MinFillPattern) / 2, Color.FromArgb(10, 23, 90), Color.FromArgb(33, 35, 35), false);
                    fs.SetApplyAll();
                    SimpleLineStyle lineStyle = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), (SimpleLineStyle.MaxLinePattern - SimpleLineStyle.MinLinePattern) /2);
                    lineStyle.Color = Color.FromArgb(111, 150, 230);
                    lineStyle.Interleaved = false;
                    lineStyle.SetApplyAll();

                    fosm.Style.AreaStyle = new AreaStyle(lineStyle, fs);
                    fLyr.Modifiers.Append(fosm);
                    break;
                case ThemeAndModifierTypes.Label_IndividualValueLabelTheme:
                    IndividualValueLabelTheme ivlt = new IndividualValueLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias);
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(ivlt);
                    break;
                case ThemeAndModifierTypes.Label_RangedLabelTheme:
                    RangedLabelTheme rlt = new RangedLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias, 5, DistributionMethod.EqualCountPerRange);
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(rlt);
                    break;
                case ThemeAndModifierTypes.Label_OverrideLabelModifier:
                    OverrideLabelModifier olm = new OverrideLabelModifier(alias, "OverrideLabelModifier");
                    MapInfo.Styles.Font font = new MapInfo.Styles.Font("Arial", 24, Color.Red, Color.Yellow, FontFaceStyle.Italic,
                        FontWeight.Bold, TextEffect.Halo, TextDecoration.All, TextCase.AllCaps, true, true);

                    font.Attributes = StyleAttributes.FontAttributes.All;

                    olm.Properties.Style = new TextStyle(font);
                    olm.Properties.Caption = GetThemeOrModifierExpression();
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(olm);
                    break;
                default:
                    break;
            }
        }
 private void buttonLineStyleDialog_Click(object sender, System.EventArgs e)
 {
     if (_lineStyleDlg == null)
     {
         _lineStyleDlg = new LineStyleDlg();
     }
     _lineStyleDlg.LineStyle = _lineStyle;
     if (_lineStyleDlg.ShowDialog() == DialogResult.OK)
     {
         BaseLineStyle ls = _lineStyleDlg.LineStyle;
         if (ls is SimpleLineStyle)
         {
             _lineStyle = (SimpleLineStyle)ls;
             SetLineSample();
         }
         else
         {
             throw new System.NotImplementedException("New style type not handled.");
         }
     }
 }
Exemple #10
0
 private void buttonAreaStyleDialog_Click(object sender, System.EventArgs e)
 {
     if (_areaStyleDlg == null)
     {
         _areaStyleDlg = new AreaStyleDlg();
     }
     _areaStyleDlg.AreaStyle = new AreaStyle(_lineStyle, _fillStyle);
     if (_areaStyleDlg.ShowDialog() == DialogResult.OK)
     {
         if (_areaStyleDlg.AreaStyle.Border is SimpleLineStyle)
         {
             _lineStyle = (SimpleLineStyle)_areaStyleDlg.AreaStyle.Border;
         }
         else
         {
             throw new System.NotImplementedException("New style type not handled.");
         }
         if (_areaStyleDlg.AreaStyle.Interior is SimpleInterior)
         {
             _fillStyle = (SimpleInterior)_areaStyleDlg.AreaStyle.Interior;
         }
         else
         {
             throw new System.NotImplementedException("New style type not handled.");
         }
         SetFillSample();
     }
 }
Exemple #11
0
        private void MapForm1_Load(object sender, System.EventArgs e)
        {
            //replace default Map created by mapcontrol with FeatureRenderer
            CoordSys csys = Session.Current.CoordSysFactory.CreateCoordSys(CoordSysType.NonEarth, null, DistanceUnit.Meter, 0, 0, 0, 0, 0, 0, 0, 0, 0, new MapInfo.Geometry.DRect(0, 0, mapControl1.Map.Size.Width, mapControl1.Map.Size.Height), null);
            FeatureRenderer fr = Session.Current.MapFactory.CreateFeatureRenderer("stylesample", "stylesample", mapControl1.Map.Handle, mapControl1.Map.Size, csys);
            mapControl1.Map = fr;

            fr.SetView(csys.Bounds, csys);

            radioBlackFillStyle.Checked = true;

            // used as storage for line tab
            _lineStyle = new SimpleLineStyle();

            // set updown limits for line tab
            numericUpDownPixelWidth.Minimum = (decimal)LineWidth.MinPixel;
            numericUpDownPixelWidth.Maximum = (decimal)LineWidth.MaxPixel;
            numericUpDownPixelWidth.Value = (decimal)LineWidth.MinPixel;
            numericUpDownPointWidth.Minimum = (decimal)LineWidth.MinPoint;
            numericUpDownPointWidth.Maximum = (decimal)LineWidth.MaxPoint;
            numericUpDownPointWidth.Value = (decimal)LineWidth.MinPoint;
            if (_lineStyle.Width.Unit == LineWidthUnit.Pixel)
            {
                numericUpDownPixelWidth.Value = (decimal)_lineStyle.Width.Value;
                radioPixelWidth.Checked = true;
            }
            else
            {
                numericUpDownPointWidth.Value = (decimal)_lineStyle.Width.Value;
                radioPointWidth.Checked = true;
            }

            numericUpDownLinePattern.Minimum = SimpleLineStyle.MinLinePattern;
            numericUpDownLinePattern.Maximum = SimpleLineStyle.MaxLinePattern;
            numericUpDownLinePattern.Value = _lineStyle.Pattern;

            // for fill tab
            _fillStyle = new SimpleInterior();
            numericUpDownFillPattern.Minimum = SimpleInterior.MinFillPattern;
            numericUpDownFillPattern.Maximum = SimpleInterior.MaxFillPattern;
            numericUpDownLinePattern.Value = _fillStyle.Pattern;

            // vector symbols
            _vectorSymbol = new SimpleVectorPointStyle();
            numericUpDownVectorPointSize.Minimum = BasePointStyle.MinPointSize;
            numericUpDownVectorPointSize.Maximum = BasePointStyle.MaxPointSize;
            numericUpDownVectorPointSize.Value = (decimal)_vectorSymbol.PointSize;

            // mapinfo.fnt valid values
            numericUpDownVectorCode.Minimum = 31;
            numericUpDownVectorCode.Maximum = 67;

            // bitmap symbol
            _bitmapSymbol = new BitmapPointStyle();
            foreach (BitmapPointStyle b in Session.Current.StyleRepository.BitmapPointStyleRepository)
            {
                listBoxBitmapNames.Items.Add(b.Name);
            }
            checkBoxBitmapShowBackground.Checked = _bitmapSymbol.ShowWhiteBackground;
            checkBoxBitmapApplyColor.Checked = _bitmapSymbol.ApplyColor;
            numericUpDownBitmapPointSize.Minimum = BasePointStyle.MinPointSize;
            numericUpDownBitmapPointSize.Maximum = BasePointStyle.MaxPointSize;
            numericUpDownBitmapPointSize.Value = (decimal)_bitmapSymbol.PointSize;
            // font symbol
            _fontSymbol = new FontPointStyle();
            numericUpDownFontPointSize.Minimum = BasePointStyle.MinPointSize;
            numericUpDownFontPointSize.Maximum = BasePointStyle.MaxPointSize;
            numericUpDownFontPointSize.Value = (decimal)_fontSymbol.PointSize;
            numericUpDownFontCode.Minimum = BasePointStyle.MinCode;
            numericUpDownFontCode.Maximum = BasePointStyle.MaxCode;
            numericUpDownFontCode.Value = _fontSymbol.Code;

            // text
            _textStyle = new TextStyle();
              _textAngle = 0.0;
            numericUpDownTextSize.Minimum = 1;
            numericUpDownTextSize.Maximum = 96;
              numericUpDownTextSize.Value = (decimal)_fontSymbol.PointSize;
              numericUpDownTextAngle.Minimum = -360;
              numericUpDownTextAngle.Maximum = 360;

            Graphics g = CreateGraphics();
            FontFamily[] families = FontFamily.GetFamilies(g);
            // Draw text using each of the font families.
            foreach (FontFamily family in families)
            {
                comboBoxFontFamilies.Items.Add(family.Name);
                comboBoxTextFontFamily.Items.Add(family.Name);
            }
            g.Dispose();

            // select first fontname in each list (note that _fontSymbol and _textStyle
            // have to be constructed first since this causes a SelectedIndexChanged event).
            comboBoxFontFamilies.SelectedIndex = 0;
            comboBoxTextFontFamily.SelectedIndex = 0;

            foreach (Alignment alignment in Enum.GetValues(typeof(Alignment))) {
              comboBoxTextAlignment.Items.Add(alignment);
            }
              comboBoxTextAlignment.SelectedIndex = 0;

            foreach (Spacing spacing in Enum.GetValues(typeof(Spacing))) {
              comboBoxTextSpacing.Items.Add(spacing);
            }
            comboBoxTextSpacing.SelectedIndex = 0;

            // force first sample to be drawn
            tabControl1.SelectedIndex = 0;
            tabControl1_SelectedIndexChanged(this, null);
        }