Exemple #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();
        }
Exemple #2
0
        private static void OnRangeOfFieldOfViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Panorama panorama = d as Panorama;

            double oldValue = (double)e.OldValue;
            double newValue = (double)e.NewValue;

            if (oldValue != newValue)
            {
                panorama.UpdateAngleRangePerLayer();

                if (panorama._hasInitializedComponet)
                {
                    int layerLevel = panorama.GetLayerLevelByFieldOfView();
                    if (panorama.CanChangeLayer(layerLevel))
                    {
                        panorama.UpdateLayer(layerLevel);
                    }
                }
            }
        }