Skip to content

Commit

Permalink
Favorites, Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
newcat committed Oct 2, 2016
1 parent eecf104 commit 6595d39
Show file tree
Hide file tree
Showing 21 changed files with 985 additions and 337 deletions.
6 changes: 6 additions & 0 deletions tvdc/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="showJoinLeave" serializeAs="String">
<value>True</value>
</setting>
<setting name="favoriteChannels" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</value>
</setting>
</tvdc.Properties.Settings>
</userSettings>
<runtime>
Expand Down
223 changes: 223 additions & 0 deletions tvdc/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,228 @@
</BulletDecorator>
</ControlTemplate>

<!-- Progress Bar Style -->
<Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid Height="18" MinWidth="100" Background="Transparent">
<Border x:Name="PART_Track" CornerRadius="6" BorderBrush="White" BorderThickness="1" Margin="2"/>
<Border x:Name="PART_Indicator" CornerRadius="4" BorderThickness="1" HorizontalAlignment="Left" Background="White" Margin="6,5,0,5" BorderBrush="White" Padding="0" RenderTransformOrigin="0,0.5" >
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.97"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


<!-- Scroll Bar Style -->
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="18" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Template" Value="{DynamicResource sbVert}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto" />
<Setter Property="Height" Value="18" />
<Setter Property="Template" Value="{DynamicResource sbHori}" />
</Trigger>
</Style.Triggers>
</Style>

<ControlTemplate x:Key="sbVert" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18" />
<RowDefinition Height="0.00001*" />
<RowDefinition MaxHeight="18" />
</Grid.RowDefinitions>

<Border Grid.RowSpan="3" CornerRadius="4" BorderBrush="White" BorderThickness="0" />

<RepeatButton Grid.Row="0"
Style="{DynamicResource ScrollBarLineButton}"
Height="18"
Command="ScrollBar.LineUpCommand"
Content="M 0 4 L 8 4 L 4 0 Z" />

<RepeatButton Grid.Row="3"
Style="{DynamicResource ScrollBarLineButton}"
Height="18"
Command="ScrollBar.LineDownCommand"
Content="M 0 0 L 4 4 L 8 0 Z" />

<Track x:Name="PART_Track" Grid.Row="1" IsDirectionReversed="True">
<Track.Thumb>
<Thumb Margin="1,0,1,0">
<Thumb.Style>
<Style TargetType="{x:Type Thumb}">
<Setter Property="Focusable" Value="False" />
<Setter Property="Template" Value="{DynamicResource scrollBarThumb}" />
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>

</Grid>
</ControlTemplate>

<ControlTemplate x:Key="sbHori" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="18" />
<ColumnDefinition Width="0.00001*" />
<ColumnDefinition MaxWidth="18" />
</Grid.ColumnDefinitions>

<Border Grid.ColumnSpan="4" Background="Transparent" BorderThickness="0" />

<RepeatButton Grid.Column="0"
Style="{DynamicResource ScrollBarLineButton}"
Width="18"
Command="ScrollBar.LineLeftCommand"
Content="M 4 0 L 4 8 L 0 4 Z" />

<RepeatButton Grid.Column="3"
Style="{DynamicResource ScrollBarLineButton}"
Width="18"
Command="ScrollBar.LineRightCommand"
Content="M 0 0 L 4 4 L 0 8 Z" />

<Track x:Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
<Track.Thumb>
<Thumb Margin="0,1,0,1">
<Thumb.Style>
<Style TargetType="{x:Type Thumb}">
<Setter Property="Focusable" Value="False" />
<Setter Property="Template" Value="{DynamicResource scrollBarThumb}" />
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>

</Grid>
</ControlTemplate>

<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border x:Name="repbtnBorder" Margin="1" CornerRadius="2" BorderThickness="1" BorderBrush="White" Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<ColorAnimation To="Transparent" Duration="00:00:00.1"
Storyboard.TargetName="repbtnBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation To="#40FFFFFF" Duration="00:00:00.1"
Storyboard.TargetName="repbtnBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation To="#40000000" Duration="00:00:00.0"
Storyboard.TargetName="repbtnBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Path x:Name="repbtnPath" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="White"
Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<ControlTemplate x:Key="scrollBarThumb" TargetType="{x:Type Thumb}">
<Border BorderBrush="White" BorderThickness="1" CornerRadius="2" x:Name="thumbBorder" Background="#00000000">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<ColorAnimation To="Transparent" Duration="00:00:00.1"
Storyboard.TargetName="thumbBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation To="#40FFFFFF" Duration="00:00:00.1"
Storyboard.TargetName="thumbBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation To="#40000000" Duration="00:00:00.0"
Storyboard.TargetName="thumbBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>

