public void LeftOf_Measures_Correctly() { using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 }; var target = new RelativePanel { VerticalAlignment = Layout.VerticalAlignment.Center, HorizontalAlignment = Layout.HorizontalAlignment.Center, Children = { rect1, rect2 } }; RelativePanel.SetLeftOf(rect2, rect1); target.Measure(new Size(400, 400)); target.Arrange(new Rect(target.DesiredSize)); Assert.Equal(new Size(20, 20), target.Bounds.Size); Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds); Assert.Equal(new Rect(-20, 0, 20, 20), target.Children[1].Bounds); }
public void LeftOf_Measures_Correctly() { var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 }; var target = new RelativePanel { VerticalAlignment = Layout.VerticalAlignment.Center, HorizontalAlignment = Layout.HorizontalAlignment.Center, Children = { rect1, rect2 } }; RelativePanel.SetLeftOf(rect2, rect1); target.Measure(new Size(400, 400)); target.Arrange(new Rect(target.DesiredSize)); Assert.Equal(new Size(20, 20), target.Bounds.Size); Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds); Assert.Equal(new Rect(-20, 0, 20, 20), target.Children[1].Bounds); }
private void AddAlarmToScreen(Alarm AlarmToAdd) { // each alarm is wrapped in a relative panel RelativePanel alarmPanel = new RelativePanel(); alarmPanel.Margin = new Thickness(5, 0, 5, 5); var borderBrush = new SolidColorBrush(Windows.UI.Colors.Gray); alarmPanel.BorderBrush = borderBrush; alarmPanel.BorderThickness = new Thickness(1); // create the text blocks for the title and date var alarmTitleBlock = this.CreateAlarmTitleBlock(AlarmToAdd); var alarmDateBlock = this.CreateAlarmDateBlock(AlarmToAdd); var deleteButton = this.CreateDeleteButton(AlarmToAdd); var editButton = this.CreateEditButton(AlarmToAdd); // add the blocks and buttons alarmPanel.Children.Add(alarmTitleBlock); alarmPanel.Children.Add(alarmDateBlock); alarmPanel.Children.Add(deleteButton); alarmPanel.Children.Add(editButton); // relatively place the edit text block RelativePanel.SetBelow(alarmDateBlock, alarmTitleBlock); // relatively place the delete button RelativePanel.SetAlignBottomWithPanel(deleteButton, true); RelativePanel.SetAlignLeftWithPanel(deleteButton, true); RelativePanel.SetBelow(deleteButton, alarmDateBlock); RelativePanel.SetLeftOf(deleteButton, editButton); // relatively place the edit button RelativePanel.SetAlignBottomWithPanel(editButton, true); RelativePanel.SetAlignRightWithPanel(editButton, true); RelativePanel.SetBelow(editButton, alarmDateBlock); this.VariableGrid.Children.Add(alarmPanel); }
private void SetUpUI() { this.StartRecordingButton = VoiceMemoUIHelper.BuildStartRecordingButton(this.StartRecording); this.StopRecordingButton = VoiceMemoUIHelper.BuildStopRecordingButton(this.StopRecording); this.SaveRecordingButton = VoiceMemoUIHelper.BuildSaveRecordingButton(this.SaveRecording); this.DeleteRecordingButton = VoiceMemoUIHelper.BuildDeleteRecordingButton(this.DeleteRecording); this.RecordingNameBox = VoiceMemoUIHelper.BuildDisplayNameTextBox(); // relatively place all the components RelativePanel.SetAlignVerticalCenterWithPanel(StartRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(StartRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(StopRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(StopRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(SaveRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(SaveRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(DeleteRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(DeleteRecordingButton, true); // place the save and delete buttons next to each other RelativePanel.SetLeftOf(DeleteRecordingButton, SaveRecordingButton); // place the text box below the save button RelativePanel.SetBelow(RecordingNameBox, SaveRecordingButton); RelativePanel.SetAlignLeftWith(RecordingNameBox, SaveRecordingButton); RelativePanel.SetAlignRightWith(RecordingNameBox, SaveRecordingButton); // hide all our buttons except the start recording one this.ResetUIComponents(); // now add everything to the dynamic area this.DynamicArea.Children.Add(StartRecordingButton); this.DynamicArea.Children.Add(StopRecordingButton); this.DynamicArea.Children.Add(SaveRecordingButton); this.DynamicArea.Children.Add(DeleteRecordingButton); this.DynamicArea.Children.Add(RecordingNameBox); }
private void CmbSubclass_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!clsChanged) { var temp = (Class)cmbClass.SelectedItem; // Define hitPoints txtHitPoints.Text = "HP:"; txtHitPoints.Margin = new Thickness(10, 10, 0, 0); txtHitPoints.Width = 50; txtHitPoints.Height = 40; txtHitPoints.FontSize = 25; txbHitPoints.PlaceholderText = "1" + temp.HitDice; txbHitPoints.Margin = new Thickness(10, 10, 0, 0); txbHitPoints.Width = 150; txbHitPoints.Height = 40; txbHitPoints.FontSize = 25; RelativePanel.SetAlignRightWithPanel(txbHitPoints, true); RelativePanel.SetBelow(txbHitPoints, sender); RelativePanel.SetLeftOf(txtHitPoints, txbHitPoints); RelativePanel.SetBelow(txtHitPoints, sender); // Define level txtLevel.Text = "Lvl:"; txtLevel.Margin = new Thickness(10, 10, 0, 0); txtLevel.Width = 50; txtLevel.Height = 40; txtLevel.FontSize = 25; txbLevel.Text = "1"; txbLevel.Margin = new Thickness(10, 10, 0, 0); txbLevel.Width = 50; txbLevel.Height = 40; txbLevel.FontSize = 25; RelativePanel.SetLeftOf(txbLevel, txtHitPoints); RelativePanel.SetBelow(txbLevel, sender); RelativePanel.SetLeftOf(txtLevel, txbLevel); RelativePanel.SetBelow(txtLevel, sender); // Define AddClassButton addClass.Content = "Add Class"; addClass.Click += AddClass_Click; addClass.Width = 150; addClass.Height = 50; addClass.Margin = new Thickness(0, 10, 100, 0); addClass.FontSize = 20; RelativePanel.SetBelow(addClass, txbHitPoints); RelativePanel.SetAlignRightWithPanel(addClass, true); // Create entities if (!rpBasicInfo.Children.Contains(txbHitPoints)) { rpBasicInfo.Children.Add(txbHitPoints); rpBasicInfo.Children.Add(txtHitPoints); rpBasicInfo.Children.Add(txbLevel); rpBasicInfo.Children.Add(txtLevel); rpBasicInfo.Children.Add(addClass); } } }
public async Task LeftOfRightAligned() { /* * <RelativePanel> * <Border x:Name="BlueRect" Background="Blue" Height="100" Width="150" RelativePanel.AlignRightWithPanel="True"/> * <Border x:Name="RedRect" Background="Red" Height="100" Width="150" RelativePanel.LeftOf="BlueRect" Tag="Red"/> * </RelativePanel> */ await UIHelpers.RunUITest(async (container, info) => { container.Width = 400; container.Height = 300; var panel = new RelativePanel(); panel.Background = new SolidColorBrush(Colors.Green); var blueRect = new Border() { Width = 150, Height = 100, Background = new SolidColorBrush(Colors.Blue) }; RelativePanel.SetAlignRightWithPanel(blueRect, true); panel.Children.Add(blueRect); var redRect = new Border() { Width = 150, Height = 100, Background = new SolidColorBrush(Colors.Red) }; RelativePanel.SetLeftOf(redRect, blueRect); panel.Children.Add(redRect); container.Content = panel; var bitmap = await UIHelpers.RenderAsync(container, info.ScaleFactor); var redblobs = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Red); var blueblobs = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Blue); Assert.AreEqual(1, redblobs.Count); Assert.AreEqual(150, redblobs[0].Width); Assert.AreEqual(100, redblobs[0].Height); Assert.AreEqual(1, blueblobs.Count); Assert.AreEqual(150, blueblobs[0].Width); Assert.AreEqual(100, blueblobs[0].Height); Assert.AreEqual(redblobs[0].MaxColumn + 1, blueblobs[0].MinColumn); Assert.AreEqual(0, blueblobs[0].MinRow); Assert.AreEqual(100, redblobs[0].MinColumn); Assert.AreEqual(0, redblobs[0].MinRow); Assert.AreEqual(399, blueblobs[0].MaxColumn); }); }
private RelativePanel CreateReminderCard(Reminder ReminderToAdd) { // each reminder is wrapped in a relative panel RelativePanel reminderPanel = new RelativePanel(); reminderPanel.Margin = new Thickness(5, 0, 5, 5); var borderBrush = new SolidColorBrush(Windows.UI.Colors.Gray); reminderPanel.BorderBrush = borderBrush; reminderPanel.BorderThickness = new Thickness(1); // create the text blocks for the title and date var ReminderTitleBlock = this.CreateReminderTitleBlock(ReminderToAdd); var ReminderDateBlock = this.CreateReminderDateBlock(ReminderToAdd); var ReminderDescriptionBlock = this.CreateDescriptionBlock(ReminderToAdd); var deleteButton = this.CreateDeleteButton(); var editButton = this.CreateEditButton(); // add the blocks and buttons reminderPanel.Children.Add(ReminderTitleBlock); reminderPanel.Children.Add(ReminderDateBlock); reminderPanel.Children.Add(ReminderDescriptionBlock); reminderPanel.Children.Add(deleteButton); reminderPanel.Children.Add(editButton); // relatively place the edit text block RelativePanel.SetRightOf(ReminderDateBlock, ReminderTitleBlock); RelativePanel.SetAlignRightWithPanel(ReminderDateBlock, true); // relatively place the description block RelativePanel.SetBelow(ReminderDescriptionBlock, ReminderTitleBlock); // relatively place the delete button RelativePanel.SetAlignBottomWithPanel(deleteButton, true); RelativePanel.SetAlignLeftWithPanel(deleteButton, true); RelativePanel.SetLeftOf(deleteButton, editButton); // relatively place the edit button RelativePanel.SetAlignBottomWithPanel(editButton, true); RelativePanel.SetAlignRightWithPanel(editButton, true); return(reminderPanel); }