Skip to content

Commit

Permalink
Lots of bugfixes and small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
newcat committed Oct 3, 2016
1 parent ac95e2b commit 1b32437
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 132 deletions.
9 changes: 8 additions & 1 deletion pollPlugin/PollSetup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ public partial class PollSetup : Window, IPlugin

public PollSetup()
{
Assembly.LoadFrom("plugin.dll");
try
{
Assembly.LoadFrom("plugin.dll");
} catch (Exception e)
{
MessageBox.Show("Unable to initialize poll plugin:\n" + e.Message);
return;
}
InitializeComponent();
listBox.ItemsSource = pollOptions;
}
Expand Down
2 changes: 1 addition & 1 deletion tvdc/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private async void Application_Startup(object sender, StartupEventArgs e)

try
{
tvdc.Properties.Settings.Default.GetPreviousVersion("name");
tvdc.Properties.Settings.Default.GetPreviousVersion("nick");

tvdc.Properties.Settings.Default.Reset();
tvdc.Properties.Settings.Default.upgradeRequired = false;
Expand Down
32 changes: 28 additions & 4 deletions tvdc/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
</LinearGradientBrush>

<ContextMenu x:Key="UserContextMenu">
<MenuItem Header="Mod" />
<MenuItem Header="Unmod" />
<MenuItem Header="Timeout" />
<MenuItem Header="Mod" Command="{Binding CmdMod, Source={x:Static local:MainWindowVM.Instance}}"
CommandParameter="{Binding Username}" />
<MenuItem Header="Unmod" Command="{Binding CmdUnmod, Source={x:Static local:MainWindowVM.Instance}}"
CommandParameter="{Binding Username}"/>
<MenuItem Header="Timeout" Command="{Binding CmdTimeout, Source={x:Static local:MainWindowVM.Instance}}"
CommandParameter="{Binding Username}"/>
</ContextMenu>

<!-- Control Templates for the chat box -->
Expand Down Expand Up @@ -103,6 +106,9 @@
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.TURBO}">
<Setter Property="Source" Value="{x:Static local:Badges.turbo}" />
</DataTrigger>
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.PREMIUM}">
<Setter Property="Source" Value="{x:Static local:Badges.premium}" />
</DataTrigger>
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.SUBSCRIBER}">
<Setter Property="Source" Value="{x:Static local:Badges.subscriber}" />
</DataTrigger>
Expand Down Expand Up @@ -221,6 +227,9 @@
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.TURBO}">
<Setter Property="Source" Value="{x:Static local:Badges.turbo}" />
</DataTrigger>
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.PREMIUM}">
<Setter Property="Source" Value="{x:Static local:Badges.premium}" />
</DataTrigger>
<DataTrigger Binding="{Binding}" Value="{x:Static local:Badges+BadgeTypes.SUBSCRIBER}">
<Setter Property="Source" Value="{x:Static local:Badges.subscriber}" />
</DataTrigger>
Expand Down Expand Up @@ -420,10 +429,25 @@
</ListView.ItemContainerStyle>

</ListView>
<Expander x:Name="expanderChannel" HorizontalAlignment="Right" VerticalAlignment="Stretch" ExpandDirection="Left" Margin="0,12,12,12" Panel.ZIndex="3">
<Expander x:Name="expanderChannel" HorizontalAlignment="Right" ExpandDirection="Left"
Margin="0,12,12,12" Panel.ZIndex="3">
<Expander.Effect>
<DropShadowEffect BlurRadius="36" Direction="138"/>
</Expander.Effect>

<Expander.Style>
<Style TargetType="Expander">
<Setter Property="VerticalAlignment" Value="Top" />
<Style.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Trigger.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
</Trigger.Setters>
</Trigger>
</Style.Triggers>
</Style>
</Expander.Style>

<Grid Background="#CC000000" Width="200">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
Expand Down
4 changes: 2 additions & 2 deletions tvdc/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace tvdc
{

//TODO: Add support for cheering
//TODO: Make context menu functional
//TODO: Replace ViewerRow control
//TODO: Maybe problems with the plugins (either plugin.dll [unlikely] or the pollplugin)

/// <summary>
/// Interaction logic for MainWindow.xaml
Expand All @@ -26,6 +25,7 @@ public partial class MainWindow : Window

public MainWindow(MainWindowVM vm)
{

InitializeComponent();
this.vm = vm;
vm.chatEntryList.CollectionChanged += ChatEntryList_CollectionChanged;
Expand Down
6 changes: 6 additions & 0 deletions tvdc/MainWindowVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public string SelectedChannel
public RelayCommand<string> cmdSendChat { get; private set; }
public RelayCommand CmdRemoveChannelEntry { get; private set; }
public RelayCommand<string> CmdAddChannelEntry { get; private set; }
public RelayCommand<string> CmdMod { get; private set; }
public RelayCommand<string> CmdUnmod { get; private set; }
public RelayCommand<string> CmdTimeout { get; private set; }

public event EventHandler<PluginClickedEventArgs> PluginClicked;
public event EventHandler<SendMessageEventArgs> SendMessage;
Expand Down Expand Up @@ -154,6 +157,9 @@ private MainWindowVM()
}
},
() => SelectedChannel != null);
CmdMod = new RelayCommand<string>((s) => sendMessage("/mod " + s));
CmdUnmod = new RelayCommand<string>((s) => sendMessage("/unmod " + s));
CmdTimeout = new RelayCommand<string>((s) => sendMessage("/timeout " + s));

