Skip to content

Commit

Permalink
show welcome tab on startup; settings UI tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Mar 16, 2024
1 parent a3dbb05 commit b786675
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 28 deletions.
35 changes: 20 additions & 15 deletions Client/Rubberduck.Editor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,26 @@ private void ShowStartupToolwindows(EditorSettings settings)

private async Task LoadWelcomeTabAsync(IShellWindowViewModel model)
{
//var fileSystem = _serviceProvider.GetRequiredService<IFileSystem>();
//var path = fileSystem.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Rubberduck", "Templates", "Welcome.md");
//var content = await fileSystem.File.ReadAllTextAsync(path);

//var showSettingsCommand = _serviceProvider.GetRequiredService<ShowRubberduckSettingsCommand>();
//var closeToolWindowCommand = _serviceProvider.GetRequiredService<CloseToolWindowCommand>();
//var activeDocumentStatus = _serviceProvider.GetRequiredService<IDocumentStatusViewModel>();
//var welcome = new MarkdownDocumentTabViewModel(new WorkspaceFileUri(null!, new Uri(path)), "Welcome", content, isReadOnly: true, showSettingsCommand, closeToolWindowCommand, activeDocumentStatus, () => _languageClient.LanguageClient!);

//var welcomeTabContent = new MarkdownEditorControl() { DataContext = welcome };
//welcome.ContentControl = welcomeTabContent;
//welcome.IsSelected = true;

//model.DocumentWindows.Add(welcome);
//model.ActiveDocumentTab = welcome;
var fileSystem = _serviceProvider.GetRequiredService<IFileSystem>();
var folder = fileSystem.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Rubberduck", "Templates");
var filename = "Welcome.md";
var path = fileSystem.Path.Combine(folder, filename);
var content = await fileSystem.File.ReadAllTextAsync(path);

var rootUri = new Uri(folder);
var fileUri = new WorkspaceFileUri(filename, rootUri);

var showSettingsCommand = _serviceProvider.GetRequiredService<ShowRubberduckSettingsCommand>();
var closeToolWindowCommand = _serviceProvider.GetRequiredService<CloseToolWindowCommand>();
var activeDocumentStatus = _serviceProvider.GetRequiredService<IDocumentStatusViewModel>();
var documentState = new DocumentState(fileUri, content, isOpened: true);
var welcome = new MarkdownDocumentTabViewModel(documentState, isReadOnly: true, showSettingsCommand, closeToolWindowCommand, activeDocumentStatus, () => _languageClient.LanguageClient!);
var welcomeTabContent = new MarkdownEditorControl() { DataContext = welcome };
welcome.ContentControl = welcomeTabContent;
welcome.IsSelected = true;

model.DocumentWindows.Add(welcome);
model.ActiveDocumentTab = welcome;
}

protected override void OnExit(ExitEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Rubberduck.UI.Converters
public class WrapPanelItemWidthConverter : IValueConverter
{
public double MinItemWidth { get; set; } = 300;
public double MaxItemWidth { get; set; } = 512;
public double MaxItemWidth { get; set; } = 720;

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Client/Rubberduck.UI/Rubberduck.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<None Remove="Resources\Custom\vector-ducky-blur-1480.png" />
<None Remove="Resources\Custom\vector-ducky-color.png" />
<None Remove="Resources\Custom\vector-ducky-shadow-1480.png" />
<None Remove="Resources\FontAwesome\arrows-left-right-to-line-solid.png" />
<None Remove="Resources\FontAwesome\arrows-spin-solid.png" />
<None Remove="Resources\FontAwesome\ban-solid.png" />
<None Remove="Resources\FontAwesome\bomb-solid.png" />
Expand Down Expand Up @@ -417,6 +418,7 @@
<Resource Include="Resources\Custom\vector-ducky-blur-1480.png" />
<Resource Include="Resources\Custom\vector-ducky-color.png" />
<Resource Include="Resources\Custom\vector-ducky-shadow-1480.png" />
<Resource Include="Resources\FontAwesome\arrows-left-right-to-line-solid.png" />
<Resource Include="Resources\FontAwesome\arrows-spin-solid.png" />
<Resource Include="Resources\FontAwesome\ban-solid.png" />
<Resource Include="Resources\FontAwesome\bomb-solid.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public SettingsWindowViewModel(UIServiceHelper service, MessageActionCommand[] a
ShowSettingsCommand = new DelegateCommand(service, parameter => ResetToDefaults());
service.RunOnMainThread(() => Settings = _factory.CreateViewModel(_service.Settings));

ExpandSettingGroupCommand = new DelegateCommand(service, parameter =>
{
if (parameter is ISettingGroupViewModel model)
{
ExecuteExpandSettingGroupCommand(model);
}
});

CommandBindings = new CommandBinding[]
{
new(NavigationCommands.Search, DialogCommandHandlers.BrowseLocationCommandBinding_Executed, DialogCommandHandlers.BrowseLocationCommandBinding_CanExecute),
Expand All @@ -38,7 +46,26 @@ public SettingsWindowViewModel(UIServiceHelper service, MessageActionCommand[] a

public bool ShowPinButton => false;

public ISettingGroupViewModel Settings { get; private set; }
public ICommand ExpandSettingGroupCommand { get; }

private void ExecuteExpandSettingGroupCommand(ISettingGroupViewModel model)
{
Selection = model;
}

private ISettingGroupViewModel _settings;
public ISettingGroupViewModel Settings
{
get => _settings;
private set
{
if (_settings != value)
{
_settings = value;
OnPropertyChanged();
}
}
}

private ISettingViewModel _selection;
public ISettingViewModel Selection
Expand Down
14 changes: 14 additions & 0 deletions Client/Rubberduck.UI/Shared/Settings/SettingGroupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public bool IsEnabled
}
}

private bool _isExpanded;
public bool IsExpanded
{
get => _isExpanded;
set
{
if (_isExpanded != value)
{
_isExpanded = value;
OnPropertyChanged();
}
}
}

public RubberduckSetting ToSetting() => _settingGroup with { Value = Items.Select(e => e.ToSetting()).ToArray() };
}
}
14 changes: 10 additions & 4 deletions Client/Rubberduck.UI/Shared/Settings/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Border Background="{DynamicResource ThemeWhiteLightColorBrush50}">
<Border>
<ListView MinWidth="160" Margin="4"
Background="Transparent"
BorderThickness="0"
Background="{DynamicResource ThemeBackgroundColorBrush}"
BorderThickness="1"
BorderBrush="{DynamicResource ThemeWhiteDarkColorBrush}"
VerticalAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Expand All @@ -62,7 +63,12 @@
</ListView>
</Border>

