Skip to content

Commit

Permalink
Version 24.7 Beta 1.1
Browse files Browse the repository at this point in the history
· Added Album Cover & Solid Color Backdrops
· Bugfixes
· Added tooltips for empty Hardware Monitors and Photo Widgets
  • Loading branch information
yagdev committed Jul 1, 2024
1 parent 6fd87af commit c3c03f0
Show file tree
Hide file tree
Showing 18 changed files with 691 additions and 510 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified CompanionDisplayWinUI/.vs/CompanionDisplayWinUI/v17/.suo
Binary file not shown.
982 changes: 504 additions & 478 deletions CompanionDisplayWinUI/.vs/CompanionDisplayWinUI/v17/DocumentLayout.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public App()
Globals.Wallpaper = readerconfig.ReadLine();
Globals.Blur = bool.Parse(readerconfig.ReadLine());
Globals.StealFocus = bool.Parse(readerconfig.ReadLine());
Globals.BackgroundColorR = int.Parse(readerconfig.ReadLine());
Globals.BackgroundColorG = int.Parse(readerconfig.ReadLine());
Globals.BackgroundColorB = int.Parse(readerconfig.ReadLine());
}
catch (Exception ex)
{
Expand Down
50 changes: 31 additions & 19 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/BlankPage1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ private void Button_Click(object sender, RoutedEventArgs e)
Globals.IsAllApps = true;
var frame = this.Parent as Frame;
frame.Navigate(typeof(AllWidgets));
var gridparent = frame.Parent as Grid;
var navviewparent = gridparent.Parent as NavigationView;
navviewparent.SelectedItem = null;
}
catch
{
Expand Down Expand Up @@ -297,29 +300,38 @@ private void UpdateUI()
button.DropCompleted += Button_DropCompleted;
BasicGridView.Items.Add(button);
});
WebClient client = new WebClient();
string reply = client.DownloadString(Globals.UpdateString);
if (reply == Globals.Version)
{
Globals.IsUpdateAvailable = false;
}
else
{
Globals.IsUpdateAvailable = true;
}
if (Globals.IsUpdateAvailable == true)
try
{
DispatcherQueue.TryEnqueue(() =>
WebClient client = new WebClient();
string reply = client.DownloadString(Globals.UpdateString);
if (reply == Globals.Version)
{
Globals.IsUpdateAvailable = false;
}
else
{
Globals.IsUpdateAvailable = true;
}
if (Globals.IsUpdateAvailable == true)
{
Frame frame = new()
DispatcherQueue.TryEnqueue(() =>
{
Name = "UpdateWidget1",
};
frame.RightTapped += Frame_RightTapped;
BasicGridView.Items.Add(frame);
frame.Navigate(typeof(UpdateWarning));
});
Frame frame = new()
{
Name = "UpdateWidget1",
};
frame.RightTapped += Frame_RightTapped;
BasicGridView.Items.Add(frame);
frame.Navigate(typeof(UpdateWarning));

});
}
}
catch
{

}

}

