Esempio n. 1
0
        private static void OnResourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Panorama panorama        = d as Panorama;
            string   newResourcePath = e.NewValue.ToString();

            if (string.IsNullOrEmpty(newResourcePath))
            {
                panorama.ResetPanoramaResource();
                return;
            }

            panorama._fullResourceDirectoryPath = panorama.GetRelativeOrAbsoluteFullPathOfDirectory(newResourcePath);

            string configPath = string.Format(@"{0}\{1}", panorama._fullResourceDirectoryPath, "config.json");

            if (!File.Exists(configPath))
            {
                throw new Exception("Panorama configuration file does not exist.");
            }

            string configString = File.ReadAllText(configPath);
            PanoramaResourceConfig resourceConfig = JsonSerializer.Deserialize <PanoramaResourceConfig>(configString);

            if (resourceConfig == null || resourceConfig.Layers == null || resourceConfig.Layers.Count == 0)
            {
                throw new Exception("There is something wrong with the panorama resource config.");
            }

            panorama._resourceConfig = resourceConfig;
            panorama._layerCount     = panorama._resourceConfig.Layers.Count;
            panorama.UpdateAngleRangePerLayer();
        }
Esempio n. 2
0
 /// <summary>
 /// 重置全景资源
 /// </summary>
 /// <param name="panorama"></param>
 private void ResetPanoramaResource()
 {
     _fullResourceDirectoryPath = string.Empty;
     _resourceConfig            = null;
     _layerCount         = 0;
     _angleRangePerLayer = 0;
     CurrentLayerLevel   = 0;
     if (_content != null)
     {
         _content.Content = null;
     }
 }