当前位置: 首页>>代码示例>>C#>>正文


C# MapType.ToString方法代码示例

本文整理汇总了C#中MapType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MapType.ToString方法的具体用法?C# MapType.ToString怎么用?C# MapType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapType的用法示例。


在下文中一共展示了MapType.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadActivityPreviewAsync

        /// <summary>
        /// Loads an image of a map.
        /// </summary>
        /// <param name="polyline">The polyline of your activity.</param>
        /// <param name="dimension">The dimension of the picture which will be returned.</param>
        /// <param name="mapType">Choose the map type of the image.</param>
        /// <returns>An image of your activity on the specified map.</returns>
        public static async Task<Image> LoadActivityPreviewAsync(String polyline, Dimension dimension, MapType mapType)
        {
            if (dimension.Width == 0 || dimension.Height == 0)
            {
                throw new ArgumentException("Both width and height must be greater than zero.");
            }

            String url = String.Format("http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype={0}&size={1}x{2}&path=weight:3|color:red|enc:{3}",
                mapType.ToString().ToLower(),
                dimension.Width,
                dimension.Height,
                polyline);

            Image image = await ImageLoader.LoadImage(new Uri(url));
            return image;
        }
开发者ID:JohnRuddy,项目名称:stravadotnet,代码行数:23,代码来源:GoogleImageLoader.cs

示例2: LoadActivityPreviewAsync

        /// <summary>
        /// Loads an image of a map.
        /// </summary>
        /// <param name="polyline">The polyline of your activity.</param>
        /// <param name="dimension">The dimension of the picture which will be returned.</param>
        /// <param name="mapType">Choose the map type of the image.</param>
        /// <returns>An image of your activity on the specified map.</returns>
        public static async Task<Image> LoadActivityPreviewAsync(String polyline, Dimension dimension, MapType mapType)
        {
            if (dimension.Width == 0 || dimension.Height == 0)
            {
                throw new ArgumentException("Both width and height must be greater than zero.");
            }

            List<Coordinate> c = PolylineDecoder.Decode(polyline);
            String markerStart = String.Format("&markers=icon:http://tinyurl.com/np8ozqm%7C{0},{1}", c.First().Latitude, c.First().Longitude);
            String markerEnd = String.Format("&markers=icon:http://tinyurl.com/mzj8mvq%7C{0},{1}", c.Last().Latitude, c.Last().Longitude);

            String url = String.Format("http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype={0}&size={1}x{2}&{3}&{4}&path=weight:3|color:red|enc:{5}",
                mapType.ToString().ToLower(),
                dimension.Width,
                dimension.Height,
                markerStart,
                markerEnd,
                polyline);

            Image image = await ImageLoader.LoadImage(new Uri(url));
            return image;
        }
开发者ID:TiBall,项目名称:stravadotnet,代码行数:29,代码来源:GoogleImageLoader.cs

示例3: Mapper

        private string Mapper(MapType type, string value)
        {
            string retval = value;

            if (xdocMap != null)
            {
                XmlNodeList nodes = xdocMap.SelectNodes(String.Format("Maps/{0}[@From='{1}']", type.ToString(), value));
                if (nodes.Count > 0)
                {
                    retval = nodes[0].Attributes["To"].ToString();
                }
            }

            return retval;
        }
开发者ID:BrianGoff,项目名称:BITS,代码行数:15,代码来源:STaARS_ImagineManager.cs

示例4: GetFilename

        private string GetFilename(MapType type, Point pos, int zoom, bool createDirectory)
        {
            string path = Path.Combine(CacheLocation, type.ToString());
            path = Path.Combine(path, string.Format("Zoom{0:D2}", zoom));
            int x0 = pos.X / 100000;
            int x1 = pos.X / 100;
            path = Path.Combine(path, string.Format("X{0:D2}0000\\X{1:D4}00", x0, x1));
            int y0 = pos.Y / 100000;
            int y1 = pos.Y / 100;
            path = Path.Combine(path, string.Format("Y{0:D2}0000\\Y{1:D4}00", y0, y1));

            if (createDirectory)
                Directory.CreateDirectory(path);

            path = Path.Combine(path, string.Format("Tile_{0}_{1}.dat", pos.X, pos.Y));

            return path;
        }