private void BasicGridView_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
Expand Down
9 changes: 8 additions & 1 deletion CompanionDisplayWinUI/CompanionDisplayWinUI/BlankPage3.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
<x:String>Acrylic</x:String>
<x:String>Mica</x:String>
<x:String>Image</x:String>
<!--<x:String>Solid Color</x:String>-->
<x:String>Album Cover</x:String>
<x:String>Solid Color</x:String>
</ComboBox>
</Grid>
<Expander HorizontalAlignment="Stretch" Header="Custom" HorizontalContentAlignment="Stretch">
Expand All @@ -64,6 +65,12 @@
<TextBlock Text="Blur" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,5,0,0"/>
<ToggleSwitch Name="ImageBlurToggle" HorizontalAlignment="Right" VerticalAlignment="Center" OffContent="" OnContent="" IsOn="True" Toggled="ImageBlurToggle_Toggled" Margin="0,0,-110,0"/>
</Grid>
<Expander HorizontalAlignment="Stretch" Header="Custom Color">
<StackPanel>
<ColorPicker Name="BackgroundColorPicker"/>
<Button Content="Save" HorizontalAlignment="Stretch" Style="{StaticResource AccentButtonStyle}" Click="Button_Click_4"/>
</StackPanel>
</Expander>
</StackPanel>
</Expander>
</StackPanel>
Expand Down
19 changes: 15 additions & 4 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/BlankPage3.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ private void ComboBox_SelectionChanged_2(object sender, SelectionChangedEventArg
case "Image":
Globals.Backdrop = 2;
break;
case "Solid Color":
Globals.Backdrop = 3;
break;
}
mainframe.IsEnabled = false;
mainframe.IsEnabled = true;
Expand Down Expand Up @@ -194,7 +191,7 @@ private void Save_Settings()
{
DispatcherQueue.TryEnqueue(() =>
{
string settingsfile = Globals.ColorSchemeSelect + "\n" + Globals.InjectCustomAccent + "\n" + Globals.ColorSchemeSelectAccentR + "\n" + Globals.ColorSchemeSelectAccentG + "\n" + Globals.ColorSchemeSelectAccentB + "\n" + Globals.Backdrop + "\n" + Globals.BackgroundLink + "\n" + Globals.Wallpaper + "\n" + Globals.Blur + "\n" + Globals.StealFocus;
string settingsfile = Globals.ColorSchemeSelect + "\n" + Globals.InjectCustomAccent + "\n" + Globals.ColorSchemeSelectAccentR + "\n" + Globals.ColorSchemeSelectAccentG + "\n" + Globals.ColorSchemeSelectAccentB + "\n" + Globals.Backdrop + "\n" + Globals.BackgroundLink + "\n" + Globals.Wallpaper + "\n" + Globals.Blur + "\n" + Globals.StealFocus + "\n" + Globals.BackgroundColorR + "\n" + Globals.BackgroundColorG + "\n" + Globals.BackgroundColorB;
File.WriteAllText("Config/GlobalSettings.crlh", settingsfile);
});
}
Expand Down Expand Up @@ -248,5 +245,19 @@ private void Button_Click_3(object sender, RoutedEventArgs e)
cmd.Start();
}
}

