Esempio n. 1
0
        public LayerPropertiesCtrl(IMapLayer layer, IResourceService resSvc, IEditorService edSvc)
            : this()
        {
            layer.PropertyChanged += new PropertyChangedEventHandler(OnLayerChanged);
            _resSvc = resSvc;
            _edSvc = edSvc;

            TextBoxBinder.BindText(txtResourceId, layer, "ResourceId");
            TextBoxBinder.BindText(txtName, layer, "Name");
            TextBoxBinder.BindText(txtLegendLabel, layer, "LegendLabel");
        }
Esempio n. 2
0
        public static void ZoomToLayer(IMapLayer layerToZoom)
        {

            var App = CustomerExtension.MyAppManager;

            const double eps = 1e-7;
            IEnvelope layerEnvelope = layerToZoom.Extent.ToEnvelope();

            if (layerEnvelope.Width > eps && layerEnvelope.Height > eps)
            {
                layerEnvelope.ExpandBy(layerEnvelope.Width / 10, layerEnvelope.Height / 10); // work item #84
            }
            else
            {
                double zoomInFactor = 0.05; //fixed zoom-in by 10% - 5% on each side
                double newExtentWidth = App.Map.ViewExtents.Width * zoomInFactor;
                double newExtentHeight = App.Map.ViewExtents.Height * zoomInFactor;
                layerEnvelope.ExpandBy(newExtentWidth, newExtentHeight);
            }

            App.Map.ViewExtents = layerEnvelope.ToExtent();
        }
