Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
neversaatisfied authored and toughtcrime committed Jun 11, 2023
0 parents commit 106e679
Show file tree
Hide file tree
Showing 11 changed files with 554 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="TaskManager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TaskManager"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace TaskManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
31 changes: 31 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Window x:Class="TaskManager.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TaskManager"
mc:Ignorable="d"
Title="Task Manager" Height="450" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition/>
</Grid.RowDefinitions>

<TextBox Grid.Row="0" Height="20" Name="Search" FontSize="14" BorderBrush="White" TextChanged="Search_KeyDown"/>
<ListView Margin="10" Name="ProcessInfo" Grid.Row="1">
<ListView.View>
<GridView>
<GridViewColumn Header="PROCESS NAME" Width="120" DisplayMemberBinding="{Binding name}"/>
<GridViewColumn Header="ID" Width="50" DisplayMemberBinding="{Binding id}" />
</GridView>
</ListView.View>

<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete" Click="Delete_Click"/>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
</Grid>
</Window>
111 changes: 111 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

namespace TaskManager
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
private Process[] processes = Process.GetProcesses();
private List<Processlist> processlist = new List<Processlist>();
private List<Processlist> foundList = new List<Processlist>();
public MainWindow()
{
InitializeComponent();
processes = Process.GetProcesses();
ProcessInfo.Foreground = new SolidColorBrush(Colors.Black);
foreach (Process item in processes)
{
processlist.Add(new Processlist() { id = item.Id, name = item.ProcessName });
}
ProcessInfo.ItemsSource = processlist;
}


//TODO
private void LoadProcesses()
{

}



private void Delete_Click(object sender, RoutedEventArgs e)
{
var pid = (ProcessInfo.SelectedItem as Processlist).id;
var process = Process.GetProcessById(pid);
processlist.RemoveAt(ProcessInfo.SelectedIndex);
ICollectionView view = CollectionViewSource.GetDefaultView(ProcessInfo.ItemsSource);
view.Refresh();
process.Kill();
}

public event PropertyChangedEventHandler PropertyChanged;

public void OnPropertyChanged([CallerMemberName] string property = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}


//TODO
private void Search_KeyDown(object sender, KeyEventArgs e)
{
for (int i = 0; i < processlist.Count; i++)
{
if (e.Key == Key.Enter)
{
if (Search.Text.Contains(processlist[i].name))
{
foundList.Add(processlist[i]);
}

else if (Search.Text.Contains(processlist[i].id.ToString()))
{
foundList.Add(processlist[i]);
}

else
{

}
}
}
ProcessInfo.ItemsSource = foundList;
ICollectionView view = CollectionViewSource.GetDefaultView(ProcessInfo.ItemsSource);
view.Refresh();

if(Search.Text == string.Empty)
{
LoadProcesses();

view = CollectionViewSource.GetDefaultView(ProcessInfo.ItemsSource);
view.Refresh();
}
}
}

public class Processlist
{
public int id { get; set; }
public string name { get; set; }
}
}
55 changes: 55 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TaskManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TaskManager")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
71 changes: 71 additions & 0 deletions Properties/Resources.Designer.cs

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

Loading

0 comments on commit 106e679

Please sign in to comment.