Пример #1
0
 public MainMenuView()
 {
     this.fluentItem = this
                       .AsFluent <Grid>()
                       .Set(Control.BackgroundProperty, Theme.ThemeColors.Control.Normal)
                       .Set(StackPanel.OrientationProperty, Orientation.Horizontal)
                       .Set(Control.FontFamilyProperty, new FontFamily("SEGOE MDL2 assets"))
                       .Set(Control.FontSizeProperty, 18d)
                       .Set(FrameworkElement.HeightProperty, 80d)
                       .DefaultCellSize("*", "*")
                       .Cell(GridCellExtensions.Create()
                             .Contains(new Button()
                                       .AsFluent()
                                       .Contains("\xE90B")
                                       .Bind(BindingExtensions
                                             .OneTime(ButtonBase.CommandProperty)
                                             .With(nameof(RootViewModel.OpenSearchViewCommand)))))
                       .Cell(GridCellExtensions.Create()
                             .Column(1)
                             .Contains(new Button()
                                       .AsFluent()
                                       .Contains("\xE8D6")
                                       .Bind(BindingExtensions
                                             .OneTime(ButtonBase.CommandProperty)
                                             .With(nameof(RootViewModel.OpenPlayerViewCommand)))))
                       .Cell(GridCellExtensions.Create()
                             .Column(2)
                             .Contains(new Button()
                                       .AsFluent()
                                       .Contains("\xE74F")));
 }
Пример #2
0
 public PlayerView()
 {
     this.fluentItem = this.AsFluent <TabItem>()
                       .Bind(BindingExtensions
                             .OneTime(FrameworkElement.DataContextProperty)
                             .With(nameof(RootViewModel.Player)))
                       .Set(FrameworkElement.VisibilityProperty, Visibility.Collapsed)
                       .Contains(new StackPanel()
                                 .AsFluent()
                                 .Stack(new Image()
                                        .AsFluent()
                                        .Margin(0, 25, 0, 0)
                                        .Size(300, 300)
                                        .Stretch(Stretch.UniformToFill)
                                        .Source(@"/Resources/Queen_Jazz.png"))
                                 .Stack(new Grid()
                                        .AsFluent()
                                        .Set(Control.BackgroundProperty, Theme.ThemeColors.Control.Normal)
                                        .Set(FrameworkElement.HeightProperty, 80d)
                                        .Cell(GridCellExtensions.Create()
                                              .Width("*")
                                              .Height("*")
                                              .Contains(new Button()
                                                        .AsFluent()
                                                        .Contains("⏮")
                                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))))
                                        .Set(Control.FontSizeProperty, 18d)
                                        .Cell(GridCellExtensions.Create()
                                              .Column(1)
                                              .Width("*")
                                              .Contains(new Button()
                                                        .AsFluent()
                                                        .Contains("▶")
                                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))))
                                        .Set(Control.FontSizeProperty, 18d)
                                        .Cell(GridCellExtensions.Create()
                                              .Width("*")
                                              .Column(2)
                                              .Contains(new Button()
                                                        .AsFluent()
                                                        .Contains("⏭")
                                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))))
                                        .Set(Control.FontSizeProperty, 18d)
                                        .Cell(GridCellExtensions.Create()
                                              .AutoHeight()
                                              .Row(1)
                                              .Span(1, 3)
                                              .Contains(new ProgressBar()
                                                        .AsFluent()
                                                        .Value(30)
                                                        .Set(FrameworkElement.HeightProperty, 8d)
                                                        .Set(Control.ForegroundProperty, Theme.ThemeColors.Control.Accent2)))));
 }
Пример #3
0
 public PlayerMainWindow()
 {
     this.AsFluent <Window>()
     .DataContext(new RootViewModel())
     .NoBorder()
     .NoResize()
     .Set(Control.MaxHeightProperty, 420d)
     .SizeToContent(SizeToContent.WidthAndHeight)
     .Transparent()
     .Contains(new Grid()
               .AsFluent()
               .Cell(GridCellExtensions.Create()
                     .AutoHeight()
                     .Contains(new Expander()
                               .AsFluent <HeaderedContentControl>()
                               .Top()
                               .Size(400, 400)
                               .Bind(BindingExtensions
                                     .TwoWay(Expander.IsExpandedProperty)
                                     .With(nameof(RootViewModel.IsMenuOpened)))
                               .Set(Panel.ZIndexProperty, 1)
                               .UseStyle(Theme.HambergerMenu)
                               .Header("Titre")
                               .Contains(new MainMenuView().AsFluent())))
               .Cell(GridCellExtensions.Create()
                     .Height("*")
                     .Contains(new TabControl()
                               .AsFluent()
                               .Bind(BindingExtensions
                                     .TwoWay(TabControl.SelectedIndexProperty)
                                     .With(nameof(RootViewModel.CurrentView)))
                               .Tab(new PlayerView().AsFluent())
                               .Tab(new SearchView().AsFluent())
                               )))
     .Initialize(null);
 }
