Skip to content

Commit

Permalink
Add some shortcuts to the main group list, can be controlled by setti…
Browse files Browse the repository at this point in the history
…ngs in future (WiP)
  • Loading branch information
morpheusxx committed Sep 10, 2015
1 parent 3e61bc4 commit 23a117f
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 64 deletions.
3 changes: 3 additions & 0 deletions MediaPortal/Incubator/BlueVision/BlueVision.csproj
Expand Up @@ -84,6 +84,7 @@
<Content Include="plugin.xml" />
<Content Include="Skin\BlueVision\fonts\default-font.xml" />
<Content Include="Skin\BlueVision\images\02992BEC-1E6D-4C29-8D79-F95F59E3F625.jpg" />
<Content Include="Skin\BlueVision\images\05D4F591-CB92-4204-955A-5FF665BD8727.png" />
<Content Include="Skin\BlueVision\images\09EAE702-D9EC-4325-82D9-4843502C966B.jpg" />
<Content Include="Skin\BlueVision\images\1190A648-90F3-413D-88AC-DA89684E9766.png" />
<Content Include="Skin\BlueVision\images\17D2390E-5B05-4fbd-89F6-24D60CEB427F.jpg" />
Expand Down Expand Up @@ -480,6 +481,7 @@
<Content Include="Skin\BlueVision\images\Medialogos\video\wvc1.png" />
<Content Include="Skin\BlueVision\images\Medialogos\video\x264.png" />
<Content Include="Skin\BlueVision\images\Medialogos\video\xvid.png" />
<Content Include="Skin\BlueVision\images\Menu_button.png" />
<Content Include="Skin\BlueVision\images\news.png" />
<Content Include="Skin\BlueVision\images\NewTab_small.png" />
<Content Include="Skin\BlueVision\images\NextPage.png" />
Expand Down Expand Up @@ -526,6 +528,7 @@
<Content Include="Skin\BlueVision\images\PlayerControls.Small\SkipForwardButton.png" />
<Content Include="Skin\BlueVision\images\PlayerControls.Small\StopButton.png" />
<Content Include="Skin\BlueVision\images\power_blur.png" />
<Content Include="Skin\BlueVision\images\Power_button.png" />
<Content Include="Skin\BlueVision\images\settings.png" />
<Content Include="Skin\BlueVision\images\shadow_00.png" />
<Content Include="Skin\BlueVision\images\shadow_01.png" />
Expand Down
108 changes: 106 additions & 2 deletions MediaPortal/Incubator/BlueVision/Models/HomeMenuModel.cs
Expand Up @@ -30,6 +30,7 @@
using MediaPortal.Common.Commands;
using MediaPortal.Common.General;
using MediaPortal.Common.Logging;
using MediaPortal.Common.Messaging;
using MediaPortal.Common.Services.Settings;
using MediaPortal.Common.Settings;
using MediaPortal.UI.Presentation.DataObjects;
Expand All @@ -38,6 +39,7 @@
using MediaPortal.UiComponents.BlueVision.Settings;
using MediaPortal.UiComponents.SkinBase.General;
using MediaPortal.UiComponents.SkinBase.Models;
using MediaPortal.UI.Presentation.Players;
using MediaPortal.UI.SkinEngine.MpfElements;
using MediaPortal.Utilities.Xml;

Expand All @@ -62,7 +64,14 @@ public class HomeMenuModel : MenuModel
protected AbstractProperty _lastSelectedItemProperty;
protected AbstractProperty _lastSelectedItemNameProperty;
protected AbstractProperty _isHomeProperty;
protected AbstractProperty _isPlayerActiveProperty;
protected bool _noSettingsRefresh;
protected bool _isPlayerActive;
protected List<Guid> _shortcutWfStates = new List<Guid>
{
new Guid("D83604C0-0936-4416-9DE8-7B6D7C50023C"), // CP
new Guid("9C3E6701-6856-49ec-A4CD-0CEB15F385F6"), // FS
};

#endregion

Expand Down Expand Up @@ -183,15 +192,29 @@ public bool IsHome
set { _isHomeProperty.SetValue(value); }
}

public AbstractProperty IsPlayerActiveProperty
{
get { return _isPlayerActiveProperty; }
}

public bool IsPlayerActive
{
get { return (bool)_isPlayerActiveProperty.GetValue(); }
set { _isPlayerActiveProperty.SetValue(value); }
}

#endregion

