public void When_Horizontal_And_SimpleLayout() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Horizontal }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(5, 8) } ); var c2 = SUT.AddChild( new View { Name = "Child02", RequestedDesiredSize = new Windows.Foundation.Size(12, 7) } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(17, 8), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(5, 8), c1.RequestedDesiredSize); Assert.AreEqual(new Windows.Foundation.Size(12, 7), c2.RequestedDesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 0, 5, 20), c1.Arranged); Assert.AreEqual(new Windows.Foundation.Rect(5, 0, 12, 20), c2.Arranged); Assert.AreEqual(2, SUT.GetChildren().Count()); }
public void When_Vertical_And_SimpleLayout_With_Spacing() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Vertical, Spacing = 5 }; var c1 = SUT.AddChild( child: new View { Name = "Child01", RequestedDesiredSize = new Size(width: 10, height: 8) } ); var c2 = SUT.AddChild( child: new View { Name = "Child02", RequestedDesiredSize = new Size(width: 10, height: 7) } ); SUT.Measure(availableSize: new Size(width: 20, height: 20)); Assert.AreEqual(expected: new Size(width: 10, height: 20), actual: SUT.DesiredSize, message: "measuredSize"); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 20, height: 20)); Assert.AreEqual(expected: new Rect(x: 0, y: 0, width: 20, height: 8), actual: c1.Arranged); Assert.AreEqual(expected: new Rect(x: 0, y: 13, width: 20, height: 7), actual: c2.Arranged); Assert.AreEqual(expected: 2, actual: SUT.GetChildren().Count()); }
public void When_Vertical_And_SimpleLayout_With_Spacing() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Vertical, Spacing = 5 }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(10, 8) } ); var c2 = SUT.AddChild( new View { Name = "Child02", RequestedDesiredSize = new Windows.Foundation.Size(10, 7) } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); Assert.AreEqual(new Windows.Foundation.Size(10, 20), SUT.DesiredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(10, 8), c1.RequestedDesiredSize); Assert.AreEqual(new Windows.Foundation.Size(10, 7), c2.RequestedDesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 0, 20, 8), c1.Arranged); Assert.AreEqual(new Windows.Foundation.Rect(0, 13, 20, 7), c2.Arranged); Assert.AreEqual(2, SUT.GetChildren().Count()); }
public void When_Vertical_And_Fixed_MaxWidth_Oversized() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(10, 8), MaxWidth = 20 } ); SUT.Measure(new Windows.Foundation.Size(25, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(10, 8), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(25, float.PositiveInfinity), c1.AvailableMeasureSize, "AvailableMeasureSize"); Assert.AreEqual(new Windows.Foundation.Size(10, 8), c1.DesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 30, 20)); Assert.AreEqual(new Windows.Foundation.Rect(5, 0, 20, 8), c1.Arranged); Assert.AreEqual(1, SUT.GetChildren().Count()); }
public void When_Horizontal_And_Fixed_Width_Item_And_Measured_Height_is_Valid() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Horizontal }; var c1 = SUT.AddChild( new View { Name = "Child01", DesiredSizeSelector = s => { s.Height.Should().Be(20.0d); return(new Windows.Foundation.Size(8, 10)); }, Height = 10 } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(8, 10), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(8, 10), c1.DesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 5, 8, 10), c1.Arranged); Assert.AreEqual(1, SUT.GetChildren().Count()); }
protected override void OnTurnedOn() { if (Patterns == null) { return; } RemoveButtons(); foreach (var pattern in Patterns) { var button = new PatternButton(pattern) { Style = Style, OnColor = OnColor, OffColor = OffColor }; _currentButtons.Add(button); _panel.AddChild(button); } _panel.IsVisible = true; }
public void When_Vertical_And_Fixed_Height_And_Width_Item_With_Margin() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( child: new View { Name = "Child02", DesiredSizeSelector = s => { s.Width.Should().Be(expected: 30.0d); s.Height.Should().Be(expected: double.PositiveInfinity); return(new Size(width: 10, height: 10)); }, Height = 10, Margin = new Thickness(uniformLength: 10) } ); SUT.Measure(availableSize: new Size(width: 30, height: 30)); SUT.DesiredSize.Should().Be(new Size(10, 10)); c1.DesiredSize.Should().Be(new Size(10, 10)); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 30, height: 30)); SUT.Arranged.Should().Be((Rect)"0,0,30,30"); c1.Arranged.Should().Be((Rect)"10,10,10,0"); // size is 10x0 because of margins (w= 30-(10+10), h=10-(10+10)) SUT.GetChildren().Should().HaveCount(1); }
private ControlBase CreateContentPanel() { var contentPanel = new StackPanel { Margin = "5 5 5 5", }; var grid = new Grid(Levels.Count, 3); int row = 0; foreach (Level level in Levels) { CreateRadioLabel(grid, row, level.Label, new LevelEnabled(), level.Label + "_radio", val => { level.Disabled = val == "Off" ? true : false; Robot.Print("Level {0} {1}", level.Label, val); LevelRenderer.RenderLevel(level); return(true); }); row++; } contentPanel.AddChild(grid); return(contentPanel); }
public void When_Vertical_And_Fixed_MaxWidth_Oversized() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( child: new View { Name = "Child01", RequestedDesiredSize = new Size(width: 10, height: 8), MaxWidth = 20 } ); SUT.Measure(availableSize: new Size(width: 25, height: 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(expected: new Size(width: 10, height: 8), actual: measuredSize, message: "measuredSize"); Assert.AreEqual(expected: new Size(width: 25, height: float.PositiveInfinity), actual: c1.AvailableMeasureSize, message: "AvailableMeasureSize"); Assert.AreEqual(expected: new Size(width: 10, height: 8), actual: c1.DesiredSize); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 30, height: 20)); Assert.AreEqual(expected: new Rect(x: 5, y: 0, width: 20, height: 8), actual: c1.Arranged); Assert.AreEqual(expected: 1, actual: SUT.GetChildren().Count()); }
public void When_Horizontal_And_Fixed_Width_Item_And_Measured_Height_is_Valid() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Horizontal }; var c1 = SUT.AddChild( child: new View { Name = "Child01", DesiredSizeSelector = s => { s.Height.Should().Be(expected: 20.0d); return(new Size(width: 8, height: 10)); }, Height = 10 } ); SUT.Measure(availableSize: new Size(width: 20, height: 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(expected: new Size(width: 8, height: 10), actual: measuredSize, message: "measuredSize"); Assert.AreEqual(expected: new Size(width: 8, height: 10), actual: c1.DesiredSize); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 20, height: 20)); Assert.AreEqual(expected: new Rect(x: 0, y: 5, width: 8, height: 10), actual: c1.Arranged); Assert.AreEqual(expected: 1, actual: SUT.GetChildren().Count()); }
public void When_Vertical_And_Fixed_Height_And_Width_Item_With_Margin() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( new View { Name = "Child02", DesiredSizeSelector = s => { s.Width.Should().Be(30.0d); s.Height.Should().Be(double.PositiveInfinity); return(new Windows.Foundation.Size(10, 10)); }, Height = 10, Margin = new Thickness(10) } ); SUT.Measure(new Windows.Foundation.Size(30, 30)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(30, 30), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(30, 30), c1.DesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 30, 30)); Assert.AreEqual(new Windows.Foundation.Rect(10, 10, 10, 10), c1.Arranged); Assert.AreEqual(1, SUT.GetChildren().Count()); }
public void When_Horizontal_And_Fixed_Height_Item() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Horizontal }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(8, 10), Height = 10 } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(8, 10), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(8, 10), c1.DesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 5, 8, 10), c1.Arranged); Assert.AreEqual(1, SUT.GetChildren().Count()); }
private void AddItem(object item) { var wrappedItem = GenerateTemplateFor(item); panel.AddChild(wrappedItem); // Set the data context after adding the child, because the act of adding the child to a panel automatically sets the data context to its parent's wrappedItem.DataContext = item; }
public void When_Vertical_And_Fixed_Height_Item_With_Margin() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(10, 10), } ); var c2 = SUT.AddChild( new View { Name = "Child02", DesiredSizeSelector = s => { Assert.AreEqual(new Windows.Foundation.Size(20, 10), s); return(new Windows.Foundation.Size(10, 10)); }, Height = 10, Margin = new Thickness(10) } ); SUT.Measure(new Windows.Foundation.Size(40, float.PositiveInfinity)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(30, 40), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(10, 10), c1.DesiredSize); Assert.AreEqual(new Windows.Foundation.Size(30, 30), c2.DesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 30, 40)); Assert.AreEqual(new Windows.Foundation.Rect(0, 0, 30, 10), c1.Arranged); Assert.AreEqual(new Windows.Foundation.Rect(10, 20, 10, 10), c2.Arranged); Assert.AreEqual(2, SUT.GetChildren().Count()); }
public void When_Vertical_And_Fixed_Height_Item_With_Margin() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( child: new View { Name = "Child01", RequestedDesiredSize = new Size(width: 10, height: 10), } ); var c2 = SUT.AddChild( child: new View { Name = "Child02", Height = 10, Margin = new Thickness(uniformLength: 10) } ); SUT.Measure(availableSize: new Size(width: 40, height: float.PositiveInfinity)); using (new AssertionScope("Desired Sizes")) { SUT.DesiredSize.Should().Be(new Size(20, 40)); c1.DesiredSize.Should().Be(new Size(10, 10)); c2.DesiredSize.Should().Be(new Size(20, 30)); } SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 30, height: 40)); using (new AssertionScope("Arranged Sizes")) { SUT.Arranged.Should().Be((Rect)"0,0,30,40"); c1.Arranged.Should().Be((Rect)"0,0,30,10"); c2.Arranged.Should().Be((Rect)"10,20,10,10"); SUT.GetChildren().Should().HaveCount(2); } }
// Use this for initialization void Start () { var frame = FindObjectOfType<Frame>(); var sp = new StackPanel(); sp.HorizontalAlignment = FirstWave.Unity.Gui.Enums.HorizontalAlignment.Center; sp.VerticalAlignment = FirstWave.Unity.Gui.Enums.VerticalAlignment.Top; sp.AddChild(new TextBlock("This is the second scene.")); frame.AddControl(sp); }
IVisualElement?IDataTemplate.BuildVisual(Object?dataContext) { var sp = new StackPanel(_visualBootstrapper); foreach (var vis in BuildVisuals(dataContext)) { sp.AddChild(vis); } return(sp); }
public IVisualElement BuildVisual() { var sp = new StackPanel(_visualBootstrapper); foreach (var vis in BuildVisuals()) { sp.AddChild(vis); } return(sp); }
public void When_Horizontal_And_Three_With_Spacing() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Horizontal, Spacing = 5 }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(5, 8) } ); var c2 = SUT.AddChild( new View { Name = "Child02", RequestedDesiredSize = new Windows.Foundation.Size(12, 7) } ); var c3 = SUT.AddChild( new View { Name = "Child02", RequestedDesiredSize = new Windows.Foundation.Size(12, 5) } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(39, 8), measuredSize, "measuredSize"); Assert.AreEqual(new Windows.Foundation.Size(5, 8), c1.RequestedDesiredSize); Assert.AreEqual(new Windows.Foundation.Size(12, 7), c2.RequestedDesiredSize); Assert.AreEqual(new Windows.Foundation.Size(12, 5), c3.RequestedDesiredSize); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 0, 5, 20), c1.Arranged); Assert.AreEqual(new Windows.Foundation.Rect(10, 0, 12, 20), c2.Arranged); Assert.AreEqual(new Windows.Foundation.Rect(27, 0, 12, 20), c3.Arranged); Assert.AreEqual(3, SUT.GetChildren().Count()); }
// Use this for initialization void Start() { var frame = FindObjectOfType <Frame>(); var sp = new StackPanel(); sp.HorizontalAlignment = FirstWave.Unity.Gui.Enums.HorizontalAlignment.Center; sp.VerticalAlignment = FirstWave.Unity.Gui.Enums.VerticalAlignment.Top; sp.AddChild(new TextBlock("This is the second scene.")); frame.AddControl(sp); }
public void When_Horizontal_And_Three_With_Spacing() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Horizontal, Spacing = 5 }; var c1 = SUT .AddChild( child: new View { Name = "Child01", RequestedDesiredSize = new Size(width: 5, height: 8) } ); var c2 = SUT .AddChild( child: new View { Name = "Child02", RequestedDesiredSize = new Size(width: 12, height: 7) } ); var c3 = SUT .AddChild( child: new View { Name = "Child02", RequestedDesiredSize = new Size(width: 12, height: 5) } ); SUT.Measure(availableSize: new Size(width: 20, height: 20)); SUT.DesiredSize.Should().Be(new Size(20, 8)); SUT.UnclippedDesiredSize.Should().Be(new Size(39, 8)); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 20, height: 20)); Assert.AreEqual(expected: new Rect(x: 0, y: 0, width: 5, height: 20), actual: c1.Arranged); Assert.AreEqual(expected: new Rect(x: 10, y: 0, width: 12, height: 20), actual: c2.Arranged); Assert.AreEqual(expected: new Rect(x: 27, y: 0, width: 12, height: 20), actual: c3.Arranged); Assert.AreEqual(expected: 3, actual: SUT.GetChildren().Count()); }
public IView <CompanyViewModel> GetCompanyView(IStyleContext styleContext) { var companyVm = typeof(CompanyViewModel); var employeeVm = typeof(EmployeeViewModel); var companyView = new View <CompanyViewModel>(styleContext); var employeesBinding = new DeferredPropertyBinding <IEnumerable <EmployeeViewModel> > (companyVm, nameof(CompanyViewModel.Employees)); var employeesView = new RepeaterPanel <EmployeeViewModel>(employeesBinding); var employeeView = new StackPanel <EmployeeViewModel> { Orientation = Orientations.Horizontal }; var lblFirst = new Label(new DeferredPropertyBinding <string>(employeeVm, nameof(EmployeeViewModel.FirstName))); var lblLast = new Label(new DeferredPropertyBinding <string>(employeeVm, nameof(EmployeeViewModel.LastName))); employeeView.AddChild(lblFirst); employeeView.AddChild(lblLast); var labelStyle0 = new StyleForLabel(lblFirst, 12, FontStyle.Regular, Color.White); styleContext.RegisterStyle(labelStyle0); var labelStyle = new StyleForLabel(lblLast, 18, FontStyle.Bold, Color.Orange); styleContext.RegisterStyle(labelStyle); employeesView.Content = employeeView; companyView.Content = employeesView; return(companyView); }
public MenuItem(string label, Action selectedAction, BorderTextures textures = null) { _textures = textures; Label = label; SelectedAction = selectedAction; var child = new StackPanel { Orientation = Orientation.Horizontal }; pointer = new Image(Textures.Pointer) { VerticalAlignment = Enums.VerticalAlignment.Center }; labelText = new TextBlock(label); PointerPadding = 10; child.AddChild(pointer); child.AddChild(labelText); Child = child; }
public override GuiObject SideMenu() { GuiObject dimensionCopy = Sim.instance.sideMenu; StackPanel p = new StackPanel(dimensionCopy.x, dimensionCopy.y, dimensionCopy.width, dimensionCopy.height); p.AddChild(new GuiText(0, 0, 100, 50, Assets.Font24, "&l", new ObjectLinker(this, "Name"))); p.AddChild(new GuiText(0, 50, 100, 50, Assets.Font18, "&l", new ObjectLinker(this, "ParkedString"))); p.AddChild(new GuiText(0, 100, 100, 50, Assets.Font18, "Speed: &l", new ObjectLinker(this, "Speed"))); p.AddChild(new GuiText(0, 150, 100, 50, Assets.Font18, "Speed goal: &l", new ObjectLinker(this, "MinLimit"))); p.AddChild(new GuiText(0, 200, 100, 50, Assets.Font18, "Last visited: &l", new ObjectLinker(this, "LastVisitedString"))); p.AddChild(new GuiText(0, 250, 100, 50, Assets.Font18, "&l", new ObjectLinker(this, "LimitsString"))); return(p); }
public void When_Horizontal_And_ArrangeIsBiggerThanMeasure() { var SUT = new StackPanel { Name = "test", Orientation = Orientation.Horizontal }; var c1 = SUT.AddChild( child: new View { Name = "Child01", RequestedDesiredSize = new Size(width: 10, height: 10) } ); SUT.Measure(availableSize: new Size(width: 20, height: 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(expected: new Size(width: 10, height: 10), actual: measuredSize, message: "measuredSize"); SUT.Arrange(finalRect: new Rect(x: 0, y: 0, width: 20, height: 20)); Assert.AreEqual(expected: new Rect(x: 0, y: 0, width: 10, height: 20), actual: c1.Arranged); Assert.AreEqual(expected: 1, actual: SUT.GetChildren().Count()); }
public BlendModeChooser() { InitializeComponent(); ignoreSelection = true; foreach (var item in Enum.GetValues(typeof(BlendMode))) { var rad = new RadioButton(); rad.Tag = item; rad.Content = Enum.GetName(typeof(BlendMode), item); rad.Checked += blendMode_Checked; StackPanel.AddChild(rad); } var arr = Enum.GetValues(typeof(FillMode)); foreach (var item in arr) { var rad = new RadioButton(); rad.Tag = item; rad.Content = Enum.GetName(typeof(FillMode), item); rad.Checked += fillMode_Checked; FillModePanel.AddChild(rad, 0); } foreach (var item in BColors) { var rad = new RadioButton(); rad.Tag = item; rad.Content = new Border() { Width = 150, Height = 50, BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(2), Child = new Grid() { Background = new SolidColorBrush(item) } }; rad.Checked += color_Checked; ColorsPanel.AddChild(rad); } ignoreSelection = false; }
public void When_Vertical_And_ArrangeIsBiggerThanMeasure() { var SUT = new StackPanel() { Name = "test", Orientation = Orientation.Vertical }; var c1 = SUT.AddChild( new View { Name = "Child01", RequestedDesiredSize = new Windows.Foundation.Size(10, 10) } ); SUT.Measure(new Windows.Foundation.Size(20, 20)); var measuredSize = SUT.DesiredSize; Assert.AreEqual(new Windows.Foundation.Size(10, 10), measuredSize, "measuredSize"); SUT.Arrange(new Windows.Foundation.Rect(0, 0, 20, 20)); Assert.AreEqual(new Windows.Foundation.Rect(0, 0, 20, 10), c1.Arranged); Assert.AreEqual(1, SUT.GetChildren().Count()); }
protected override void OnLoad(EventArgs e) { _graphicsDevice = new GraphicsDevice(this); VSync = VSyncMode.On; spriteBatch = new SpriteBatch(_graphicsDevice); GL.ClearColor(0.1f, 0.2f, 0.5f, 0.0f); GL.Enable(EnableCap.DepthTest); ContentManager content = new ContentManager(new ServiceProvider(), @"..\..\..\Content\"); content.RegisterTypeReader <BitmapFont>(new SpriteFontReader(Shaders.FontShader)); _font = content.Get <BitmapFont>(@"SourceCodePro16.meb").Content as BitmapFont; _graphicsDevice.DebugBatch.DefaultFont = _font; System.Drawing.Bitmap bmp = new System.Drawing.Bitmap("checkbox16on.png"); _checkBoxOn = Texture2D.Create(bmp); bmp = new System.Drawing.Bitmap("checkbox16off.png"); _checkBoxOff = Texture2D.Create(bmp); bmp = new System.Drawing.Bitmap("slider16.png"); _trackSprite = Texture2D.Create(bmp); bmp = new System.Drawing.Bitmap("sliderknob16.png"); _thumbSprite = Texture2D.Create(bmp); bmp = new System.Drawing.Bitmap("buttons.png"); Texture2D buttons = Texture2D.Create(bmp); bmp = new System.Drawing.Bitmap("disk.png"); Texture2D disk = Texture2D.Create(bmp); //projectionMatrix = Matrix4.CreateOrthographicOffCenter(0, _graphicsDevice.ViewPort.Width, _graphicsDevice.ViewPort.Height, 0, 0, 1); world = Matrix4.Scale(0.5f) * Matrix4.CreateTranslation(0, -1.5f, 0); _graphicsDevice.Camera = new GuiCamera(_graphicsDevice); _graphicsDevice.DebugBatch.ScreenCamera = _graphicsDevice.Camera; _graphicsDevice.DebugBatch.WorldCamera = _graphicsDevice.Camera; _guiRoot = new GuiComponent(_graphicsDevice.Width, _graphicsDevice.Height); // { Position = new Vector2(100, 100) }; _checkBox = new CheckBox("Test Check Box", new Binding(this, "Check"), new Sprite(_checkBoxOn, 0, 0, 0, 0), new Sprite(_checkBoxOff, 0, 0, 0, 0), _font); Label label = new Label("test label", _font); // { Position = new Vector2(0, 50)}; Sprite trackSprite = new Sprite(_trackSprite, 0, 0, 0, 0); Sprite thumbSprite = new Sprite(_thumbSprite, 0, 0, 0, 0); FloatValue = 0f; Slider slider = new Slider("Test slider: {0:0.00}", new Binding(this, "FloatValue"), 0f, 1f, trackSprite, thumbSprite, _font); SlicedSprite buttonNormal = new SlicedSprite(buttons, 0, 0, 30, 30, 2); SlicedSprite buttonHover = new SlicedSprite(buttons, 0, 32, 30, 30, 2); SlicedSprite buttonPressed = new SlicedSprite(buttons, 0, 64, 30, 30, 2); Button button = new Button("Button.", buttonNormal, buttonHover, buttonPressed, new Sprite(disk, 0, 0, 0, 0), _font); button.Click += (o, ev) => System.Diagnostics.Debug.WriteLine("Button Pressed!!!!"); StackPanel hpanel = new StackPanel(Dimension.Vertical); Panel panel = new Panel(Color4.Gray, 1f) { Color = new Color4(128, 128, 128, 63), Position = new Vector2(100, 100), Margin = 5 }; hpanel.AddChild(_checkBox); hpanel.AddChild(label); hpanel.AddChild(slider); hpanel.AddChild(button); panel.AddChild(hpanel); _guiRoot.AddChild(panel); //debugGuis.Add(button); Mouse.ButtonUp += new EventHandler <MouseButtonEventArgs>(OnButtonUp); Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(OnButtonDown); Mouse.Move += new EventHandler <MouseMoveEventArgs>(OnMouseMove); _depthTexture = new Texture2D(800, 600, PixelInternalFormat.DepthComponent, PixelFormat.DepthComponent, PixelType.Float); _screenTexture = new Texture2D(800, 600); //_fbo = new FrameBuffer(_graphicsDevice, new Texture2D[] { _screenTexture }, _depthTexture); string vsSrc = @"#version 150 uniform mat4 WorldViewProj; in vec3 Position; in vec3 Color; in vec2 TexCoord; noperspective out vec2 fragTexCoord; void main() { fragTexCoord = TexCoord; gl_Position = WorldViewProj * vec4(Position, 1); } "; string fsSrc = @"#version 150 uniform sampler2D Texture; uniform vec4 Diffuse = vec4(1); noperspective in vec2 fragTexCoord; out vec4 finalColor; void main() { float n = 1.0; // camera z near float f = 100.0; // camera z far float z = texture(Texture, fragTexCoord).x; float d = (2.0 * n) / (f + n - z * (f - n)); finalColor = vec4(d,d,d,1); } "; wireframeShader = new Program(vsSrc, fsSrc); }
/// <summary> /// Formalizza i tasti per il controllo popup /// </summary> private void _createDrawingDialog() { string separator = "---------------------"; var stackPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = API.HorizontalAlignment.Left, Orientation = API.Orientation.Vertical, IsVisible = false, Width = 160, BackgroundColor = PBackgroundColor }; var trendLineHorizontalButton = new API.Button { Text = "TrendLine Horizontal", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var barAverageButton = new API.Button { Text = "Bar Average", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var bodyAverageButton = new API.Button { Text = "Body Average", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var equiChannelButton = new API.Button { Text = "Equidistant Channel", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var linearRegressionButton = new API.Button { Text = "Linear Regression", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var fibonacciRetracementButton = new API.Button { Text = "Fibonacci Retracement", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var supportTrendLineButton = new API.Button { Text = "Support Trend", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var resistanceTrendLineButton = new API.Button { Text = "Resistance Trend", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var resistanceSupportTrendLineButton = new API.Button { Text = "Rex / Sup Trend", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var supportLevelButton = new API.Button { Text = "Support", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var resistanceLevelButton = new API.Button { Text = "Resistance", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var removeAllObjButton = new API.Button { Text = "Remove all (Shift + Click)", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var resistanceSupportLevelButton = new API.Button { Text = "Rex / Sup Level", HorizontalContentAlignment = API.HorizontalAlignment.Left }; var space = new API.Button { Text = separator, HorizontalContentAlignment = API.HorizontalAlignment.Center }; var space2 = new API.Button { Text = separator, HorizontalContentAlignment = API.HorizontalAlignment.Center }; trendLineHorizontalButton.Click += _trendLineHorizontalButton_Click; barAverageButton.Click += _barAverageButton_Click; bodyAverageButton.Click += _bodyAverageButton_Click; equiChannelButton.Click += _equiChannelButton_Click; linearRegressionButton.Click += _linearRegressionTo_Click; fibonacciRetracementButton.Click += _fibonacciRetracementButton_Click; supportTrendLineButton.Click += _supportTrendLineButton_Click; resistanceTrendLineButton.Click += _resistanceTrendLineButton_Click; resistanceSupportTrendLineButton.Click += _resistanceSupportTrendLineButton_Click; supportLevelButton.Click += _supportLevelButton_Click; resistanceLevelButton.Click += _resistanceLevelButton_Click; resistanceSupportLevelButton.Click += _resistanceSupportLevelButton_Click; removeAllObjButton.Click += _removeAllObject_Click; stackPanel.AddChild(trendLineHorizontalButton); stackPanel.AddChild(barAverageButton); stackPanel.AddChild(bodyAverageButton); stackPanel.AddChild(fibonacciRetracementButton); stackPanel.AddChild(linearRegressionButton); stackPanel.AddChild(equiChannelButton); stackPanel.AddChild(space); stackPanel.AddChild(supportTrendLineButton); stackPanel.AddChild(resistanceTrendLineButton); stackPanel.AddChild(resistanceSupportTrendLineButton); stackPanel.AddChild(supportLevelButton); stackPanel.AddChild(resistanceLevelButton); stackPanel.AddChild(resistanceSupportLevelButton); stackPanel.AddChild(space2); stackPanel.AddChild(removeAllObjButton); DrawingDialog = stackPanel; Chart.AddControl(DrawingDialog); }
public ArticleCollection(IModelObject parent, IGetArticles modelObject, bool hideEmptyMultipleFields, bool showIcon, bool isHorizontal, string separator = ", ") { HideEmptyMultipleFields = hideEmptyMultipleFields; ShowIcon = showIcon; IsHorizontal = isHorizontal; CurrentItem = parent; var field = modelObject as ArticleField; if (field != null) { PropertyDisplay pd = new PropertyDisplay() { Title = field.FieldDisplayName }; var articles = modelObject.GetArticles(null).ToArray(); UIItemsControl stackPanel = new StackPanel { IsHorizontal = isHorizontal };; UIItemsControl container; if (isHorizontal) { container = new StackPanel(); container.AddChild(stackPanel); } else { container = stackPanel; } if (hideEmptyMultipleFields && !articles.Any()) { return; } if (showIcon) { container.PrependChild(new ActionLink { Title = ProductCardStrings.Edit, CurrentItem = parent, ShowIcon = true, IconClass = "edit" }); } for (int i = 0; i < articles.Length; i++) { var article = articles[i]; if (article == null) { continue; } var valueTitleSource = article.Fields.Values.OfType <IGetFieldStringValue>().FirstOrDefault(); stackPanel.AddChild(new ActionLink { CurrentItem = article, Title = valueTitleSource != null ? valueTitleSource.Value : null }); if (isHorizontal && !string.IsNullOrEmpty(separator) && i < articles.Length - 1) { stackPanel.AddChild(new Label { Title = separator }); } } pd.Value = container; Content = pd; } }
protected override void OnStart() { if (!RunInOptimization) { CheckBox StopBuyNextTp = new CheckBox { Text = "STOP BUY NEXT TP", IsChecked = !Buy, Margin = "5 5 5 5", ForegroundColor = Color.LightGreen, BackgroundColor = Color.Black }; StopBuyNextTp.Click += OnCheckChange; CheckBox StopSellNextTp = new CheckBox { Text = "STOP SELL NEXT TP", IsChecked = !Sell, Margin = "5 5 5 5", ForegroundColor = Color.Red, BackgroundColor = Color.Black }; StopSellNextTp.Click += OnCheckChange; CheckBox StopBuy = new CheckBox { Text = "STOP BUY", IsChecked = !Buy, Margin = "5 5 5 5", ForegroundColor = Color.LightGreen, BackgroundColor = Color.Black }; StopBuy.Click += OnCheckChange; CheckBox StopSell = new CheckBox { Text = "STOP SELL", IsChecked = !Sell, Margin = "5 5 5 5", ForegroundColor = Color.Red, BackgroundColor = Color.Black }; StopSell.Click += OnCheckChange; CheckBox EvaluteOnNewBar = new CheckBox { Text = "NEW POS ON BAR", IsChecked = EvalutePipsStepOnNewBar, Margin = "5 5 5 5", ForegroundColor = Color.Yellow, BackgroundColor = Color.Black }; EvaluteOnNewBar.Click += OnCheckChange; CheckBox ChkJustForSofferenceSide = new CheckBox { Text = "OPTIMIZE RETRACEMENT", IsChecked = EvalutePipsStepOnNewBar, Margin = "5 5 5 5", ForegroundColor = Color.Yellow, BackgroundColor = Color.Black }; ChkJustForSofferenceSide.Click += OnCheckChange; StackPanel option = new StackPanel { Orientation = Orientation.Vertical, Margin = "10 10 10 10", BackgroundColor = Color.Transparent, Style = CreatePanelBackgroundStyle() }; Border OptionBorder = new Border { Width = 200, HorizontalAlignment = HorizontalAlignment.Right, Child = option, Style = CreatePanelBackgroundStyle(), Margin = "20 20 20 20" }; option.AddChild(StopBuy); option.AddChild(StopSell); option.AddChild(StopBuyNextTp); option.AddChild(StopSellNextTp); option.AddChild(EvaluteOnNewBar); option.AddChild(ChkJustForSofferenceSide); Chart.AddControl(OptionBorder); Positions.Closed += OnPositionClosed; } _initialPipStep = PipStep; _buyPipStep = PipStep; _sellPipStep = PipStep; _evaluteOnBar = EvalutePipsStepOnNewBar; _justForSofferenceSide = JustForSofferenceSide; }