private void TourPopup_Load(object sender, EventArgs e) { if (popupType == PopupTypes.Popup) { Height = 335; Preview.Visible = true; CloseTour.Visible = false; WatchAgain.Visible = false; tourWrapPanel.Visible = false; averageStars.Visible = true; ratingLabel.Visible = true; runLengthLabel.Visible = true; runLength.Visible = true; } else { Height = 405; TourTitle.Left -= 53; TourTitle.Width = 430; Preview.Visible = false; CloseTour.Visible = true; WatchAgain.Visible = true; tourWrapPanel.Visible = true; averageStars.Visible = false; ratingLabel.Visible = false; runLengthLabel.Visible = false; runLength.Visible = false; Left = (Earth3d.MainWindow.RenderWindow.ClientRectangle.Width - this.Width) / 2; Top = (Earth3d.MainWindow.RenderWindow.ClientRectangle.Height - this.Height) / 2; MyRating.Stars = GetMyRating(tourResult.Id); }; averageStars.Stars = tourResult.AverageUserRating; TourTitle.Text = tourResult.Title; if (TourTitle.Text.Length < 23) { TourTitle.Font = UiTools.StandardGargantuan; } else if (TourTitle.Text.Length < 30) { TourTitle.Font = UiTools.StandardHuge; } else if (TourTitle.Text.Length < 40) { TourTitle.Font = UiTools.StandardLarge; } else if (TourTitle.Text.Length < 50) { TourTitle.Font = UiTools.StandardRegular; } else { TourTitle.Font = UiTools.StandardSmall; } TourDescription.Text = tourResult.Description; authorImage.Image = tourResult.AuthorImage; authorUrl.Text = tourResult.Author; if (tourResult.OrgName != "None") { orgUrl.Text = tourResult.OrgName; } this.ttTourPopup.SetToolTip(TourTitle, tourResult.Title); Rectangle rect = Screen.GetWorkingArea(this); if (this.Left + this.Width > rect.Width) { this.Left -= (this.Left + this.Width) - rect.Width; } TimeSpan ts = new TimeSpan(0,0,(int)tourResult.LengthInSeconds); this.runLength.Text = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); fadein = new BlendState(false, 500); fadein.TargetState = true; if (!string.IsNullOrEmpty(tourResult.RelatedTours)) { string[] relatedList = tourResult.RelatedTours.Split(new char[] { ';' }); foreach (string id in relatedList) { Tour relatedItem = FolderBrowser.GetRelatedTour(id); if (relatedItem != null) { relatedTours.Add(relatedItem); } } } }
public static BlendState Parse(string val) { string[] parts = ((string)val).Split(new char[] { ',' }); bool state = false; float opacity = 0; double delay = 2000; try { state = bool.Parse(parts[0]); if (parts.Length > 1) { opacity = float.Parse(parts[1]); } if (parts.Length > 2) { delay = int.Parse(parts[2]); } } catch { } BlendState blendState = new BlendState(state, delay, opacity); return blendState; }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is string) { string[] parts = ((string)value).Split(new char[] { ',' }); bool state = false; float opacity = 0; double delay = 2000; try { state = bool.Parse(parts[0]); if (parts.Length > 1) { opacity = float.Parse(parts[1]); } if (parts.Length > 2) { delay = int.Parse(parts[2]); } } catch { } BlendState blendState = new BlendState(state, delay, opacity); blendState.SettingsOwned = true; return blendState; } return base.ConvertFrom(context, culture, value); }
private void ObjectProperties_Load(object sender, EventArgs e) { fadein = new BlendState(false, 500); fadein.TargetState = true; }
// ** Begin public static void DrawMPC3D(RenderContext11 renderContext, float opacity, Vector3d centerPoint) { var zoom = Earth3d.MainWindow.ZoomFactor; var distAlpha = ((Math.Log(Math.Max(1, zoom), 4)) - 15.5) * 90; var alpha = Math.Min(255, Math.Max(0, (int)distAlpha)); if (alpha > 254) { return; } if (mpcVertexBuffer == null) { for (var i = 0; i < 7; i++) { mpcBlendStates[i] = new BlendState(false, 1000, 0); } if (!initBegun) { var initDelegate = new MethodInvoker(StartInit); initDelegate.BeginInvoke(null, null); initBegun = true; } return; } renderContext.DepthStencilMode = DepthStencilMode.Off; renderContext.setRasterizerState(TriangleCullMode.Off); var offset = Matrix3d.Translation(-centerPoint); var world = renderContext.World * offset; var matrixWVP = (world * renderContext.View * renderContext.Projection).Matrix11; matrixWVP.Transpose(); var cam = Vector3.TransformCoordinate(renderContext.CameraPosition.Vector311, Matrix.Invert(renderContext.World.Matrix11)); renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, Grids.StarProfile.ResourceView); renderContext.BlendMode = BlendMode.Additive; if (mpcVertexBuffer != null) { for (var i = 0; i < 7; i++) { mpcBlendStates[i].TargetState = ((Properties.Settings.Default.MinorPlanetsFilter & (int)Math.Pow(2, i)) != 0); if (mpcBlendStates[i].State) { if (mpcVertexBuffer[i].Downlevel) { DownlevelKeplerPointSpriteShader11.Constants.JNow = (float)(SpaceTimeController.JNow - KeplerVertex.baseDate); DownlevelKeplerPointSpriteShader11.Constants.Opacity = opacity * mpcBlendStates[i].Opacity; DownlevelKeplerPointSpriteShader11.Constants.MM = 0; DownlevelKeplerPointSpriteShader11.Constants.WorldViewProjection = matrixWVP; DownlevelKeplerPointSpriteShader11.Constants.Scale = new Vector2(100f, 100f); DownlevelKeplerPointSpriteShader11.Constants.ViewportScale = new Vector2(2f / renderContext.ViewPort.Width, 2f / renderContext.ViewPort.Height); DownlevelKeplerPointSpriteShader11.Constants.CameraPosition = new Vector4(cam, 1); DownlevelKeplerPointSpriteShader11.Use(renderContext.devContext, mpcVertexBuffer[i].Instanced); } else { KeplerPointSpriteShader11.Constants.JNow = (float)(SpaceTimeController.JNow - KeplerVertex.baseDate); KeplerPointSpriteShader11.Constants.Opacity = opacity * mpcBlendStates[i].Opacity; KeplerPointSpriteShader11.Constants.MM = 0; KeplerPointSpriteShader11.Constants.WorldViewProjection = matrixWVP; KeplerPointSpriteShader11.Constants.Scale = new Vector2(100f, 100f); KeplerPointSpriteShader11.Constants.ViewportScale = new Vector2(2f / renderContext.ViewPort.Width, 2 / renderContext.ViewPort.Height); KeplerPointSpriteShader11.Constants.CameraPosition = new Vector4(cam, 1); KeplerPointSpriteShader11.Use(renderContext.devContext); } mpcVertexBuffer[i].Draw(renderContext, mpcVertexBuffer[i].Count, null, opacity); } } } renderContext.BlendMode = BlendMode.Alpha; renderContext.Device.ImmediateContext.GeometryShader.Set(null); }
// ** Begin public static void DrawMPC3D(RenderContext11 renderContext, float opacity, Vector3d centerPoint) { double zoom = Earth3d.MainWindow.ZoomFactor; double distAlpha = ((Math.Log(Math.Max(1, zoom), 4)) - 15.5) * 90; int alpha = Math.Min(255, Math.Max(0, (int)distAlpha)); if (alpha > 254) { return; } if (mpcVertexBuffer == null) { for (int i = 0; i < 7; i++) { mpcBlendStates[i] = new BlendState(false, 1000, 0); } if (!initBegun) { MethodInvoker initDelegate = new MethodInvoker(StartInit); initDelegate.BeginInvoke(null, null); initBegun = true; } return; } renderContext.DepthStencilMode = DepthStencilMode.Off; renderContext.setRasterizerState(TriangleCullMode.Off); Matrix3d offset = Matrix3d.Translation(-centerPoint); Matrix3d world = renderContext.World * offset; Matrix matrixWVP = (world * renderContext.View * renderContext.Projection).Matrix11; matrixWVP.Transpose(); Vector3 cam = Vector3.TransformCoordinate(renderContext.CameraPosition.Vector311, Matrix.Invert(renderContext.World.Matrix11)); renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, Grids.StarProfile.ResourceView); renderContext.BlendMode = BlendMode.Additive; if (mpcVertexBuffer != null) { for (int i = 0; i < 7; i++) { mpcBlendStates[i].TargetState = ((Properties.Settings.Default.MinorPlanetsFilter & (int)Math.Pow(2, i)) != 0); if (mpcBlendStates[i].State) { if (mpcVertexBuffer[i].Downlevel) { DownlevelKeplerPointSpriteShader11.Constants.JNow = (float)(SpaceTimeController.JNow - KeplerVertex.baseDate); DownlevelKeplerPointSpriteShader11.Constants.Opacity = opacity * mpcBlendStates[i].Opacity; DownlevelKeplerPointSpriteShader11.Constants.MM = 0; DownlevelKeplerPointSpriteShader11.Constants.WorldViewProjection = matrixWVP; DownlevelKeplerPointSpriteShader11.Constants.Scale = new SharpDX.Vector2(100f, 100f); DownlevelKeplerPointSpriteShader11.Constants.ViewportScale = new SharpDX.Vector2(2f / renderContext.ViewPort.Width, 2f / renderContext.ViewPort.Height); DownlevelKeplerPointSpriteShader11.Constants.CameraPosition = new SharpDX.Vector4(cam, 1); DownlevelKeplerPointSpriteShader11.Use(renderContext.devContext, mpcVertexBuffer[i].Instanced); } else { KeplerPointSpriteShader11.Constants.JNow = (float)(SpaceTimeController.JNow - KeplerVertex.baseDate); KeplerPointSpriteShader11.Constants.Opacity = opacity * mpcBlendStates[i].Opacity; KeplerPointSpriteShader11.Constants.MM = 0; KeplerPointSpriteShader11.Constants.WorldViewProjection = matrixWVP; KeplerPointSpriteShader11.Constants.Scale = new SharpDX.Vector2(100f, 100f); KeplerPointSpriteShader11.Constants.ViewportScale = new SharpDX.Vector2(2f / renderContext.ViewPort.Width, 2 / renderContext.ViewPort.Height); KeplerPointSpriteShader11.Constants.CameraPosition = new SharpDX.Vector4(cam, 1); KeplerPointSpriteShader11.Use(renderContext.devContext); } mpcVertexBuffer[i].Draw(renderContext, mpcVertexBuffer[i].Count, null, opacity); } } } renderContext.BlendMode = BlendMode.Alpha; renderContext.Device.ImmediateContext.GeometryShader.Set(null); }
private void TourPopup_Load(object sender, EventArgs e) { if (popupType == PopupTypes.Popup) { Height = 335; Preview.Visible = true; CloseTour.Visible = false; WatchAgain.Visible = false; tourWrapPanel.Visible = false; averageStars.Visible = true; ratingLabel.Visible = true; runLengthLabel.Visible = true; runLength.Visible = true; } else { Height = 405; TourTitle.Left -= 53; TourTitle.Width = 430; Preview.Visible = false; CloseTour.Visible = true; WatchAgain.Visible = true; tourWrapPanel.Visible = true; averageStars.Visible = false; ratingLabel.Visible = false; runLengthLabel.Visible = false; runLength.Visible = false; Left = (Earth3d.MainWindow.RenderWindow.ClientRectangle.Width - this.Width) / 2; Top = (Earth3d.MainWindow.RenderWindow.ClientRectangle.Height - this.Height) / 2; MyRating.Stars = GetMyRating(tourResult.Id); }; averageStars.Stars = tourResult.AverageUserRating; TourTitle.Text = tourResult.Title; if (TourTitle.Text.Length < 23) { TourTitle.Font = UiTools.StandardGargantuan; } else if (TourTitle.Text.Length < 30) { TourTitle.Font = UiTools.StandardHuge; } else if (TourTitle.Text.Length < 40) { TourTitle.Font = UiTools.StandardLarge; } else if (TourTitle.Text.Length < 50) { TourTitle.Font = UiTools.StandardRegular; } else { TourTitle.Font = UiTools.StandardSmall; } TourDescription.Text = tourResult.Description; authorImage.Image = tourResult.AuthorImage; authorUrl.Text = tourResult.Author; if (tourResult.OrgName != "None") { orgUrl.Text = tourResult.OrgName; } this.ttTourPopup.SetToolTip(TourTitle, tourResult.Title); Rectangle rect = Screen.GetWorkingArea(this); if (this.Left + this.Width > rect.Width) { this.Left -= (this.Left + this.Width) - rect.Width; } TimeSpan ts = new TimeSpan(0, 0, (int)tourResult.LengthInSeconds); this.runLength.Text = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); fadein = new BlendState(false, 500); fadein.TargetState = true; if (!string.IsNullOrEmpty(tourResult.RelatedTours)) { string[] relatedList = tourResult.RelatedTours.Split(new char[] { ';' }); foreach (string id in relatedList) { Tour relatedItem = FolderBrowser.GetRelatedTour(id); if (relatedItem != null) { relatedTours.Add(relatedItem); } } } }
public Tile() { renderPart = new BlendState[4]; for (int i = 0; i < 4; i++ ) { renderPart[i] = new BlendState(false, 500); } }