Inheritance: Caliburn.Micro.PropertyChangedBase, IConvertibleXml
Example #1
0
        public bool StartRecording(Media ppt, Event e, PoiService ps)
        {
            //media = ppt;
            //service = ps;
            //pptEvent = e;
            if (Active) return false;
            //_stream = new MemoryStream();
            //_stream.Seek(0, SeekOrigin.Begin);
            //_microphone = Microphone.Default;
            //_microphone.BufferReady -= microphone_BufferReady;
            //_microphone.BufferReady += microphone_BufferReady;

            //_microphone.BufferDuration = TimeSpan.FromMilliseconds(300);
            //_buffer = new byte[_microphone.GetSampleSizeInBytes(_microphone.BufferDuration)];


            //_microphone.Start();
            return true;
        }
Example #2
0
        private void WcDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            // AppStateSettings.Instance.FinishDownload((Guid) e.UserState);
            if (e.Error != null) return;
            var n = new List<string>();
            var r = new JsonTextReader(new StringReader(e.Result));
            JObject j = JObject.Parse(e.Result);
            var av = new List<string>();
            var cams = j["content"];
            foreach (var c in cams)
            {
                var Id = c["webcamid"].Value<string>();
                var lng = double.Parse(c["lng"].Value<string>(), CultureInfo.InvariantCulture);
                var lat = double.Parse(c["lat"].Value<string>(), CultureInfo.InvariantCulture);
                var ImageUrl = c["thumbnail"].Value<string>();
                var current = c["preview"]["current"].Value<string>();
                if (service.PoIs.All(k => k.ContentId != Id))
                {
                    var bc = new PoI
                    {
                        PoiTypeId = webcam.PoiId,
                        Service = service,
                        PoiType = webcam,
                        ContentId = Id,
                        Style = new PoIStyle {Icon = ImageUrl},
                        Position = new Position(lng, lat),

                    };

                    var m = new Media();
                    m.PublicUrl = current;
                    m.LocalPath = current;
                    bc.AllMedia.Add(m);
                    service.PoIs.Add(bc);
                    av.Add(Id);
                }
            }


            //string sReferences = e.Result;
            //int iStart = sReferences.IndexOf("[{");
            //int iLength = sReferences.IndexOf("}]") - iStart;
            //if (iStart <= 1) return;
            //string sPhotos = sReferences.Substring(iStart + 1, iLength - 1);
            //////string[] sPhotoArray = sPhotos.Split(new char[] { (char)10 });
            //var sSeparator = new string[1];
            //sSeparator[0] = "},";

            //string[] sPhotoArray = sPhotos.Split(sSeparator, StringSplitOptions.RemoveEmptyEntries);

            ////PrepLayer();

            //

            //foreach (string sPhoto in sPhotoArray)
            //{
            //    try
            //    {

            //        var Id = GetValueFromTag(sPhoto, "photo_id");
            //        var Name = GetValueFromTag(sPhoto, "photo_title");
            //        var ImageUrl = GetValueFromTag(sPhoto, "photo_file_url");
            //        var Height = Convert.ToInt16(GetValueFromTag(sPhoto, "height"));
            //        var Width = Convert.ToInt16(GetValueFromTag(sPhoto, "width"));
                    
                    

            //        var bc = new PoI
            //        {
            //            PoiTypeId = webcam.PoiId,
            //            Service = service,
            //            PoiType = webcam,
            //            ContentId = Id,
            //            Style = new PoIStyle { Icon = ImageUrl },
            //            Position = new Position(Convert.ToDouble(GetValueFromTag(sPhoto, "longitude"),
            //                CultureInfo.InvariantCulture),
            //                Convert.ToDouble(GetValueFromTag(sPhoto, "latitude"),
            //                    CultureInfo.InvariantCulture)),

            //        };
            //        var m = new Media();
            //        m.PublicUrl = ImageUrl;
            //        m.LocalPath = ImageUrl;
            //        bc.AllMedia.Add(m);
            //        service.PoIs.Add(bc);
            //        av.Add(Id);
                    

            //        //CurrentFeatures.Add(pf);
            //        //}
            //        //else
            //        //{
            //        //    f.First().Attributes["visible"] = true;
            //        //    //((PhotoFeature)f.First()).Enabled = true;
            //        //}
            //    }
            //    catch
            //    {

            //    }

                //), "photo",
                //GetValueFromTag(sPhoto, "photo_title"), "", Double.Parse(GetValueFromTag(sPhoto, "latitude"), ciEnglish), Double.Parse(GetValueFromTag(sPhoto, "longitude"), ciEnglish),
                //16, Int32.Parse(GetValueFromTag(sPhoto, "owner_id")), GetValueFromTag(sPhoto, "owner_name"), DateTime.MinValue,
                //DateTime.MinValue, "http://www.panoramio.com");
            //}

            var tbr = service.PoIs.Where(k => !av.Contains(k.ContentId)).ToList();
            foreach (var c in tbr) if (service.PoIs.Contains(c)) service.PoIs.Remove(c);

            //CleanLayer();

            //CurrentFeatures.RemoveAll(k => !((PhotoFeature) k).Enabled);
        }
