示例#1
0
        public string SegregateScenes(int _tasksCount = 3, int _unitsCount = 3)
        {
            TimeSpan Dur       = VideoInfo.Duration;
            int      NumScenes = (int)Math.Ceiling(VideoInfo.Duration.TotalMinutes / 2);

            //Scenes = new ObservableCollection<Scene>();
            Scenes.Clear();
            for (int i = 1; i <= NumScenes; i++)
            {
                Scene s      = new Scene();
                int   nextid = 0;
                if (Scenes.Count > 0)
                {
                    nextid = Scenes.Max(a => a.Id);
                }
                s.Id                     = ++nextid;
                s.Position               = i;
                s.UnitsCount             = _unitsCount;
                s.TasksCount             = _tasksCount;
                s.VideoSegment.TimeBegin = TimeSpan.FromSeconds((i - 1) * 120);
                if (i < NumScenes)
                {
                    s.VideoSegment.TimeEnd = TimeSpan.FromSeconds(i * 120);
                }
                else
                {
                    s.VideoSegment.TimeEnd = VideoInfo.Duration - TimeSpan.FromSeconds(0.5);
                }
                s.VideoSegment.Source = VideoInfo.Source;
                Scenes.Add(s);
            }

            return("someShit");
        }
示例#2
0
 public void ClearAllScenes()
 {
     lock (Scenes)
     {
         foreach (var i in Scenes)
         {
             i.Value.Cleanup();
         }
         Scenes.Clear();
     }
 }
示例#3
0
        private void LoadScenes(XmlNode parent)
        {
            if (parent.ChildNodes != null)
            {
                Scenes.Clear();
            }
            SceneDescription d;

            foreach (XmlNode node in parent.ChildNodes)
            {
                d = new SceneDescription();
                // traverse each attribute
                foreach (XmlAttribute a in node.Attributes)
                {
                    switch (a.Name)
                    {
                    case XmlAttributeNames.Name:
                        d.Name = a.Value;
                        break;

                    case XmlAttributeNames.Description:
                        d.Description = a.Value;
                        break;

                    case XmlAttributeNames.Column:
                        d.Column = Int32.Parse(a.Value);
                        break;

                    case XmlAttributeNames.TimePosition:
                        d.TimePosition = Int32.Parse(a.Value);
                        break;

                    case XmlAttributeNames.Duration:
                        d.Duration = Int32.Parse(a.Value);
                        break;
                    }
                }
                foreach (XmlNode contentNode in node.ChildNodes)
                {
                    IContent content = new UnrecognizedContent();
                    foreach (IRiddleHandler h in ContentHandlers)
                    {
                        if (h.CanLoad(contentNode))
                        {
                            content = h.Load(contentNode);
                        }
                    }
                    d.Pages.Add(content);
                }
                Scenes.Add(d);
            }
        }
示例#4
0
        void UpdateScenes()
        {
            if (goToScene == null)
            {
                if (removeSceneCount > 0)
                {
                    for (int i = 0; i < removeSceneCount; i++)
                    {
                        Scenes.Pop().EndInternal();
                        if (Scene != null)
                        {
                            Scene.ResumeInternal();
                        }
                    }
                    removeSceneCount = 0;
                }
                if (goToScenes.Count > 0)
                {
                    for (int i = 0; i < goToScenes.Count; i++)
                    {
                        if (Scene != null)
                        {
                            Scene.PauseInternal();
                        }
                        Scenes.Push(goToScenes[i]);
                        goToScenes[i].Game = this;
                        goToScenes[i].BeginInternal();
                        goToScenes[i].UpdateLists();
                        if (i < goToScenes.Count - 1)
                        {
                            goToScenes[i].Update();
                        }
                    }
                    goToScenes.Clear();
                }
            }
            else
            {
                if (Scene != null)
                {
                    Scene.EndInternal();
                }
                Scenes.Clear();
                Scenes.Push(goToScene);
                Scene.Game = this;
                Scene.UpdateLists();
                Scene.BeginInternal();

                goToScene = null;
            }
        }
示例#5
0
 private void HandleBootstrap(Bootstrap <NuimoDevice, Scene> bootstrap)
 {
     Devices.Clear();
     foreach (var device in bootstrap.Devices)
     {
         Devices.Add(device);
         device.PropertyChanged += Device_PropertyChanged;
     }
     Scenes.Clear();
     foreach (var scene in bootstrap.Scenes)
     {
         Scenes.Add(scene);
         scene.PropertyChanged += Scene_PropertyChanged;
     }
     _settingsControl.Settings = bootstrap.Settings;
     _settingsControl.Settings.PropertyChanged += Settings_PropertyChanged;
 }
