public void AnimateShowForm(string caption, int x, int y, Stencil stencil) { if (stencil.rgImages.Count > 0) { this.Left = x; this.Top = y; this.Width = 204; this.Height = ((int)Math.Ceiling((float)(stencil.rgImages.Count / 5.0))) * 40 + 3 + this.Font.Height; this.m_caption = caption; this.m_stencil = stencil; this.m_MouseX = 0; this.m_MouseY = 0; if (this.Bottom > Screen.PrimaryScreen.Bounds.Bottom) { this.Top = Screen.PrimaryScreen.Bounds.Bottom - this.Height; } if (this.Right > Screen.PrimaryScreen.Bounds.Right) { this.Left = Screen.PrimaryScreen.Bounds.Right - this.Width; } this.Refresh(); if (this.HideOnDeactivated) { this.Activate(); } } else { HideForm(); } }
public void TestNoneSingletons() { var options = new Options { UseSingletons = false }; options.Assemblies.Add(typeof(StencilTest).Assembly); var stencil = new Stencil(); stencil.Initilize(options); var one = stencil.Resolve<IBar>(); var two = stencil.Resolve<IBar>(); Assert.AreNotEqual(one, two); }
public FloatSelectionForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.Left = 0; this.Top = 0; this.Width = 0; this.Height = 0; this.m_caption = ""; this.m_stencil = null; this.HideOnDeactivated = false; this.TemplateSelected = null; }
public void InitializeStencil(Stencil stencil) { ListViewItem item; lvStencil.Items.Clear(); imgsStencil.Images.Clear(); for (int i = 0; i < stencil.rgImages.Count; i++) { imgsStencil.Images.Add((Image)stencil.rgImages[i]); item = new ListViewItem(); item.Text = stencil.rgTemplates[i].id; item.Tag = stencil.rgTemplates[i]; item.ImageIndex = i; lvStencil.Items.Add(item); } m_stencil = stencil; }
/// <summary> /// Configures the rendering pipeline. /// </summary> /// <param name="cull">The polygon culling options.</param> /// <param name="depth">The depth processing options.</param> /// <param name="stencil">The stenciling mode.</param> /// <param name="blend">The blending mode.</param> public static void Use(Cull cull, Depth depth, Stencil stencil, Blend blend) { if (gl.HasPendingPops) { throw new InvalidOperationException("Cannot change GPU state while the attribute stack is active."); } if (currentCull != cull) { if (cull == Cull.None) { gl.Disable(GL.CULL_FACE); } else { gl.Enable(GL.CULL_FACE); switch (cull) { case Cull.Front: gl.CullFace(GL.FRONT); break; case Cull.Back: gl.CullFace(GL.BACK); break; case Cull.Front | Cull.Back: gl.CullFace(GL.FRONT_AND_BACK); break; } } currentCull = cull; } if (currentDepth != depth) { if (depth == Depth.None) { gl.Disable(GL.DEPTH_TEST); } else { gl.Enable(GL.DEPTH_TEST); if ((depth & Depth.Test) == Depth.Test) { if ((depth & Depth.TestReversed) == Depth.TestReversed) { gl.DepthFunc(GL.GREATER); } else { gl.DepthFunc(GL.LEQUAL); } } else { gl.DepthFunc(GL.ALWAYS); } if ((depth & Depth.Write) == Depth.Write) { gl.DepthMask(true); } else { gl.DepthMask(false); } if ((depth & Depth.Clamp) == Depth.Clamp) { gl.Enable(GL.DEPTH_CLAMP); } else { gl.Disable(GL.DEPTH_CLAMP); } if ((depth & Depth.Offset) == Depth.Offset) { gl.Enable(GL.POLYGON_OFFSET_FILL); gl.PolygonOffset(0.02f, 0); } else { gl.Disable(GL.POLYGON_OFFSET_FILL); } } currentDepth = depth; } if (currentStencil != stencil) { if (stencil == Stencil.None) { gl.Disable(GL.STENCIL_TEST); } else { gl.Enable(GL.STENCIL_TEST); switch (stencil) { case Stencil.Shadows: gl.StencilFunc(GL.FRONT_AND_BACK, GL.ALWAYS, 0, 0xFF); gl.StencilOp(GL.FRONT, GL.KEEP, GL.INCR_WRAP, GL.KEEP); // <- increase when going in gl.StencilOp(GL.BACK, GL.KEEP, GL.DECR_WRAP, GL.KEEP); // <- decrease when going out break; case Stencil.Light: gl.StencilFunc(GL.FRONT_AND_BACK, GL.EQUAL, 0, 0xFF); // <- if (stencil != 0) { in shadow } gl.StencilOp(GL.FRONT_AND_BACK, GL.KEEP, GL.KEEP, GL.KEEP); break; } } currentStencil = stencil; } if (currentBlend != blend) { if (blend == Blend.None) { gl.Disable(GL.BLEND); } else { gl.Enable(GL.BLEND); switch (blend) { case Blend.Additive: gl.BlendFunc(GL.ONE, GL.ONE, GL.ONE, GL.ONE); break; case Blend.Alpha: gl.BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA, GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); break; } } currentBlend = blend; } }
private void AddStencilImplementation(Stencil stencil) { Suspend(); foreach(StencilItem item in stencil.Values) { Shape shape = new Shape(item); shape.Label = new TextLabel(item.Key); Shapes.Add(Shapes.CreateKey(),shape); } Resume(); }
public virtual void AddStencil(Stencil stencil) { Suspend(); CreateRenderList(new RectangleF(),true); AddStencilImplementation(stencil); ArrangeImplementation(50,50); Resume(); Invalidate(); }
private void m_catalog_StencilSelected(Stencil selectedStencil, string caption) { FloatControlLib.FloatItem item; StencilForm frmStencil; frmStencil = new StencilForm(); frmStencil.TopLevel = false; frmStencil.InitializeStencil(selectedStencil); frmStencil.TemplateSelected +=new TemplateSelectedEvent(frmStencil_TemplateSelected); item = fbMain.AddFloatWindow(frmStencil, imgsToolbox.Images[1], caption, 160, 100, true); if (fbMain.Width == 0) { fbMain.Width = m_floatBarWidth; } fbMain.AnimateShowFloatWindow(item); }