or
radChartView1.ShowTrackBall =
true
;
Private
Sub
Timer_RefreshProcessList_Tick(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs) _
Handles
Timer_RefreshProcessList.Tick
' Processes that shouldn't be listed.
Dim
BlackListedProcesses
As
String
() =
{
My.Application.Info.AssemblyName,
"Idle"
,
"System"
,
"audiodg"
}
' Get the runing processes.
Dim
Processes
As
Process() = Process.GetProcesses
' Filter the processes by its name
' then set the RadListDataItem items containing the names and the process icons.
Dim
ProcessItems
As
IEnumerable(Of RadListDataItem) =
(From proc
As
Process
In
Processes
Where
Not
BlackListedProcesses.Contains(proc.ProcessName)
Order By proc.ProcessName Ascending).
GroupBy(
Function
(proc
As
Process) proc.ProcessName).
Select
(
Function
(procs
As
IGrouping(Of
String
, Process))
If
Not
procs.First.HasExited
Then
Try
Return
New
RadListDataItem
With
{
.Active =
False
,
.Text =
String
.Format(
"{0}.exe"
, procs.First.ProcessName),
.Image = ResizeImage(Icon.ExtractAssociatedIcon(procs.First.MainModule.FileName).ToBitmap,
Width:=16, Height:=16)
}
Catch
ex
As
Exception
Return
Nothing
End
Try
Else
Return
Nothing
End
If
End
Function
)
' If the RadListControl does not contain any item then...
If
Me
.RadListControl_ProcessList.Items.Count = 0
Then
With
Me
.RadListControl_ProcessList
.BeginUpdate()
.Items.AddRange(ProcessItems)
' Add the RadListDataItems for first time.
.EndUpdate()
End
With
Exit
Sub
End
If
' If RadListDataItems count is not equal than the runing process list count then...
If
Me
.RadListControl_ProcessList.Items.Count <> ProcessItems.Count
Then
' Save the current selected items.
Dim
SelectedItems
As
IEnumerable(Of
String
) =
From Item
As
RadListDataItem
In
Me
.RadListControl_ProcessList.SelectedItems
Select
Item.Text
' For Each ctrl As RadListDataItem In ProcessItems
' ctrl.Dispose()
' Next
With
Me
.RadListControl_ProcessList
' .AutoScroll = False
' .SuspendSelectionEvents = True
' .SuspendItemsChangeEvents = True
' .SuspendLayout()
' .BeginUpdate()
.Items.Clear()
' Clear the current RadListDataItems
.Items.AddRange(ProcessItems)
' Add the new RadListDataItems.
' .EndUpdate()
' .ResumeLayout()
End
With
' Restore the selected item(s).
For
Each
Item
As
RadListDataItem
In
Me
.RadListControl_ProcessList.Items
If
SelectedItems.Contains(Item.Text)
Then
Item.Selected =
True
Item.Active =
True
With
Me
.RadListControl_ProcessList
' .ScrollToItem(Item)
' .ListElement.ScrollToItem(Item)
' .ListElement.ScrollToActiveItem()
End
With
End
If
Next
Item
With
Me
.RadListControl_ProcessList
' .AutoScroll = True
' .SuspendSelectionEvents = False
' .SuspendItemsChangeEvents = False
End
With
End
If
End
Sub
' [ListBox] Select item without jump
'
' Original author of code is "King King"
' Url: stackoverflow.com/questions/19479774/how-to-prevent-listbox-jumps-to-item
'
' Examples :
'
' Select_Item_Without_Jump(ListBox1, 50, ListBoxItemSelected.Select)
'
' For x As Integer = 0 To ListBox1.Items.Count - 1
' Select_Item_Without_Jump(ListBox1, x, ListBoxItemSelected.Select)
' Next
''' <summary>
''' Indicates whether the ListBox Item should be Selected or Unselected.
''' </summary>
Private
Enum
ListBoxItemSelected
''' <summary>
''' Indicate that ListBox Item should be Selected.
''' </summary>
[
Select
] = 1
''' <summary>
''' Indicate that ListBox Item should be Unselected.
''' </summary>
[Unselect] = 0
End
Enum
''' <summary>
''' Selects or unselects a ListBox Item without jumping to the Item location on the layout.
''' </summary>
Public
Shared
Sub
Select_Item_Without_Jump(lb
As
ListBox, index
As
Integer
, selected
As
ListBoxItemSelected)
Dim
i
As
Integer
= lb.TopIndex
' Store the selected item index
lb.BeginUpdate()
' Disable drawing on control
lb.SetSelected(index, selected)
' Select the item
lb.TopIndex = i
' Jump to the previous selected item
lb.EndUpdate()
' Eenable drawing
End
Sub