示例#6
0
 public static void ResetData(bool clearScenes = false)
 {
     HasReset = true;
     foreach (var obj in SceneManager.GetActiveScene().GetRootGameObjects())
     {
         obj.SetActive(false);
     }
     PlayerPrefs.DeleteAll();
     PlayerPrefs.Save();
     OnGlobalReset?.Invoke();
     if (clearScenes)
     {
         Scenes.Clear();
     }
     else
     {
         Scenes.Reload();
     }
 }
示例#7
0
        public void Cleanup()
        {
            var it = Scenes.Values.GetEnumerator();

            while (it.MoveNext())
            {
                it.Current.Cleanup();
            }
            it.Dispose();
            Scenes.Clear();

            var it2 = Actors.Values.GetEnumerator();

            while (it2.MoveNext())
            {
                it2.Current.OnRemoveWorld(this);
            }
            it2.Dispose();
            Actors.Clear();
            Cleanup_Editor();
            mDefaultScene = null;
        }
示例#8
0
        /// <summary>
        /// Разбивает видеозапись заданное количество сцен с равной длительностью
        /// </summary>
        /// <param name="scenesCount">Нужное количество сцен</param>
        /// <returns></returns>
        public string SegregateScenes(int scenesCount, TimeSpan OverlapSegregateTime, int _tasksCount = 3, int _unitsCount = 3)
        {
            TimeSpan Dur      = VideoInfo.Duration;
            TimeSpan segrTime = TimeSpan.FromSeconds((Dur.TotalSeconds - 0.1) / scenesCount);

            int NumScenes = scenesCount;

            //Scenes = new ObservableCollection<Scene>();
            Scenes.Clear();
            for (int i = 1; i <= NumScenes; i++)
            {
                Scene s = new Scene();

                int nextid = 0;
                if (Scenes.Count > 0)
                {
                    nextid = Scenes.Max(a => a.Id);
                }
                s.Id                     = ++nextid;
                s.Position               = i;
                s.UnitsCount             = _unitsCount;
                s.TasksCount             = _tasksCount;
                s.VideoSegment.TimeBegin = TimeSpan.FromSeconds((i - 1) * segrTime.TotalSeconds);
                if (i < NumScenes)
                {
                    s.VideoSegment.TimeEnd = TimeSpan.FromSeconds((i * segrTime.TotalSeconds) + OverlapSegregateTime.TotalSeconds);
                }
                else
                {
                    s.VideoSegment.TimeEnd = VideoInfo.Duration - TimeSpan.FromSeconds(0.1);
                }
                s.VideoSegment.Source = VideoInfo.Source;
                Scenes.Add(s);
            }

            return("someShit");
        }
示例#9
0
 internal static void Clear()
 {
     GameObjects.Clear();
     Components.Clear();
     Scenes.Clear();
 }
