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

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

            if (oldValue != newValue && panorama._hasInitializedComponet)
            {
                int layerLevel = panorama.GetLayerLevelByFieldOfView();
                panorama.UpdateLayer(layerLevel);
            }
        }
예제 #3
0
        private static void OnLookDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Panorama            panorama      = d as Panorama;
            CameraLookDirection lookDirection = (CameraLookDirection)e.NewValue;

            if (lookDirection == new CameraLookDirection())
            {
                return;
            }

            if (panorama.Camera != null)
            {
                panorama.Camera.LookDirection = lookDirection.LookDirection;
                panorama.Camera.UpDirection   = lookDirection.UpDirection;
            }
        }
예제 #4
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);
                    }
                }
            }
        }