Exemple #1
0
        protected override void OnTreeNodeCheckChanged(TreeNodeEventArgs e)
        {
            string[] keys = e.Node.ValuePath.Split(PathSeparator);

            WebMap       wm  = (WebMap)FindControl(WebMapID);
            GDIMap       m   = wm.ControlMap;
            WebMapClient wmc = wm.Back;

            bool found = false;

            for (int i = m.Layers.Count - 1; i >= 0; i--)
            {
                LegendItem liR = (LegendItem)m.Layers[i];

                LegendItem li = GetLegendItem(keys, liR);

                if (li != null)
                {
                    li.Checked = e.Node.Checked;
                    found      = true;
                    break;
                }
            }

            if (found == false)
            {
                wmc.Check(keys, e.Node.Checked);
            }

            base.OnTreeNodeCheckChanged(e);
        }
Exemple #2
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            base.RenderContents(output);

            if (this.DesignMode)
            {
                output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td style='vertical-align:middle;text-align:center'> Map: " + ClientID + "</td></tr></table>");

                //output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td width=300px height=100px style='vertical-align:middle;text-align:center'> Map: " + ClientID + "</td></tr></table>");

                //string w = WebUtil.UnitFormat(Width);
                //string h = WebUtil.UnitFormat(Height);

                //output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td width="+w+" height="+h+" style='vertical-align:middle;text-align:center'> DSMap: " + ClientID  + "</td></tr></table>");
            }
            else
            {
                if (Page.IsPostBack)
                {
                    GDIMap m   = ControlMap;
                    string htm = redraw(ref m);
                    output.Write(htm);
                }
            }
        }
Exemple #3
0
        private void MapOnCache(ref GDIMap m)
        {
            //Bitmap b = new Bitmap();
            //Graphics g = Graphics.FromImage(b);

            //Rectangle r = new Rectangle(0, 0, m.Width, m.Height);

            //string ID = ClientID;

            //Size sz = ControlSize;

            //m.MapFrame.Print(g, r);


            Bitmap b = m.Draw();

            MemoryStream MS = new MemoryStream();

            b.Save(MS, System.Drawing.Imaging.ImageFormat.Png);
            byte[] buffer = MS.ToArray();
            HttpContext.Current.Cache.Insert((string)ViewState[ClientID], buffer, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1));


            //g.Dispose();
            b.Dispose();
        }
Exemple #4
0
 public void ZoomAll(ref GDIMap m)
 {
     if (MapViewExtents == null)
     {
         m.ZoomToMaxExtent();
     }
     else
     {
         m.ViewExtents = MapViewExtents;
     }
 }
Exemple #5
0
        protected override void OnSelectedNodeChanged(EventArgs e)
        {
            base.OnSelectedNodeChanged(e);

            string[] keys = SelectedNode.ValuePath.Split(PathSeparator);

            WebMap wm = (WebMap)FindControl(WebMapID);
            GDIMap m  = wm.ControlMap;

            m.Layers.SelectedLayer = null;
            for (int i = m.Layers.Count - 1; i >= 0; i--)
            {
                LegendItem liR = (LegendItem)m.Layers[i];

                LegendItem li = GetLegendItem(keys, liR);

                if (li != null)
                {
                    li.IsSelected          = true;
                    m.Layers.SelectedLayer = m.Layers[i];
                    break;
                }
            }

            //GDIMapXXX
            //bool found = false;
            //foreach (LegendItem liR in m.Legend.RootNodes)
            //{
            //    if (liR.LegendText == keys[0])
            //    {
            //        string[] k = keysPop(keys);

            //        LegendItem li = GetLegendItem(k, liR);

            //        if (li != null)
            //        {
            //            li.IsSelected = true;
            //            found = true;
            //            break;
            //        }

            //    }
            //}

            //if (found == false)
            //{

            //}
        }
Exemple #6
0
        private string refresh(ref GDIMap m)
        {
            Rectangle Rect = m.ProjToPixel(m.ViewExtents);

            WebMapClient MapClient = (WebMapClient)System.Web.HttpContext.Current.Session["bck_" + SessionName];

            string htm = "";
            string MS  = Milliseconds();

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

            MapOnCache(ref m);

            htm = htm + "ImageHandler.ashx?ID=" + (string)ViewState[ClientID] + "?" + MS; // + "|";


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

                htm += "|" + h + "|" + Rect.Left.ToString() + "|" + Rect.Top.ToString() + "|" + Rect.Width.ToString() + "|" + Rect.Height.ToString() + "|" + "copi";
            }
            else
            {
                htm += "|Tile|Tl|Tt|Tw|Th|(C)";
            }

            WebMarkers Markers = (WebMarkers)System.Web.HttpContext.Current.Session["mrk_" + SessionName];

            if (Markers != null)
            {
                htm += "|";
                htm += Markers.ToHtml(ref m);
            }
            else
            {
                htm += "|Markers";
            }

            htm = htm + "|" + m.ViewExtents.MinX.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MinY.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MaxX.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MaxY.ToString(nfi);

            return(htm);
        }
