-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from NiceAustrian/main
Applied WPF Design Concepts and added some C# Syntax + CommunityToolk…
- Loading branch information
Showing
13 changed files
with
474 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
<Application x:Class="Switchy.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Switchy" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
<Style TargetType="StackPanel" x:Key="GlobalStackPanelStyle"> | ||
<Style.Resources> | ||
<Style TargetType="Button"> | ||
<Setter Property="Margin" Value="0,0,0,20" /> | ||
<Setter Property="Height" Value="30" /> | ||
<Setter Property="Width" Value="35" /> | ||
</Style> | ||
</Style.Resources> | ||
</Style> | ||
</Application.Resources> | ||
StartupUri="View/MainWindow.xaml"> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Windows; | ||
using System.Windows; | ||
|
||
namespace Switchy | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
namespace Switchy; | ||
|
||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,42 @@ | ||
using System.ComponentModel; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Switchy.Model | ||
namespace Switchy.Model; | ||
|
||
public partial class ProcessListViewItem(Process p) : ObservableObject | ||
{ | ||
public class ProcessListViewItem : INotifyPropertyChanged | ||
private Process _process = p; | ||
[ObservableProperty] | ||
private bool _isExited; | ||
public Process Process | ||
{ | ||
public Process Process { get; } | ||
public bool HasExited { get; internal set; } | ||
public event PropertyChangedEventHandler? PropertyChanged; | ||
|
||
public ProcessListViewItem(Process p) | ||
get | ||
{ | ||
Process = p; | ||
return _process; | ||
} | ||
private set | ||
{ | ||
_process = value; | ||
|
||
try //Needed to prevent application crash when executing switchy without debug mode or admin rights; Effectively disables process exit listview binding however. | ||
{ | ||
p.EnableRaisingEvents = true; | ||
p.Exited += P_Exited; | ||
_process.EnableRaisingEvents = true; | ||
_process.Exited += P_Exited; | ||
} | ||
catch (Exception) { } | ||
} | ||
|
||
private void P_Exited(object? sender, EventArgs e) | ||
{ | ||
this.HasExited = true; | ||
NotifyPropertyChanged(nameof(Process.HasExited)); | ||
catch { } | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return Process?.ProcessName ?? "No Process"; | ||
} | ||
private void P_Exited(object? sender, EventArgs e) | ||
=> IsExited = true; | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
if (obj is ProcessListViewItem it) | ||
return Process.Id.Equals(it.Process.Id); | ||
public override string ToString() | ||
=> Process?.ProcessName ?? "No Process"; | ||
|
||
return false; | ||
} | ||
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
public override bool Equals(object? obj) | ||
=> obj is ProcessListViewItem it && Process.Id.Equals(it.Process.Id); | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Process.Id); | ||
} | ||
} | ||
public override int GetHashCode() | ||
=> HashCode.Combine(Process.Id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.