void DrawFluentSwitchBackground(ICanvas canvas, RectangleF dirtyRect) { canvas.SaveState(); if (IsEnabled) { if (IsToggled) { canvas.FillColor = OnColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary); } else { canvas.FillColor = BackgroundColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary); } } else { canvas.FillColor = ColorHelper.GetGraphicsColor(Fluent.Color.Background.NeutralLighter, Fluent.Color.Background.NeutralDark); } var x = dirtyRect.X; var y = dirtyRect.Y; var height = 20; var width = FluentSwitchBackgroundWidth; canvas.FillRoundedRectangle(x, y, width, height, 10); canvas.RestoreState(); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { if (null != m_brep) { MRhinoViewport vp = dp.GetRhinoVP(); OnColor saved_color = vp.SetDrawColor(RhUtil.RhinoApp().AppSettings().TrackingColor()); for (int i = 0; i < m_points.Count(); i++) { if (i % 100 == 0 && vp.InterruptDrawing()) { break; } On3dPoint pt = m_points[i]; On3dVector dir = new On3dVector(m_normals[i]); if (m_bFlip) { dir.Reverse(); } vp.DrawDirectionArrow(pt, dir); } vp.SetDrawColor(saved_color); } } return(true); }
void DrawMaterialSwitchBackground(ICanvas canvas, RectangleF dirtyRect) { canvas.SaveState(); if (IsToggled) { canvas.FillColor = OnColor.ToGraphicsColor(Material.Color.LightBlue); canvas.Alpha = 0.5f; } else { canvas.FillColor = BackgroundColor.ToGraphicsColor(Material.Color.Gray2); canvas.Alpha = 1.0f; } var margin = MaterialSwitchBackgroundMargin; var x = dirtyRect.X + margin; var y = dirtyRect.Y + margin; var height = 14; var width = MaterialSwitchBackgroundWidth; canvas.FillRoundedRectangle(x, y, width, height, 10); canvas.RestoreState(); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOBJECT) { if (null != m_pChannelAttrs.m_pObject) { if (m_pChannelAttrs.m_pObject.m_runtime_object_serial_number == m_runtime_object_serial_number) { if (null == m_mesh_face_colors) { IRhinoMeshObject mesh_object = MRhinoMeshObject.ConstCast(m_pChannelAttrs.m_pObject); if (null != mesh_object) { int mesh_face_count = mesh_object.Mesh().FaceCount(); m_mesh_face_colors = new ArrayOnColor(mesh_face_count); for (int i = 0; i < mesh_face_count; i++) { OnColor color = new OnColor(m_random.Next(0, 255), m_random.Next(0, 255), m_random.Next(0, 255)); m_mesh_face_colors.Append(color); } } } if (null != m_mesh_face_colors) { m_pChannelAttrs.m_bDrawObject = false; MDisplayPipelineAttributes da = new MDisplayPipelineAttributes(); da.m_bShadeSurface = true; da.m_pMaterial.m_FrontMaterial.SetTransparency(0.0); da.m_pMaterial.m_BackMaterial.SetTransparency(0.0); da.m_pMaterial.m_FrontMaterial.m_bFlatShaded = true; da.m_pMaterial.m_BackMaterial.m_bFlatShaded = true; dp.EnableDepthWriting(true); if (da.m_bCullBackfaces) { dp.PushCullFaceMode(1); } for (int i = 0; i < m_mesh_face_colors.Count(); i++) { da.m_pMaterial.m_FrontMaterial.m_diffuse = m_mesh_face_colors[i]; da.m_pMaterial.m_BackMaterial.m_diffuse = m_mesh_face_colors[i]; dp.DrawFace(m_pChannelAttrs.m_pObject, i, da); } if (da.m_bCullBackfaces) { dp.PopCullFaceMode(); } } } } } return(true); }
OnColor FalseColor(double z) { // Simple example of one way to change a number into a color. double s = m_z_range.NormalizedParameterAt(z); if (s < 0.0) { s = 0.0; } else if (s > 1.0) { s = 1.0; } double hue = m_hue_range.ParameterAt(s); OnColor color = new OnColor(); color.SetHSV(hue, 1.0, 1.0); return(color); }
/// <summary> /// MRhinoVisualAnalysisMode override /// </summary> public override void UpdateVertexColors(IRhinoObject obj, OnMesh[] meshes) { // Rhino calls this function when it is time for you // to set the false colors on the analysis mesh vertices. // For breps, there is one mesh per face. For mesh objects, // there is a single mesh. int count = meshes.Length; if (count > 0) { // A "mapping tag" is used to determine if the colors need to be set OnMappingTag mt = MappingTag(); for (int mi = 0; mi < count; mi++) { OnMesh mesh = meshes[mi]; if (null != mesh && 0 != mt.Compare(mesh.m_Ctag)) { // The mesh's mapping tag is different from ours. Either // the mesh has no false colors, has false colors set by // another analysis mode, has false colors set using // different m_z_range[]/m_hue_range[] values, or the // mesh has been moved. In any case, we need to set // the false colors to the ones we want. int vcount = mesh.m_V.Count(); ArrayOnColor vertex_colors = mesh.m_C; vertex_colors.SetCount(0); // in case something else had set the colors vertex_colors.Reserve(vcount); // for efficiency for (int vi = 0; vi < vcount; vi++) { double z = mesh.m_V[vi].z; OnColor color = FalseColor(z); vertex_colors.Append(color); } // set the mesh's color tag mesh.m_Ctag = mt; } } } }
void DrawCupertinoSwitchBackground(ICanvas canvas, RectangleF dirtyRect) { canvas.SaveState(); var x = dirtyRect.X; var y = dirtyRect.Y; if (IsToggled) { canvas.FillColor = OnColor.ToGraphicsColor(Cupertino.Color.SystemColor.Light.Green, Cupertino.Color.SystemColor.Dark.Green); } else { canvas.FillColor = BackgroundColor.ToGraphicsColor(Cupertino.Color.SystemGray.Light.Gray4, Cupertino.Color.SystemGray.Dark.Gray4); } var height = 30; var width = CupertinoSwitchBackgroundWidth; canvas.FillRoundedRectangle(x, y, width, height, 36.5f); canvas.RestoreState(); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOBJECT) { if (null != m_pChannelAttrs.m_pObject) { if (m_pChannelAttrs.m_pObject.m_runtime_object_serial_number == m_runtime_object_serial_number) { if (null == m_mesh_face_colors) { IRhinoMeshObject mesh_object = MRhinoMeshObject.ConstCast(m_pChannelAttrs.m_pObject); if (null != mesh_object) { int mesh_face_count = mesh_object.Mesh().FaceCount(); m_mesh_face_colors = new ArrayOnColor(mesh_face_count); for (int i = 0; i < mesh_face_count; i++) { OnColor color = new OnColor(m_random.Next(0, 255), m_random.Next(0, 255), m_random.Next(0, 255)); m_mesh_face_colors.Append(color); } } } if (null != m_mesh_face_colors) { m_pChannelAttrs.m_bDrawObject = false; MDisplayPipelineAttributes da = new MDisplayPipelineAttributes(); da.m_bShadeSurface = true; da.m_pMaterial.m_FrontMaterial.SetTransparency(0.0); da.m_pMaterial.m_BackMaterial.SetTransparency(0.0); da.m_pMaterial.m_FrontMaterial.m_bFlatShaded = true; da.m_pMaterial.m_BackMaterial.m_bFlatShaded = true; dp.EnableDepthWriting(true); if (da.m_bCullBackfaces) dp.PushCullFaceMode(1); for (int i = 0; i < m_mesh_face_colors.Count(); i++) { da.m_pMaterial.m_FrontMaterial.m_diffuse = m_mesh_face_colors[i]; da.m_pMaterial.m_BackMaterial.m_diffuse = m_mesh_face_colors[i]; dp.DrawFace(m_pChannelAttrs.m_pObject, i, da); } if (da.m_bCullBackfaces) dp.PopCullFaceMode(); } } } } return true; }
OnColor FalseColor(double z) { // Simple example of one way to change a number into a color. double s = m_z_range.NormalizedParameterAt(z); if (s < 0.0) s = 0.0; else if (s > 1.0) s = 1.0; double hue = m_hue_range.ParameterAt(s); OnColor color = new OnColor(); color.SetHSV(hue, 1.0, 1.0); return color; }
public void RpcChangePlayerColor(Color color) { OnColor?.Invoke(playerInfo, color); }