<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}"
TargetType="{x:Type ScrollViewer}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<DockPanel Margin="{TemplateBinding Padding}">

<ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
KeyboardNavigation.DirectionalNavigation="Local"
CanContentScroll="True"
CanHorizontallyScroll="False"
CanVerticallyScroll="False" />

</DockPanel>

<ScrollBar x:Name="PART_HorizontalScrollBar" Orientation="Horizontal"
Grid.Row="1" Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Value="{TemplateBinding HorizontalOffset}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />

<ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="1"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Value="{TemplateBinding VerticalOffset}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />

</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</Application.Resources>
</Application>
29 changes: 19 additions & 10 deletions tvdc/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,33 @@ private async void Application_Startup(object sender, StartupEventArgs e)
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "tvd_settings.cfg")))
{
string[] cfg = File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, "tvd_settings.cfg"));
if (cfg.Length == 5)
if (cfg.Length >= 5)
{
tvdc.Properties.Settings.Default.nick = cfg[0];
tvdc.Properties.Settings.Default.oauth = cfg[1];
tvdc.Properties.Settings.Default.channel = cfg[2];
tvdc.Properties.Settings.Default.debug = cfg[3] == "True" ? true : false;
tvdc.Properties.Settings.Default.showJoinLeave = cfg[4] == "True" ? true : false;
for (int i = 5; i < cfg.Length; i++)
{
tvdc.Properties.Settings.Default.favoriteChannels.Add(cfg[i]);
}
}
File.Delete(Path.Combine(Environment.CurrentDirectory, "tvd_settings.cfg"));
}

if (tvdc.Properties.Settings.Default.nick == "")
if (tvdc.Properties.Settings.Default.nick == "" ||
tvdc.Properties.Settings.Default.oauth == "" ||
tvdc.Properties.Settings.Default.channel == "")
{
Settings s = new Settings();
s.btnCancel.IsEnabled = false;
s.ShowDialog();
}

if (tvdc.Properties.Settings.Default.nick == "")
if (tvdc.Properties.Settings.Default.nick == "" ||
tvdc.Properties.Settings.Default.oauth == "" ||
tvdc.Properties.Settings.Default.channel == "")
{
Shutdown();
}
Expand Down Expand Up @@ -209,10 +217,10 @@ private void IRC_Userstate(object sender, UserstateEventArgs e)
return;

if (e.tags.ContainsKey("color") && e.tags["color"] != null && e.tags["color"] != "")
mainVM.invoke(() => { u.color = e.tags["color"]; });
mainVM.invoke(() => { u.Color = e.tags["color"]; });

if (e.tags.ContainsKey("display-name") && e.tags["display-name"] != null && e.tags["display-name"] != "")
mainVM.invoke(() => { u.displayName = e.tags["display-name"]; });
mainVM.invoke(() => { u.DisplayName = e.tags["display-name"]; });

if (e.tags.ContainsKey("badges") && e.tags["badges"] != null)
mainVM.invoke(() => { u.setBadges(Badges.parseBadgeString(e.tags["badges"])); });
Expand All @@ -236,10 +244,11 @@ private void IRC_PrivmsgReceived(object sender, PrivmsgReceivedEventArgs e)

List<Badges.BadgeTypes> badges = new List<Badges.BadgeTypes>();

if (u != null && e.tags.ContainsKey("badges") && e.tags["badges"] != null)
if (e.tags.ContainsKey("badges") && e.tags["badges"] != null)
{
badges = Badges.parseBadgeString(e.tags["badges"]);
mainVM.invoke(() => { u.setBadges(badges); });
if (u != null)
mainVM.invoke(() => { u.setBadges(badges); });
}

e.tags.Add("text", e.message);
Expand Down Expand Up @@ -320,9 +329,9 @@ public void sendChatMessage(string message)

if (u != null)
{
name = u.displayName;
color = u.color;
badges = u.badges;
name = u.DisplayName;
color = u.Color;
badges = u.Badges;
}

mainVM.chatEntryList_Add(new ChatEntry(name, color, MessageParser.GetParagraphsFromMessage(message), badges));
Expand Down
Loading

0 comments on commit 6595d39

Please sign in to comment.