Exemple #7
0
        public string ToHtml(ref GDIMap m)
        {
            string htm = "";
            int    n   = GetNum();


            for (int i = 0; i < n; i++)
            {
                System.Drawing.Point pt = m.ProjToPixel(_crds[i]);

                pt.X += _dxy[i].X;
                pt.Y += _dxy[i].Y;

                if (_aRef[i] != "" & _aRef[i] != null)
                {
                    htm += "<a href=\"" + _aRef[i] + "\">";
                }

                htm += "<img alt=\"\" src=\"" + _imgs[i] + "\" style=\"border:0px; cursor:pointer; position:absolute; left:" + pt.X.ToString() + "px; top:" + pt.Y.ToString() + "px; z-index:400\"";

                if (_onClick[i] != "" & _onClick[i] != null)
                {
                    htm += " onclick=\"" + _onClick[i] + "\"";
                }
                if (_onMouseOver[i] != "" & _onMouseOver[i] != null)
                {
                    htm += " onmouseover=\"" + _onMouseOver[i] + "\"";
                }
                if (_onMouseOut[i] != "" & _onMouseOut[i] != null)
                {
                    htm += " onmouseout=\"" + _onMouseOut[i] + "\"";
                }

                htm += " />";

                if (_aRef[i] != "" & _aRef[i] != null)
                {
                    htm += "</a>";
                }
            }

            return(htm);
        }
Exemple #8
0
        public void RaisePostBackEvent(string eventArgument)
        {
            GDIMap m = ControlMap;

            string[] arg = eventArgument.Split('|');

            string cmd = arg[0].ToUpper();

            switch (cmd)
            {
            case "CLICK":
            {
                if (MapClick != null)
                {
                    Point      pt1 = new Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                    Coordinate pm1 = m.PixelToProj(pt1);

                    MapClickEventArgs mc = new MapClickEventArgs
                    {
                        Button = Convert.ToInt32(arg[1]),
                        X      = pm1.X,
                        Y      = pm1.Y
                    };

                    MapClick(this, mc);
                }
            }
            break;

            //                case "ADDFEATURE":  //moved to RaiseCallbackEvent

            //                case "DATAGRID":  //never gets here - wrong place? moved to RaiseCallbackEvent

            case "FORCEREFRESH":
            {
                //simply do nothing
            }
            break;
            }
        }
Exemple #9
0
        protected void CreateLegend()
        {
            WebMap wm = (WebMap)FindControl(WebMapID);

            if (wm == null)
            {
                return;
            }

            GDIMap m = wm.ControlMap;

            if (m == null)
            {
                return;
            }

            Nodes.Clear();

            for (int i = m.Layers.Count - 1; i >= 0; i--)
            {
                LegendItem l = (LegendItem)m.Layers[i];

                AddLegItems(null, l);
            }



            WebMapClient c = wm.Back;

            if (c != null)
            {
                c.List(this);
            }

            foreach (TreeNode tn in Nodes)
            {
                tn.ExpandAll();
            }
        }
Exemple #10
0
        public void Move(ref GDIMap m, int direction)
        {
            int w = ControlSize.Width / 2;
            int h = ControlSize.Height / 2;

            int dx = 0, dy = 0;

            switch (direction)
            {
            case 0:
            {
                dx = -w;
            }
            break;

            case 1:
            {
                dy = -h;
            }
            break;

            case 2:
            {
                dx = w;
            }
            break;

            case 3:
            {
                dy = h;
            }
            break;
            }

            m.MapFrame.Pan(new System.Drawing.Point(dx, dy));
        }
Exemple #11
0
        public void ZoomAll(ref GDIMap m)
        {

            if (MapViewExtents == null)
            {
                m.ZoomToMaxExtent();
            }
            else
            {
                m.ViewExtents = MapViewExtents;
            }
        }
Exemple #12
0
        public void RaiseCallbackEvent(String eventArgument)