public HomeMenuModel()
{
_lastSelectedItemProperty = new WProperty(typeof(ListItem), null);
_lastSelectedItemNameProperty = new WProperty(typeof(string), null);
_isHomeProperty = new WProperty(typeof(bool), false);
_isPlayerActiveProperty = new WProperty(typeof(bool), false);
IsHomeProperty.Attach(IsHomeChanged);

SubscribeToMessages();

ReadPositions();

CreateMenuGroupItems();
Expand Down Expand Up @@ -271,6 +294,42 @@ protected void CreateMenuGroupItems()
}
_mainMenuGroupList.Add(groupItem);
}
// Look for "shortcut items" that will be placed next to the regular groups
foreach (var menuItem in MenuItems)
{
object action;
if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action))
continue;
WorkflowAction wfAction = action as WorkflowAction;
if (wfAction == null)
continue;

if (!_shortcutWfStates.Contains(wfAction.ActionId))
continue;

string groupId = wfAction.ActionId.ToString();
string groupName = groupId;
var groupItem = new GroupMenuListItem(Consts.KEY_NAME, groupName);
if (_menuSettings.Settings.DisableAutoSelection)
groupItem.Command = new MethodDelegateCommand(() =>
{
wfAction.Execute();
});

groupItem.AdditionalProperties["Id"] = groupId;
_mainMenuGroupList.Add(groupItem);
}

// "Currently playing button" if any player is active
//if (_isPlayerActive)
//{
// var groupItem = new GroupMenuListItem(Consts.KEY_NAME, MenuSettings.MENU_NAME_PLAYING);
// if (_menuSettings.Settings.DisableAutoSelection)
// groupItem.Command = new MethodDelegateCommand(() => IsPlayerActive = true );

// groupItem.AdditionalProperties["Id"] = MenuSettings.MENU_ID_PLAYING;
// _mainMenuGroupList.Add(groupItem);
//}
}
}
_mainMenuGroupList.FireChange();
Expand Down Expand Up @@ -308,7 +367,7 @@ protected void CreatePositionedItems()
// Under "others" all items are places, that do not fit into any other category
if (CurrentKey == MenuSettings.MENU_NAME_OTHERS)
{
bool found = _menuSettings.Settings.MenuItems.Keys.Any(key => _menuSettings.Settings.MenuItems[key].ContainsKey(wfAction.ActionId));
bool found = IsManuallyPositioned(wfAction);
if (!found)
{
GridListItem gridItem = new GridListItem(menuItem)
Expand Down Expand Up @@ -341,8 +400,21 @@ protected void CreatePositionedItems()
_positionedItems.FireChange();
}

private bool IsManuallyPositioned(WorkflowAction wfAction)
{
return _menuSettings.Settings.MenuItems.Keys.Any(key => _menuSettings.Settings.MenuItems[key].ContainsKey(wfAction.ActionId));
}

private void SetGroup(string groupId)
{
bool wasPlayerActive = IsPlayerActive;
if (wasPlayerActive)
{
IsPlayerActive = false;
// Do not navigate in workflow, but only toggle visibility
return;
}

if (_menuSettings.Settings.DefaultMenuGroupId == groupId)
return;
_menuSettings.Settings.DefaultMenuGroupId = groupId;
Expand All @@ -357,7 +429,7 @@ private void SetGroup(string groupId)
UpdateSelectedGroup();
}
}
finally
finally
{
_noSettingsRefresh = false;
}
Expand Down Expand Up @@ -485,5 +557,37 @@ positions[new Guid("17D2390E-5B05-4fbd-89F6-24D60CEB427F")] = new GridPosition {
ServiceRegistration.Get<ISettingsManager>().Save(menuSettings);
}
}

private void SubscribeToMessages()
{
if (_messageQueue == null)
return;
_messageQueue.SubscribeToMessageChannel(PlayerManagerMessaging.CHANNEL);
_messageQueue.MessageReceived += OnMessageReceived;
}

private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
{
if (message.ChannelName == PlayerManagerMessaging.CHANNEL)
{
// React to player changes
PlayerManagerMessaging.MessageType messageType = (PlayerManagerMessaging.MessageType)message.MessageType;
switch (messageType)
{
case PlayerManagerMessaging.MessageType.PlayerEnded:
case PlayerManagerMessaging.MessageType.PlayerStopped:
case PlayerManagerMessaging.MessageType.PlayerStarted:
UpdatePlayerState();
break;
}
}
}

private void UpdatePlayerState()
{
_isPlayerActive = ServiceRegistration.Get<IPlayerContextManager>().PlayerContexts.Any(pc => pc.IsActive);
CreateMenuGroupItems();
CreatePositionedItems();
}
}
}
5 changes: 2 additions & 3 deletions MediaPortal/Incubator/BlueVision/Settings/MenuSettings.cs
Expand Up @@ -50,6 +50,8 @@ public class MenuSettings
public const string MENU_ID_OTHERS = "D805F21B-0A1F-4323-BEB5-B108778F89AA";
public const string MENU_NAME_HOME = "[Menu.Home]";
public const string MENU_ID_HOME = "DF153D5E-0CD9-416c-B18B-E09AD5A864D8";
public const string MENU_NAME_PLAYING = "[Menu.CurrentlyPlaying]";
public const string MENU_ID_PLAYING = "05D4F591-CB92-4204-955A-5FF665BD8727";

