Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ message Cpu {
* @return total memory on system, available memory on system
* */
message Memory {
string total = 1;
string free = 2;
uint64 total = 1;
uint64 free = 2;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void OnFilterChanged(object sender, RoutedEventArgs args)
IEnumerable<ProcessInfo> filtered = allProcesses.Where(process => Filter(process));
Remove_NonMatching(filtered);
AddBack_Processes(filtered);
Order_services();
Order_processes();
}

private bool Filter(ProcessInfo process)
Expand Down Expand Up @@ -155,6 +155,10 @@ private async void RefreshButton_Click(object sender, RoutedEventArgs e)
await ClearAllProcesses();
// Refresh is user-initiated; use non-cancellable token
await LoadAllProcesses(CancellationToken.None);
IEnumerable<ProcessInfo> filtered = allProcesses.Where(process => Filter(process));
Remove_NonMatching(filtered);
AddBack_Processes(filtered);
Order_processes();
}

private async void ProcessTerminate_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -560,7 +564,7 @@ await DispatcherQueue.EnqueueAsync(() =>
{
ProcessState.Unspecified => (SolidColorBrush)Application.Current.Resources["SystemFillColorNeutralBrush"],
ProcessState.Running => (SolidColorBrush)Application.Current.Resources["SystemFillColorAttentionBrush"],
ProcessState.Sleeping => (SolidColorBrush)Application.Current.Resources["SystemFillColorCautionBrush"],
ProcessState.Sleeping => (SolidColorBrush)Application.Current.Resources["SystemFillColorSuccessBrush"],
ProcessState.Stopped => (SolidColorBrush)Application.Current.Resources["SystemFillColorCriticalBrush"],
_ => (SolidColorBrush)Application.Current.Resources["SystemFillColorCriticalBackgroundBrush"],
};
Expand All @@ -579,16 +583,16 @@ await DispatcherQueue.EnqueueAsync(() =>
}
await DispatcherQueue.EnqueueAsync(() =>
{
Order_services();
Order_processes();
});
}

public void OnOrderChanged(object sender, SelectionChangedEventArgs args)
{
Order_services();
Order_processes();
}

private void Order_services()
private void Order_processes()
{
string order = OrderByCombo?.SelectedValue as string ?? "State";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ private async void RefreshButton_Click(object sender, RoutedEventArgs e)
await ClearAllServices();
await DispatcherQueue.EnqueueAsync(() => LoadingProgressRing.IsActive = true);
await LoadAllServices();
IEnumerable<ServiceInfo> filtered = allServices.Where(service => Filter(service));
Remove_NonMatching(filtered);
AddBack_Services(filtered);
Order_Services();
await DispatcherQueue.EnqueueAsync(() => LoadingProgressRing.IsActive = false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
<TextBlock Margin="5,0" x:Name="CPU" HorizontalAlignment="Right" VerticalAlignment="Center" Text="N/A" />
</Grid>

<!-- <Grid Margin="20, 0" Background="#10FFFFFF" CornerRadius="8" Padding="12">
<Grid Margin="20, 0" Background="#10FFFFFF" CornerRadius="8" Padding="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid Grid.Row="0">
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" Text="CPU Usage" />
<TextBlock Margin="5,0" HorizontalAlignment="Right" VerticalAlignment="Center" Text="NaN%" />
<TextBlock Margin="5,0" x:Name="CpuUsagePercent" HorizontalAlignment="Right" VerticalAlignment="Center" Text="NaN%" />
</Grid>

<components:ProgressBar x:Name="CpuUsageBar" Progress="100" Grid.Row="1" Margin="5,8,5,0" />
</Grid> -->
</Grid>

<Grid Margin="20, 0" Background="#10FFFFFF" CornerRadius="8" Padding="12">
<Grid.RowDefinitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ private async void updatePage()

Processes.Text = string.Format("{0} running", data.Resources.Processes.Count());

var totalRamGB = Math.Floor(float.Parse(data.Resources.Memory.Total) / 1024 / 1024);
var usedRam = float.Parse(data.Resources.Memory.Total) - float.Parse(data.Resources.Memory.Free);
var usedRamPercentage = (usedRam / float.Parse(data.Resources.Memory.Total)) * 100;
ulong cpuTotalTime = data.Resources.Cpu.TotalTime;
ulong cpuIdleTime = data.Resources.Cpu.IdleTime;

double cpuUsagePercentage = ((double)(cpuTotalTime - cpuIdleTime) / (double)cpuTotalTime) * 100;

CpuUsageBar.Progress = cpuUsagePercentage;
CpuUsagePercent.Text = string.Format("{0:F2}%", cpuUsagePercentage);

var totalRamGB = Math.Floor((decimal)data.Resources.Memory.Total / 1024 / 1024);
ulong usedRam = data.Resources.Memory.Total - data.Resources.Memory.Free;
double usedRamPercentage = ((double)usedRam / (double)data.Resources.Memory.Total) * 100;

RamUsageBar.Progress = usedRamPercentage;
RamUsagePercent.Text = string.Format("{0:F2}%", usedRamPercentage);
Expand Down
Loading