예제 #1
0
 public SimulationVisualPod2D(
     IPodInfo pod,
     DetailLevel detailLevel,
     Transformation2D transformer,
     double strokeThickness,
     Func <bool> heatModeEnabled,
     MouseButtonEventHandler elementClickAction,
     SimulationAnimation2D controller)
     : base(pod, detailLevel, transformer, strokeThickness, elementClickAction, controller)
 {
     _pod             = pod;
     _heatModeEnabled = heatModeEnabled;
     // Build geometry
     _geometry =
         new RectangleGeometry(
             new Rect(
                 new Point(-_transformer.ProjectXLength(_pod.GetInfoRadius()), -_transformer.ProjectYLength(_pod.GetInfoRadius())),
                 new Size(_transformer.ProjectXLength(_pod.GetInfoRadius() * 2), _transformer.ProjectYLength(_pod.GetInfoRadius() * 2))));
     // Paint it
     Fill            = VisualizationConstants.BrushPodVisual;
     Cursor          = System.Windows.Input.Cursors.Hand;
     MouseDown      += _elementClickAction;
     Stroke          = VisualizationConstants.BrushOutline;
     StrokeThickness = StrokeThicknessReference;
     // Initialize
     Init();
 }
예제 #2
0
파일: Pod.cs 프로젝트: guitarrapc/Pripod
        /// <summary>
        /// Gets Pod information explicitly and initialize it.
        /// </summary>
        /// <param name="resolve"></param>
        /// <param name="throwOnFail"></param>
        public static void Initialize(OwnerReferencesResolve resolve = OwnerReferencesResolve.All, bool throwOnFail = false)
        {
            lock (_syncObject)
            {
                if (_current != null)
                {
                    return;
                }

                if (!_serviceProvider.IsRunningOnKubernetes)
                {
                    _current = new PseudoPodInfo();
                    return;
                }

                try
                {
                    _current = _serviceProvider.CreatePodInfoAsync(resolve).GetAwaiter().GetResult();
                }
                catch (Exception)
                {
                    if (throwOnFail)
                    {
                        throw;
                    }
                    else
                    {
                        _current = new PseudoPodInfo();
                    }
                }
            }
        }
예제 #3
0
 public void Register(IPodInfo pod, SimulationVisualPod2D visual)
 {
     if (!_managedInfoObjects.ContainsKey(pod))
     {
         _managedInfoObjects[pod] = new SimulationInfoPod(_infoHost, pod);
     }
     _managed2DVisuals[visual] = _managedInfoObjects[pod];
     _managed2DVisuals[visual].ManagedVisual2D = visual;
 }
예제 #4
0
 public SimulationVisualContentManager(TreeViewItem contentHost, IPodInfo pod)
 {
     _contentHost = contentHost; _pod = pod;
 }
예제 #5
0
        public SimulationVisualPod3D(IPodInfo pod, DetailLevel detailLevel, Func <bool> heatModeEnabled)
            : base(pod)
        {
            Pod = pod;
            _heatModeEnabled = heatModeEnabled;

            Brush coloredBrush = VisualizationConstants.BrushPodVisual;
            // Add main part
            var visual = new BoxVisual3D
            {
                Fill   = coloredBrush,
                Center = new Point3D(0, 0, _height / 8.0),
                Length = Pod.GetInfoRadius() * 2,
                Width  = Pod.GetInfoRadius() * 2,
                Height = _height / 4.0 * 3.0
            };

            Children.Add(visual);
            // Add feet (if detailed drawing mode)
            if (detailLevel == DetailLevel.Aesthetics)
            {
                double feetLength = Pod.GetInfoRadius() / 10;
                double feetHeight = _height / 4.0;
                visual = new BoxVisual3D
                {
                    Fill   = coloredBrush,
                    Center = new Point3D(-Pod.GetInfoRadius() + feetLength / 2.0, -Pod.GetInfoRadius() + feetLength / 2.0, -_height / 2.0 + feetHeight / 2.0),
                    Length = feetLength,
                    Width  = feetLength,
                    Height = feetHeight
                };
                Children.Add(visual);
                visual = new BoxVisual3D
                {
                    Fill   = coloredBrush,
                    Center = new Point3D(Pod.GetInfoRadius() - feetLength / 2.0, -Pod.GetInfoRadius() + feetLength / 2.0, -_height / 2.0 + feetHeight / 2.0),
                    Length = feetLength,
                    Width  = feetLength,
                    Height = feetHeight
                };
                Children.Add(visual);
                visual = new BoxVisual3D
                {
                    Fill   = coloredBrush,
                    Center = new Point3D(-Pod.GetInfoRadius() + feetLength / 2.0, Pod.GetInfoRadius() - feetLength / 2.0, -_height / 2.0 + feetHeight / 2.0),
                    Length = feetLength,
                    Width  = feetLength,
                    Height = feetHeight
                };
                Children.Add(visual);
                visual = new BoxVisual3D
                {
                    Fill   = coloredBrush,
                    Center = new Point3D(Pod.GetInfoRadius() - feetLength / 2.0, Pod.GetInfoRadius() - feetLength / 2.0, -_height / 2.0 + feetHeight / 2.0),
                    Length = feetLength,
                    Width  = feetLength,
                    Height = feetHeight
                };
                Children.Add(visual);
            }
        }