public const int DEFAULT_ROWSPAN_SMALL = 2;
public const int DEFAULT_COLSPAN_SMALL = 2;
Expand Down Expand Up @@ -90,9 +92,6 @@ public MenuSettings()

public class GroupItemSetting
{
public GroupItemSetting()
{ }

public string Name { get; set; }

public Guid Id { get; set; }
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -112,10 +112,10 @@ Parameters which have to be accessible by a DynamicResource lookup:
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>

<Control x:Name="MenuButtonDummy" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_Dummy}"> </Control>
<Control x:Name="MenuButtonDummyConfig" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_DummyConfig}"> </Control>
<Control x:Name="MenuButtonPlaceholder" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_Placeholder}"> </Control>
<Control x:Name="MenuButtonDummy" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_Dummy}"></Control>
<Control x:Name="MenuButtonDummyConfig" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_DummyConfig}"></Control>
<Control x:Name="MenuButtonPlaceholder" HorizontalAlignment="Stretch" Template="{DynamicResource ResourceKey=Menu_Button_Placeholder}"></Control>


<StackPanel Grid.Row="0" Grid.Column="0" Margin="145,-5,0,0" VerticalAlignment="Center" >
<Label x:Name="SelectedItem"
Expand All @@ -127,16 +127,16 @@ Parameters which have to be accessible by a DynamicResource lookup:
<Control.TemplateControl>
<Include Source="screens\MediaItemsListHeader.inc"/>
</Control.TemplateControl>
</Control>
</Control>
</StackPanel>
<!-- Main Menu Group tabs -->
<!-- use custom ListView to modify focus behavior -->

<!-- Main Menu Group tabs -->
<!-- use custom ListView to modify focus behavior -->

<!--Image Source="Menu_Background.png" Grid.Row="0" Grid.Column="1" Opacity="0.25" Stretch="Fill" Height="90" Margin="15,-5,15,-5"
VerticalAlignment="Center" HorizontalAlignment="Center"/-->

<bvm:GroupMenuListView x:Name="GroupList" Style="{ThemeResource HomeGroupListViewStyle}" Grid.Row="0" Grid.Column="1"
<bvm:GroupMenuListView x:Name="GroupList" Style="{ThemeResource HomeGroupListViewStyle}" Grid.Row="0" Grid.Column="1"
VerticalAlignment="Center" HorizontalAlignment="Center"
HomeMenuModel="{StaticResource MenuModel}" Margin="-5,8,-5,-8"
IsEnabled="{Binding Source={StaticResource MenuModel},Path=!IsMenuOpen}"
Expand All @@ -148,13 +148,13 @@ Parameters which have to be accessible by a DynamicResource lookup:
</bvm:GroupMenuListView>

<!-- Time & Date -->
<StackPanel Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Margin="-70,-5,5,0" VerticalAlignment="Center">
<Label x:Name="TimeLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentTime}"
<StackPanel Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Margin="-70,-5,5,0" VerticalAlignment="Center">
<Label x:Name="TimeLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentTime}"
FontSize="{ThemeResource BiggerFontSize}" FontFamily="DefaultBold"
Color="{ThemeResource TextColor}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<Label x:Name="DateLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentDate}" FontSize="{ThemeResource SmallFontSize}" FontFamily="DefaultBold"
<Label x:Name="DateLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentDate}" FontSize="{ThemeResource SmallFontSize}" FontFamily="DefaultBold"
Color="{ThemeResource TextColor}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,-8,0,0"/>
</StackPanel>
</StackPanel>

<!-- Power button -->
<!--StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center"-->
Expand Down Expand Up @@ -189,16 +189,30 @@ Parameters which have to be accessible by a DynamicResource lookup:
</Trigger.Setters>
</Trigger>
</Button.Triggers>
</Button>


</Button>

<!--/StackPanel-->

<Image Source="shadow_top.png" Grid.Row="1" Grid.ColumnSpan="4" Margin="0,0,0,0" />
</Grid>

<!-- Order matters here: The client area control has to be the last control (LastChildFill) -->
<Control x:Name="ClientArea" Grid.Row="2" Template="{DynamicResource ResourceKey=Client_Template}" Margin="115,17,115,-3"/>
<!-- This is the normal content for home (and all other screens) -->
<Control x:Name="ClientArea" Grid.Row="2" Template="{DynamicResource ResourceKey=Client_Template}" IsVisible="{Binding Source={StaticResource MenuModel},Path=!IsPlayerActive}" Margin="115,17,115,-3"/>

