void DisposeReferences() { if (Device != null) { if (state_old != null) { state_old.Dispose(); } if (vb_cube != null) { vb_cube.Dispose(); } if (vert_decl_nocolor != null) { vert_decl_nocolor.Dispose(); } foreach (var font in fontCache) { font.Value.Dispose(); } Device.Dispose(); Device = null; vert_decl_nocolor = null; vb_cube = null; state_old = null; fontCache.Clear(); } }
/// <summary> /// Destroy any resources and clear the caches /// </summary> public void OnDestroyDevice() { foreach (FontNode fn in fontCache) { if (fn.Font != null) { fn.Font.Dispose(); } } foreach (TextureNode tn in textureCache) { if (tn.Texture != null) { tn.Texture.Dispose(); } } if (dialogSprite != null) { dialogSprite.Dispose(); dialogSprite = null; } if (dialogStateBlock != null) { dialogStateBlock.Dispose(); dialogStateBlock = null; } }
public void Apply() { if (m_stateBlock == null) { m_device.BeginStateBlock(); m_device.SetRenderState(RenderState.CcwStencilZFail, CounterClockwiseStencilDepthBufferFail); m_device.SetRenderState(RenderState.CcwStencilFail, CounterClockwiseStencilFail); m_device.SetRenderState(RenderState.CcwStencilFunc, CounterClockwiseStencilFunction); m_device.SetRenderState(RenderState.CcwStencilPass, CounterClockwiseStencilPass); m_device.SetRenderState(RenderState.ZEnable, DepthBufferEnable); m_device.SetRenderState(RenderState.ZFunc, DepthBufferFunction); m_device.SetRenderState(RenderState.ZWriteEnable, DepthBufferWriteEnable); m_device.SetRenderState(RenderState.StencilRef, ReferenceStencil); m_device.SetRenderState(RenderState.StencilZFail, StencilDepthBufferFail); m_device.SetRenderState(RenderState.StencilEnable, StencilEnable); m_device.SetRenderState(RenderState.StencilFail, StencilFail); m_device.SetRenderState(RenderState.StencilFunc, StencilFunction); m_device.SetRenderState(RenderState.StencilMask, StencilMask); m_device.SetRenderState(RenderState.StencilPass, StencilPass); m_device.SetRenderState(RenderState.StencilWriteMask, StencilWriteMask); m_device.SetRenderState(RenderState.TwoSidedStencilMode, TwoSidedStencilMode); m_stateBlock = m_device.EndStateBlock(); m_instances.Add(this); } m_stateBlock.Apply(); Current = this; }
public override void ResourceLoad() { base.ResourceLoad(); stateBlock = new StateBlock(Device, StateBlockType.All); lineBuffer = new DynamicPrimitiveBuffer9 <ColoredVertex>(Device); }
public void Apply() { if (m_stateBlock == null) { m_device.BeginStateBlock(); m_device.SetRenderState(RenderState.AlphaBlendEnable, true); m_device.SetRenderState(RenderState.AlphaFunc, Compare.Always); m_device.SetRenderState(RenderState.BlendOperationAlpha, AlphaBlendFunction); m_device.SetRenderState(RenderState.DestinationBlendAlpha, AlphaDestinationBlend); m_device.SetRenderState(RenderState.SourceBlendAlpha, AlphaSourceBlend); m_device.SetRenderState(RenderState.BlendFactor, BlendFactor.ToRgba()); m_device.SetRenderState(RenderState.BlendOperation, ColorBlendFunction); m_device.SetRenderState(RenderState.DestinationBlend, ColorDestinationBlend); m_device.SetRenderState(RenderState.SourceBlend, ColorSourceBlend); m_device.SetRenderState(RenderState.ColorWriteEnable, ColorWriteChannels); m_device.SetRenderState(RenderState.ColorWriteEnable1, ColorWriteChannels1); m_device.SetRenderState(RenderState.ColorWriteEnable2, ColorWriteChannels2); m_device.SetRenderState(RenderState.ColorWriteEnable3, ColorWriteChannels3); m_stateBlock = m_device.EndStateBlock(); m_instances.Add(this); } m_stateBlock.Apply(); Current = this; }
private static void SetIconToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature) { if (signature.IsValid) { if (signature.SignatureType == Core.SignatureType.Approval) { signingBlock.AssignIcon(ApprovalTasks.Resources.Sign, StateBlockIconSize.Small); } else { signingBlock.AssignIcon(ApprovalTasks.Resources.Approve, StateBlockIconSize.Small); } } else { if (signature.ValidationErrors.Any(e => e.ErrorType == Sungero.Domain.Shared.SignatureValidationErrorType.Signature)) { signingBlock.AssignIcon(ApprovalReviewAssignments.Resources.SignatureAttributeChanged, StateBlockIconSize.Small); } else { signingBlock.AssignIcon(ApprovalReviewAssignments.Resources.SignedDataChanged, StateBlockIconSize.Small); } } }
private static void AddExternalSignatureInfoToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature, int?versionNumber, IOfficialDocument document) { var subject = Docflow.PublicFunctions.Module.GetSignatureCertificate(signature.GetDataSignature()).SubjectName.Format(true); var parsedSubject = ParseSignatureSubject(subject); signingBlock.AddLabel(ApprovalReviewAssignments.Resources.SignatureBlockFormat(parsedSubject.JobTitle, Docflow.Server.ModuleFunctions.GetCertificateOwnerShortName(parsedSubject), parsedSubject.OrganizationName, parsedSubject.TIN), Functions.Module.CreateHeaderStyle()); signingBlock.AddLineBreak(); signingBlock.AddLabel(Constants.Module.SeparatorText, Docflow.PublicFunctions.Module.CreateSeparatorStyle()); signingBlock.AddLineBreak(); var exchangeServiceName = GetOriginalExchangeServiceNameByDocument(document); signingBlock.AddLabel(ApprovalReviewAssignments.Resources.DocumentSignedByCounterpartyIsExchangeServiceNoteFormat(exchangeServiceName), Docflow.PublicFunctions.Module.CreateNoteStyle()); var number = versionNumber.HasValue ? versionNumber.Value.ToString() : string.Empty; var numberLabel = string.Format("{0} {1}", ApprovalReviewAssignments.Resources.StateViewVersion, number); Functions.Module.AddInfoToRightContent(signingBlock, numberLabel, Docflow.PublicFunctions.Module.CreateNoteStyle()); // Добавить информацию о валидности подписи. AddValidationInfoToBlock(signingBlock, signature); // Установить иконку. signingBlock.AssignIcon(Docflow.ApprovalReviewAssignments.Resources.ExternalSignatureIcon, StateBlockIconSize.Small); signingBlock.DockType = DockType.Bottom; }
/// <summary> /// Установить иконку. /// </summary> /// <param name="block">Блок, для которого требуется установить иконку.</param> /// <param name="assignment">Задание, от которого построен блок.</param> private void SetIcon(StateBlock block, IExchangeDocumentProcessingAssignment assignment) { var iconSize = StateBlockIconSize.Large; // Иконка по умолчанию. block.AssignIcon(StateBlockIconType.OfEntity, iconSize); // Прекращено, остановлено по ошибке. if (assignment.Status == Workflow.AssignmentBase.Status.Aborted || assignment.Status == Workflow.AssignmentBase.Status.Suspended || assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.Abort) { block.AssignIcon(StateBlockIconType.Abort, iconSize); return; } if (assignment.Result == null) { return; } if (assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.Complete || assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.ReAddress) { block.AssignIcon(StateBlockIconType.Completed, iconSize); return; } }
/// <summary> /// Установить иконку. /// </summary> /// <param name="block">Блок, для которого требуется установить иконку.</param> /// <param name="assignment">Задание, от которого построен блок.</param> private void SetIcon(StateBlock block, IVerificationAssignment assignment) { var iconSize = StateBlockIconSize.Large; // Иконка по умолчанию. block.AssignIcon(StateBlockIconType.OfEntity, iconSize); // Прекращено, остановлено по ошибке. if (assignment.Status == Workflow.AssignmentBase.Status.Aborted || assignment.Status == Workflow.AssignmentBase.Status.Suspended) { block.AssignIcon(StateBlockIconType.Abort, iconSize); return; } if (assignment.Result == null) { return; } // Проверено. if (assignment.Result == SmartProcessing.VerificationAssignment.Result.Complete) { block.AssignIcon(StateBlockIconType.Completed, iconSize); return; } // Переадресовано. if (assignment.Result == SmartProcessing.VerificationAssignment.Result.Forward) { block.AssignIcon(Sungero.Docflow.FreeApprovalTasks.Resources.Forward, iconSize); } }
/// <summary> /// Restore the font after a device has been reset /// </summary> public void RestoreDeviceObjects(object sender, EventArgs e) { vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured), MaxNumfontVertices, device, Usage.WriteOnly | Usage.Dynamic, 0, Pool.Default); // Create the state blocks for rendering text for (int which = 0; which < 2; which++) { device.BeginStateBlock(); device.SetTexture(0, fontTexture); if (isZEnable) { renderState.ZBufferEnable = true; } else { renderState.ZBufferEnable = false; } renderState.AlphaBlendEnable = true; renderState.SourceBlend = Blend.SourceAlpha; renderState.DestinationBlend = Blend.InvSourceAlpha; renderState.AlphaTestEnable = true; renderState.ReferenceAlpha = 0x08; renderState.AlphaFunction = Compare.GreaterEqual; renderState.FillMode = FillMode.Solid; renderState.CullMode = Cull.CounterClockwise; renderState.StencilEnable = false; renderState.Clipping = true; device.ClipPlanes.DisableAll(); renderState.VertexBlend = VertexBlend.Disable; renderState.IndexedVertexBlendEnable = false; renderState.FogEnable = false; renderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha; textureState0.ColorOperation = TextureOperation.Modulate; textureState0.ColorArgument1 = TextureArgument.TextureColor; textureState0.ColorArgument2 = TextureArgument.Diffuse; textureState0.AlphaOperation = TextureOperation.Modulate; textureState0.AlphaArgument1 = TextureArgument.TextureColor; textureState0.AlphaArgument2 = TextureArgument.Diffuse; textureState0.TextureCoordinateIndex = 0; textureState0.TextureTransform = TextureTransform.Disable; // REVIEW textureState1.ColorOperation = TextureOperation.Disable; textureState1.AlphaOperation = TextureOperation.Disable; samplerState0.MinFilter = TextureFilter.Point; samplerState0.MagFilter = TextureFilter.Point; samplerState0.MipFilter = TextureFilter.None; if (which == 0) { savedStateBlock = device.EndStateBlock(); } else { drawTextStateBlock = device.EndStateBlock(); } } }
/// <summary> /// Called when the device is lost /// </summary> public virtual void OnLostDevice() { if (state != null) { state.Dispose(); } state = null; }
/// <summary> /// Добавить блок информации о создании поручения по резолюции. /// </summary> /// <param name="parentBlock">Основной блок.</param> /// <param name="startDate">Дата начала текущей итерации рассмотрения.</param> private void AddReviewResolutionBlock(StateBlock parentBlock, DateTime startDate) { var resolutionAssignment = ReviewResolutionAssignments.GetAll() .Where(a => Equals(a.Task, _obj) && a.Created >= startDate) .OrderByDescending(a => a.Created) .FirstOrDefault(); this.AddAssignmentBlock(parentBlock, resolutionAssignment, DocumentReviewTasks.Resources.StateViewSendActionItemOnResolution, string.Empty); }
public BaseGUI() { stateBlock = new StateBlock(); colorBlock = new GUIColorBlock(); labelWidthBlock = new LabelWidthBlock(); contentColorBlock = new ContentColorBlock(); indentBlock = new IndentBlock(this); ScrollView = new ScrollViewBlock(this); }
private static void AddSignatureInfoToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature, int?versionNumber) { // Добавить подписавшего. var signatory = Sungero.Company.Employees.As(signature.Signatory); if (signatory != null) { signingBlock.AddLabel(string.Format("{0} {1}", signatory.JobTitle, Company.PublicFunctions.Employee.GetShortName(signatory, false)), Functions.Module.CreateHeaderStyle()); } else { signingBlock.AddLabel(signature.Signatory.Name, Functions.Module.CreateHeaderStyle()); } // Добавить дату подписания. var signDate = signature.SigningDate.FromUtcTime().ToUserTime(); signingBlock.AddLabel(string.Format("{0}: {1}", OfficialDocuments.Resources.StateViewDate.ToString(), Functions.Module.ToShortDateShortTime(signDate)), Functions.Module.CreatePerformerDeadlineStyle()); // Добавить замещаемого. var substitutedUser = GetSubstitutedEmployee(signature); if (!string.IsNullOrEmpty(substitutedUser)) { signingBlock.AddLineBreak(); signingBlock.AddLabel(substitutedUser); } // Добавить комментарий пользователя. var comment = GetSignatureComment(signature); if (!string.IsNullOrEmpty(comment)) { signingBlock.AddLineBreak(); signingBlock.AddLabel(Constants.Module.SeparatorText, Docflow.PublicFunctions.Module.CreateSeparatorStyle()); signingBlock.AddLineBreak(); var commentStyle = Functions.Module.CreateNoteStyle(); signingBlock.AddLabel(comment, commentStyle); } // Добавить номер версии документа. var number = versionNumber.HasValue ? versionNumber.Value.ToString() : string.Empty; var numberLabel = string.Format("{0} {1}", ApprovalReviewAssignments.Resources.StateViewVersion, number); Functions.Module.AddInfoToRightContent(signingBlock, numberLabel, Docflow.PublicFunctions.Module.CreateNoteStyle()); // Добавить информацию о валидности подписи. AddValidationInfoToBlock(signingBlock, signature); // Установить иконку. SetIconToBlock(signingBlock, signature); }
public BumpedState(StateBlock block, BlockState nextState) { this.position = block.PositionInGame; this.block = block; this.nextState = nextState; this.movingUp = true; this.totalYChange = 0; this.originalY = this.position.Y; }
public void Render() //渲染 { if (device == null) //如果device为空则不渲染 { return; } if (pause) //如果窗口被切换或者最小化则停止渲染,减少CPU压力 { return; } Matrix viewMatrix = Matrix.LookAtLH(CamPostion, CamTarget, new Vector3(0, 1, 0)); device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 0.3f, 500f); device.Transform.View = viewMatrix; device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkSlateBlue, 1.0f, 0); //清除windows界面为深蓝色 device.BeginScene(); //在此添加渲染图形代码 device.RenderState.CullMode = Cull.None; device.RenderState.FillMode = FillMode.Solid; device.RenderState.Lighting = false; device.SetTexture(0, texture);//设置贴图 device.VertexFormat = CustomVertex.PositionTextured.Format; device.SetStreamSource(0, vertexBuffer, 0); device.Indices = indexBuffer; device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, (xCount + 1) * (yCount + 1), 0, indices.Length / 3); device.Transform.World = Matrix.Translation(0.0f, 0.0f, 0.0f); //底部世界变换 device.Material = bottomMaterial; //底部使用的材质 StateBlock sb = new StateBlock(device, StateBlockType.All); sb.Capture();//将device以前的设置保存到sb device.RenderState.DiffuseMaterialSource = ColorSource.Material; device.RenderState.AlphaBlendEnable = true; device.SetTexture(0, bottomTexture); device.TextureState[0].ColorOperation = TextureOperation.Modulate; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; device.TextureState[0].AlphaOperation = TextureOperation.Modulate; device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; device.RenderState.SourceBlend = Blend.SourceColor; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; device.SetStreamSource(0, bottomVertexBuffer, 0); device.VertexFormat = CustomVertex.PositionNormalTextured.Format; device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); sb.Apply(); device.EndScene(); device.Present(); }
protected void InitializeDeviceObjects() { SetupDevice(); SetupMatrices(); SetupLights(); initState = new StateBlock(engine.Device, StateBlockType.All); foreach (IRenderable o in objects) { o.InitDevice(engine.Device, false); } }
/// <summary> /// Добавить блок с заданием. /// </summary> /// <param name="parentBlock">Основной блок.</param> /// <param name="assignment">Задание.</param> /// <param name="header">Заголовок блока.</param> /// <param name="result">Результат выполнения задания.</param> private void AddAssignmentBlock(StateBlock parentBlock, IAssignment assignment, string header, string result) { if (assignment != null && (assignment.Status != Workflow.AssignmentBase.Status.Completed || !string.IsNullOrEmpty(result))) { var isDraft = _obj.Status == Workflow.Task.Status.Draft; var labelStyle = Docflow.PublicFunctions.Module.CreateStyle(false, isDraft, false); parentBlock.IsExpanded = true; var block = parentBlock.AddChildBlock(); block.Entity = assignment; block.AssignIcon(StateBlockIconType.OfEntity, StateBlockIconSize.Large); if (assignment.Status == Workflow.AssignmentBase.Status.InProcess && assignment.IsRead == false) { Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewUnRead); } else { this.AddAssignmentStatusInfoToRight(block, labelStyle, assignment); } var headerStyle = Docflow.PublicFunctions.Module.CreateHeaderStyle(isDraft); var performerStyle = Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle(isDraft); block.AddLabel(header, headerStyle); block.AddLineBreak(); var resolutionPerformerName = Employees.Is(assignment.Performer) ? Company.PublicFunctions.Employee.GetShortName(Employees.As(assignment.Performer), false) : assignment.Performer.Name; block.AddLabel(string.Format("{0}: {1} {2}: {3}", Docflow.OfficialDocuments.Resources.StateViewTo, resolutionPerformerName, Docflow.OfficialDocuments.Resources.StateViewDeadline, Docflow.PublicFunctions.Module.ToShortDateShortTime(assignment.Deadline.Value.ToUserTime())), performerStyle); if (!string.IsNullOrEmpty(result)) { var separatorStyle = Docflow.PublicFunctions.Module.CreateSeparatorStyle(); block.AddLineBreak(); block.AddLabel(Docflow.Constants.Module.SeparatorText, separatorStyle); block.AddLineBreak(); block.AddEmptyLine(Docflow.Constants.Module.EmptyLineMargin); block.AddLabel(result); } else { Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, assignment.Deadline.Value, assignment.Performer); } } }
/// <summary> /// Добавить блок информации о подготовке проекта резолюции. /// </summary> /// <param name="parentBlock">Основной блок.</param> /// <param name="startDate">Дата начала текущей итерации рассмотрения.</param> private void AddPreraringDraftResolutionBlock(StateBlock parentBlock, DateTime startDate) { var resolutionAssignment = this.GetPreparingDraftResolutionAssignment(startDate); var result = string.Empty; if (this.GetManagerAssignment(startDate) == null && resolutionAssignment != null && resolutionAssignment.Status == Workflow.AssignmentBase.Status.Completed && resolutionAssignment.Result != RecordManagement.PreparingDraftResolutionAssignment.Result.AddAssignment) { result = Docflow.PublicFunctions.Module.GetFormatedUserText(resolutionAssignment.Texts.Last().Body); } this.AddAssignmentBlock(parentBlock, resolutionAssignment, DocumentReviewTasks.Resources.PreparingDraftResolution, result); }
/// <summary> /// Called when the device is reset /// </summary> public void OnResetDevice(Device device) { foreach (FontNode fn in fontCache) { fn.Font.OnResetDevice(); } if (dialogSprite != null) { dialogSprite.OnResetDevice(); } // Create new state block dialogStateBlock = new StateBlock(device, StateBlockType.All); }
/// <summary> /// Добавить статус выполнения задания. /// </summary> /// <param name="block">Блок.</param> /// <param name="style">Стиль.</param> /// <param name="assignment">Задание.</param> private void AddAssignmentStatusInfoToRight(StateBlock block, Sungero.Core.StateBlockLabelStyle style, IAssignment assignment) { // Добавить колонку справа, если всего одна колонка (main). var rightContent = block.Contents.LastOrDefault(); if (block.Contents.Count() <= 1) { rightContent = block.AddContent(); } else { rightContent.AddLineBreak(); } rightContent.AddLabel(Assignments.Info.Properties.Status.GetLocalizedValue(assignment.Status), style); }
public override void ResourceUnload() { base.ResourceUnload(); if (stateBlock != null) { stateBlock.Dispose(); stateBlock = null; } if (lineBuffer != null) { lineBuffer.Dispose(); lineBuffer = null; } }
protected override void Initialize() { content = new ContentManager(Services, "Content"); // Load all trees in the Content/Trees folder string[] files = Directory.GetFiles("Content/Trees", "*.xnb", SearchOption.TopDirectoryOnly); foreach (string filename in files) { string assetName = filename.Substring("Content/".Length, filename.Length - "Content/.xnb".Length); Profiles.Add(content.Load <TreeProfile>(assetName)); ProfileNames.Add(Path.GetFileName(assetName)); } profileIndex = 0; // Create the wind animator wind = new WindStrengthSin(); animator = new TreeWindAnimator(wind); // Create the ground plane and an effect for it groundPlane = new Quad(GraphicsDevice, 10000, 10000); groundEffect = new BasicEffect(GraphicsDevice, new EffectPool()); groundEffect.Texture = content.Load <Texture2D>("Textures/Grass"); groundEffect.TextureEnabled = true; // Create a camera Camera = new Camera(); Camera.Position = new Vector3(4000, 4000, 4000); Camera.Target = new Vector3(0, 2000, 0); Camera.AspectRatio = GraphicsDevice.Viewport.Width / (float)GraphicsDevice.Viewport.Height; CameraOrbitAngle = 0.0f; CameraPitchAngle = -10.0f; CameraDistance = 5000.0f; // Enable mipmaps GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Linear; // Store the initial renderstate block = new StateBlock(GraphicsDevice); block.Capture(); Initialized = true; UpdateTree(); Application.Idle += new EventHandler(Application_Idle); }
/// <summary> /// Called when the device has been reset. /// </summary> public void OnResetDevice() { _fontCache.ForEach(node => node.Font.OnResetDevice()); if (Sprite != null) { Sprite.OnResetDevice(); } // Create new state block StateBlock = new StateBlock(Engine.Device, StateBlockType.All); // Reposition the message box according to the new Viewport MessageBox.Location = new Point( (Engine.RenderSize.Width - MessageBox.Width) / 2, (Engine.RenderSize.Height - MessageBox.Height) / 2); }
/// <summary> /// Initializes a new instance of the <see cref="UserInterfaceRenderer9"/> class. /// </summary> /// <param name="device">The device.</param> /// <param name="width">The width of the renderable area.</param> /// <param name="height">The height of the renderable area.</param> public UserInterfaceRenderer9(Device device, int width, int height) { if (device == null) throw new ArgumentNullException("device"); if (width < 0) throw new ArgumentException("Value must be positive.", "width"); if (height < 0) throw new ArgumentException("Value must be positive.", "height"); this.device = device; halfWidth = width / 2; halfHeight = height / 2; font = new Font(device, 18, 0, FontWeight.Bold, 0, false, CharacterSet.Default, Precision.Default, FontQuality.Antialiased, PitchAndFamily.Default, "Arial"); lineBuffer = new DynamicPrimitiveBuffer9<ColoredVertex>(device); stateBlock = new StateBlock(device, StateBlockType.All); }
public void Render() //渲染方法,本方法没有任何渲染代码,可认为是渲染方法的框架 { if (device == null) //如果未建立设备对象,退出 { return; } device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.WhiteSmoke, 1.0f, 0); device.BeginScene(); //开始渲染 //下句设置上方茶壶的世界变换矩阵 device.Transform.World = Matrix.RotationYawPitchRoll(angleY, angleY, 0) //茶壶旋转 * Matrix.Translation(0.0f, 1.5f, 5.0f); //世界变换,y=0平面上方1.5f绘制茶壶 device.Material = meshMaterials; mesh.DrawSubset(0); //绘制上方的茶壶 //设置倒影茶壶世界变换矩阵,Matrix.Scaling(1,-1,1)将3D物体的Y轴坐标*(-1) //Matrix.Translation(0.0f, -1.5f, 5.0f),表示y=0平面下方1.5f绘制茶壶 device.Transform.World = Matrix.RotationYawPitchRoll(angleY, angleY, 0) * //茶壶旋转 Matrix.Scaling(1, -1, 1) * Matrix.Translation(0.0f, -1.5f, 5.0f); device.Lights[0].Direction = new Vector3(0, 1, 4); //灯光方向从(0,0,0)到(0,1,4) device.RenderState.CullMode = Cull.Clockwise; //只绘制逆时针三角形 mesh.DrawSubset(0); //绘制下边的茶壶 device.Lights[0].Direction = new Vector3(0, -1, 4); //恢复灯光方向 device.RenderState.CullMode = Cull.CounterClockwise; //恢复背面剔除 device.Transform.World = Matrix.Translation(0.0f, 0.0f, 0.0f); //世界变换 device.Material = mtr; //地板使用的材质 StateBlock sb = new StateBlock(device, StateBlockType.All); sb.Capture();//使用sb保存设置会降低运行速度,不建议使用,可采用使用后逐项恢复的方法 device.RenderState.DiffuseMaterialSource = ColorSource.Material; device.RenderState.AlphaBlendEnable = true; device.SetTexture(0, texture); device.TextureState[0].ColorOperation = TextureOperation.Modulate; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; device.TextureState[0].AlphaOperation = TextureOperation.Modulate; device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; device.RenderState.SourceBlend = Blend.SourceColor; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; device.SetStreamSource(0, vertexBuffer, 0); device.VertexFormat = CustomVertex.PositionNormalTextured.Format; device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); sb.Apply(); device.EndScene(); //渲染结束 device.Present(); //更新显示区域,把后备缓存的3D图形送到图形卡的屏幕显示区中显示 }
/// <summary> /// Called when the device is reset /// </summary> public void OnResetDevice() { SurfaceDescription desc = parent.BackBufferSurfaceDescription; // Set up the dialog dialog.SetLocation(0, 0); dialog.SetSize(desc.Width, desc.Height); dialog.SetBackgroundColors(new ColorValue((float)98 / 255, (float)138 / 255, (float)206 / 255), new ColorValue((float)54 / 255, (float)105 / 255, (float)192 / 255), new ColorValue((float)54 / 255, (float)105 / 255, (float)192 / 255), new ColorValue((float)10 / 255, (float)73 / 255, (float)179 / 255)); Device device = parent.Device; device.BeginStateBlock(); device.RenderState.FillMode = FillMode.Solid; state = device.EndStateBlock(); }
public void Apply() { if (m_stateBlock == null) { m_device.BeginStateBlock(); m_device.SetRenderState(RenderState.CullMode, CullMode); m_device.SetRenderState(RenderState.DepthBias, DepthBias); m_device.SetRenderState(RenderState.FillMode, FillMode); m_device.SetRenderState(RenderState.MultisampleAntialias, MultiSampleAntiAlias); m_device.SetRenderState(RenderState.ScissorTestEnable, ScissorTestEnable); m_device.SetRenderState(RenderState.SlopeScaleDepthBias, SlopeScaleDepthBias); m_stateBlock = m_device.EndStateBlock(); m_instances.Add(this); } m_stateBlock.Apply(); Current = this; }
private Result EndStateBlock(IntPtr devicePointer, [In, Out] StateBlock stateBlock) { try { this.Log.LogMethodSignatureTypesAndValues(devicePointer, stateBlock); this.GetOrCreateDevice(devicePointer); stateBlock = this.Device.EndStateBlock(); return(Result.Ok); } catch (SharpDXException ex) { Log.Warn(ex); return(ex.ResultCode); } catch (Exception ex) { this.Log.Fatal(ex); return(Result.UnexpectedFailure); } }
/// <summary> /// Clear any resources that need to be lost /// </summary> public void OnLostDevice() { foreach (FontNode fn in fontCache) { if ((fn.Font != null) && (!fn.Font.Disposed)) { fn.Font.OnLostDevice(); } } if (dialogSprite != null) { dialogSprite.OnLostDevice(); } if (dialogStateBlock != null) { dialogStateBlock.Dispose(); dialogStateBlock = null; } }
private static void AddValidationInfoToBlock(StateBlock block, Sungero.Domain.Shared.ISignature signature) { var redTextStyle = Functions.Module.CreateStyle(Sungero.Core.Colors.Common.Red); var greenTextStyle = Functions.Module.CreateStyle(Sungero.Core.Colors.Common.Green); var separator = ". "; var errorValidationText = string.Empty; var validationInfo = GetValidationInfo(signature); if (validationInfo.IsInvalidCertificate) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewCertificateIsNotValid + separator; } if (validationInfo.IsInvalidData) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewDocumentIsChanged + separator; } if (validationInfo.IsInvalidAttributes) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewSignatureAttributesNotValid + separator; } // Если нет ошибок - выйти. if (string.IsNullOrWhiteSpace(errorValidationText)) { return; } block.AddLineBreak(); block.AddLabel(errorValidationText, redTextStyle); // Для подписи с невалидными атрибутами добавить информацию, что тело небыло изменено. if (validationInfo.IsInvalidAttributes && !validationInfo.IsInvalidData) { var trueValidationText = ApprovalReviewAssignments.Resources.StateViewDocumentIsValid + separator; block.AddLabel(trueValidationText, greenTextStyle); } }
/// <summary> /// Called when the device is reset /// </summary> public void OnResetDevice(Device device) { foreach(FontNode fn in fontCache) fn.Font.OnResetDevice(); if (dialogSprite != null) dialogSprite.OnResetDevice(); // Create new state block dialogStateBlock = new StateBlock(device, StateBlockType.All); }
/// <summary> /// Clear any resources that need to be lost /// </summary> public void OnLostDevice() { foreach(FontNode fn in fontCache) { if ( (fn.Font != null) && (!fn.Font.Disposed) ) fn.Font.OnLostDevice(); } if (dialogSprite != null) dialogSprite.OnLostDevice(); if (dialogStateBlock != null) { dialogStateBlock.Dispose(); dialogStateBlock = null; } }
/// <summary> /// Destroy any resources and clear the caches /// </summary> public void OnDestroyDevice() { foreach(FontNode fn in fontCache) fn.Font.Dispose(); foreach(TextureNode tn in textureCache) tn.Texture.Dispose(); if (dialogSprite != null) { dialogSprite.Dispose(); dialogSprite = null; } if (dialogStateBlock != null) { dialogStateBlock.Dispose(); dialogStateBlock = null; } }
/// <summary>Do not allow creation</summary> private DialogResourceManager() { device = null; dialogSprite = null; dialogStateBlock = null; }
private void pn3D_DeviceReset( object sender, EventArgs e ) { Device dev = pn3D.Device; depthTex1 = new Texture( dev, pn3D.ClientSize.Width, pn3D.ClientSize.Height, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default ); depthTex2 = new Texture( dev, pn3D.ClientSize.Width, pn3D.ClientSize.Height, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default ); defState = new StateBlock( dev, StateBlockType.All ); defState.Capture(); }
void DirectX_OnCreateDevice() { DisposeReferences(); device_ptr = detour.Direct3DDevice9; Device = Device.FromPointer(device_ptr); state_old = new StateBlock(Device, StateBlockType.All); vb_cube = new VertexBuffer(Device, Marshal.SizeOf(typeof(Vector3)) * 3 * 12, Usage.WriteOnly, VertexFormat.None, Pool.Managed); vb_cube.Lock(0, 0, LockFlags.None).WriteRange(new[] { new Vector3(-1f, -1f, -1f), // front new Vector3(+1f, -1f, -1f), new Vector3(+1f, -1f, +1f), new Vector3(+1f, -1f, +1f), new Vector3(-1f, -1f, +1f), new Vector3(-1f, -1f, -1f), new Vector3(-1f, +1f, -1f), // back new Vector3(+1f, +1f, -1f), new Vector3(+1f, +1f, +1f), new Vector3(+1f, +1f, +1f), new Vector3(-1f, +1f, +1f), new Vector3(-1f, +1f, -1f), new Vector3(-1f, -1f, -1f), // left new Vector3(-1f, -1f, +1f), new Vector3(-1f, +1f, +1f), new Vector3(-1f, +1f, +1f), new Vector3(-1f, +1f, -1f), new Vector3(-1f, -1f, -1f), new Vector3(+1f, -1f, -1f), // right new Vector3(+1f, -1f, +1f), new Vector3(+1f, +1f, +1f), new Vector3(+1f, +1f, +1f), new Vector3(+1f, +1f, -1f), new Vector3(+1f, -1f, -1f), new Vector3(-1f, -1f, -1f), // top new Vector3(+1f, -1f, -1f), new Vector3(+1f, +1f, -1f), new Vector3(+1f, +1f, -1f), new Vector3(-1f, +1f, -1f), new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, +1f), // bottom new Vector3(+1f, -1f, +1f), new Vector3(+1f, +1f, +1f), new Vector3(+1f, +1f, +1f), new Vector3(-1f, +1f, +1f), new Vector3(-1f, -1f, +1f) }); vb_cube.Unlock(); var vertexElems = new[] { new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), //new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), VertexElement.VertexDeclarationEnd }; vert_decl_nocolor = new VertexDeclaration(Device, vertexElems); Font = new Font(Device, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 14)); }
/// <summary> /// Restore the font after a device has been reset /// </summary> public void RestoreDeviceObjects(object sender, EventArgs e) { vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured), MaxNumfontVertices, device, Usage.WriteOnly | Usage.Dynamic, 0, Pool.Default); Surface surf = device.GetRenderTarget( 0 ); bool bSupportsAlphaBlend = Manager.CheckDeviceFormat(device.DeviceCaps.AdapterOrdinal, device.DeviceCaps.DeviceType, device.DisplayMode.Format, Usage.RenderTarget | Usage.QueryPostPixelShaderBlending, ResourceType.Surface, surf.Description.Format ); // Create the state blocks for rendering text for (int which=0; which < 2; which++) { device.BeginStateBlock(); device.SetTexture(0, fontTexture); if (isZEnable) renderState.ZBufferEnable = true; else renderState.ZBufferEnable = false; if( bSupportsAlphaBlend ) { renderState.AlphaBlendEnable = true; renderState.SourceBlend = Blend.SourceAlpha; renderState.DestinationBlend = Blend.InvSourceAlpha; } else { renderState.AlphaBlendEnable = false; } renderState.AlphaTestEnable = true; renderState.ReferenceAlpha = 0x08; renderState.AlphaFunction = Compare.GreaterEqual; renderState.FillMode = FillMode.Solid; renderState.CullMode = Cull.CounterClockwise; renderState.StencilEnable = false; renderState.Clipping = true; device.ClipPlanes.DisableAll(); renderState.VertexBlend = VertexBlend.Disable; renderState.IndexedVertexBlendEnable = false; renderState.FogEnable = false; renderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha; textureState0.ColorOperation = TextureOperation.Modulate; textureState0.ColorArgument1 = TextureArgument.TextureColor; textureState0.ColorArgument2 = TextureArgument.Diffuse; textureState0.AlphaOperation = TextureOperation.Modulate; textureState0.AlphaArgument1 = TextureArgument.TextureColor; textureState0.AlphaArgument2 = TextureArgument.Diffuse; textureState0.TextureCoordinateIndex = 0; textureState0.TextureTransform = TextureTransform.Disable; // REVIEW textureState1.ColorOperation = TextureOperation.Disable; textureState1.AlphaOperation = TextureOperation.Disable; samplerState0.MinFilter = TextureFilter.Point; samplerState0.MagFilter = TextureFilter.Point; samplerState0.MipFilter = TextureFilter.None; if (which==0) savedStateBlock = device.EndStateBlock(); else drawTextStateBlock = device.EndStateBlock(); } }
void DisposeReferences() { if (Device != null) { Device.Dispose(); state_old.Dispose(); vb_cube.Dispose(); vert_decl_nocolor.Dispose(); Font.Dispose(); Device = null; vert_decl_nocolor = null; vb_cube = null; state_old = null; Font = null; } }
/// <summary> /// Called when the device is reset /// </summary> public void OnResetDevice() { SurfaceDescription desc = parent.BackBufferSurfaceDescription; // Set up the dialog dialog.SetLocation(0, 0); dialog.SetSize(desc.Width, desc.Height); dialog.SetBackgroundColors(new ColorValue((float)98/255, (float)138/255, (float)206/255), new ColorValue((float)54/255, (float)105/255, (float)192/255), new ColorValue((float)54/255, (float)105/255, (float)192/255), new ColorValue((float)10/255, (float)73/255, (float)179/255) ); Device device = parent.Device; device.BeginStateBlock(); device.RenderState.FillMode = FillMode.Solid; state = device.EndStateBlock(); }
/// <summary> /// Called when the device is lost /// </summary> public void OnLostDevice() { if (state != null) state.Dispose(); state = null; }
private void pn3D_DeviceReset( object sender, EventArgs e ) { Device dev = pn3D.Device; dev.RenderState.ColorVertex = false; dev.RenderState.SourceBlend = Blend.SourceAlpha; dev.RenderState.DestinationBlend = Blend.InvSourceAlpha; dev.SamplerState[0].MagFilter = TextureFilter.Anisotropic; dev.SamplerState[0].MinFilter = TextureFilter.Linear; dev.SamplerState[0].MipFilter = TextureFilter.Linear; dev.SamplerState[0].MaxAnisotropy = 4; dev.SamplerState[1].MagFilter = TextureFilter.Anisotropic; dev.SamplerState[1].MinFilter = TextureFilter.Linear; dev.SamplerState[1].MipFilter = TextureFilter.Linear; dev.SamplerState[1].MaxAnisotropy = 4; defState = new StateBlock( dev, StateBlockType.All ); defState.Capture(); SelectionChanged(); //force a refresh of anything that depends on this }