Example #3
0
      private void AddTaskWithScreenshot()
      {
          if (Service == null) return;
          var id2 = Guid.NewGuid().ToString();
          var task = new Task { Title = "New RFI", Date = DateTime.UtcNow };
          var taskDetailsViewModel = new TaskDetailsViewModel { Task = task, Service = Service, Plugin = Plugin, FloatingElementId = id2 };
          var size = new Size(300, 500);
          
          var id = Guid.NewGuid() + ".png";
          
          
              var media = new Media
              {
                  Id = id,
                  LocalPath = Service.store.GetLocalUrl(Service.Folder, id),
                  Type = MediaType.Photo,
                  Title = task.Title
              };
          
          Screenshots.SaveImageOfControl(AppStateSettings.Instance.ViewDef.MapControl, media.LocalPath);
          //media.Image = Screenshot as BitmapSource;
          foreach (var m in task.AllMedia)
          {
              try { if (File.Exists(m.LocalPath)) File.Delete(m.LocalPath); }
              catch (Exception) { }
          }
          task.AllMedia.Clear();
          task.AllMedia.Add(media);
          //await Service.store.SaveBytes(id, media.ByteArray);
 
          var fe = FloatingHelpers.CreateFloatingElement("RFI", new Point(300, 300), size, taskDetailsViewModel);
          fe.Id = id2;
          AppStateSettings.Instance.FloatingItems.AddFloatingElement(fe);
      }
Example #4
0
 public void TakeScreenshotMap() {
     var id = Guid.NewGuid() + ".png";
     var media = new Media {
         Id = id,
         LocalPath = Service.store.GetLocalUrl(Service.Folder, id),
         Type = MediaType.Photo,
         Title = task.Title
     };
     Screenshot = Screenshots.SaveImageOfControl(AppState.ViewDef.MapControl, media.LocalPath);
     //media.Image = Screenshot as BitmapSource;
     foreach (var m in task.AllMedia) {
         try { if (File.Exists(m.LocalPath)) File.Delete(m.LocalPath); }
         catch (Exception) {}
     }
     task.AllMedia.Clear(); 
     task.AllMedia.Add(media);
     //await Service.store.SaveBytes(id, media.ByteArray);
     AppState.TriggerNotification("Map Screenshot saved.");            
 }