<!-- Alternative content if any player is active -->
<DockPanel x:Name="PlayerControlPanel" DockPanel.Dock="Bottom" Grid.Row="2" IsVisible="{Binding Source={StaticResource MenuModel},Path=IsPlayerActive}" HorizontalAlignment="Center">

<mp_special_controls:PlayerControl x:Name="PrimaryPlayerControl" Margin="3" Style="{ThemeResource NavigationScreenPlayerControlStyle}" Width="710" DockPanel.Dock="Left"
HorizontalAlignment="Left" VerticalAlignment="Top" Height="205"
AutoVisibility="True" PlayerContext="PrimaryPlayer"/>

<mp_special_controls:PlayerControl x:Name="SecondaryPlayerControl" Margin="3" Style="{ThemeResource NavigationScreenPlayerControlStyleSecondary}" Width="710" DockPanel.Dock="Right"
HorizontalAlignment="Right" VerticalAlignment="Top"
AutoVisibility="True" PlayerContext="SecondaryPlayer"/>

</DockPanel>


<Image Source="shadow_bottom.png" Margin="-115,0,-115,0" Grid.Row="3" VerticalAlignment="Top" />

Expand All @@ -216,45 +230,6 @@ Parameters which have to be accessible by a DynamicResource lookup:
Template="{DynamicResource ResourceKey=Alternative_Footer_Template}">
</Control>

<!-- PlayerControlsPanel Focusable="True"-->
<Grid x:Name="FooterPanel" Grid.Row="3" Height="{ThemeResource FooterPanelHeight}" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5"
IsEnabled="{Binding Source={StaticResource MenuModel},Path=!IsMenuOpen}">

<Grid.RenderTransform>
<!--<TranslateTransform Y="200" />-->
</Grid.RenderTransform>
<Grid.Triggers>
<!--<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard x:Name="SlideIn_BeginStoryboard" Storyboard="{ThemeResource SlideInStoryboard}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="SlideIn_BeginStoryboard"/>
</Trigger.ExitActions>
</Trigger>-->
<!--<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Trigger.EnterActions>
<BeginStoryboard x:Name="SlideIn_BeginStoryboard2" Storyboard="{ThemeResource SlideInStoryboard}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="SlideIn_BeginStoryboard2"/>
</Trigger.ExitActions>
</Trigger>-->
</Grid.Triggers>

<DockPanel x:Name="PlayerControlPanel" DockPanel.Dock="Bottom" Grid.Row="1" LastChildFill="False">

<mp_special_controls:PlayerControl x:Name="PrimaryPlayerControl" Margin="3" Style="{ThemeResource NavigationScreenPlayerControlStyle}" Width="710" DockPanel.Dock="Left"
HorizontalAlignment="Left" VerticalAlignment="Top" Height="205"
AutoVisibility="True" PlayerContext="PrimaryPlayer"/>

<mp_special_controls:PlayerControl x:Name="SecondaryPlayerControl" Margin="3" Style="{ThemeResource NavigationScreenPlayerControlStyleSecondary}" Width="710" DockPanel.Dock="Right"
HorizontalAlignment="Right" VerticalAlignment="Top"
AutoVisibility="True" PlayerContext="SecondaryPlayer"/>

</DockPanel>
</Grid>

</Grid>
<!-- FooterPanel -->

Expand Down
Expand Up @@ -280,15 +280,15 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!--Rectangle x:Name="ButtonControlRectangle" StrokeThickness="1.5" Opacity="0" Margin="-2">
<Rectangle x:Name="ButtonControlRectangle" StrokeThickness="1.5" Opacity="0" Margin="-2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#00A0A0A0" Offset="0.05"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="#00A0A0A0" Offset="0.95"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle-->
</Rectangle>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Expand Up @@ -639,7 +639,8 @@

<!-- Displayed texts in main menu -->
<DataTemplate x:Key="HomeGroupDataTemplate" DataType="{x:Type collections:ListItem}">
<Image DockPanel.Dock="Center" HorizontalAlignment="Center" VerticalAlignment="Center" Width="63" Height="63" Stretch="Fill" Margin="7,0,7,0">
<Image DockPanel.Dock="Center" HorizontalAlignment="Center" VerticalAlignment="Center" Width="63" Height="63" Stretch="Fill" Margin="7,0,7,0"
FallbackSource="FavouriteTab_smalll.png">
<Image.Source>
<MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} + {1}">
<Binding Path="AdditionalProperties[Id]"/>
Expand Down

0 comments on commit 23a117f

Please sign in to comment.