开发者ID:deb761,项目名称:BikeMap,代码行数:18,代码来源:FilePureImageCache.cs

示例5: MakeUrlRequest

    /// <summary>
    /// Make request url string 
    /// for Google Static Maps
    /// </summary>
    /// <param name="coo"></param>
    /// <param name="size"></param>
    /// <param name="zoom"></param>
    /// <param name="type"></param>
    /// <returns>string url</returns>
    private string MakeUrlRequest(Vector2 coo, 
                                  Vector2 size, 
                                  int zoom, 
                                  MapType type, 
                                  ArrayList markers)
    {
        //Check coordinates
        int maxLat = 6 * zoom;
        if(coo[1] > maxLat || coo[1] < -maxLat)
        {
            //Wrong latitude
            Debug.LogWarning("Latitude wrong");
            if(coo[1] < 0)
            {
                coo[1] = -maxLat;
            }
            else
            {
                coo[1] = maxLat;
            }
        }

        string ret = urlBase                                          // request base string adress
            + "center=" + coo[0].ToString() + "," + coo[1].ToString() // + position
            + "&zoom=" + zoom.ToString()                              // + zoom
            + "&size=" + size[0].ToString() + "x" + size[1].ToString()// + size
            + "&maptype=" + type.ToString();                          // + maptype
                                                                      // + "&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7C" + coo[0].ToString() + "," + coo[1].ToString() // + marker example
                                                                      // + "&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7C" + coo[1].ToString() + "," + coo[1].ToString();// + marker example

        GameObject[] gos = GameObject.FindGameObjectsWithTag("MarkerLabel");
        foreach (GameObject go in gos)
        {
            DestroyObject(go);
        }


        int count = 35;
        if (markers != null)
        {
            //add markers to request           
            foreach (Vector2 marker in markers)
            {
                
                if (count-- == 0)
                {                  
                    break;
                }
                ret += "&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7C" + marker[0].ToString() + "," + marker[1].ToString();
             //   ret += "&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7C" + marker[0].ToString() + "," + marker[1].ToString();
                GameObject mlObj = Instantiate<GameObject>(markerLabelPrefab);
                MarkerLabel ml = mlObj.GetComponent<MarkerLabel>();
                ml.coordinates = marker;
                ml.zoom = zoom;
            }
        }
        //add custom markers to request      
        if (markersList != null)
        {
           
            foreach (Vector2 marker in markersList /* gui property */)
            {
                if (count-- <= 0)
                {
                    break;
                }
                ret += "&markers=%7Clabel:1%7C" + marker[0].ToString() + "," + marker[1].ToString();
                GameObject mlObj = Instantiate<GameObject>(markerLabelPrefab);
                MarkerLabel ml = mlObj.GetComponent<MarkerLabel>();
                ml.coordinates = marker;
                ml.zoom = zoom;
            }
        }
        /* google static map api key */
        ret += "&key=AIzaSyDb-yIJTeihCDkU_GAVK67i878h88zfYIk";
        //set gui propery
        url = ret;
        return ret;
    }
开发者ID:Nedja995,项目名称:WikiVisualizer,代码行数:88,代码来源:GMapStaticImage.cs