示例#10
0
        private async void Ws_SceneChanged(SLOBSWebsocket sender, SLOBSSceneEvent eventdata)
        {
            if (eventdata.Type == ESLOBSEventType.SceneAdded)
            {
                SOBSScene item = _translateScene(eventdata.Scene);
                Scenes.Add(item);
                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneAdded, item);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneRemoved)
            {
                int       reindex = 0;
                SOBSScene item    = _translateScene(eventdata.Scene);
                for (int i = 0; i < Scenes.Count; i++)
                {
                    if (Scenes[i].Id == eventdata.Scene.Id)
                    {
                        Scenes.RemoveAt(i);
                    }
                    else
                    {
                        var scene = Scenes[i];
                        scene.Index = reindex;
                        Scenes[i]   = scene;
                        reindex++;
                    }
                }
                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneRemoved, item);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneSwitched)
            {
                if (!_setActiveScene(eventdata.Scene))
                {
                    var ascenes = await ws.ListScenes();

                    Scenes.Clear();
                    Scenes = _translateScenes(ascenes);
                    _setActiveScene(eventdata.Scene);
                }

                var audio = await ws.ListAudioSources();

                AudioSources.Clear();
                AudioSources = _translateAudioSources(audio);
                if (AudioSourceChanged != null)
                {
                    AudioSourceChanged(this, EOBSEvent.SourceAdded);
                }

                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneSwitched, ActiveScene);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneCollectionChanged)
            {
                var ascenes = await ws.ListScenes();

                Scenes.Clear();
                Scenes = _translateScenes(ascenes);
                var active_scene = await ws.GetActiveScene();

                if (active_scene != null)
                {
                    for (int i = 0; i < Scenes.Count; i++)
                    {
                        if (Scenes[i].Id == ((SLOBSScene)active_scene).Id)
                        {
                            ActiveScene = Scenes[i];
                        }
                    }
                }

                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneUpdated, ActiveScene);
                }
            }
        }
        // Do a Query request on the selected point to get the list of overlapping scenes
        private Task ExtractInfoAsync(string X, string Y)
        {
            return(Application.Current.Dispatcher.Invoke(async() =>
            {
                try
                {
                    if (Scenes != null)
                    {
                        Scenes.Clear();
                        _selection.Clear();
                    }
                    // Get the image service URL from the current layer
                    SelectedLayer = MapView.Active.GetSelectedLayers().FirstOrDefault();
                    if (SelectedLayer is ImageServiceLayer)
                    {
                        string ImageServiceURL = null;
                        ImageServiceLayer imageServiceLayer = (ImageServiceLayer)SelectedLayer;
                        await QueuedTask.Run(() =>
                        {
                            CIMDataConnection DataConnection = imageServiceLayer.GetDataConnection();
                            string DataConnectionXMLString = DataConnection.ToXml();
                            var ParsedDataConnectionString = XElement.Parse(DataConnectionXMLString);
                            var URLNode = ParsedDataConnectionString.Elements("URL");
                            foreach (XElement nodeValue in URLNode)
                            {
                                ImageServiceURL = nodeValue.ToString();
                            }
                        });

                        // Send a request to the REST end point to get information
                        var point = "{x:" + X + ",y:" + Y + "}";
                        string[] URLSplit = Regex.Split(ImageServiceURL, "arcgis/");
                        //string ServiceURL = "https://landsat2.arcgis.com/";
                        string ServiceURL = URLSplit[0].Replace("<URL>", string.Empty);
                        string url = ServiceURL + "query";
                        var ubldr = new UriBuilder(ServiceURL);
                        string path = "arcgis/rest/" + URLSplit[1].Replace("</URL>", string.Empty) + "/query";
                        ubldr.Path = path;
                        //ubldr.Path = $"arcgis/rest/services/Landsat/MS/ImageServer/query";

                        // Allows to give parameters as dictionary key,pair values rather than manually constructing a json
                        var query = HttpUtility.ParseQueryString(ubldr.Query);
                        query["f"] = "json";
                        query["geometry"] = point;
                        query["geometryType"] = "esriGeometryPoint";
                        query["spatialRel"] = "esriSpatialRelIntersects";
                        query["outFields"] = "*";
                        query["pixelSize"] = "30";
                        query["returnGeometry"] = "false";
                        ubldr.Query = query.ToString();
                        var httpClient = new EsriHttpClient();
                        var response = httpClient?.Get(ubldr.Uri.ToString());
                        var respstr = await response?.Content?.ReadAsStringAsync();
                        var SceneList = JObject.Parse(respstr);
                        var SceneListInfo = (JArray)SceneList["features"];
                        foreach (JObject value in SceneListInfo)
                        {
                            foreach (var property in value.Properties())
                            {
                                if (property.Name == "attributes")
                                {
                                    {
                                        // Add obtained json response as a dictionary to a list of dictionaries
                                        var attribute = property.Value.ToString();
                                        var attributeValue = JObject.Parse(attribute);
                                        var category = Int32.Parse(attributeValue["Category"].ToString());
                                        var attributeValueDict = attributeValue.ToObject <Dictionary <string, string> >();
                                        if (category == 1)
                                        {
                                            _selection.Add(attributeValueDict);
                                        }
                                    }
                                }
                            }
                        }

                        foreach (var value in _selection)
                        {
                            // Extract and convert epoch time to dd/MM/yyyy format
                            double UnixTime = Convert.ToDouble(value["AcquisitionDate"].ToString());
                            var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                            DateTime date = epoch.AddMilliseconds(UnixTime);
                            var AcqDate = date.ToString("dd / MM / yyyy");
                            var objID = value["OBJECTID"].ToString();
                            var ClCover = value["CloudCover"].ToString();
                            var SceneName = value["Name"].ToString();
                            Scenes.Add(new Scene {
                                AcqDate = AcqDate, Name = SceneName, CloudCover = ClCover, ObjectID = objID
                            });
                        }
                        // Add recieved information to an Observable Collection and notfy UI
                        NotifyPropertyChanged(() => Scenes);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
            }));
        }
 public void SetScene(string path)
 {
     Scenes.Clear();
     AddScene(path);
 }