Пример #4
0
        public SearchView()
        {
            var bmp = new BitmapImage(new Uri(@"pack://application:,,,/Resources/no-artist.png", UriKind.Absolute));

            var dataTemplate = TemplateExtensions.Create <DockPanel>()
                               .Contains(TemplateExtensions.Create <Image>()
                                         .Set(DockPanel.DockProperty, Dock.Left)
                                         .Set(Control.HeightProperty, 25d)
                                         .Set(Control.WidthProperty, 25d)
                                         .Bind(Image.SourceProperty, nameof(IArtist.PictureUri), null, bmp))
                               .Contains(TemplateExtensions.Create <TextBlock>()
                                         .Set(Control.MarginProperty, new Thickness(8, 0, 0, 0))
                                         .Set(Control.VerticalAlignmentProperty, VerticalAlignment.Center)
                                         .Set(Control.MaxWidthProperty, 250d)
                                         .Set(Control.HorizontalAlignmentProperty, HorizontalAlignment.Left)
                                         .Set(TextBlock.TextWrappingProperty, TextWrapping.WrapWithOverflow)
                                         .Bind(TextBlock.TextProperty, nameof(IArtist.Name)))
                               .AsDataTemplate <IArtist>();

            var navigationButtonStyle = StyleExtensions.Create()
                                        .BasedOn <Button>()
                                        .Set(Control.HorizontalAlignmentProperty, HorizontalAlignment.Left)
                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                        .Set(Control.FontSizeProperty, 18d)
                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))
                                        .When(TriggerExtensions
                                              .Property(FrameworkElement.IsEnabledProperty)
                                              .Is(false)
                                              .Then(FrameworkElement.VisibilityProperty, Visibility.Hidden))
                                        .AsStyle <Button>();

            this.fluentItem = this.AsFluent <TabItem>()
                              .Bind(BindingExtensions
                                    .OneTime(FrameworkElement.DataContextProperty)
                                    .With(nameof(RootViewModel.Search)))
                              .Set(FrameworkElement.VisibilityProperty, Visibility.Collapsed)
                              .Contains(new Grid()
                                        .AsFluent()
                                        .Margin(0, 25, 0, 0)
                                        .Cell(GridCellExtensions.Create()
                                              .Contains(new Button()
                                                        .AsFluent()
                                                        .UseStyle(navigationButtonStyle)
                                                        .Contains("")
                                                        .SubDataContext(nameof(SearchViewModel.NavigationViewModel))
                                                        .Bind(BindingExtensions
                                                              .OneTime(ButtonBase.CommandProperty)
                                                              .With(nameof(SearchNavigationViewModel.GoBackCommand)))))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(1).AutoWidth()
                                              .Contains(new TextBlock()
                                                        .AsFluent()
                                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                        .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                                        .Set(TextBlock.TextProperty, "Search")))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(2).Width("*")
                                              .Contains(new TextBox()
                                                        .AsFluent()
                                                        .Bind(BindingExtensions
                                                              .TwoWay(TextBox.TextProperty)
                                                              .With(nameof(SearchViewModel.Search)))
                                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                        .Set(TextBox.VerticalContentAlignmentProperty, VerticalAlignment.Center)
                                                        .On(TextBoxBase.KeyUpEvent, OnTextChanged)))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(3).AutoWidth()
                                              .Contains(new DropDownButton()
                                                        .AsFluent()
                                                        .Contains("⋮")
                                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))
                                                        .Set(Control.FontSizeProperty, 18d)
                                                        .Set(Control.ContextMenuProperty, SearchContextMenuBuilder.Create())))
                                        .Cell(GridCellExtensions.Create()
                                              .Row(1).Span(1, 4).Height("*")
                                              .Contains(new ListBox()
                                                        .AsFluent()
                                                        .Set(ListBox.MarginProperty, new Thickness(4))
                                                        .Set(ListBox.ItemTemplateProperty, dataTemplate)
                                                        .Bind(BindingExtensions
                                                              .OneWay(ListBox.ItemsSourceProperty)
                                                              .With(nameof(SearchViewModel.Artists)))
                                                        ))
                                        );
        }
