public void horizontal_stack_panel_should_have_desired_size_with_columns_when_autoResize_is_true() { var stackPanel = new StackPanel(false) {AutoResize = true, Size = new Size(500, 25),Columns = 2}; var child1 = new TextElement("someText 1") { Size = new Size(18, 100) }; var child2 = new TextElement("someText 2") { Size = new Size(100, 100) }; var child3 = new TextElement("someText 3") { Size = new Size(100, 100) }; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); Assert.AreEqual(child2.Width + child3.Width, stackPanel.Width); }
public void horizontal_stack_panel_should_increase_width_for_children_if_need() { var stackPanel = new StackPanel(false); var child1 = new TextElement("someText 1") {Size = new Size(100, 75)}; var child2 = new TextElement("someText 2") {Size = new Size(100, 75)}; var child3 = new TextElement("someText 3") {Size = new Size(100, 75)}; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); stackPanel.Size = new Size(100, 200); Assert.AreEqual(child1.Width + child2.Width + child3.Width, stackPanel.Size.Width); }
public SystemPivotItem() { this.Title = "system"; var items = new StackPanel(); items.AddElement(this.CreateGroup("theme", "blue")); items.AddElement(this.CreateGroup("date & time", "UTC-03 Buenos Aires")); items.AddElement(this.CreateGroup("something longer enough to force multiline text in the title!", "Something longer enough to force multiline text in the body! Something longer enough to force multiline text in the body!")); items.AddElement(this.CreateGroup("region & language", "United States")); this.Body = items; this.DelayInTransitions.AddRange(items.ChildrenEnumerable.Select(x => (x as TitledGroup).Content)); }
private PivotItem CreateFirstPage() { var page = new PivotItem { Title = "first", }; var stackPanel = new StackPanel { Size = new Size(480, 700) }; page.Body = stackPanel; var txtIntro = new TextElement( "Change your phone's background and accent color to match your mood today, this week, or all month.\n\r\n\r") { Size = new Size(stackPanel.Size.Width - 10, 50), Style = new TextStyle(MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeSmall, MetroTheme.PhoneForegroundBrush), AutoSizeMode = TextElement.AutoSizeModeOptions.WrapText, }; stackPanel.AddElement(txtIntro); stackPanel.AddElement( new FontEdit() { Size = new Size(300, 50), } ); stackPanel.AddElement(new Canvas() { Size = new Size(100, 100), }); stackPanel.AddElement(new ComboBox() { Size = new Size(300, 50), Items = new List<object>() { "dark", "light" }, Style = MetroTheme.PhoneTextNormalStyle, } ); stackPanel.AddElement(new Canvas() { Size = new Size(100, 100), }); stackPanel.AddElement(new ComboBox() { Size = new Size(300, 50), Items = new List<object>() { "11111", "222222", "333333", "444444", "5", "6", "7", "8" }, Style = MetroTheme.PhoneTextNormalStyle, } ); stackPanel.AddElement(new Canvas() { Size = new Size(100, 100), }); stackPanel.AddElement(new ColorComboBox() { Size = new Size(300, 50), Items = new List<object>() { new ColorItem(Color.Magenta, "magenta"), new ColorItem(Color.Purple, "purple"), new ColorItem(Color.Teal, "teal"), new ColorItem(Color.Lime, "lime"), new ColorItem(Color.Brown, "brown"), new ColorItem(Color.Pink, "pink"), new ColorItem(Color.Orange, "orange"), new ColorItem(Color.Blue, "blue"), new ColorItem(Color.Red, "red"), new ColorItem(Color.Green, "green") }, Style = MetroTheme.PhoneTextNormalStyle, } ); stackPanel.AddElement(new Canvas() { Size = new Size(100, 100), }); return page; }
private PivotItem CreateSecondPage() { var page = new PivotItem { Title = "second" }; var stackPanel = new StackPanel { Size = new Size(480, 700) }; page.Body = stackPanel; stackPanel.AddElement( new Button("Test button 1") { Size = new Size(300, 50), AutoSizeMode = Button.AutoSizeModeOptions.None, TapHandler = point => OpenFile(), } ); return page; }
private PivotItem CreateFontPage() { var page = new PivotItem { Title = "incoming", }; var stackPanel = new StackPanel { Size = new Size(480, 700) }; var scroller = new ScrollViewer { Content = stackPanel, Location = new Point(0, 0), ShowScrollbars = true, HorizontalScroll = false, VerticalScroll = true, }; stackPanel.AddElement( new TextBox(this) { Size = new Size(300, 50), MultiLine = false, Text = "abc", }); stackPanel.AddElement( new TextBox(this) { Size = new Size(300, 150), MultiLine = true, Text = "abc\n123", }); stackPanel.AddElement( new FileSettingsControl(this) { } ); stackPanel.AddElement( new StringSettingsControl(this) { Value = "123", Caption = "Name", } ); page.Body = scroller; return page; }
public void horizontal_stack_panel_should_relayout_correct() { var stackPanel = new StackPanel(false); var child1 = new TextElement("someText 1") {Size = new Size(50, 75)}; var child2 = new TextElement("someText 2") {Size = new Size(50, 75)}; var child3 = new TextElement("someText 3") {Size = new Size(50, 75)}; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); stackPanel.Size = new Size(300, 100); Assert.AreEqual(child1.Location.X, 0); Assert.AreEqual(child2.Location.X, child1.Width); Assert.AreEqual(child3.Location.X, child1.Width + child2.Width); Assert.AreEqual(child1.Location.Y, 0); Assert.AreEqual(child2.Location.Y, 0); Assert.AreEqual(child3.Location.Y, 0); }
public void vertical_stack_panel_should_relayout_correct_with_columns() { var stackPanel = new StackPanel(true) {Columns = 2}; var child1 = new TextElement("someText 1") { Size = new Size(70, 75) }; var child2 = new TextElement("someText 2") { Size = new Size(70, 75) }; var child3 = new TextElement("someText 3") { Size = new Size(70, 75) }; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); stackPanel.Size = new Size(100, 300); var columnSize = stackPanel.Size.Width / stackPanel.Columns; Assert.AreEqual(child1.Location.Y, 0); Assert.AreEqual(child1.Location.X, 0); Assert.AreEqual(child2.Location.Y, 0); Assert.AreEqual(child2.Location.X, columnSize); Assert.AreEqual(child3.Location.X, 0); Assert.AreEqual(child3.Location.Y, child1.Height); }
public void vertical_stack_panel_should_relayout_correct() { var stackPanel = new StackPanel(true); var child1 = new TextElement("someText 1") {Size = new Size(50, 75)}; var child2 = new TextElement("someText 2") {Size = new Size(50, 75)}; var child3 = new TextElement("someText 3") {Size = new Size(50, 75)}; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); stackPanel.Size = new Size(100, 300); Assert.AreEqual(child1.Location.Y, 0); Assert.AreEqual(child2.Location.Y, child1.Height); Assert.AreEqual(child3.Location.Y, child1.Height + child2.Height); Assert.AreEqual(child1.Location.X, 0); Assert.AreEqual(child2.Location.X, 0); Assert.AreEqual(child3.Location.X, 0); }
public void vertical_stack_panel_should_increase_height_for_children_if_need() { var stackPanel = new StackPanel(true); var child1 = new TextElement("someText 1") {Size = new Size(50, 75)}; var child2 = new TextElement("someText 2") {Size = new Size(50, 75)}; var child3 = new TextElement("someText 3") {Size = new Size(50, 75)}; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); stackPanel.Size = new Size(100, 200); Assert.AreEqual(child1.Height + child2.Height + child3.Height, stackPanel.Size.Height); }
public void vertical_stack_panel_should_have_desired_size_with_columns_when_autoResize_is_true() { var stackPanel = new StackPanel(false) { AutoResize = true, Size = new Size(50, 250), Columns = 2, IsVertical = true }; var child1 = new TextElement("someText 1") { Size = new Size(100, 100) }; var child2 = new TextElement("someText 2") { Size = new Size(100, 150) }; var child3 = new TextElement("someText 3") { Size = new Size(100, 200) }; stackPanel.AddElement(child1); stackPanel.AddElement(child2); stackPanel.AddElement(child3); Assert.AreEqual(child2.Height + child3.Height, stackPanel.Height); }
private void AddCallPanel(StackPanel parent, string phoneName, string phoneNumber) { if (string.IsNullOrEmpty(phoneNumber)) return; parent.AddElement(new TextElement(str_Call.Localize() + " " + phoneName) { Style = _titleStyle, AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, TapHandler = p => MakeCall(phoneNumber), }); parent.AddElement(new TextElement(phoneNumber) { Style = _subTitleStyle, AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, TapHandler = p => MakeCall(phoneNumber), }); parent.AddElement(new DelegateUIElement { Size = new Size(10, PaddingVer), }); }
private void CreateControls() { ScreenRoutines.CursorWait(); try { Control.ShadowedAnimationMode = FleuxControl.ShadowedAnimationOptions.FromRight; var appBar = new ApplicationBar { Size = new Size(Size.Width, 48 + 2 * 10), Location = new Point(0, Size.Height - 48 - 2 * 10) }; appBar.AddButton(ResourceManager.Instance.GetBitmapFromEmbeddedResource( (MetroTheme.PhoneBackgroundBrush == Color.White) ? "Metrohome65.Settings.Controls.Images.back-light.bmp" : "Metrohome65.Settings.Controls.Images.back-dark.bmp" )); appBar.ButtonTap += (sender, args) => Close(); Control.AddElement(appBar.AnimateHorizontalEntrance(false)); var stackPanel = new StackPanel { Size = new Size(SettingsConsts.MaxWidth, 10), }; // buttons for selecting font family stackPanel.AddElement( new TextElement("Font family") { AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, } ); var fonts = new List<string> { MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontFamilyLight, MetroTheme.PhoneFontFamilySemiLight, MetroTheme.PhoneFontFamilySemiBold, }; var fontBindingManager = new BindingManager() { MultiBind = true, }; foreach (var font in fonts) { var button = new ToggleButton(font) { Size = new Size(SettingsConsts.MaxWidth, 50), }; stackPanel.AddElement(button); fontBindingManager.Bind(_textStyle, "FontFamily", button, "Value", true); stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 10), }); } stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20) }); // buttons for selecting font size stackPanel.AddElement( new TextElement("Font size") { AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, } ); var sizePanel = new Canvas() { Size = new Size(SettingsConsts.MaxWidth, 10), }; stackPanel.AddElement(sizePanel); var sizeBindingManager = new BindingManager() { MultiBind = true, }; var sizes = new List<int> { 8, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 42, 46, 50, }; var i = 0; foreach (var size in sizes) { var button = new ToggleButton(size) { Location = new Point((i%5)*90, (i/5)*60), Size = new Size(80, 50), }; sizeBindingManager.Bind(_textStyle, "FontSize", button, "Value", true); sizePanel.AddElement(button); i++; } stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20)}); // font color var fontColor = new ColorSettingsControl(false) { Size = new Size(SettingsConsts.MaxWidth, 50), Caption = "Font color", }; fontBindingManager.Bind(_textStyle, "Foreground", fontColor, "Value", true); stackPanel.AddElement(fontColor); stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20) }); // example text block _example = new TextElement("Example") { AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, Style = _textStyle, }; _textStyle.PropertyChanged += (sender, args) => _example.Update(); stackPanel.AddElement(_example); var scroller = new SolidScrollViewer { Content = stackPanel, Location = new Point(SettingsConsts.PaddingHor, SettingsConsts.PaddingHor), Size = new Size(this.Size.Width - SettingsConsts.PaddingHor, this.Size.Height - appBar.Size.Height - SettingsConsts.PaddingHor), ShowScrollbars = true, HorizontalScroll = false, VerticalScroll = true, }; Control.AddElement(scroller); } finally { ScreenRoutines.CursorNormal(); } }