Skip to content

Commit

Permalink
Button Facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
cydyn committed Mar 11, 2024
1 parent ae825d2 commit 4bf172f
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions Intersect.Client/Interface/Menu/MainMenuWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class MainMenuWindow : Window
private readonly Button _buttonSettings;
private readonly Button _buttonStart;
private readonly Button _buttonDiscord;
private readonly Button _buttonFacebook;
private readonly MainMenu _mainMenu;

// ReSharper disable once SuggestBaseTypeForParameterInConstructor
Expand Down Expand Up @@ -80,13 +81,20 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M
Text = Strings.MainMenu.Start,
};
_buttonStart.Clicked += ButtonStartOnClicked;

_buttonDiscord = new Button(this, nameof(_buttonDiscord))
{
IsTabable = true,
Text = "Discord", // Tekst przycisku Discord
};
_buttonDiscord.Clicked += ButtonDiscordOnClicked;

_buttonFacebook = new Button(this, nameof(_buttonFacebook))
{
IsTabable = true,
Text = "Facebook", // Tekst przycisku Facebook
};
_buttonFacebook.Clicked += ButtonFacebookOnClicked;
}


Expand Down Expand Up @@ -236,7 +244,55 @@ void ButtonDiscordOnClicked(Base sender, ClickedEventArgs arguments)
Console.WriteLine($"Error opening Discord link: {ex.Message}");
}
}
internal void Reset()
void ButtonFacebookOnClicked(Base sender, ClickedEventArgs arguments)
{
try
{
// Spróbuj otworzyć link za pomocą odpowiedniego polecenia dla danego systemu operacyjnego
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "cmd",
Arguments = $"/c start https://www.facebook.com/112847381775846",
UseShellExecute = false,
CreateNoWindow = true
});
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "xdg-open",
Arguments = $"\"https://www.facebook.com/112847381775846\"",
UseShellExecute = false,
CreateNoWindow = true
});
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "open",
Arguments = $"\"https://www.facebook.com/112847381775846\"",
UseShellExecute = false,
CreateNoWindow = true
});
}
else
{
// Obsługa błędu dla nieobsługiwanego systemu operacyjnego
Console.WriteLine("Unsupported operating system.");
}
}
catch (Exception ex)
{
// Obsłużanie błędu, jeśli nie udało się otworzyć linku
Console.WriteLine($"Error opening Discord link: {ex.Message}");
}
}

internal void Reset()
{
_buttonSettings.Show();
}
Expand Down

0 comments on commit 4bf172f

Please sign in to comment.