//        public virtual void RaiseCallbackEvent(String eventArgument)  //to override in subclass
        {
//            returnCommand = "REFRESH";  //unsightly refresh when change legend selection
            returnCommand = "NOTHING";

//            string Nm = SessionName;  //not used

            GDIMap m = (GDIMap)System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]];

            if (m == null)
            {
                return;
            }

            string[] arg = eventArgument.Split('|');

            string cmd = arg[0].ToUpper();

            switch (cmd)
            {
            case "ZOOMALL":
            {
                ZoomAll(ref m);
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "SELECT":
            {
                if (m.Layers.SelectedLayer != null)
                {
                    System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                    System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                    Coordinate pm1 = m.PixelToProj(pt1);
                    Coordinate pm2 = m.PixelToProj(pt2);

                    Extent ex = new Extent(Math.Min(pm1.X, pm2.X), Math.Min(pm1.Y, pm2.Y),
                                           Math.Max(pm1.X, pm2.X), Math.Max(pm1.Y, pm2.Y));

                    IEnvelope MapEnv = m.Extent.ToEnvelope();

                    m.Layers.SelectedLayer.ClearSelection(out MapEnv);


                    m.Layers.SelectedLayer.ClearSelection();

                    IEnvelope affectedarea = null;

//                                m.Layers.SelectedLayer.Select(m.ViewExtents.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.IntersectsExtent, out affectedarea);
                    m.Layers.SelectedLayer.Select(ex.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.Intersects, out affectedarea);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
//                                returnValue = "Select a layer first.";
//                                returnCommand = "ALERT";
                }
            }
            break;

            case "INFO":
            {
                System.Drawing.Point pt = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Coordinate           pm = m.PixelToProj(pt);

                Extent ex = new Extent(pm.X, pm.Y, pm.X, pm.Y);

                if (m.Layers.SelectedLayer != null)
                {
                    FeatureSet fs = m.Layers.SelectedLayer.DataSet as FeatureSet;

//                                List<IFeature> flist = fs.Select(ex);  //returns empty list when IndexMode == false
                    List <int> flist = fs.SelectIndices(ex);

                    int n = flist.Count;

//                                returnValue = "<table border='1'>";  //looks goofy
                    returnValue = "<table>";

                    if (n > 0)
                    {
                        for (int i = 0; i < fs.DataTable.Columns.Count; i++)
                        {
                            returnValue += "<tr><td>" + fs.DataTable.Columns[i].ColumnName +
//                                                       "</td><td>" + flist[0].DataRow[i].ToString() + "</td></tr>";
                                           "</td><td>" + fs.GetFeature(flist[0]).DataRow[i].ToString() + "</td></tr>";
                        }

                        returnValue  += "</table>";
                        returnCommand = "POPUP";
                    }
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
//                                returnValue = "Select a layer first.";
//                                returnCommand = "ALERT";
                }
            }
            break;


            case "RESIZE":
            {
                Size NewSz    = new Size(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Size ActualSz = ControlSize;

                if (ActualSz.Width == 0 || ActualSz.Height == 0)
                {
                    ControlSize = NewSz;

                    ZoomAll(ref m);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    if (NewSz != ActualSz)
                    {
                        ControlSize = NewSz;

                        returnCommand = "STRUCTURE";
                    }
                    else
                    {
                        returnCommand = "NOTHING";
                    }
                }
            }
            break;

            case "ZOOMRECT":
            {
                System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                Coordinate pm1 = m.PixelToProj(pt1);
                Coordinate pm2 = m.PixelToProj(pt2);

                Extent x = new Extent(Math.Min(pm1.X, pm2.X),
                                      Math.Min(pm1.Y, pm2.Y),
                                      Math.Max(pm1.X, pm2.X),
                                      Math.Max(pm1.Y, pm2.Y));

                m.ViewExtents = x;
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMIN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pntZoomAndCenter = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));
                m.MapFrame.Pan(pntZoomAndCenter);
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMOUT":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(pnt);
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "PAN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

// not used:                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(new System.Drawing.Point(x, y));
                returnCommand = "REFRESH";
            }
            break;

            case "WHEELIN":
            {
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "WHEELOUT":
            {
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "DATAGRID":          //moved to here from RaisePostBackEvent
            {
                if (m.Layers.SelectedLayer != null)
                {
                    //string script=null;

                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                    int n = MFL.Selection.Count;

                    FeatureSet fs;
                    DataTable  rs;
                    if (n > 0)
                    {
                        fs = MFL.Selection.ToFeatureSet();
                        rs = fs.DataTable;
                    }
                    else
                    {
                        fs = MFL.DataSet as FeatureSet;
                        rs = fs.DataTable;
                    }

                    if (DataOnGrid != null)              //Let event handler display grid?
                    {
                        DataGridEventArgs e = new DataGridEventArgs();
                        e.Recordsource = rs;
                        DataOnGrid(this, e);
                    }
                    else              //Display default HTML grid
                    {
                        returnValue = "<table border='1'><tr>";

                        for (int h = 0; h < rs.Columns.Count; h++)
                        {
                            returnValue += "<th>" + rs.Columns[h].ColumnName + "</th>";
                        }
                        returnValue += "</tr>";

                        string rowHtml;
                        for (int r = 0; r < rs.Rows.Count; r++)
                        {              //note: _much_ faster if build each row separately
                            rowHtml = "<tr>";
                            for (int c = 0; c < rs.Columns.Count; c++)
                            {
                                rowHtml += "<td>" + fs.GetFeature(r).DataRow[c].ToString() + "</td>";
                            }
                            rowHtml     += "</tr>";
                            returnValue += rowHtml;
                        }
                        returnValue  += "</table>";
                        returnCommand = "POPUP";
                    }
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
                }
            }
            break;

            case "ADDFEATURE":          //moved to here from RaisePostBackEvent
            {
                int num = Convert.ToInt32(arg[1]);

                System.Drawing.Point pt = new System.Drawing.Point();
                Coordinate[]         pm = new Coordinate[num];

                for (int i = 0; i < num; i++)
                {
                    pt.X = Convert.ToInt32(arg[(i + 1) * 2]);
                    pt.Y = Convert.ToInt32(arg[(i + 1) * 2 + 1]);

                    pm[i] = m.PixelToProj(pt);
                }

                if (m.Layers.SelectedLayer != null)
                {
                    FeatureSet  fs = m.Layers.SelectedLayer.DataSet as FeatureSet;
                    Feature     f;
                    FeatureType ft = FeatureType.Unspecified;

                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                    if (MFL.GetType() == typeof(MapPointLayer))
                    {
                        ft = FeatureType.Point;
                    }
                    if (MFL.GetType() == typeof(MapLineLayer))
                    {
                        ft = FeatureType.Line;
                    }
                    if (MFL.GetType() == typeof(MapPolygonLayer))
                    {
                        ft = FeatureType.Polygon;
                    }

                    if (ft != FeatureType.Unspecified)
                    {
                        f = new Feature(ft, pm);

                        try
                        {
                            if (AddFeature != null)
                            {
                                AddFeature(this, fs, f);
                            }
                            else
                            {
                                try
                                {
                                    fs.AddFeature(f);
                                    fs.Save();
                                }
                                catch
                                {
                                    fs.Features.Remove(f);
                                    throw;              //re-throw exception
                                }
                                fs.InitializeVertices();
                            }
                            //Apparently have to force recreating labels when add feature.
                            if (MFL.LabelLayer != null)
                            {
                                // Recreating label layer works.
//                                            MapLabelLayer NewLabels = new MapLabelLayer();
//                                            NewLabels.Symbology = MFL.LabelLayer.Symbology;
//                                            NewLabels.Symbolizer = MFL.LabelLayer.Symbolizer;
//                                            MFL.LabelLayer = NewLabels;
                                // Recreating just labels also works.
                                MFL.LabelLayer.CreateLabels();
                            }
                            returnCommand = "FORCEREFRESH";
                        }
                        catch (Exception e)
                        {
                            returnValue   = "Unable to save feature.<p>" + e.Message;
                            returnCommand = "POPUPANDREFRESH";              //erase new shape too
                        }

//                                    fs.IndexMode = true;
                        //Adding a feature sets FeatureSet.IndexMode to false,
                        // causing fs.Select above in INFO case to return a list
                        // with Count == 0. One workaround is to set IndexMode
                        // back to true. This does cause all existing labels
                        // to disapper with refresh, but recreating label layer
                        // above fixed that. (Also tried InitializeVertices,
                        // InvalidateEnvelope, InvalidateVertices, UpdateExtents, etc.)
                        // Oops, setting IndexMode back to true corrupts shapes...
                    }
                }
            }
            break;
            }

            //ControlMap = m;
            System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]] = m;

            if (returnCommand == "STRUCTURE")
            {
                returnValue = redraw(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }

            if (returnCommand == "REFRESH" | returnCommand == "REFRESHANDHIDEBUFFER")
            {
                returnValue = refresh(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }
        }
Exemple #13
0
        public void RaisePostBackEvent(string eventArgument)
        {
            GDIMap m = ControlMap;

            string[] arg = eventArgument.Split('|');

            string cmd = arg[0].ToUpper();

            switch (cmd)
            {
            case "CLICK":
            {
                if (MapClick != null)
                {
                    System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                    Coordinate           pm1 = m.PixelToProj(pt1);

                    MapClickEventArgs mc = new MapClickEventArgs();

                    mc.button = Convert.ToInt32(arg[1]);;
                    mc.x      = pm1.X;
                    mc.y      = pm1.Y;

                    MapClick(this, mc);
                }
            }
            break;

            case "ADDFEATURE":
            {
                int num = Convert.ToInt32(arg[1]);

                System.Drawing.Point pt = new System.Drawing.Point();
                Coordinate[]         pm = new Coordinate[num];

                for (int i = 0; i < num; i++)
                {
                    pt.X = Convert.ToInt32(arg[(i + 1) * 2]);
                    pt.Y = Convert.ToInt32(arg[(i + 1) * 2 + 1]);

                    pm[i] = m.PixelToProj(pt);
                }


                FeatureSet  fs = m.Layers.SelectedLayer.DataSet as FeatureSet;
                Feature     f;
                FeatureType ft = FeatureType.Unspecified;

                if (m.Layers.SelectedLayer != null)
                {
                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                    if (MFL.GetType() == typeof(MapPointLayer))
                    {
                        ft = FeatureType.Point;
                    }
                    if (MFL.GetType() == typeof(MapLineLayer))
                    {
                        ft = FeatureType.Line;
                    }
                    if (MFL.GetType() == typeof(MapPolygonLayer))
                    {
                        ft = FeatureType.Polygon;
                    }

                    if (ft != FeatureType.Unspecified)
                    {
                        f = new Feature(ft, pm);

                        if (AddFeature != null)
                        {
                            AddFeature(this, fs, f);
                        }
                        else
                        {
                            fs.AddFeature(f);
                            fs.InitializeVertices();
                        }
                    }
                }
            }
            break;

            case "DATAGRID":
            {
                if (m.Layers.SelectedLayer != null)
                {
                    //string script=null;

                    if (DataOnGrid != null)
                    {
                        DataGridEventArgs e   = new DataGridEventArgs();
                        IMapFeatureLayer  MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                        int n = MFL.Selection.Count;

                        if (n > 0)
                        {
                            FeatureSet fs = MFL.Selection.ToFeatureSet();
                            e.Recordsource = fs.DataTable;
                        }
                        else
                        {
                            e.Recordsource = MFL.DataSet.DataTable;
                        }

                        DataOnGrid(this, e);
                    }
                }
            }
            break;

            case "FORCEREFRESH":
            {
                //simply do nothing
            }
            break;
            }
        }
Exemple #14
0
        public string ToHtml(ref GDIMap m)
        {
            string htm = "";
            int n=GetNum();


            for (int i = 0; i < n; i++)
            {
                System.Drawing.Point pt = m.ProjToPixel(_crds[i]);

                pt.X += _dxy[i].X;
                pt.Y += _dxy[i].Y;

                if (_aRef[i] != "" & _aRef[i] != null)
                {
                    htm += "<a href=\"" + _aRef[i] + "\">";
                }

                htm += "<img alt=\"\" src=\"" + _imgs[i] + "\" style=\"border:0px; cursor:pointer; position:absolute; left:" + pt.X.ToString() + "px; top:" + pt.Y.ToString() + "px; z-index:400\"";

                if (_OnClick[i] != "" & _OnClick[i] != null) htm += " onclick=\"" + _OnClick[i] + "\"";
                if (_OnMouseOver[i] != "" & _OnMouseOver[i] != null) htm += " onmouseover=\"" + _OnMouseOver[i] + "\"";
                if (_OnMouseOut[i] != "" & _OnMouseOut[i] != null) htm += " onmouseout=\"" + _OnMouseOut[i] + "\"";

                htm+=" />";
                
                if (_aRef[i] != "" & _aRef[i] != null)
                {
                    htm += "</a>";
                }


            }

            return htm;
        }
Exemple #15
0
        public string GetHTML(ref GDIMap m, Size size, string DivID)
        {
            string htm = "";

            int w = size.Width;
            int h = size.Height;

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

            Extent WmsEx = m.ViewExtents;

            if(Projection != m.Projection)
            {

                double[] xy = new double[4];

                xy[0] = m.ViewExtents.MinX;
                xy[1] = m.ViewExtents.MinY;
                xy[2] = m.ViewExtents.MaxX;
                xy[3] = m.ViewExtents.MaxY;

                double[] z = { };


                Projections.Reproject.ReprojectPoints(xy, z, m.Projection, Projection, 0, 2);

                WmsEx.MinX = Math.Min(xy[0], xy[2]);
                WmsEx.MinY = Math.Min(xy[1], xy[3]);

                WmsEx.MaxX = Math.Max(xy[0], xy[2]);
                WmsEx.MaxY = Math.Max(xy[1], xy[3]);

                if (double.IsNaN(WmsEx.MinX) | double.IsNaN(WmsEx.MinY) | double.IsNaN(WmsEx.MaxX) | double.IsNaN(WmsEx.MaxY))
                {
                    htm += "<div id=\"Back_" + DivID + "\" style=\"position:absolute; left:" + Rect.Left.ToString() + "px; top:" + Rect.Top.ToString() + "px; width:" + Rect.Width.ToString() + "px; height:" + Rect.Height.ToString() + "px; \">";
                    htm += "<p>Out of WMS zone</p>";
                    htm += "</div>";

                    return htm;
                }
            }

            htm += "<div id=\"Back_" + DivID + "\" style=\"position:absolute; left:" + Rect.Left.ToString() + "px; top:" + Rect.Top.ToString() + "px; width:" + Rect.Width.ToString() + "px; height:" + Rect.Height.ToString() + "px; \">";

            double Hint = Math.Sqrt(Math.Pow(m.ViewExtents.Width / size.Width, 2) + Math.Pow(m.ViewExtents.Height / size.Height, 2));

            List<ServerLayer> list = GetVisibleLayer();

            if (list == null)
            {
                htm += "<p>NO WMS LAYERS</p>";
            }
            else if (list != null & list.Count > 0)
            {


                int num = list.Count;

                string Lays = "";
                for (int i = 0; i < num - 1; i++)
                {
                    Lays += list[i].Name + ",";
                }
                Lays += list[num - 1].Name;


                string svr = Server;

                if (svr == null)
                {
                    throw new ApplicationException("WMS server must not be null");
                }

                if (svr.Contains('?'))
                    svr += "&";
                else
                    svr += "?";


                string f = svr;
                f += "Version=" + Version;
                f += "&REQUEST=GetMap";
                f += "&Layers=" + Lays;

                if (Version=="1.3.0")
                {
                    f += "&crs=" + CRS;
                }
                else
                {
                    f += "&srs=" + CRS;
                }
                
                f += "&format=image/png";

                f += "&styles=";

                f += "&bbox={0},{1},{2},{3}&width={4}&height={5}";

                f += "&TRANSPARENT=TRUE";

                //string t = string.Format(CultureInfo.InvariantCulture, f, m.ViewExtents.MinX, m.ViewExtents.MinY, m.ViewExtents.MaxX, m.ViewExtents.MaxY, size.Width, size.Height);
                string t = string.Format(CultureInfo.InvariantCulture, f, WmsEx.MinX, WmsEx.MinY, WmsEx.MaxX, WmsEx.MaxY, size.Width, size.Height);

                string o = "";
                if (Opacity != 100)
                {
                    //o = "filter:alpha(opacity=30);opacity: 0.3;";
                    o = "filter:alpha(opacity=" + Opacity.ToString() + "); opacity: " + (Opacity / 100).ToString(CultureInfo.InvariantCulture) + "; ";
                }

                htm += "<img alt=\"\" style=\"position:absolute; " + o + "left:0px; top:0px; width:" + size.Width.ToString() + "px; height:" + size.Height.ToString() + "px; \" src=\"" + t + "\" />";

            }
            
            htm += "</div>";

            return htm;

        }
Exemple #16
0
        //public void AddService(WebServiceType ServiceType, string WMSserver = "", string XMLCustomFile = "")
        //{
            
        //    switch (ServiceType)
        //    {
        //        case (WebServiceType.WMS):
        //            {
        //                WMSCapabilities WmsCapabilities = new WMSCapabilities();
        //                WmsCapabilities.ReadCapabilities(WMSserver, XMLCustomFile, Proxy);

        //                Servicies.Add(WmsCapabilities);
        //            }
        //            break;
                
        //        default:
        //            {
        //                WMTClient WmtClient = new WMTClient();
        //                WmtClient.Create(ServiceType, Proxy);

        //                Servicies.Add(WmtClient);
        //            }
        //            break;
        //    }

        //}

        public string GetHTML(ref GDIMap m, Size size, string ClientID)
        {
            string htm="";

            Rectangle Rect = m.ProjToPixel(m.ViewExtents);
 
            htm += "<div id=\"Back_" + ClientID + "\" style=\"position:absolute; left:" + Rect.Left.ToString() + "px; top:" + Rect.Top.ToString() + "px; width:" + Rect.Width.ToString() + "px; height:" + Rect.Height.ToString() + "px; z-index:1; \">";

            for (int i = 0; i < Servicies.Count(); i++)
            {

                if (Servicies.ElementAt(i).GetType() == typeof(WMSClient))
                {
                    WMSClient WmsClient = (WMSClient)Servicies.ElementAt(i);

                    htm += WmsClient.GetHTML(ref m, size, ClientID + "_" + i.ToString());
                }
                else
                {           
                    WMTClient WmtClient = (WMTClient)Servicies.ElementAt(i);

                    if (WmtClient.Visible)
                    {
                        htm += WmtClient.GetHTML(ref m, size, ClientID + "_" + i.ToString());
                    }
                }
            }
            htm += "</div>";


            return htm;
        }
Exemple #17
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)System.Web.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 = (IMapLayer)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)System.Web.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;
        }