PropertyChanged += MainWindowVM_PropertyChanged;
}
Expand Down
10 changes: 7 additions & 3 deletions tvdc/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Net;
using System.Web.Script.Serialization;
using System.Windows;
using System.Linq;

namespace tvdc
{
Expand Down Expand Up @@ -171,7 +170,7 @@ private async void getDisplayName()
WebClient wr = new WebClient();
string json = "";

wr.Headers.Add("Client-ID", (string)Application.Current.Resources["client_id"]);
wr.Headers.Add("Client-ID", Properties.Resources.client_id);

try
{
Expand All @@ -191,7 +190,9 @@ private async void getDisplayName()
}

try {
json = await wr.DownloadStringTaskAsync(string.Format("https://api.twitch.tv/kraken/users/{0}/follows/channels/{1}", Name, Properties.Settings.Default.channel));
json = await wr.DownloadStringTaskAsync(
string.Format("https://api.twitch.tv/kraken/users/{0}/follows/channels/{1}",
Name, Properties.Settings.Default.channel));
}
catch (WebException ex)
{
Expand Down Expand Up @@ -243,6 +244,9 @@ private int getBadgeLevel()
if (Badges.Contains(tvdc.Badges.BadgeTypes.TURBO))
badgeLevel = 2;

if (Badges.Contains(tvdc.Badges.BadgeTypes.PREMIUM))
badgeLevel = 2;

if (Badges.Contains(tvdc.Badges.BadgeTypes.MODERATOR))
badgeLevel = 3;

Expand Down
10 changes: 10 additions & 0 deletions tvdc/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tvdc/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
<data name="mod_alpha" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mod-alpha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="premium" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\premium.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="staff_alpha" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\staff-alpha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file added tvdc/Resources/premium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion tvdc/Static Stuff/Badges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public class Badges
public static BitmapImage turbo { get; private set; }
public static BitmapImage broadcaster { get; private set; }
public static BitmapImage subscriber { get; private set; }
public static BitmapImage premium { get; private set; }

public enum BadgeTypes
{
SUBSCRIBER, TURBO, MODERATOR, BROADCASTER, GLOBAL_MOD, ADMIN, STAFF
SUBSCRIBER, TURBO, MODERATOR, BROADCASTER, GLOBAL_MOD, ADMIN, STAFF, PREMIUM
}

public static void init()
Expand All @@ -42,6 +43,7 @@ public static void init()
moderator = convert(Properties.Resources.mod_alpha);
turbo = convert(Properties.Resources.turbo_alpha);
broadcaster = convert(Properties.Resources.broadcaster_alpha);
premium = convert(Properties.Resources.premium);

loaded = true;

Expand Down Expand Up @@ -137,6 +139,9 @@ public static List<BadgeTypes> parseBadgeString(string bs)
if (bs.Contains("subscriber"))
returnList.Add(BadgeTypes.SUBSCRIBER);

if (bs.Contains("premium"))
returnList.Add(BadgeTypes.PREMIUM);

if (bs.Contains("turbo"))
returnList.Add(BadgeTypes.TURBO);

Expand Down
14 changes: 0 additions & 14 deletions tvdc/UserControls/ViewerRow.xaml

This file was deleted.

99 changes: 0 additions & 99 deletions tvdc/UserControls/ViewerRow.xaml.cs

This file was deleted.

10 changes: 3 additions & 7 deletions tvdc/tvdc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@
<Compile Include="UserControls\Graph.xaml.cs">
<DependentUpon>Graph.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\ViewerRow.xaml.cs">
<DependentUpon>ViewerRow.xaml</DependentUpon>
</Compile>
<Page Include="AuthenticationWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -182,10 +179,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\ViewerRow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down Expand Up @@ -277,6 +270,9 @@
<Name>plugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\premium.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.28.3\build\Fody.targets" Condition="Exists('..\packages\Fody.1.28.3\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down

0 comments on commit 1b32437

Please sign in to comment.