示例6: GetExportJobsImp

        /// <summary>
        /// Gets the ExportJobs for the particular map schema type for a domain and root map.
        /// </summary>
        /// <param name="mapType">OPTIONALLY: The map schema type</param>
        /// <param name="domainUid">The DomainUid for the exports</param>
        /// <param name="rootMapUid">The RootMapUid for the exports</param>
        /// <returns>A list of all the ExportJobs that match the criteria supplied as arguments</returns>
        private ExportJobsResponse GetExportJobsImp(MapType? mapType, Guid domainUid, Guid rootMapUid)
        {
            ExportJobsResponse response = new ExportJobsResponse();
            response.ExportJobs = new Dictionary<Guid, ExportJob>();

            try
            {
                Guid webID = SPContext.Current.Web.ID;
                Guid siteID = SPContext.Current.Site.ID;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(siteID))
                    {
                        using (SPWeb web = site.OpenWeb(webID))
                        {
                            if (web != null)
                            {
                                SPList exportsList = web.TryGetList(web.GetServerRelativeListUrlPrefix() + "GlymaExports"); //TODO get the name from a constant
                                if (exportsList != null)
                                {
                                    SPQuery query = new SPQuery();
                                    if (mapType.HasValue)
                                    {
                                        query.Query = "<Where><And><And>" +
                                            "<Eq><FieldRef Name='DomainUid' /><Value Type='Text'>" + domainUid.ToString() + "</Value></Eq>" +
                                            "<Eq><FieldRef Name='RootMapUid' /><Value Type='Text'>" + rootMapUid.ToString() + "</Value></Eq>" +
                                            "</And><Eq><FieldRef Name='MapType' /><Value Type='Text'>" + mapType.ToString() + "</Value></Eq></And></Where>" +
                                            "<OrderBy><FieldRef Name='Created' Ascending='TRUE'></FieldRef></OrderBy>";
                                    }
                                    else
                                    {
                                        query.Query = "<Where><And>" +
                                            "<Eq><FieldRef Name='DomainUid' /><Value Type='Text'>" + domainUid.ToString() + "</Value></Eq>" +
                                            "<Eq><FieldRef Name='RootMapUid' /><Value Type='Text'>" + rootMapUid.ToString() + "</Value></Eq>" +
                                            "</And></Where>" +
                                            "<OrderBy><FieldRef Name='Created' Ascending='TRUE'></FieldRef></OrderBy>";
                                    }
                                    //get the exports for this domain/rootmap in ascending order
                                    SPListItemCollection exports = exportsList.GetItems(query);
                                    foreach (SPListItem export in exports)
                                    {
                                        ExportJob exportJob = GetExportJob(export);
                                        response.ExportJobs.Add(exportJob.Id, exportJob);

                                        if (exportJob.Status == ExportStatus.Error)
                                        {
                                            //maintenance task if the export job had an error clear the TimerJobWorkItem if it was left behind
                                            CleanupErrorWorkItems(exportJob, site, web);
                                        }
                                    }
                                }
                                else
                                {
                                    throw new Exception("Failed to find the Glyma Exports list.");
                                }
                            }
                            else
                            {
                                throw new Exception("The SPWeb was not found.");
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                ExportError error = new ExportError() { ErrorMessage = "Failed to get the export jobs for the site." };
                throw new FaultException<ExportError>(error, ex.ToString());
            }

            return response;
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:79,代码来源:UtilityServiceManager.cs

示例7: CreateExportJobListEntry

        /// <summary>
        /// Adds the SPListItem for the ExportJob to the GlymaExports lists if there isn't one already in the Scheduled ExportState for the exact same export.
        /// </summary>
        /// <param name="exportsList">The SPList that contains the ExportJobs</param>
        /// <param name="domainId">The DomainUid for the export to be created</param>
        /// <param name="rootmapId">The RootMapUid for the export to be created</param>
        /// <param name="mapType">The type of map (schema) that is being exported</param>
        /// <param name="type">The format of the export to be created</param>
        /// <param name="workItemId">The ID of the workitem</param>
        /// <param name="serializedExportProperties">The ExportProperties as an XML string</param>
        /// <returns>The ID of the list item created or -1 if it wasn't created because an existing item matched it in scheduled state.</returns>
        private int CreateExportJobListEntry(SPList exportsList, Guid domainId, Guid rootmapId, MapType mapType, ExportType type, Guid workItemId, string serializedExportProperties, int userId)
        {
            int listItemId = -1; //default value indicates that item wasn't created
            if (exportsList != null)
            {
                SPQuery query = new SPQuery();
                query.Query = "<Where><And><And><And><And>" +
                            "<And><Eq><FieldRef Name='DomainUid' /><Value Type='Text'>" + domainId.ToString() + "</Value></Eq>" +
                            "<Eq><FieldRef Name='RootMapUid' /><Value Type='Text'>" + rootmapId.ToString() + "</Value></Eq></And>" +
                            "<Eq><FieldRef Name='ExportStatus' /><Value Type='Choice'>" + ExportStatus.Scheduled.ToString() + "</Value></Eq></And>" +
                            "<Eq><FieldRef Name='ExportType' /><Value Type='Choice'>" + type.ToString() + "</Value></Eq></And>" +
                            "<Eq><FieldRef Name='ExportProperties' /><Value Type='Note'>" + serializedExportProperties + "</Value></Eq></And>" +
                            "<Eq><FieldRef Name='MapType' /><Value Type='Choice'>" + mapType.ToString() + "</Value></Eq>"  +
                            "</And></Where>";
                // Query for where this particular rootmap has been scheduled for export to the same type already
                SPListItemCollection existingSchedules = exportsList.GetItems(query);

                if (existingSchedules.Count == 0)
                {
                    //TODO get field names from constants
                    SPListItem exportJob = exportsList.Items.Add();
                    exportJob["ExportType"] = type.ToString();
                    exportJob["MapType"] = mapType.ToString();
                    exportJob["ExportStatus"] = ExportStatus.Scheduled.ToString();
                    exportJob["RootMapUid"] = rootmapId.ToString();
                    exportJob["DomainUid"] = domainId.ToString();
                    exportJob[SPBuiltInFieldId.Title] = workItemId.ToString();
                    exportJob["ExportProperties"] = serializedExportProperties;
                    exportJob["PercentageComplete"] = 0;
                    exportJob[SPBuiltInFieldId.Author] = userId;
                    exportJob[SPBuiltInFieldId.Editor] = userId;
                    exportJob.Update();
                    listItemId = exportJob.ID;
                }
            }
            return listItemId;
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:48,代码来源:UtilityServiceManager.cs

示例8: CreateExportJob

        /// <summary>
        /// Creates an ExportJob and schedules the WorkItem for the timer job that processes the exports.
        /// </summary>
        /// <param name="domainUid">The DominUid for the map being exported</param>
        /// <param name="rootMapUid">The RootMapUid for the map being exported</param>
        /// <param name="exportProperties">The export properties for the export</param>
        /// <param name="mapType">The map type (schema) for the map being exported</param>
        /// <param name="exportType">The output format for the export</param>
        /// <returns>The ExportJob that was created</returns>
        public ExportJobResponse CreateExportJob(Guid domainUid, Guid rootMapUid, IDictionary<string, string> exportProperties, MapType mapType, ExportType exportType)
        {
            ExportJobResponse response = new ExportJobResponse();

            try
            {
                Guid webID = SPContext.Current.Web.ID;
                Guid siteID = SPContext.Current.Site.ID;
                SPUser currentUser = null;
                using (SPSite site = new SPSite(siteID)) 
                {
                    using (SPWeb web = site.OpenWeb(webID))
                    {
                        if (web != null)
                        {
                            currentUser = web.CurrentUser;
                        }
                    }
                }
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    int userId = -1;
                    SPList exportsList = null;
                    int listItemIdNum = -1;
                    
                    using (SPSite site = new SPSite(siteID)) 
                    {
                        using (SPWeb web = site.OpenWeb(webID))
                        {
                            if (web != null)
                            {
                                if (currentUser == null)
                                {
                                    //The current user shouldn't be null, it should have been resolved outside of this RunWithElevatedPrivileges delegate
                                    currentUser = web.CurrentUser;
                                }
                                if (currentUser != null)
                                {
                                    userId = currentUser.ID;

                                    exportsList = web.TryGetList(web.GetServerRelativeListUrlPrefix() + "GlymaExports"); //TODO get the name from a constant
                                    if (exportsList != null)
                                    {

                                        //the text payload will contain the properties serialized into a simple XML format
                                        ExportPropertiesDictionary serializableDict = new ExportPropertiesDictionary(exportProperties);
                                        string textPayload = serializableDict.ConvertToXml();

                                        Guid workItemId = Guid.NewGuid(); // Create a unique id for the work item and export job
                                        listItemIdNum = CreateExportJobListEntry(exportsList, domainUid, rootMapUid, mapType, exportType, workItemId, textPayload, userId);

                                        // if the list item was created then create the export job, if it wasn't it was because an export
                                        // for this particular root map of this type was already scheduled (changing the properties doesn't have effect)
                                        if (listItemIdNum != -1)
                                        {
                                            site.AddWorkItem(workItemId, //gWorkItemId - A Guid that identifies the work item
                                                DateTime.Now.ToUniversalTime(), //schdDateTime - represents a time in universal time for when the work item should take place
                                                GlymaExportWorkItemTimerJob.WorkItemTypeId, //gWorkItemType - this must be the GUID used in the GlymaExportWorkItemTimerJob
                                                web.ID, //gWebId - The identifier of the web containing the list
                                                exportsList.ID, //gParentId - The list ID
                                                listItemIdNum, //nItemId - The list item ID number
                                                true, //fSetWebId - true to set the Web identifier
                                                exportsList.Items.GetItemById(listItemIdNum).UniqueId, //gItemGuid - The unique identifier of the list item
                                                domainUid, //gBatchId - A Guid context identifier for the work item engine
                                                userId, //nUserId - SPUser ID number
                                                null, //rgbBinaryPayload - not used
                                                textPayload, //strTextPayload
                                                Guid.Empty); //gProcessingId - needs to be Guid.Empty

                                            ExportJob scheduledJob = new ExportJob();
                                            scheduledJob.Created = (DateTime)exportsList.Items.GetItemById(listItemIdNum)[SPBuiltInFieldId.Created];
                                            scheduledJob.CreatedBy = new GlymaUser() { Name = currentUser.Name };
                                            scheduledJob.Id = workItemId;
                                            scheduledJob.IsCurrent = true;
                                            scheduledJob.Status = ExportStatus.Scheduled;
                                            scheduledJob.Type = exportType;
                                            scheduledJob.MapType = mapType;
                                            scheduledJob.ExportProperties = exportProperties;
                                            scheduledJob.PercentageComplete = 0;
                                            response.ExportJob = scheduledJob;
                                        }
                                        else
                                        {
                                            //already scheduled so throw an exception to be handled with an error
                                            throw new Exception(string.Format("A scheduled export job already exists for the Glyma map: DomainUid: {0}, RootMapUid: {1}, Export Type: {2}, Map Type: {3}",
                                                domainUid.ToString(), rootMapUid.ToString(), exportType.ToString(), mapType.ToString()));
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception("Failed to find the Glyma Exports list.");
//.........这里部分代码省略.........
开发者ID:chris-tomich,项目名称:Glyma,代码行数:101,代码来源:UtilityServiceManager.cs

示例9: using

        bool PureImageCache.PutImageToCache(MemoryStream tile, MapType type, GPoint pos, int zoom)
        {
            bool ret = true;
             if(Created)
             {
            try
            {
                string file = CacheLocation + Path.DirectorySeparatorChar + type.ToString() + Path.DirectorySeparatorChar + zoom + Path.DirectorySeparatorChar + pos.Y + Path.DirectorySeparatorChar + pos.X + ".jpg";
                string dir = Path.GetDirectoryName(file);
                Directory.CreateDirectory(dir);
                using (BinaryWriter sw = new BinaryWriter(File.OpenWrite(file)))
                {
                    sw.Write(tile.ToArray());

                    sw.Close();
                }
            }
            catch(Exception ex)
            {
            #if MONO
            Console.WriteLine("PutImageToCache: " + ex.ToString());
            #endif
               Debug.WriteLine("PutImageToCache: " + ex.ToString());
               ret = false;
            }
             }
             return ret;
        }
开发者ID:RobertCL,项目名称:MissionPlanner,代码行数:28,代码来源:myPureImageCache.cs

示例10: BinaryReader

        PureImage PureImageCache.GetImageFromCache(MapType type, GPoint pos, int zoom)
        {
            PureImage ret = null;
             try
             {
             string file = CacheLocation + Path.DirectorySeparatorChar + type.ToString() + Path.DirectorySeparatorChar + zoom + Path.DirectorySeparatorChar + pos.Y + Path.DirectorySeparatorChar + pos.X + ".jpg";
             if (File.Exists(file))
             {

                 BinaryReader sr = new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));

                 {
                     byte[] tile = sr.ReadBytes((int)sr.BaseStream.Length);

                                 MemoryStream stm = new MemoryStream(tile, 0, tile.Length, false, true);

                                 ret = GMaps.Instance.ImageProxy.FromStream(stm);
                                 if(ret != null)
                                 {
                                    ret.Data = stm;
                                 }
                 }
             }
             }
             catch(Exception ex)
             {
            #if MONO
            Console.WriteLine("GetImageFromCache: " + ex.ToString());
            #endif
            Debug.WriteLine("GetImageFromCache: " + ex.ToString());
            ret = null;
             }

             return ret;
        }
开发者ID:RobertCL,项目名称:MissionPlanner,代码行数:35,代码来源:myPureImageCache.cs


注:本文中的MapType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。