<templates:SettingGroupControl Grid.Column="1" DataContext="{Binding Selection}" />

<templates:SettingGroupControl Grid.Column="1"
DataContext="{Binding Selection}"
Background="{DynamicResource ThemeWhiteLightColorBrush75}"
BorderThickness="1" BorderBrush="{DynamicResource ThemeWhiteDarkColorBrush}"
Margin="5"/>
</Grid>
</shell:ThunderFrame>
<Thumb Grid.Row="1" HorizontalAlignment="Right" IsEnabled="True" IsHitTestVisible="True" WindowChrome.IsHitTestVisibleInChrome="True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
</Label>
</ScrollViewer>
<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto">
<ListBox HorizontalContentAlignment="Stretch"
Background="Transparent" BorderThickness="0"
<ListBox HorizontalContentAlignment="Stretch" BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
VerticalContentAlignment="Stretch"
Expand All @@ -58,7 +57,9 @@
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemWidth="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer, Mode=FindAncestor}, Converter={StaticResource WrapPanelItemWidthConverter}, ConverterParameter={StaticResource ItemsViewSource}}" />
<WrapPanel ItemWidth="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer, Mode=FindAncestor},
Converter={StaticResource WrapPanelItemWidthConverter},
ConverterParameter={StaticResource ItemsViewSource}}" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
CheckedIcon="{DynamicResource UnlockedIcon}"
IsChecked="{Binding IsEnabled}"
Visibility="{Binding IsReadOnlyRecommended, Converter={StaticResource BoolToVisibilityConverter}}" />
<shell:FlatToggleButton DockPanel.Dock="Right" VerticalAlignment="Top" Height="16"
Icon="{DynamicResource ExpandSectionIcon}"
ToolTip="Expand this setting group"
Command="{Binding DataContext.ExpandSettingGroupCommand, RelativeSource={RelativeSource AncestorType=viewmodels:SettingsWindow, Mode=FindAncestor}}"
CommandParameter="{Binding}"
IsChecked="{Binding IsExpanded}">
</shell:FlatToggleButton>
<Label DockPanel.Dock="Top" Style="{DynamicResource FormTitleLabelStyle}" Margin="0" IsEnabled="{Binding IsEnabled}">
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" />
</Label>
Expand Down
6 changes: 3 additions & 3 deletions Client/Rubberduck.UI/Styles/DefaultStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@

<Style x:Key="SectionBorderStyle" TargetType="Border">
<Style.Setters>
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundMediumColorBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBackgroundDarkColorBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundColorBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeAccent1DarkColorBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="Padding" Value="10,10,10,10" />
</Style.Setters>
Expand Down
2 changes: 2 additions & 0 deletions Client/Rubberduck.UI/Styles/Icons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<BitmapImage x:Key="CircleCheckIcon" UriSource="pack://application:,,,/Rubberduck.UI;component/Resources/FontAwesome/circle-check-solid.png" />
<BitmapImage x:Key="CircleWarnIcon" UriSource="pack://application:,,,/Rubberduck.UI;component/Resources/FontAwesome/circle-exclamation-solid.png" />

<BitmapImage x:Key="ExpandSectionIcon" UriSource="pack://application:,,,/Rubberduck.UI;component/Resources/FontAwesome/arrows-left-right-to-line-solid.png" />

<BitmapImage x:Key="CollapseAllIcon" UriSource="pack://application:,,,/Rubberduck.UI;component/Resources/FontAwesome/square-minus-regular.png" />
<BitmapImage x:Key="ExpandAllIcon" UriSource="pack://application:,,,/Rubberduck.UI;component/Resources/FontAwesome/square-plus-regular.png" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public record class IsTelemetryEnabledSetting : BooleanRubberduckSetting
{
public static bool DefaultSettingValue { get; } = true;
public static bool DefaultSettingValue { get; } = false;

public IsTelemetryEnabledSetting()
{
Expand Down

0 comments on commit b786675

Please sign in to comment.