Esempio n. 3
0
        private void PrintLayer(IMapLayer layer, MapArgs args)
        {
            //MapLabelLayer.ExistingLabels.Clear();
            IMapGroup group = layer as IMapGroup;
            if (group != null)
            {
                foreach (IMapLayer subLayer in group.Layers)
                {
                    PrintLayer(subLayer, args);
                }
            }

            IMapLayer geoLayer = layer;
            if (geoLayer != null)
            {
                if (geoLayer.UseDynamicVisibility)
                {
                    if (ViewExtents.Width > geoLayer.DynamicVisibilityWidth)
                    {
                        return;  // skip the geoLayer if we are zoomed out too far.
                    }
                }

                if (geoLayer.IsVisible == false) return;

                geoLayer.DrawRegions(args, new List<Extent> { args.GeographicExtents });

                IMapFeatureLayer mfl = geoLayer as IMapFeatureLayer;
                if (mfl != null)
                {
                    if (mfl.UseDynamicVisibility)
                    {
                        if (ViewExtents.Width > mfl.DynamicVisibilityWidth) return;
                    }
                    if (mfl.ShowLabels && mfl.LabelLayer != null)
                    {
                        if (mfl.LabelLayer.UseDynamicVisibility)
                        {
                            if (ViewExtents.Width > mfl.LabelLayer.DynamicVisibilityWidth) return;
                        }
                        mfl.LabelLayer.DrawRegions(args, new List<Extent> { args.GeographicExtents });
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RuntimeMapLayer"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="source">The source.</param>
 /// <param name="suppressErrors"></param>
 protected internal RuntimeMapLayer(RuntimeMap parent, IMapLayer source, bool suppressErrors)
     : this(parent, source, (ILayerDefinition)parent.CurrentConnection.ResourceService.GetResource(source.ResourceId), suppressErrors)
 {
     _disableChangeTracking = false;
 }
Esempio n. 5
0
 /// <summary>
 /// Removes the first occurrence of a specific object from the System.Collections.Generic.List&lt;T&gt;.
 /// </summary>
 /// <param name="item">The object to remove from the System.Collections.Generic.List&lt;T&gt;. The value can be null for reference types.</param>
 /// <returns>true if item is successfully removed; otherwise, false. This method also returns false if item was not
 /// found in the System.Collections.Generic.List&lt;T&gt;.</returns>
 /// <exception cref="System.ApplicationException">Unable to remove while the ReadOnly property is set to true.</exception>
 public bool Remove(IMapLayer item)
 {
     return base.Remove(item);
 }
Esempio n. 6
0
 /// <summary>
 /// Gets the zero-based integer index of the specified IGeoLayer in this collection
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(IMapLayer item)
 {
     return IndexOf(item as ILayer);
 }
Esempio n. 7
0
 /// <summary>
 /// This copies the members of this collection to the specified array index, but
 /// only if they match the IGeoLayer interface.  (Other kinds of layers can be
 /// added to this collection by casting it to a LayerCollection)
 /// </summary>
 /// <param name="inArray">The array of IGeoLayer interfaces to copy values to</param>
 /// <param name="arrayIndex">The zero-based integer index in the output array to start copying values to</param>
 public void CopyTo(IMapLayer[] inArray, int arrayIndex)
 {
     int index = arrayIndex;
     foreach (IMapLayer layer in this)
     {
         if (layer != null)
         {
             inArray[index] = layer;
             index++;
         }
     }
 }
Esempio n. 8
0
        public PropertiesForm( IMapLayer ml )
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            FilenameLabel.Text = ml.ToString();

            _ml = ml;
            _foreColor = ml.LayerPen.Color;
            _fillColor = ml.LayerBrush.Color;
            _featureAlpha = ml.LayerPen.Color.A;
            _penWidth = ml.LayerPen.Width;
            _labelFont = _ml.LabelFont;
            _labelForeColor = _ml.LabelForeColor;
            _labelFillColor = _ml.LabelFillColor;
            _labelAlpha = ml.LabelForeColor.A;

            showLabelsCheckBox.Checked = _ml.Labels;
            showLabelsBGCheckBox.Checked = _ml.LabelBackground;
            labelSourceComboBox.Items.AddRange( _ml.FieldNames );
            labelSourceComboBox.SelectedIndex = _ml.LabelSourceField;
            labelFontButton.Font = _ml.LabelFont;
            featureOpacityTrackBar.Enabled = false;
            featureOpacityTrackBar.Value = _featureAlpha;
            featureOpacityTrackBar.Enabled = true;
            fontOpacityTrackBar.Enabled = false;
            fontOpacityTrackBar.Value = _labelAlpha;
            fontOpacityTrackBar.Enabled = true;

            Bitmap foreColorImg = new Bitmap( 35, 24 );
            Bitmap fillColorImg = new Bitmap( 35, 24 );
            Bitmap labelForeColorImg = new Bitmap( 35, 24 );
            Bitmap labelFillColorImg = new Bitmap( 35, 24 );

            Graphics foreGr = Graphics.FromImage( foreColorImg );
            Graphics fillGr = Graphics.FromImage( fillColorImg );
            Graphics labelForeGr = Graphics.FromImage( labelForeColorImg );
            Graphics labelFillGr = Graphics.FromImage( labelFillColorImg );

            foreGr.FillRectangle( new SolidBrush( _foreColor ), 0, 0, foreColorImg.Width, foreColorImg.Height );
            fillGr.FillRectangle( new SolidBrush( _fillColor ), 0, 0, fillColorImg.Width, fillColorImg.Height );
            labelForeGr.FillRectangle( new SolidBrush( _labelForeColor ), 0, 0, labelForeColorImg.Width, labelForeColorImg.Height );
            labelFillGr.FillRectangle( new SolidBrush( _labelFillColor ), 0, 0, labelFillColorImg.Width, labelFillColorImg.Height );

            foreColorButton.Image = foreColorImg;
            fillColorButton.Image = fillColorImg;
            labelForeColorButton.Image = labelForeColorImg;
            labelFillColorButton.Image = labelFillColorImg;

            lineWidthUpDown.Value = (decimal) ml.LayerPen.Width;

            foreGr.Dispose();
            fillGr.Dispose();
            labelForeGr.Dispose();
            labelFillGr.Dispose();
        }
        private XmlElement CreateFeatureLayerElement(XmlDocument _doc, IMapLayer layer, string uniqueID)
        {
            Map map = GetMapObj(_mapAlias);
            FeatureLayer flayer = (FeatureLayer)layer;
            bool bRasterLayer = false;
            bool bHasModifiers = false;
            FeatureStyleModifiers mods = flayer.Modifiers;
            if ( mods.Count > 0 ) {
                bHasModifiers = true;
            }
            if ( flayer.Type == LayerType.Raster ||
                flayer.Type == LayerType.Grid ||
                flayer.Type == LayerType.Wms ) {
                bRasterLayer = true;
            }
            XmlElement element = _doc.CreateElement("branch");
            if ( bHasModifiers ) {
                element.SetAttribute("branchtype", "", "folder");
                element.SetAttribute("expanded", null, "true");
            } else {
                element.SetAttribute("branchtype", "", "leaf");
            }
            element.SetAttribute("title", null, layer.Name);
            element.SetAttribute("alias", "", layer.Alias);
            element.SetAttribute("type", "", layer.Type.ToString());
            element.SetAttribute("uniqueid", "", uniqueID);
            if ( bRasterLayer ) {
                element.SetAttribute("code", "", "nonselectable");
            } else if ( bHasModifiers ) {
                element.SetAttribute("code", "", "4");
            } else {
                element.SetAttribute("code", "", "featurelayer");
            }

            if (layer.IsVisible) {
                element.SetAttribute("visible", "true");
            } else {
                element.SetAttribute("visible", "false");
                if (flayer.VisibleRangeEnabled && !flayer.VisibleRange.Within(map.Zoom)) {
                    element.SetAttribute("rangevisible", "true");
                } else {
                    element.SetAttribute("rangevisible", "false");
                }
            }

            // If layer is remote, image can be set from database style
            // null value returned if layer is not remote
            string image = DetermineRemoteGeomType(flayer);
            if ( image == null ) {
                image = "lclayerpoint.bmp";
                if ( bRasterLayer ) {
                    image = "lclayerraster.bmp";
                } else {
                    TableInfo tableInfo = flayer.Table.TableInfo;
                    GeometryColumn geoCol = null;
                    Columns columns = tableInfo.Columns;
                    foreach (Column col in columns) {
                        geoCol = col as GeometryColumn;
                        if (geoCol != null) {
                            break;
                            // TODO: Check for the case where there are MULTIPLE columns.
                        }
                    }
                    if (geoCol != null) {
                        if (geoCol.PredominantGeometryType == GeometryType.MultiCurve) {
                            image = "lclayerline.bmp";
                        }
                        else if ((geoCol.PredominantGeometryType == GeometryType.MultiPolygon)
                            || (geoCol.PredominantGeometryType == GeometryType.Rectangle)) {
                            image = "lclayerregion.bmp";
                        }
                        else if (geoCol.PredominantGeometryType == GeometryType.Point) {
                            image = "lclayerpoint.bmp";
                        }
                    }
                }
            }
            element.SetAttribute("img", null, image);

            if ( bHasModifiers ) {
                CreateFeatureModifierElement(_doc, flayer, element, uniqueID);
            }
            return element;
        }
Esempio n. 10
0
        /// <summary>
        /// Compares two feature layers for equality.
        /// </summary>
        /// <param name="FeatureLayer">A feature layer to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(IMapLayer FeatureLayer)
        {
            if ((Object) FeatureLayer == null)
                return false;

            return this.Id.Equals(FeatureLayer.Id);
        }
Esempio n. 11
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="Identifier">An object to compare with.</param>
        public Int32 CompareTo(IMapLayer FeatureLayer)
        {
            if ((Object) FeatureLayer == null)
                throw new ArgumentNullException("The given feature layer must not be null!");

            return this.Id.CompareTo(FeatureLayer.Id);
        }
Esempio n. 12
0
        /// <inheritdoc />
        public override bool Remove(ILayer layer)
        {
            IMapLayer ml = layer as IMapLayer;

            return(ml != null && _layers.Remove(ml));
        }
Esempio n. 13
0
        /// <inheritdoc />
        public override bool Contains(ILayer item)
        {
            IMapLayer ml = item as IMapLayer;

            return(ml != null && _layers.Contains(ml));
        }
Esempio n. 14
0
        private string Redraw(ref GDIMap m)
        {
            //MessageBox.Show(this.ID + " " + Name);

            //Rectangle Rect = m.ProjToPixel(m.ViewExtents);

            //Rectangle Rect = new Rectangle(0, 0, (int)this.Width.Value, (int)this.Height.Value);

            bool nullMap = (this.DesignMode | m == null);

            NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

            string ms = Milliseconds();

            if (!nullMap)
            {
                MapOnCache(ref m);
            }

            string htm = "";

            htm += "<div id=\"Container_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; width:100%; height:100%;  overflow:hidden \">";

            WebMapClient mapClient = (WebMapClient)HttpContext.Current.Session["bck_" + SessionName];

            if (mapClient != null)
            {
                string x = mapClient.GetHTML(ref m, ControlSize, ClientID);

                htm += x;
            }

            htm += "<div id=\"DivCanvas_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:2; overflow:hidden \">";

            if (!nullMap)
            {
                htm += "<img id=\"Buffer_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; z-index:1; \" src=\"" + "ImageHandler.ashx?ID=" + (string)ViewState[ClientID] + "?" + ms + "\" />";
                htm += "<img id=\"Canvas_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; z-index:2; \" src=\"" + "ImageHandler.ashx?ID=" + (string)ViewState[ClientID] + "?" + ms + "\" />";
            }

            htm += "</div>";

            htm += "<div id=\"EditCanvas_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:1000; overflow:hidden \">";
            htm += "</div>";


            htm += "<div id=\"Wait_" + ClientID + "\" style=\"position:absolute; visibility:visible; left:0px; top:0px; width:100%; height:100%;background-color:white;filter:alpha(opacity=50);z-index:2000\">";

            htm += "<table style=\"width:100%; height:100%\"><tr><td style=\"vertical-align:middle; text-align:center\">";
            htm += "<img id=\"ImgWait_" + ClientID + "\" alt=\"\" src=\"" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "DotSpatial.WebControls.Images.Wait.gif") + "\" style=\"z-index:2001\" />";
            htm += "</td></tr></table>";

            htm += "</div>";

            int activeLayerType = -1;

            if (m.Layers.SelectedLayer != null)
            {
                //                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;
                // exception if cast MapRasterLayer in previous line, so use IMapLayer:
                IMapLayer mfl = m.Layers.SelectedLayer;

                activeLayerType = 0;
                if (mfl.GetType() == typeof(MapPointLayer))
                {
                    activeLayerType = 1;
                }
                if (mfl.GetType() == typeof(MapLineLayer))
                {
                    activeLayerType = 2;
                }
                if (mfl.GetType() == typeof(MapPolygonLayer))
                {
                    activeLayerType = 3;
                }
            }

            htm += "<div id=\"LayerType_" + ClientID + "\" style=\"visibility:hidden;\">" + activeLayerType.ToString() + "</div>";



            // QQQ
            //if (theTiler != null)
            //{
            //    htm += "<div id=\"Copyright_" + ClientID + "\" style=\"position:absolute; top:auto; left:3px; bottom:3px; right:auto; width:auto; z-index:200000; font-family: Arial, Helvetica, sans-serif; font-size: x-small; font-weight: normal; color: #000000;  border: 1px solid #C0C0C0; background-color: #FFFFFF \">&nbsp;" + theTiler.Copyright + "&nbsp;</div>";
            //}

            //htm += "<div id=\"StatusBar_" + ClientID + "\" style=\"position:absolute; top:auto; left:auto; bottom:3px; right:3px; width:auto; height:24px; border: 1px solid #000000; background-color: #FFFFFF; z-index:1000\"></div>";

            htm += "<div id=\"MinX_" + ClientID + "\" style=\"visibility:hidden;\">" + m.ViewExtents.MinX.ToString(nfi) + "</div>";
            htm += "<div id=\"MinY_" + ClientID + "\" style=\"visibility:hidden;\">" + m.ViewExtents.MinY.ToString(nfi) + "</div>";
            htm += "<div id=\"MaxX_" + ClientID + "\" style=\"visibility:hidden;\">" + m.ViewExtents.MaxX.ToString(nfi) + "</div>";
            htm += "<div id=\"MaxY_" + ClientID + "\" style=\"visibility:hidden;\">" + m.ViewExtents.MaxY.ToString(nfi) + "</div>";


            string islatlon = "0";

            //if (m.Extent.MaxX <= 180 && m.Extent.MinX >= -180.0 & m.Extent.MinY >= -90 & m.Extent.MaxY <= 90.0)
            if (m.Projection.IsLatLon == true)
            {
                islatlon = "1";
            }

            htm += "<div id=\"IsLatLon_" + ClientID + "\" style=\"visibility:hidden;\" >" + islatlon + "</div>";

            htm += "<div id =\"Floater_" + ClientID + "\" style=\"border: 1px solid #000000; background: #FFFF00; position:absolute; width: 0px; height:0px; top:0px; left:0px; visibility:hidden; z-index:11\" onmousedown=\"\" onmousemove=\"\" onmouseup=\"\" ondrag(event)=\"return false\" onSelectStart=\"return false\"></div>";

            WebMarkers markers = (WebMarkers)HttpContext.Current.Session["mrk_" + SessionName];

            if (markers != null)
            {
                htm += "<div id =\"Markers_" + ClientID + "\" style=\"position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:300\">";
                htm += markers.ToHtml(ref m);
                htm += "</div>";
            }


            htm += "</div>";


            return(htm);
        }
Esempio n. 15
0
 public MapIconOverlay AddLayer(IMapLayer layer)
 {
     _layers.Add(layer);
     return(this);
 }
Esempio n. 16
0
        private void BtnConform_Click(object sender, EventArgs e)
        {
            ///로드 시작
            IMapLayer layer = null;

            if (_allWTLayerBtns.Cast <RadioButtonAdv>().FirstOrDefault(x => x.Checked).Text != "기타")
            {
                ///매핑 완료 체크
                if (_stdColumnCnts != _mappingCnts)
                {
                    MessageBox.Show("모든 표준 속성이 매핑 완료된 후"
                                    + "\n진행할 수 있습니다."
                                    , base.MmakerShell.AppTitle);
                    return;
                }

                ///선택 레이어를 표준 WTL레이어로 변환한다.
                IFeatureSet cfs = CurrentFeatureSet();
                if (cfs == null)
                {
                    MessageBox.Show("표준 레이어에 등록되지 않은 레이어입니다."
                                    , base.MmakerShell.AppTitle);
                    return;
                }

                ///[20200323] fdragons - 표준 레이어가 이미 로드되어 있으면 합칠 것인지 확인한다.
                var v = MmakerShell.AppManager.Map.Layers.FirstOrDefault(x => x.DataSet?.Name == cfs.Name);
                if (v != null)
                {
                    layer = v;

                    if (DialogResult.Yes != MessageBox.Show($"[{cfs.Name}]"
                                                            + "\n표준 레이어는 이미 로드되어 있습니다."
                                                            + "\n기존 레이어에 추가 하시겠습니까?"
                                                            , base.MmakerShell.AppTitle
                                                            , MessageBoxButtons.YesNo))
                    {
                        MessageBox.Show($"[{cfs.Name}]"
                                        + "\n선택한 레이어는 중복하여 등록할 수 없습니다."
                                        , base.MmakerShell.AppTitle, MessageBoxButtons.YesNo);
                        return;
                    }
                }

                ///1. 컬럼 매핑정보 읽기
                DataTable dataTable = ((IFeatureSet)_orgData).DataTable;

                try
                {
                    for (int i = 0; i < lstMappedCols.Items.Count; i++)
                    {
                        ///2. 매핑정보를 이용하여 _orgData의 컬럼명을 표준 컬럼명으로 이름변경
                        bool a = GetFieldNameInlstMappedColsUsingIndex(i, out string szOrg, out string szStd);
                        if (szOrg.Equals("*None*"))
                        {
                            continue;
                        }

                        /// 표준 명칭이 기 존재하면 스킵
                        if (IsFieldUsedInlstMappedCols(2, szStd))
                        {
                            continue;
                        }

                        dataTable.Columns[szOrg].ColumnName = szStd;
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    throw;
                }

                ///3. 선택된 레이어 데이터를 표준레이어로 복제한다.
                try
                {
                    foreach (IFeature f in ((IFeatureSet)_orgData).Features)
                    {
                        IFeature nf = cfs.AddFeature(f.Geometry);
                        nf.CopyAttributes(f);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    throw;
                }

                ///4. 복제된 레이어를 등록한다.
                if (layer == null)
                {
                    layer = MmakerShell.AppManager.Map.Layers.Add(cfs);
                }
            }
            else
            {
                ///[20200323] fdragons - 동일 이름의 레이어가 이미 로드되어 있으면 합칠 것인지 확인한다.
                var v = MmakerShell.AppManager.Map.Layers.FirstOrDefault(x => x.DataSet?.Name == _orgData.Name);
                if (v != null)
                {
                    layer = v;

                    if (DialogResult.Yes != MessageBox.Show($"[{_orgData.Name}]"
                                                            + "\n동일 레이어가 존재합니다."
                                                            + "\n기존 레이어에 추가 하시겠습니까?"
                                                            , base.MmakerShell.AppTitle
                                                            , MessageBoxButtons.YesNo))
                    {
                        MessageBox.Show($"[{_orgData.Name}]"
                                        + "\n선택한 레이어는 등록할 수 없습니다."
                                        , base.MmakerShell.AppTitle, MessageBoxButtons.YesNo);
                        return;
                    }

                    ///[20200323] fdragons 선택된 레이어 데이터를 표준레이어로 복제한다.
                    try
                    {
                        var fcs = (IFeatureSet)layer.DataSet;
                        foreach (IFeature f in ((IFeatureSet)_orgData).Features)
                        {
                            IFeature nf = fcs.AddFeature(f.Geometry);
                            nf.CopyAttributes(f);
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.ToString());
                        throw;
                    }
                }
                else
                {
                    ///참조용 레이어로 추가한다.
                    layer = MmakerShell.AppManager.Map.Layers.Add((IFeatureSet)_orgData);
                }
            }

            ///[20200320] fdragons - 레이어 영역 업데이트
            if (layer != null)
            {
                layer.Extent.ExpandToInclude(((IFeatureSet)_orgData).Extent);
                ZoomToLayer(layer);
            }

            MmakerShell.AppManager.Map.Refresh();

            DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 17
0
 /// <summary>
 /// Insert a IMaplayer object into the map collection at index.
 /// </summary>
 /// @param index the index to insert the layer at
 /// @param ml the layer to insert
 public void Insert( int index, IMapLayer ml )
 {
     List.Insert( index, ml );
     CalculateExtents();
 }
        private XmlElement CreateGroupLayerElement(XmlDocument _doc, IMapLayer layer, string uniqueID)
        {
            Map map = GetMapObj(_mapAlias);

            XmlElement element = _doc.CreateElement("branch");
            element.SetAttribute("branchtype", "", "folder");
            element.SetAttribute("title", "", ((GroupLayer)layer).Name);
            element.SetAttribute("code", "", "3");
            element.SetAttribute("uniqueid", "", uniqueID);
            element.SetAttribute("alias", "", layer.Alias);
            element.SetAttribute("expanded", null, "true");
            element.SetAttribute("img", null,  "lcgroup.bmp");
            element.SetAttribute("type", "", layer.Type.ToString());
            if (layer.Enabled) {
                element.SetAttribute("visible", "true");
            } else {
                element.SetAttribute("visible", "false");
                if (layer.VisibleRangeEnabled && !layer.VisibleRange.Within(map.Zoom)) {
                    element.SetAttribute("rangevisible", "true");
                } else {
                    element.SetAttribute("rangevisible", "false");
                }
            }

            foreach (IMapLayer inlayer in (GroupLayer)layer) {
                if ( inlayer is LabelLayer ) {
                    element.AppendChild(CreateLabelLayerElement(_doc, inlayer, uniqueID));
                }
                else if ( inlayer is FeatureLayer ) {
                    element.AppendChild(CreateFeatureLayerElement(_doc, inlayer, uniqueID));
                }
                else if ( inlayer is GroupLayer ) {
                    element.AppendChild(CreateGroupLayerElement(_doc, inlayer, uniqueID));
                }
                else if (inlayer is ObjectThemeLayer) {
                    element.AppendChild(CreateObjectThemeElement(_doc, inlayer, uniqueID));
                }
            }
            return element;
        }
Esempio n. 19
0
 /// <summary>
 /// This overload automatically constructs a new MapLayer from the specified
 /// feature layer with the default drawing characteristics and returns a valid
 /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
 /// a PolygonLayer, depending on the data that is passed in.
 /// </summary>
 /// <param name="layer">A pre-existing FeatureLayer that has already been created from a featureSet</param>
 public void Add(IMapLayer layer)
 {
     base.Add(layer);
 }
        private XmlElement CreateLabelLayerElement(XmlDocument _doc, IMapLayer layer, string uniqueID)
        {
            Map map = GetMapObj(_mapAlias);

            XmlElement element = _doc.CreateElement("branch");
            element.SetAttribute("title", "", layer.Name);
            element.SetAttribute("uniqueid", "", uniqueID);
            element.SetAttribute("alias", "", layer.Alias);
            element.SetAttribute("type", "", layer.Type.ToString());
            element.SetAttribute("expanded", null, "true");
            element.SetAttribute("img", null,  "lclabel.bmp");
            element.SetAttribute("branchtype", "", "folder");
            if (layer.IsVisible) {
                element.SetAttribute("visible", "true");
            } else {
                element.SetAttribute("visible", "false");
                if (layer.VisibleRangeEnabled && !layer.VisibleRange.Within(map.Zoom)) {
                    element.SetAttribute("rangevisible", "true");
                } else {
                    element.SetAttribute("rangevisible", "false");
                }
            }

            foreach (LabelSource source in ((LabelLayer)layer).Sources) {
                XmlElement leafElement = _doc.CreateElement("branch");
                bool bHasModifiers = false;
                LabelModifiers mods = source.Modifiers;
                if ( mods.Count > 0 ) {
                    bHasModifiers = true;
                }
                leafElement.SetAttribute("uniqueid", "", uniqueID);
                leafElement.SetAttribute("title", null, source.Name);
                leafElement.SetAttribute("alias", "", source.Alias);
                leafElement.SetAttribute("type", "", layer.Type.ToString());
                if (source.Visible) {
                    leafElement.SetAttribute("visible", "true");
                } else {
                    leafElement.SetAttribute("visible", "false");
                    if (source.VisibleRangeEnabled && !source.VisibleRange.Within(map.Zoom)) {
                        leafElement.SetAttribute("rangevisible", "true");
                    } else {
                        leafElement.SetAttribute("rangevisible", "false");
                    }
                }
                if ( bHasModifiers ) {
                    leafElement.SetAttribute("branchtype", "", "folder");
                    leafElement.SetAttribute("expanded", null, "true");
                    leafElement.SetAttribute("code", "", "2");
                } else {
                    leafElement.SetAttribute("branchtype", "", "leaf");
                    leafElement.SetAttribute("code", "", "nonselectable");
                }
                leafElement.SetAttribute("img", null,  "lclabelsource.bmp");
                if ( bHasModifiers ) {
                    CreateLabelModifierElement(_doc, source, leafElement, uniqueID);
                }
                element.AppendChild(leafElement);
            }
            return element;
        }
Esempio n. 21
0
 /// <summary>
 /// Tests to see if the specified IGeoLayer exists in the current collection
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(IMapLayer item)
 {
     return Contains(item as ILayer);
 }
 private XmlElement CreateObjectThemeElement(XmlDocument _doc, IMapLayer layer, string uniqueID)
 {
     Map map = GetMapObj(_mapAlias);
     XmlElement element = _doc.CreateElement("branch");
     element.SetAttribute("branchtype", "", "leaf");
     element.SetAttribute("alias", "", layer.Alias);
     if (layer.Enabled) {
         element.SetAttribute("visible", "true");
     } else {
         element.SetAttribute("visible", "false");
         if (layer.VisibleRangeEnabled && !layer.VisibleRange.Within(map.Zoom)) {
             element.SetAttribute("rangevisible", "true");
         } else {
             element.SetAttribute("rangevisible", "false");
         }
     }
     element.SetAttribute("type", "", layer.Type.ToString());
     element.SetAttribute("uniqueid", "", uniqueID);
     element.SetAttribute("title", null, layer.Name);
     element.SetAttribute("code", "", "nonselectable");
     element.SetAttribute("img", null,   "lcmodifier.bmp");
     return element;
 }
Esempio n. 23
0
 /// <summary>
 /// Inserts an element into the System.Collections.Generic.List&lt;T&gt; at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which item should be inserted.</param>
 /// <param name="item">The object to insert. The value can be null for reference types.</param>
 /// <exception cref="System.ArgumentOutOfRangeException">index is less than 0.-or-index is greater than System.Collections.Generic.List&lt;T&gt;.Count.</exception>
 /// <exception cref="System.ApplicationException">Unable to insert while the ReadOnly property is set to true.</exception>
 public void Insert(int index, IMapLayer item)
 {
     base.Insert(index, item);
 }
Esempio n. 24
0
        private void ReprojectOnTheFly(IMapLayer layer)
        {
            if (layer.DataSet == null) return;
            if (!Data.DataSet.ProjectionSupported()) return;

            bool preventReproject = DefineProjection(layer);
            if ((Projection == null || Layers.Count == 1))
            {
                Projection = layer.DataSet.Projection;
                return;
            }

            if (preventReproject) return;

            if (Data.DataSet.ProjectionSupported())
            {
                if (!Projection.Equals(layer.DataSet.Projection))
                {
                    Boolean bReproject = false;
                    if (ProjectionModeReproject == ActionMode.Prompt || ProjectionModeReproject == ActionMode.PromptOnce)
                    {
                        string message = MessageStrings.MapFrame_GlcLayerAdded_ProjectionMismatch;
                        if (ProjectionModeReproject == ActionMode.PromptOnce)
                        {
                            message =
                                "The newly added layer has a coordinate system, but that coordinate system does not match the other layers in the map.  Do you want to reproject new layers on the fly so that they are drawn in the same coordinate system as the other layers?";
                        }
                        DialogResult result = MessageBox.Show(
                            message,
                            MessageStrings.MapFrame_GlcLayerAdded_Projection_Mismatch,
                            MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            bReproject = true;
                        }
                        if (ProjectionModeReproject == ActionMode.PromptOnce)
                        {
                            ProjectionModeReproject = result == DialogResult.Yes ?
                                                                                     ActionMode.Always : ActionMode.Never;
                        }
                    }
                    if (bReproject || ProjectionModeReproject == ActionMode.Always)
                    {
                        layer.Reproject(Projection);
                    }
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Finds and removes the online basemap layer.
        /// </summary>
        private void RemoveBasemapLayer(IMapLayer Layer)
        {
            //attempt to remove from the top-level
            if (App.Map.Layers.Remove(Layer)) return;

            //Remove from other groups if the user has moved it
            foreach (var group in App.Map.Layers.OfType<IMapGroup>())
            {
                group.Remove(Layer);
            }
        }
Esempio n. 26
0
        private bool DefineProjection(IMapLayer layer)
        {
            if (layer.DataSet.Projection == null || layer.DataSet.Projection.Transform == null)
            {
                if (ProjectionModeDefine == ActionMode.Always && _chosenProjection == null)
                {
                    _chosenProjection = Projection;
                }
                ProjectionInfo result = _chosenProjection;
                if (ProjectionModeDefine == ActionMode.Prompt || ProjectionModeDefine == ActionMode.PromptOnce)
                {
                    UndefinedProjectionDialog dlg = new UndefinedProjectionDialog();
                    dlg.OriginalString = layer.DataSet.ProjectionString;

                    dlg.MapProjection = Projection;

                    if (_chosenProjection != null) dlg.SelectedCoordinateSystem = _chosenProjection;
                    dlg.AlwaysUse = (ProjectionModeDefine == ActionMode.PromptOnce);
                    dlg.ShowDialog(Parent);

                    if (dlg.AlwaysUse)
                    {
                        _chosenProjection = dlg.Result;
                        ProjectionModeDefine = ActionMode.Always;
                    }
                    result = dlg.Result;
                }
                if (result != null)
                {
                    layer.DataSet.Projection = result;
                }
            }
            return layer.DataSet.Projection == null;
        }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="source"></param>
        /// <param name="ldf"></param>
        /// <param name="suppressErrors"></param>
        protected internal RuntimeMapLayer(RuntimeMap parent, IMapLayer source, ILayerDefinition ldf, bool suppressErrors)
            : this(parent, (IBaseMapLayer)source, ldf, suppressErrors)
        {
            _disableChangeTracking = true;

            this.Group = source.Group;
            _visible = source.Visible;

            _disableChangeTracking = false;
        }
Esempio n. 28
0
 /// <summary>
 /// Moves the given layer to the given position.
 /// </summary>
 /// <param name="layer">Layer that gets moved.</param>
 /// <param name="newPosition">Position, the layer is moved to.</param>
 public void Move(IMapLayer layer, int newPosition)
 {
     base.Move(layer, newPosition);
 }
Esempio n. 29
0
        /// <summary>
        /// Finds and removes the online basemap layer
        /// </summary>
        /// <param name="Layer"></param>
        private void RemoveBasemapLayer(IMapLayer Layer)
        {
            //attempt to remove from the top-level
            if (App.Map.Layers.Remove(Layer)) return;

            //Remove from other groups if the user has moved it
            App.Map.Layers.OfType<IMapGroup>().Any(grp => grp.Remove(Layer));
        }
Esempio n. 30
0
        /// <summary>
        /// Add the given map layer to this expandable stack panel.
        /// </summary>
        /// <param name="Layer">A map layer.</param>
        /// <param name="Visibility">The map layer is visible or not at the start of the application.</param>
        public void AddLayer(IMapLayer Layer, Visibility Visibility = Visibility.Visible)
        {
            #region Initial checks

            if (Layer == null)
                throw new ApplicationException("The parameter 'Layer' must not be null!");

            var CurrentLayerAsCanvas = Layer as Canvas;

            if (CurrentLayerAsCanvas == null)
                throw new ApplicationException("The parameter 'Layer' must inherit from Canvas!");

            if (Layer.Id == null)
                throw new ApplicationException("The identification of the 'Layer' must be set!");

            if (Layer.MapControl == null)
                throw new ApplicationException("The MapControl of the 'Layer' must be set!");

            #endregion

            var Checkbox = new CheckBox();
            Checkbox.Content   = Layer.Id;
            Checkbox.IsChecked = Visibility == Visibility.Visible;
            Layer.Visibility   = Visibility;

            #region Register Checkbox.MouseEnter event

            Checkbox.MouseEnter += (o, e) =>
                {
                    var _CheckBox = o as CheckBox;
                    _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200));
                    _CheckBox.Background = new SolidColorBrush(Colors.White);
                };

            #endregion

            #region Register Checkbox.MouseLeave event

            Checkbox.MouseLeave += (o, e) =>
                {
                    var _CheckBox = o as CheckBox;
                    _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                    _CheckBox.Background = new SolidColorBrush(Colors.Gray);
                };

            #endregion

            #region Register Checkbox.Click event

            Checkbox.Click += (o, e) =>
                {

                    var _CheckBox = o as CheckBox;

                    if (_CheckBox.IsChecked.Value)
                        CurrentLayerAsCanvas.Animate(Property:     "Opacity",
                                                     From:         0.0,
                                                     To:           1.0,
                                                     Milliseconds: AnimationSpeed,
                                                     StartAction:  (UIElement) => {
                                                         Layer.Redraw();
                                                         UIElement.Visibility = Visibility.Visible;
                                                     });

                    else
                        CurrentLayerAsCanvas.Animate(Property:     "Opacity",
                                                     From:         1.0,
                                                     To:           0.0,
                                                     Milliseconds: AnimationSpeed,
                                                     FinalAction:  (UIElement) => UIElement.Visibility = Visibility.Hidden);

                };

            #endregion

            base.AddUIElement(Checkbox);
        }
Esempio n. 31
0
        internal void InitializePlugins(Screen screen)
        {
            AvailablePlugin plugin = Plugin.Plugins.AvailablePlugins.Find("HelpPlugin");
            if ((plugin != null) && (plugin.Instance is IHelp))
            {
                this.HelpPlugin = plugin.Instance as IHelp;
                this.HelpPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.HelpPlugin.SetScreen(screen);
                screen.PluginList.Add(this.HelpPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("PersonDetailPlugin");
            if ((plugin != null) && (plugin.Instance is IPersonDetail))
            {
                this.PersonDetailPlugin = plugin.Instance as IPersonDetail;
                this.PersonDetailPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.PersonDetailPlugin.SetScreen(screen);
                screen.PluginList.Add(this.PersonDetailPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TroopDetailPlugin");
            if ((plugin != null) && (plugin.Instance is ITroopDetail))
            {
                this.TroopDetailPlugin = plugin.Instance as ITroopDetail;
                this.TroopDetailPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.TroopDetailPlugin.SetScreen(screen);
                screen.PluginList.Add(this.TroopDetailPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ArchitectureDetailPlugin");
            if ((plugin != null) && (plugin.Instance is IArchitectureDetail))
            {
                this.ArchitectureDetailPlugin = plugin.Instance as IArchitectureDetail;
                this.ArchitectureDetailPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.ArchitectureDetailPlugin.SetScreen(screen);
                screen.PluginList.Add(this.ArchitectureDetailPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("FactionTechniquesPlugin");
            if ((plugin != null) && (plugin.Instance is IFactionTechniques))
            {
                this.FactionTechniquesPlugin = plugin.Instance as IFactionTechniques;
                this.FactionTechniquesPlugin.SetScreen(screen);
                this.FactionTechniquesPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.FactionTechniquesPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TreasureDetailPlugin");
            if ((plugin != null) && (plugin.Instance is ITreasureDetail))
            {
                this.TreasureDetailPlugin = plugin.Instance as ITreasureDetail;
                this.TreasureDetailPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.TreasureDetailPlugin.SetScreen(screen);
                screen.PluginList.Add(this.TreasureDetailPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ConmentTextPlugin");
            if ((plugin != null) && (plugin.Instance is IConmentText))
            {
                this.ConmentTextPlugin = plugin.Instance as IConmentText;
                this.ConmentTextPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.ConmentTextPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ArchitectureSurveyPlugin");
            if ((plugin != null) && (plugin.Instance is IArchitectureSurvey))
            {
                this.ArchitectureSurveyPlugin = plugin.Instance as IArchitectureSurvey;
                this.ArchitectureSurveyPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.ArchitectureSurveyPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TroopSurveyPlugin");
            if ((plugin != null) && (plugin.Instance is ITroopSurvey))
            {
                this.TroopSurveyPlugin = plugin.Instance as ITroopSurvey;
                this.TroopSurveyPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.TroopSurveyPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ContextMenuPlugin");
            if ((plugin != null) && (plugin.Instance is IGameContextMenu))
            {
                this.ContextMenuPlugin = plugin.Instance as IGameContextMenu;
                this.ContextMenuPlugin.SetScreen(screen);
                this.ContextMenuPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.ContextMenuPlugin.SetIHelp(this.HelpPlugin);
                screen.PluginList.Add(this.ContextMenuPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("GameFramePlugin");
            if ((plugin != null) && (plugin.Instance is IGameFrame))
            {
                this.GameFramePlugin = plugin.Instance as IGameFrame;
                this.GameFramePlugin.SetScreen(screen);
                this.GameFramePlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.GameFramePlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ScreenBlindPlugin");
            if ((plugin != null) && (plugin.Instance is IScreenBlind))
            {
                this.ScreenBlindPlugin = plugin.Instance as IScreenBlind;
                this.ScreenBlindPlugin.SetScreen(screen);
                this.ScreenBlindPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.ScreenBlindPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("MapViewSelectorPlugin");
            if ((plugin != null) && (plugin.Instance is IMapViewSelector))
            {
                this.MapViewSelectorPlugin = plugin.Instance as IMapViewSelector;
                this.MapViewSelectorPlugin.SetScreen(screen);
                this.MapViewSelectorPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.MapViewSelectorPlugin.SetGameFrame(this.GameFramePlugin);
                screen.PluginList.Add(this.MapViewSelectorPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TabListPlugin");
            if ((plugin != null) && (plugin.Instance is ITabList))
            {
                this.TabListPlugin = plugin.Instance as ITabList;
                this.TabListPlugin.SetScreen(screen);
                this.TabListPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.TabListPlugin.SetPersonDetailDialog(this.PersonDetailPlugin);
                this.TabListPlugin.SetTroopDetailDialog(this.TroopDetailPlugin);
                this.TabListPlugin.SetArchitectureDetailDialog(this.ArchitectureDetailPlugin);
                this.TabListPlugin.SetFactionTechniquesDialog(this.FactionTechniquesPlugin);
                this.TabListPlugin.SetTreasureDetailDialog(this.TreasureDetailPlugin);
                this.TabListPlugin.SetGameFrame(this.GameFramePlugin);
                this.TabListPlugin.SetMapViewSelector(this.MapViewSelectorPlugin);
                screen.PluginList.Add(this.TabListPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("OptionDialogPlugin");
            if ((plugin != null) && (plugin.Instance is IOptionDialog))
            {
                this.OptionDialogPlugin = plugin.Instance as IOptionDialog;
                this.OptionDialogPlugin.SetScreen(screen);
                this.OptionDialogPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.OptionDialogPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("SimpleTextDialogPlugin");
            if ((plugin != null) && (plugin.Instance is ISimpleTextDialog))
            {
                this.SimpleTextDialogPlugin = plugin.Instance as ISimpleTextDialog;
                this.SimpleTextDialogPlugin.SetScreen(screen);
                this.SimpleTextDialogPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.SimpleTextDialogPlugin.Instance as GameObject);
            }

            plugin = Plugin.Plugins.AvailablePlugins.Find("tupianwenziPlugin");
            if ((plugin != null) && (plugin.Instance is Itupianwenzi))
            {
                this.tupianwenziPlugin = plugin.Instance as Itupianwenzi;
                this.tupianwenziPlugin.SetScreen(screen);
                this.tupianwenziPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.tupianwenziPlugin.SetContextMenu(this.ContextMenuPlugin);
                screen.PluginList.Add(this.tupianwenziPlugin.Instance as GameObject);
            }

            plugin = Plugin.Plugins.AvailablePlugins.Find("ConfirmationDialogPlugin");
            if ((plugin != null) && (plugin.Instance is IConfirmationDialog))
            {
                this.ConfirmationDialogPlugin = plugin.Instance as IConfirmationDialog;
                this.ConfirmationDialogPlugin.SetScreen(screen);
                this.ConfirmationDialogPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.ConfirmationDialogPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("ToolBarPlugin");
            if ((plugin != null) && (plugin.Instance is IToolBar))
            {
                this.ToolBarPlugin = plugin.Instance as IToolBar;
                this.ToolBarPlugin.SetScreen(screen);
                this.ToolBarPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.ToolBarPlugin.SetContextMenuPlugin(this.ContextMenuPlugin);
                screen.PluginList.Add(this.ToolBarPlugin.Instance as GameObject);
            }
            if (this.ToolBarPlugin != null)
            {
                plugin = Plugin.Plugins.AvailablePlugins.Find("DateRunnerPlugin");
                if ((plugin != null) && (plugin.Instance is IDateRunner))
                {
                    this.DateRunnerPlugin = plugin.Instance as IDateRunner;
                    this.DateRunnerPlugin.SetScreen(screen);
                    this.DateRunnerPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                    this.DateRunnerPlugin.SetGameDate(screen.Scenario.Date);
                    this.ToolBarPlugin.AddTool(this.DateRunnerPlugin.ToolInstance);
                    screen.PluginList.Add(this.DateRunnerPlugin.Instance as GameObject);
                }
            }
            if (this.ToolBarPlugin != null)
            {
                plugin = Plugin.Plugins.AvailablePlugins.Find("GameRecordPlugin");
                if ((plugin != null) && (plugin.Instance is IGameRecord))
                {
                    this.GameRecordPlugin = plugin.Instance as IGameRecord;
                    this.GameRecordPlugin.SetScreen(screen);
                    this.GameRecordPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                    this.ToolBarPlugin.AddTool(this.GameRecordPlugin.ToolInstance);
                    screen.PluginList.Add(this.GameRecordPlugin.Instance as GameObject);
                }
            }
            if (this.ToolBarPlugin != null)
            {
                plugin = Plugin.Plugins.AvailablePlugins.Find("MapLayerPlugin");
                if ((plugin != null) && (plugin.Instance is IMapLayer))
                {
                    this.MapLayerPlugin = plugin.Instance as IMapLayer;
                    this.MapLayerPlugin.SetScreen(screen);
                    this.MapLayerPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                    this.ToolBarPlugin.AddTool(this.MapLayerPlugin.ToolInstance);
                    screen.PluginList.Add(this.MapLayerPlugin.Instance as GameObject);
                }
            }
            if (this.ToolBarPlugin != null)
            {
                plugin = Plugin.Plugins.AvailablePlugins.Find("GameSystemPlugin");
                if ((plugin != null) && (plugin.Instance is IGameSystem))
                {
                    this.GameSystemPlugin = plugin.Instance as IGameSystem;
                    this.GameSystemPlugin.SetScreen(screen);
                    this.GameSystemPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                    this.GameSystemPlugin.SetOptionDialog(this.OptionDialogPlugin);
                    this.ToolBarPlugin.AddTool(this.GameSystemPlugin.ToolInstance);
                    screen.PluginList.Add(this.GameSystemPlugin.Instance as GameObject);
                }
            }
            if (this.ToolBarPlugin != null)
            {
                plugin = Plugin.Plugins.AvailablePlugins.Find("AirViewPlugin");
                if ((plugin != null) && (plugin.Instance is IAirView))
                {
                    this.AirViewPlugin = plugin.Instance as IAirView;
                    this.AirViewPlugin.SetScreen(screen);
                    this.AirViewPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                    this.ToolBarPlugin.AddTool(this.AirViewPlugin.ToolInstance);
                    screen.PluginList.Add(this.AirViewPlugin.Instance as GameObject);
                }
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("PersonPortraitPlugin");
            if ((plugin != null) && (plugin.Instance is IPersonPortrait))
            {
                this.PersonPortraitPlugin = plugin.Instance as IPersonPortrait;
                this.PersonPortraitPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.PersonPortraitPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("PersonBubblePlugin");
            if ((plugin != null) && (plugin.Instance is IPersonBubble))
            {
                this.PersonBubblePlugin = plugin.Instance as IPersonBubble;
                this.PersonBubblePlugin.SetScreen(screen);
                this.PersonBubblePlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.PersonBubblePlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TroopTitlePlugin");
            if ((plugin != null) && (plugin.Instance is ITroopTitle))
            {
                this.TroopTitlePlugin = plugin.Instance as ITroopTitle;
                this.TroopTitlePlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.TroopTitlePlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("RoutewayEditorPlugin");
            if ((plugin != null) && (plugin.Instance is IRoutewayEditor))
            {
                this.RoutewayEditorPlugin = plugin.Instance as IRoutewayEditor;
                this.RoutewayEditorPlugin.SetScreen(screen);
                this.RoutewayEditorPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.RoutewayEditorPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("NumberInputerPlugin");
            if ((plugin != null) && (plugin.Instance is INumberInputer))
            {
                this.NumberInputerPlugin = plugin.Instance as INumberInputer;
                this.NumberInputerPlugin.SetScreen(screen);
                this.NumberInputerPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                screen.PluginList.Add(this.NumberInputerPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("TransportDialogPlugin");
            if ((plugin != null) && (plugin.Instance is ITransportDialog))
            {
                this.TransportDialogPlugin = plugin.Instance as ITransportDialog;
                this.TransportDialogPlugin.SetScreen(screen);
                this.TransportDialogPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.TransportDialogPlugin.SetGameFrame(this.GameFramePlugin);
                this.TransportDialogPlugin.SetTabList(this.TabListPlugin);
                this.TransportDialogPlugin.SetNumberInputer(this.NumberInputerPlugin);
                screen.PluginList.Add(this.TransportDialogPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("CreateTroopPlugin");
            if ((plugin != null) && (plugin.Instance is ICreateTroop))
            {
                this.CreateTroopPlugin = plugin.Instance as ICreateTroop;
                this.CreateTroopPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.CreateTroopPlugin.SetScreen(screen);
                this.CreateTroopPlugin.SetGameFrame(this.GameFramePlugin);
                this.CreateTroopPlugin.SetTabList(this.TabListPlugin);
                this.CreateTroopPlugin.SetNumberInputer(this.NumberInputerPlugin);
                screen.PluginList.Add(this.CreateTroopPlugin.Instance as GameObject);
            }
            plugin = Plugin.Plugins.AvailablePlugins.Find("MarshalSectionDialogPlugin");
            if ((plugin != null) && (plugin.Instance is IMarshalSectionDialog))
            {
                this.MarshalSectionDialogPlugin = plugin.Instance as IMarshalSectionDialog;
                this.MarshalSectionDialogPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.MarshalSectionDialogPlugin.SetScreen(screen);
                this.MarshalSectionDialogPlugin.SetGameFrame(this.GameFramePlugin);
                this.MarshalSectionDialogPlugin.SetTabList(this.TabListPlugin);
                screen.PluginList.Add(this.MarshalSectionDialogPlugin.Instance as GameObject);
            }

            plugin = Plugin.Plugins.AvailablePlugins.Find("youcelanPlugin");
            if ((plugin != null) && (plugin.Instance is Iyoucelan))
            {
                this.youcelanPlugin = plugin.Instance as Iyoucelan;
                this.youcelanPlugin.SetScreen(screen);
                this.youcelanPlugin.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.youcelanPlugin.SetPersonDetailDialog(this.PersonDetailPlugin);
                this.youcelanPlugin.SetTroopDetailDialog(this.TroopDetailPlugin);
                this.youcelanPlugin.SetArchitectureDetailDialog(this.ArchitectureDetailPlugin);
                this.youcelanPlugin.SetFactionTechniquesDialog(this.FactionTechniquesPlugin);
                this.youcelanPlugin.SetTreasureDetailDialog(this.TreasureDetailPlugin);
                this.youcelanPlugin.SetGameFrame(this.GameFramePlugin);
                this.youcelanPlugin.SetMapViewSelector(this.MapViewSelectorPlugin);
                screen.PluginList.Add(this.youcelanPlugin.Instance as GameObject);
            }

            plugin = Plugin.Plugins.AvailablePlugins.Find("BianduiLiebiaoChajian");
            if ((plugin != null) && (plugin.Instance is IBianduiLiebiao))
            {
                this.BianduiLiebiao  = plugin.Instance as IBianduiLiebiao;
                this.BianduiLiebiao.SetScreen(screen);
                this.BianduiLiebiao.SetGraphicsDevice(screen.spriteBatch.GraphicsDevice);
                this.BianduiLiebiao.SetPersonDetailDialog(this.PersonDetailPlugin);
                this.BianduiLiebiao.SetTroopDetailDialog(this.TroopDetailPlugin);
                this.BianduiLiebiao.SetArchitectureDetailDialog(this.ArchitectureDetailPlugin);
                this.BianduiLiebiao.SetFactionTechniquesDialog(this.FactionTechniquesPlugin);
                this.BianduiLiebiao.SetTreasureDetailDialog(this.TreasureDetailPlugin);
                this.BianduiLiebiao.SetGameFrame(this.GameFramePlugin);
                this.BianduiLiebiao.SetMapViewSelector(this.MapViewSelectorPlugin);
                screen.PluginList.Add(this.BianduiLiebiao.Instance as GameObject);
            }
        }
 private void buttonOpen_Click(object sender, EventArgs e)
 {
     layer = map1.AddLayer();
 }