Пример #5
0
        public MainWindow()
        {
            this.SetResourceReference(StyleProperty, typeof(Window));

            var content = new DockPanel()
                          .AsFluent()
                          .DockTop(new Menu()
                                   .AsFluent()
                                   .Bind(BindingExtensions
                                         .OneWay(ItemsControl.ItemsSourceProperty)
                                         .With(nameof(MyWindowDataContext.MenuItems))))
                          .Dock(new Grid()
                                .AsFluent()
                                .DefaultCellSize("*", "*")
                                .Cell(GridCellExtensions.Create()
                                      .Row(0)
                                      .Column(0)
                                      .Span(3, 2)
                                      .Contains(new Image()
                                                .AsFluent()
                                                .Source(@"/Resources/Queen_Jazz.png")
                                                .Stretch(Stretch.Fill)
                                                .Margin(10)))
                                .Cell(GridCellExtensions.Create()
                                      .Row(1)
                                      .Column(2)
                                      .Contains(new CheckBox()
                                                .AsFluent()
                                                .Center()
                                                .Contains("Shuffle")
                                                .Set(FrameworkElement.ToolTipProperty, "Play playlist in random order")
                                                .Bind(BindingExtensions
                                                      .OneWay(ButtonBase.CommandProperty)
                                                      .With(nameof(MyWindowDataContext.ShuffleCommand)))))
                                .Cell(GridCellExtensions.Create()
                                      .Row(2)
                                      .Column(2)
                                      .Contains(new CheckBox()
                                                .AsFluent()
                                                .Center()
                                                .Contains("Loop")
                                                .Set(FrameworkElement.ToolTipProperty, "Repeat playlist")
                                                .Bind(BindingExtensions
                                                      .OneWay(ButtonBase.CommandProperty)
                                                      .With(nameof(MyWindowDataContext.LoopCommand)))))
                                .Cell(GridCellExtensions.Create()
                                      .Row(3)
                                      .Column(0)
                                      .Span(1, 3)
                                      .AutoHeight()
                                      .Contains(new TextBlock()
                                                .AsFluent()
                                                .Center()
                                                .Bind(BindingExtensions
                                                      .OneWay(TextBlock.TextProperty)
                                                      .With(nameof(MyWindowDataContext.SongTitle)))))
                                .Cell(GridCellExtensions.Create()
                                      .Row(4)
                                      .Column(0)
                                      .AutoHeight()
                                      .Contains(new Button()
                                                .AsFluent()
                                                .Contains("<<")))
                                .Set(FrameworkElement.ToolTipProperty, "Go to previous song")
                                .Cell(GridCellExtensions.Create()
                                      .Row(4)
                                      .Column(1)
                                      .Contains(new Button()
                                                .AsFluent()
                                                .Contains(">")))
                                .Set(FrameworkElement.ToolTipProperty, "Play")
                                .Cell(GridCellExtensions.Create()
                                      .Row(4)
                                      .Column(2)
                                      .Contains(new Button()
                                                .AsFluent()
                                                .Contains(">>")
                                                .Set(FrameworkElement.ToolTipProperty, "Go to next song")
                                                .On(ButtonBase.ClickEvent, OnNextSong)))
                                .Cell(GridCellExtensions.Create()
                                      .Row(5)
                                      .Column(0)
                                      .Span(1, 3)
                                      .Contains(new ProgressBar()
                                                .AsFluent()
                                                .Bind(BindingExtensions
                                                      .OneWay(RangeBase.ValueProperty)
                                                      .With(nameof(MyWindowDataContext.Progress))
                                                      .Convert(x => Math.Round((double)x)))
                                                .Minium(0)
                                                .Maximum(100)
                                                .MarginTop(10)
                                                .MarginBottom(10))));

            this.AsFluent <Window>()
            .Contains(content)
            .Size(400, 250)
            .NoResize()
            .NoBorder()
            .Initialize(new MyWindowDataContext());
        }