Exemple #18
0
        private void MapOnCache(ref GDIMap m)
        {
            //Bitmap b = new Bitmap();
            //Graphics g = Graphics.FromImage(b);

            //Rectangle r = new Rectangle(0, 0, m.Width, m.Height);

            //string ID = ClientID;

            //Size sz = ControlSize;

            //m.MapFrame.Print(g, r);


            Bitmap b = m.Draw();

            MemoryStream MS = new MemoryStream();
            b.Save(MS, System.Drawing.Imaging.ImageFormat.Png);
            byte[] buffer = MS.ToArray();
            HttpContext.Current.Cache.Insert((string)ViewState[ClientID], buffer, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1));
           

            //g.Dispose();
            b.Dispose();

        }
Exemple #19
0
        private string refresh(ref GDIMap m)
        {
            Rectangle Rect = m.ProjToPixel(m.ViewExtents); 

            WebMapClient MapClient = (WebMapClient)System.Web.HttpContext.Current.Session["bck_" + SessionName];

            string htm = "";
            string MS = Milliseconds();

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

            htm = htm + "ImageHandler.ashx?ID=" + (string)ViewState[ClientID] + "?" + MS; // + "|";


            if (MapClient != null)
            {

                string h = MapClient.GetHTML(ref m, ControlSize, ClientID);

                htm += "|" + h + "|" + Rect.Left.ToString() + "|" + Rect.Top.ToString() + "|" + Rect.Width.ToString() + "|" + Rect.Height.ToString() + "|" + "copi";

            }
            else
            {
                htm += "|Tile|Tl|Tt|Tw|Th|(C)";
            }

            WebMarkers Markers = (WebMarkers)System.Web.HttpContext.Current.Session["mrk_" + SessionName];

            if (Markers != null)
            {
                htm += "|";
                htm += Markers.ToHtml(ref m);
            }
            else
            {
                htm += "|Markers";
            }

            htm = htm + "|" + m.ViewExtents.MinX.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MinY.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MaxX.ToString(nfi) + "|";
            htm = htm + m.ViewExtents.MaxY.ToString(nfi) ;

            return htm;
        }
