Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        private void showTip(String id)
        {
            try
            {
                SharedStory story = DAO.query(id);

                if (story != null)
                {
                    mStory  = story;
                    message = story.Message;
                    time    = story.Time;

                    ML.Text = message;

                    String      imageName = story.ImageName;
                    model.Image image     = DAO.getImageByName(imageName);

                    if (image != null)
                    {
                        String imageCode = image.ImageCode;
                        if (imageCode != null && imageCode != "")
                        {
                            byte[] imageBuffer = Convert.FromBase64String(image.ImageCode);

                            MemoryStream ms = new MemoryStream(imageBuffer);
                            bitmap = (Bitmap)System.Drawing.Image.FromStream(ms);

                            picture.Image = bitmap;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #2
0
        ////private string sMxdPath = Application.StartupPath;
        ////private List<ILayer> plstLayers = null;
        ////private IPoint m_PointPt = null;
        //private INewEnvelopeFeedback pNewEnvelopeFeedback;
        //private IPoint m_MovePt = null;
        //private IMap pMap = null;
        //private IActiveView pActiveView = null;
        //private IFeatureLayer pCurrentLyr = null;
        //private IEngineEditor pEngineEditor = null;
        //private IEngineEditTask pEngineEditTask = null;
        //private IEngineEditLayers pEngineEditLayers = null;


        /// <summary>
        /// 处理来自服务器的消息
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        private String handleMessage(String message)
        {
            try
            {
                Datagram data       = JsonConvert.DeserializeObject <Datagram>(message);
                String   request    = data.Request;
                String   type       = data.Type;
                String   jsonStream = data.JsonStream;

                Debug.WriteLine("request=" + request);
                Debug.WriteLine("type=" + type);

                if (request == "sendStory" && type == "story")
                {
                    SharedStory story = JsonConvert.DeserializeObject <SharedStory>(jsonStream);
                    DAO.insert(story);

                    IFeature feature = MapManager.addPointInLayer(axMap, story);

                    return("TURE");
                }
                else if (request == "sendImage" && type == "image")
                {
                    model.Image image = JsonConvert.DeserializeObject <model.Image>(jsonStream);
                    DAO.insertImage(image);

                    return("TURE");
                }

                if (request == "getStory" && type == "story")
                {
                    SharedStory story     = JsonConvert.DeserializeObject <SharedStory>(jsonStream);
                    double      longitude = Convert.ToDouble(story.Longitude);
                    double      latitude  = Convert.ToDouble(story.Latitude);

                    IFeature feature = MapManager.addPointInLayer(axMap, "invisibleLayer", longitude, latitude);
                    ILayer   layer   = MapManager.getLayerByName(axMap.Map, "invisibleLayer");

                    if (feature != null && layer != null)
                    {
                        mMap.ClearSelection();
                        mMap.SelectFeature(layer, feature);

                        mFeatures = MapManager.createBuffer(axMap, bufferSize, "story", true);
                        List <String> ids = new List <string>();

                        for (int i = 0; i < mFeatures.Count; i++)
                        {
                            String id = MapManager.getFieldByName(mFeatures[i], "story_id") as String;
                            ids.Add(id);
                        }
                        //删除添加的点
                        MapManager.deleteAllFeature("invisibleLayer", axMap);

                        List <SharedStory> stories = DAO.query(ids);

                        String jsonData = DatagramPaser.toJsonDatagram(stories, "stories", "respone");

                        Debug.WriteLine(jsonData);

                        return(jsonData);
                    }
                }
                else if (request == "getImage" && type == "image")
                {
                    String imageName = jsonStream;

                    model.Image image      = DAO.getImageByName(imageName);
                    String      jsonString = JsonConvert.SerializeObject(image);

                    return(jsonString);
                }
            }
            catch
            {
                Debug.WriteLine("error!!");
            }


            return("FALSE");
        }