Exilon
Exilon
CC#
Created by Exilon on 12/6/2023 in #help
Custom cmdlet giving me a missing assembly error
Powershell gives me this error when I try run my cmdlet:
Get-UserFromId: Could not load file or assembly 'System.Net.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Get-UserFromId: Could not load file or assembly 'System.Net.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
I'm using this guide to make API calls through this tutorial: https://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c which told me to add that assembly. When I compile it and use ipmo to add it to my powershell, I get that error when trying to run it. I was required to reference System.Net.Http.Formatting to get ReadAsAsync<>() to work (I think). Am I just building my project wrong?
87 replies
CC#
Created by Exilon on 10/17/2022 in #help
SocketIO Libs for CS?
Are there any good SocketIO libraries for C#? Most of the ones I find are very outdated and I don't believe any work for .NET 6. I'm currently trying to make this one (https://github.com/doghappy/socket.io-client-csharp) work but I haven't had luck. Any suggestions?
19 replies
CC#
Created by Exilon on 10/8/2022 in #help
Restarting audio with MediaPlayer?
I've made a button that uses MediaPlayer to play a custom MP3 file that I've made.
MediaPlayer flashSound;
flashSound = new MediaPlayer();
flashSound.Open(new Uri(@"FlashBangSound.mp3", UriKind.RelativeOrAbsolute));

...

private void Button_Click_1(object sender, RoutedEventArgs e)
{
flashSound.Play();
}
MediaPlayer flashSound;
flashSound = new MediaPlayer();
flashSound.Open(new Uri(@"FlashBangSound.mp3", UriKind.RelativeOrAbsolute));

...

private void Button_Click_1(object sender, RoutedEventArgs e)
{
flashSound.Play();
}
This does work too. It's just that it only works once. Once I press the button again, nothing happens and I believe its because the audio is finished and needs to be restarted, but how would I do that?
33 replies
CC#
Created by Exilon on 10/3/2022 in #help
Window opacity not being effected in a method?
Hello, I've been trying to change the opacity of my window through code for a while now but I've had no success. I'm changing the Window.Opacity number in my function but I've had no success. As of now, I've tried setting the background to a SolidBrushColor and setting the opacity from there to no success. I'm also trying INotifyPropertyChanged still to no avail. There are no errors either. The opacity just isn't affected. Here is the code of the overlay window that needs its opacity changed:
public partial class overlay : Window, INotifyPropertyChanged
{
public static overlay? thisOverlay;
DoubleAnimation fade = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(5)));

public event PropertyChangedEventHandler? PropertyChanged;

private double _windowOpacity;
public double WindowOpacity
{
get => _windowOpacity;
set
{
if (_windowOpacity == value)
return;

_windowOpacity = value;
OnPropertyChanged();
}
}

public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
}

private void Overlay_Loaded(object sender, RoutedEventArgs e)
{
thisOverlay = this;

}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

public void setOpacity() // Function is ran outside of this class
{
this.WindowOpacity = 0.5; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
public partial class overlay : Window, INotifyPropertyChanged
{
public static overlay? thisOverlay;
DoubleAnimation fade = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(5)));

public event PropertyChangedEventHandler? PropertyChanged;

private double _windowOpacity;
public double WindowOpacity
{
get => _windowOpacity;
set
{
if (_windowOpacity == value)
return;

_windowOpacity = value;
OnPropertyChanged();
}
}

public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
}

private void Overlay_Loaded(object sender, RoutedEventArgs e)
{
thisOverlay = this;

}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

public void setOpacity() // Function is ran outside of this class
{
this.WindowOpacity = 0.5; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
Tell me if you would like to see any XAML code or MainWindow.cs.
425 replies
CC#
Created by Exilon on 9/29/2022 in #help
Window opacity isn't being affected?
I have a button click method over here that should set a window to opaque:
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (overlay.thisOverlay != null)
{
overlay.thisOverlay.makeOpaque();
}
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (overlay.thisOverlay != null)
{
overlay.thisOverlay.makeOpaque();
}
}
The method works too. The trace here works:
// This function is in the "overlay" class
public void makeOpaque()
{
this.Opacity = 1;
Trace.WriteLine("Works");
}
// This function is in the "overlay" class
public void makeOpaque()
{
this.Opacity = 1;
Trace.WriteLine("Works");
}
The output shows the message but the opacity of the window doesn't change. What am I doing wrong?
20 replies
CC#
Created by Exilon on 9/26/2022 in #help
CS WPF (.NET framework) pass all mouse inputs to the window behind?
I'm currently trying to make an overlay for programs that can show popups and set the screen to a certain color. The only problem right now is that although the main window stays at the top and is maximized as I want it to be, The inputs I want to give to the program below are obviously taken by the window above. I've tried setting the background to Background="{x:Null}" and this worked. But the second I set the background transparency to more than 0% (Background="#08FFFFFF" which is 4% opacity), my inputs are blocked by the window. Is there a way to pass inputs through regardless of the opacity of the background?
1 replies