예제 #1
0
    private HtmlGenericControl LegendDiv(SharpMap.Layers.ILayer myLayer)
    {
        HtmlGenericControl legendDiv = new HtmlGenericControl("div");

        legendDiv.Style.Add("width", "2em");
        legendDiv.Style.Add("overflow", "hidden");
        legendDiv.Style.Add("position", "absolute");
        legendDiv.Style.Add("margin-left", "0.5em");
        legendDiv.Style.Add("margin-bottom", "0px");
        if (myLayer.GetType() == typeof(SharpMap.Layers.VectorLayer))
        {
            SharpMap.Layers.VectorLayer myVectorLayer = (myLayer as SharpMap.Layers.VectorLayer);

            SharpMap.Styles.VectorStyle myStyle = new SharpMap.Styles.VectorStyle();
            if (myVectorLayer.Theme != null)
            {
                if (myVectorLayer.Theme.GetType() == typeof(SharpMap.Rendering.Thematics.CustomTheme))
                {
                    SharpMap.Rendering.Thematics.CustomTheme myTheme = (myVectorLayer.Theme as SharpMap.Rendering.Thematics.CustomTheme);
                    myStyle = (myTheme.DefaultStyle as SharpMap.Styles.VectorStyle);
                }
                else if (myVectorLayer.Theme.GetType() == typeof(SharpMap.Rendering.Thematics.GradientTheme))
                {
                    SharpMap.Rendering.Thematics.GradientTheme myTheme = (myVectorLayer.Theme as SharpMap.Rendering.Thematics.GradientTheme);
                    myStyle = (myTheme.MinStyle as SharpMap.Styles.VectorStyle);
                }
            }
            else
            {
                myStyle = myVectorLayer.Style;
            }

            if (myStyle.Outline.Color.Name.ToString() != "Black")
            {
                string lineStyle = (myStyle.Outline.DashStyle.ToString() == "Dash") ? "dotted" : "solid";
                legendDiv.Style.Add("border", lineStyle + " " + myStyle.Outline.Width.ToString() + "px " + ColorToHex(myStyle.Outline.Color));
                legendDiv.Style.Add("height", "1em");
            }
            else
            {
                string lineStyle = (myStyle.Line.DashStyle.ToString() == "Dash") ? "dotted" : "solid";
                legendDiv.Style.Add("border-bottom", lineStyle + " " + myStyle.Line.Width.ToString() + "px " + ColorToHex(myStyle.Line.Color));
                legendDiv.Style.Add("height", "0.8em");
            }

            System.Drawing.SolidBrush fillBrush = (myVectorLayer.Style.Fill as System.Drawing.SolidBrush);
            if (fillBrush.Color.Name.ToString() != "Black")
            {
                HtmlGenericControl fillDiv = new HtmlGenericControl("div");
                fillDiv.Style.Add("border-left", "solid 2em " + ColorToHex(fillBrush.Color));
                fillDiv.Style.Add("height", "1.2em");
                fillDiv.Style.Add("overflow", "hidden");
                fillDiv.Style.Add("opacity ", ColorAlpha(fillBrush.Color) + "%");
                fillDiv.Style.Add("filter", "ALPHA(opacity=" + ColorAlpha(fillBrush.Color) + ")");
                legendDiv.Controls.Add(fillDiv);
            }
        }
        return(legendDiv);
    }
예제 #2
0
파일: MapTest.cs 프로젝트: Sony-NS/SharpMap
        public void GetLayerByName_Indexer()
        {
            Map map = new Map();

            map.Layers.Add(new VectorLayer("Layer 1"));
            map.Layers.Add(new VectorLayer("Layer 3"));
            map.Layers.Add(new VectorLayer("Layer 2"));

            SharpMap.Layers.ILayer layer = map.GetLayerByName("Layer 2");
            Assert.IsNotNull(layer);
            Assert.AreEqual("Layer 2", layer.Name);
        }
예제 #3
0
    private void recursiveCheck(Control parentControl, SharpMap.Layers.ILayer myLayer, Int32 i, string chkID)
    {
        Int32 i2 = 0;
        HtmlGenericControl myDiv = new HtmlGenericControl("div");

        myDiv.Style.Add("margin-left", "1.5em");
        myDiv.ID = "myDiv" + chkID.Substring(3);
        parentControl.Controls.Add(myDiv);
        foreach (SharpMap.Layers.ILayer subLayer in (myLayer as SharpMap.Layers.LayerGroup).Layers)
        {
            CheckBox chk = new CheckBox();
            chk.ID      = chkID + "_" + i2.ToString();
            chk.Checked = true;

            if (subLayer.GetType() == typeof(SharpMap.Layers.LabelLayer))
            {
                setLabel(chk, (subLayer as SharpMap.Layers.LabelLayer));
            }

            if (subLayer.GetType() == typeof(SharpMap.Layers.LayerGroup))
            {
                chk.Attributes.Add("OnClick", "SharpMap_HiddenLayers(ajaxMapObj);togLayerGroup(this, '" + chk.ID.Substring(3) + "');test(ajaxMapObj);");
                myDiv.Controls.Add(chk);
                HtmlImage exCol = new HtmlImage();
                exCol.ID  = "img" + i.ToString();
                exCol.Src = "images/minus.gif";
                exCol.Style.Add("cursor", "hand");
                exCol.Attributes.Add("onclick", "expandIt('" + chk.ID.Substring(3) + "');");
                myDiv.Controls.Add(exCol);
                Label myLabel = new Label();
                myLabel.Text = " " + subLayer.LayerName;
                myDiv.Controls.Add(myLabel);
                recursiveCheck((myDiv as Control), subLayer, i2, chk.ID.ToString());
            }
            else
            {
                chk.Attributes.Add("OnClick", "SharpMap_HiddenLayers(ajaxMapObj);test(ajaxMapObj);");
                chk.Text = subLayer.LayerName;
                myDiv.Controls.Add(chk);
                // if (subLayer.GetType() == typeof(SharpMap.Layers.VectorLayer))
                //     myDiv.Controls.Add(LegendDiv(subLayer));
                myDiv.Controls.Add(new LiteralControl("<br>"));
            }
            i2 += 1;
        }
    }