Exemple #20
0
        public void Move(ref GDIMap m, int direction)
        {

            int w = ControlSize.Width/2;
            int h = ControlSize.Height/2;

            int dx = 0, dy = 0;

            switch (direction)
            {
                case 0:
                    {
                        dx = -w;
                    }
                    break;
                case 1:
                    {
                        dy = -h;
                    }
                    break;

                case 2:
                    {
                        dx = w;
                    }
                    break;
                case 3:
                    {
                        dy = h;
                    }
                    break;
            }

            m.MapFrame.Pan(new System.Drawing.Point(dx, dy));
        }
Exemple #21
0
        public string GetHTML(ref GDIMap m, Size size, string DivID)
        {

            TileInfoSet[] Ts = GetTile(m.ViewExtents, size);

            string htm = "";

            int numSet = Ts.GetLength(0);

            for (int set = 0; set < numSet; set++)
            {

                if (set == 0)
                {
                    TilesExtent = Ts[set].Extent;
                }
                else
                {
                    TilesExtent.ExpandToInclude(Ts[set].Extent);
                }
            }




            Rectangle Rect = m.ProjToPixel(TilesExtent);

            int w = (int)((double)(Rect.Width + 1) / (double)Ts[0].cols);
            int h = (int)((double)(Rect.Height + 1) / (double)Ts[0].rows);

            htm += "<div id=\"Back_" + DivID + "\" style=\"position:absolute; left:" + Rect.Left.ToString() + "px; top:" + Rect.Top.ToString() + "px; width:" + Rect.Width.ToString() + "px; height:" + Rect.Height.ToString() + "px; \">";

            for (int r = 0; r < Ts[0].rows; r++)
            {
                for (int c = 0; c < Ts[0].cols; c++)
                {
                    int l = c * w;
                    int t = r * h;

                    for (int set = 0; set < numSet; set++)
                    {
                        htm += "<img alt=\"\" style=\"position:absolute; left: " + l.ToString() + "px; top:" + t.ToString() + "px; width:" + w.ToString() + "px; height:" + h.ToString() + "px; \" src=\"" + Ts[set].Tiles[r][c].url + "\" />";
                    }
                }

            }

            htm += "</div>";

            return htm;

            //Extent WmtEx;

            //{

            //    double[] xy = new double[4];

            //    xy[0] = m.ViewExtents.MinX;
            //    xy[1] = m.ViewExtents.MinY;
            //    xy[2] = m.ViewExtents.MaxX;
            //    xy[3] = m.ViewExtents.MaxY;

            //    double[] z = { };


            //    Projections.Reproject.ReprojectPoints(xy, z, m.Projection, Projection, 0, 2);

            //    WmtEx = new Extent(xy);

            //}


            //TileInfoSet[] Ts = GetTile(WmtEx, size);

            //string htm = "";

            //int numSet = Ts.GetLength(0);

            //for (int set = 0; set < numSet; set++)
            //{

            //    if (set == 0)
            //    {
            //        TilesExtent = Ts[set].Extent;
            //    }
            //    else
            //    {
            //        TilesExtent.ExpandToInclude(Ts[set].Extent);
            //    }
            //}

            //Extent MapEx;

            //{

            //    double[] xy = new double[4];

            //    xy[0] = WmtEx.MinX;
            //    xy[1] = WmtEx.MinY;
            //    xy[2] = WmtEx.MaxX;
            //    xy[3] = WmtEx.MaxY;

            //    double[] z = { };


            //    Projections.Reproject.ReprojectPoints(xy, z, m.Projection, Projection, 0, 2);

            //    MapEx = new Extent(xy);

            //}



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

            //int w = (int)((double)(Rect.Width + 1) / (double)Ts[0].cols);
            //int h = (int)((double)(Rect.Height + 1) / (double)Ts[0].rows);

            //htm += "<div id=\"Back_" + DivID + "\" style=\"position:absolute; left:" + Rect.Left.ToString() + "px; top:" + Rect.Top.ToString() + "px; width:" + Rect.Width.ToString() + "px; height:" + Rect.Height.ToString() + "px; \">";

            //for (int r = 0; r < Ts[0].rows; r++)
            //{
            //    for (int c = 0; c < Ts[0].cols; c++)
            //    {
            //        int l = c * w;
            //        int t = r * h;

            //        for (int set = 0; set < numSet; set++)
            //        {
            //            htm += "<img alt=\"\" style=\"position:absolute; left: " + l.ToString() + "px; top:" + t.ToString() + "px; width:" + w.ToString() + "px; height:" + h.ToString() + "px; \" src=\"" + Ts[set].Tiles[r][c].url + "\" />";
            //        }
            //    }

            //}

            //htm += "</div>";

            //return htm;
        }