private void Button_Click_4(object sender, RoutedEventArgs e)
{
if (LoadFinish == true)
{
Globals.BackgroundColorR = BackgroundColorPicker.Color.R;
Globals.BackgroundColorG = BackgroundColorPicker.Color.G;
Globals.BackgroundColorB = BackgroundColorPicker.Color.B;
Thread thread = new Thread(Save_Settings);
thread.Start();
mainframe.IsEnabled = false;
mainframe.IsEnabled = true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<RemoteDeploymentType>CopyToDevice</RemoteDeploymentType>
<PackageRegistrationPath>\\25.1.22.96\Users\Tomás\Desktop\DebugShit</PackageRegistrationPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<ItemGroup>
<Page Update="AllWidgets.xaml">
<SubType>Designer</SubType>
Expand Down
5 changes: 4 additions & 1 deletion CompanionDisplayWinUI/CompanionDisplayWinUI/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace CompanionDisplayWinUI
static class Globals
{
// Runtime variables
public static string Version = "24.6-BETA_1";
public static string Version = "24.7-BETA_1.1";
public static string UpdateZip = "https://www.dropbox.com/scl/fi/3pmay1a18v9wdi6y9ridh/release.zip?rlkey=9sbehxn68p4i18geb5acbe6y3&dl=1";
public static string UpdateString = "https://www.dropbox.com/scl/fi/eftx6ql3107c1j0gywb90/release.txt?rlkey=lylcncrgnhtw2q3w1l439uc45&dl=1";
public static string DiscordID = "";
Expand Down Expand Up @@ -47,6 +47,9 @@ static class Globals
public static int ColorSchemeSelectAccentR = 0;
public static int ColorSchemeSelectAccentG = 0;
public static int ColorSchemeSelectAccentB = 0;
public static int BackgroundColorR = 0;
public static int BackgroundColorG = 0;
public static int BackgroundColorB = 0;
public static int InjectCustomAccent = 0;
public static int Backdrop = 0;
public static string BackgroundLink = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TextBlock Name="ComponentType" Text="-" FontSize="30"/>
<ScrollViewer Margin="0,45,0,0">
<StackPanel Name="ComponentSensorStack" Padding="10" Spacing="2">
<TextBlock Name="NoSensorsWarning" Text="No Sensors Detected&#x0a;Try runnning Companion Display as an administrator." Foreground="{StaticResource SystemBaseMediumColor}" TextWrapping="Wrap" HorizontalAlignment="Center" HorizontalTextAlignment="Center" FontSize="30" Height="150" VerticalAlignment="Top" Visibility="Collapsed"/>
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
}
}
}
if (ComponentSensorStack.Children.Count == 1)
{
NoSensorsWarning.Visibility = Visibility.Visible;
}
else
{
NoSensorsWarning.Visibility = Visibility.Collapsed;
}
}
catch { }
foreach (ISensor sensor in hardware.Sensors)
Expand Down Expand Up @@ -132,6 +140,14 @@ private void Page_Loaded(object sender, RoutedEventArgs e)

}
}
if(ComponentSensorStack.Children.Count == 1)
{
NoSensorsWarning.Visibility = Visibility.Visible;
}
else
{
NoSensorsWarning.Visibility = Visibility.Collapsed;
}
}
catch { }
LoadFinished = true;
Expand Down
97 changes: 94 additions & 3 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using static CompanionDisplayWinUI.MediaPlayerWidget;
using Microsoft.UI.Windowing;
using Microsoft.UI;
using Windows.Media.Control;
using Windows.UI;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down Expand Up @@ -94,6 +96,65 @@ private void Window_Closed(object sender, WindowEventArgs args)
{
Environment.Exit(0);
}
string AlbumCoverCache = "", SongTitleCache = "";
int SongCoverStarted = 0;
private async void SongCoverBackground()
{
if (Globals.IsSpotify == true && Globals.SongName != SongTitleCache)
{
DispatcherQueue.TryEnqueue(() =>
{
try
{
BackgroundImage.Source = new BitmapImage(new Uri(Globals.SongBackground));
AlbumCoverCache = Globals.SongBackground;
SongTitleCache = Globals.SongName;
}
catch (Exception ex)
{
//File.AppendAllText("ErrorLog.crlh", ex.Message);
}
});
}
else
{
try
{
GlobalSystemMediaTransportControlsSessionManager sessionManager = await GlobalSystemMediaTransportControlsSessionManager.RequestAsync();
GlobalSystemMediaTransportControlsSessionMediaProperties songInfo = await sessionManager.GetCurrentSession().TryGetMediaPropertiesAsync();
if(SongTitleCache != songInfo.Title)
{
DispatcherQueue.TryEnqueue(() =>
{
try
{
BackgroundImage.Source = (ImageSource)Helper.GetThumbnail(songInfo.Thumbnail);
AlbumCoverCache = "";
SongTitleCache = songInfo.Title;
}
catch (Exception e)
{

}
});
}
}
catch (Exception ex)
{
//File.AppendAllText("ErrorLog.crlh", ex.Message);
}
}
Thread.Sleep(1000);
if(Globals.Backdrop == 3)
{
Thread thread = new(SongCoverBackground);
thread.Start();
}
else
{
SongCoverStarted = 0;
}
}
private async void UpdateUI()
{
try
Expand All @@ -103,18 +164,19 @@ private async void UpdateUI()
case (0):
DispatcherQueue.TryEnqueue(() =>
{
GridMain.Background = new SolidColorBrush(Color.FromArgb(0,0,0,0));
SystemBackdrop = new DesktopAcrylicBackdrop();
BackgroundImage.Visibility = Visibility.Collapsed;
ImageOptionalBlur.Visibility = Visibility.Collapsed;
BackgroundVideo.Visibility = Visibility.Collapsed;
BackgroundImage.Source = null;
BackgroundVideo.Source = null;

});
break;
case (1):
DispatcherQueue.TryEnqueue(() =>
{
GridMain.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
SystemBackdrop = new MicaBackdrop();
BackgroundImage.Visibility = Visibility.Collapsed;
ImageOptionalBlur.Visibility = Visibility.Collapsed;
Expand All @@ -126,6 +188,7 @@ private async void UpdateUI()
case (2):
DispatcherQueue.TryEnqueue(() =>
{
GridMain.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
SystemBackdrop = null;
if (Globals.Blur == true)
{
Expand Down Expand Up @@ -212,14 +275,42 @@ private async void UpdateUI()

break;
case (3):
DispatcherQueue.TryEnqueue(() =>
{
GridMain.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
SystemBackdrop = null;
BackgroundImage.Visibility = Visibility.Visible;
if (Globals.Blur == true)
{
ImageOptionalBlur.Visibility = Visibility.Visible;
}
else
{
ImageOptionalBlur.Visibility = Visibility.Collapsed;
}
BackgroundVideo.Visibility = Visibility.Collapsed;
});
if(SongCoverStarted == 0)
{
SongCoverStarted = 1;
Thread thread = new(SongCoverBackground);
thread.Start();
}
break;
case (4):
DispatcherQueue.TryEnqueue(() =>
{
BackgroundImage.Visibility = Visibility.Collapsed;
ImageOptionalBlur.Visibility = Visibility.Collapsed;
BackgroundVideo.Visibility = Visibility.Collapsed;
BackgroundImage.Source = null;
BackgroundVideo.Source = null;
GridMain.Background = new SolidColorBrush(Color.FromArgb(255, (byte)Globals.BackgroundColorR, (byte)Globals.BackgroundColorG, (byte)Globals.BackgroundColorB));
});
if (SongCoverStarted == 0)
{
SongCoverStarted = 1;
Thread thread = new(SongCoverBackground);
thread.Start();
}
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/WidgetPhoto.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<Grid>
<Rectangle Fill="{ThemeResource SystemBaseLowColor}" Grid.RowSpan="2" Opacity="0.3"/>
<TextBlock Name="NoDevices" Text="No image.&#x0a;Right click and press edit to add an image." FontSize="40" TextWrapping="Wrap" HorizontalTextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="50,0,50,0" Opacity="0.5" IsHitTestVisible="False" Visibility="Collapsed"/>
<FlipView Name="FlipViewImages" Width="500" Height="300" SelectionChanged="FlipViewImages_SelectionChanged"/>
<TextBlock Name="NoDevices" Text="No image.&#x0a;Right click and press edit to add an image." FontSize="40" TextWrapping="Wrap" HorizontalTextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="50,0,50,0" Opacity="0.5" IsHitTestVisible="False" Visibility="Visible"/>
<FlipView Name="FlipViewImages" Width="500" Height="300" SelectionChanged="FlipViewImages_SelectionChanged" Background="Transparent"/>
</Grid>
</Page>
12 changes: 10 additions & 2 deletions CompanionDisplayWinUI/CompanionDisplayWinUI/WidgetPhoto.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void UpdateUI()
}
image.Source = bitmapImage;
image.Stretch = Stretch.UniformToFill;
image.Name = path;
FlipViewImages.Items.Add(image);
});
}
Expand Down Expand Up @@ -161,8 +162,15 @@ private void Image_Unloaded(object sender, RoutedEventArgs e)

private void FlipViewImages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var senderImage = (sender as FlipView).SelectedItem as Image;
Globals.bitmapImage.UriSource = new System.Uri(senderImage.Name);
try
{
var senderImage = (sender as FlipView).SelectedItem as Image;
Globals.bitmapImage.UriSource = new System.Uri(senderImage.Name);
}
catch
{

}
}
}
}

0 comments on commit c3c03f0

Please sign in to comment.