예제 #1
0
        /// <summary>
        /// Attaches to each device to handle removal
        /// </summary>
        /// <param name="sender"></param>
        protected void DeviceRequestsRemoval(object sender)
        {
            try {
                // Attempt to cast the entry
                DeviceEntry deviceEntry = sender as DeviceEntry;

                // Get the index
                int entryIndex = DeviceListBox.Children.IndexOf(deviceEntry);

                // Kill the thread and remove the device
                _analysis.RemoveDeviceAt(entryIndex);

                // Detatch the Delegate
                deviceEntry.RemoveEntry -= DeviceRequestsRemoval;

                // Remove the Entry
                DeviceListBox.Children.Remove(deviceEntry);

                // Release the Entry Resources
                deviceEntry.Dispose();

                // Release the Entry
                deviceEntry = null;
            } catch (Exception exception) { Console.WriteLine(Tag + ": " + exception.Message); }
        }
예제 #2
0
        /// <summary>
        /// Removes the specified Device Entry
        /// </summary>
        /// <param name="deviceEntry"></param>
        protected void RemoveDeviceEntry(DeviceEntry deviceEntry)
        {
            // Make sure it's a valid instance
            if (deviceEntry == null)
            {
                return;
            }

            // Detatch the Delegate
            deviceEntry.RemoveEntry -= DeviceRequestsRemoval;
            deviceEntry.Toggle      -= DeviceEntryToggled;

            // Remove from the list
            DeviceListBox.Children.Remove(deviceEntry);

            // Dispose
            deviceEntry.Dispose();

            // Release the Entry
            deviceEntry = null;
        }