Example #5
0
        public void FromXmlBase(ref XElement res, string directoryName)
        {
            //var xmlSerializer = new XmlSerializer(typeof (PoI));
            //var p = xmlSerializer.Deserialize(res.CreateReader());
            try
            {
                Id = res.GetGuid("Id");
                if (Id == Guid.Empty) Id = Guid.NewGuid();
                var n = res.GetString("Name");
                ContentId = res.GetString("PoiId", "");
                if (String.IsNullOrEmpty(ContentId)) ContentId = n;
                Priority = res.GetInt("Priority", 2);
                UserId = res.GetString("UserId");
                DateLong = res.GetLong("Date", DateTime.Now.ToEpoch());
                UpdatedLong = res.GetLong("Updated", DateTime.Now.ToEpoch());
                Layer = res.GetString("Layer");
                MaxItems = res.GetNullInt("MaxItems");
                var xMid = res.Element("MetaInfoData");
                PoiTypeId = res.GetString("PoiTypeId", "");
                IsVisibleInMenu = res.GetBool("IsVisibleInMenu", true);
                Orientation = res.GetDouble("Orientation", 0.0);
                //if (!string.IsNullOrEmpty(PoiTypeId))
                //{

                //}
                if (xMid != null)
                {
                    var metaInfo = new MetaInfoCollection();
                    foreach (var xMi in xMid.Elements())
                    {
                        var mi = new MetaInfo();
                        mi.FromXml(xMi);
                        metaInfo.Add(mi);
                    }
                    MetaInfo = metaInfo;
                }

                if (res.Element("WKT") != null)
                {
                    var xElement = res.Element("WKT");
                    if (xElement != null) WktText = xElement.Value;
                }

                var xlabels = res.Element("Labels");
                if (xlabels != null)
                {
                    Labels = new Dictionary<string, string>();
                    foreach (var xk in xlabels.Elements())
                    {
                        var k = xk.Name.LocalName;
                        // Restore keys starting with numbers or having % or '.
                        k = k.Replace(LabelPercentSubst, "%");
                        k = k.Replace(LabelQuoteSubst, "'");
                        if (k.StartsWith(LabelNumPrefix))
                        {
                            k = k.Substring(LabelNumPrefix.Length);
                        }

                        var s = xk.InnerXml();
                        Labels[k] = s.RestoreInvalidCharacters();
                        Labels[k] = Labels[k].Replace("&lt;", "<").Replace("&gt;", ">");
                    }
                }

                var xkeywords = res.Element("Keywords");
                if (xkeywords != null)
                {
                    Keywords = new WordHistogram();
                    Keywords.FromXml(xkeywords);
                }

                if (res.Element("Style") != null)
                {
                    try
                    {
                        var newStyle = new PoIStyle();
                        newStyle.FromXml(res.Element("Style"), directoryName, false); //, Service.Settings); // TODO REVIEW: Settings were ignored.
                        Style = newStyle;
                    }
                    catch (Exception)
                    {
                        // OK, keep the old style.
                    }
                }

                var media = res.Element("AllMedia");
                if (media != null)
                {
                    AllMedia = new BindableCollection<Media>();
                    foreach (var m in media.Elements())
                    {
                        var me = new Media { Content = this };
                        me.FromXml(m);
                        AllMedia.Add(me);
                    }
                }
                var xpos = res.Element("Position");
                if (xpos != null)
                    Position = new Position(xpos.GetDouble(Position.LONG_LABEL), xpos.GetDouble(Position.LAT_LABEL), xpos.GetDouble(Position.ALT_LABEL)); // TODO Remember other Position attributes.

                var px = res.Element("Points");

                var mo = res.Element("Models");
                if (mo != null)
                {
                    Models = new List<Model>();
                    foreach (var xm in mo.Elements())
                    {
                        var m = new Model();
                        m.FromXml(xm);
                        Models.Add(m);
                    }
                }

                if (px == null) return;
                var pp = px.Value;
                Points = new ObservableCollection<Point>();
                var ppo = pp.Split(' ');
                foreach (var poss in ppo)
                {
                    var split = poss.Split(',');
                    var pt = new Point(
                        Double.Parse(split[0], CultureInfo.InvariantCulture),
                        Double.Parse(split[1], CultureInfo.InvariantCulture));
                    Points.Add(pt);
                }
            }
            catch (SystemException e)
            {
                Logger.Log("DataServer.BaseContent", "Error reading XML " + res + " from " + directoryName, e.Message, Logger.Level.Error, true);
            }
        }