Exemple #22
0
        public void RaiseCallbackEvent(String eventArgument)
        {
            returnCommand = "REFRESH";

            string Nm = SessionName;

            GDIMap m = (GDIMap)System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]];

            if (m == null)
            {
                return;
            }


            string[] arg = eventArgument.Split('|');

            string cmd = arg[0].ToUpper();

            switch (cmd)
            {
            case "ZOOMALL":
            {
                ZoomAll(ref m);
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "SELECT":
            {
                if (m.Layers.SelectedLayer != null)
                {
                    System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                    System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                    Coordinate pm1 = m.PixelToProj(pt1);
                    Coordinate pm2 = m.PixelToProj(pt2);

                    Extent ex = new Extent(Math.Min(pm1.X, pm2.X), Math.Min(pm1.Y, pm2.Y),
                                           Math.Max(pm1.X, pm2.X), Math.Max(pm1.Y, pm2.Y));

                    IEnvelope MapEnv = m.Extent.ToEnvelope();

                    m.Layers.SelectedLayer.ClearSelection(out MapEnv);


                    m.Layers.SelectedLayer.ClearSelection();

                    IEnvelope affectedarea = null;

                    m.Layers.SelectedLayer.Select(m.ViewExtents.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.IntersectsExtent, out affectedarea);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    returnValue   = "<table><tr><td> Choose a layer! </td></tr><table>";
                    returnCommand = "POPUP";
                }
            }
            break;

            case "INFO":
            {
                System.Drawing.Point pt = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Coordinate           pm = m.PixelToProj(pt);

                Extent ex = new Extent(pm.X, pm.Y, pm.X, pm.Y);

                if (m.Layers.SelectedLayer != null)
                {
                    FeatureSet fs = m.Layers.SelectedLayer.DataSet as FeatureSet;

                    List <IFeature> flist = fs.Select(ex);

                    int n = flist.Count;

                    returnValue = "<table>";

                    if (n > 0)
                    {
                        for (int i = 0; i < fs.DataTable.Columns.Count; i++)
                        {
                            returnValue += "<tr><td>" + fs.DataTable.Columns[i].ColumnName + "</td><td>" + flist[0].DataRow[i].ToString() + "</td></tr>";
                        }

                        returnValue  += "</table>";
                        returnCommand = "POPUP";
                    }
                }
                else
                {
                    returnValue   = "<table><tr><td> Select a layer before info !</td></tr><table>";
                    returnCommand = "POPUP";
                }
            }
            break;


            case "RESIZE":
            {
                Size NewSz    = new Size(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Size ActualSz = ControlSize;

                if (ActualSz.Width == 0 || ActualSz.Height == 0)
                {
                    ControlSize = NewSz;

                    ZoomAll(ref m);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    if (NewSz != ActualSz)
                    {
                        ControlSize = NewSz;

                        returnCommand = "STRUCTURE";
                    }
                    else
                    {
                        returnCommand = "NOTHING";
                    }
                }
            }
            break;

            case "ZOOMRECT":
            {
                System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                Coordinate pm1 = m.PixelToProj(pt1);
                Coordinate pm2 = m.PixelToProj(pt2);

                Extent x = new Extent(Math.Min(pm1.X, pm2.X),
                                      Math.Min(pm1.Y, pm2.Y),
                                      Math.Max(pm1.X, pm2.X),
                                      Math.Max(pm1.Y, pm2.Y));

                m.ViewExtents = x;
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMIN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pntZoomAndCenter = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));
                m.MapFrame.Pan(pntZoomAndCenter);
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMOUT":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(pnt);
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "PAN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(new System.Drawing.Point(x, y));
            }
            break;

            case "WHEELIN":
            {
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "WHEELOUT":
            {
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;
            }



            //ControlMap = m;
            System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]] = m;


            if (returnCommand == "STRUCTURE")
            {
                returnValue = redraw(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }

            if (returnCommand == "REFRESH" | returnCommand == "REFRESHANDHIDEBUFFER")
            {
                returnValue = refresh(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }
        }
Exemple #23
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)System.Web.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;

                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)System.Web.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);
        }