private void DeviceIconClicked(NetworkDevicePanel devicePanel, NetworkDevice device) { if (SelectedNetworkDevice == null) { //CreateFileAreaPanel(FileDisplayMinX); ChangeGuiState(GUIState.NoFilesSelected); } SelectedNetworkDevice = device; devicePanel.IsPressed = true; devicePanel.BackgroundImage = Properties.Resources.device_panel_pressed; // reset the status of the others foreach (NetworkDevicePanel c in panel_FlowLayoutDevices.Controls) { if (devicePanel != c) { c.IsPressed = false; c.BackgroundImage = Properties.Resources.device_panel_normal; } } }
public void AddNewNetworkDevice(NetworkDevice device) { NetworkDevicePanel devicePanel = new NetworkDevicePanel(); devicePanel.Size = new Size(panel_FlowLayoutDevices.Width - 10, 60); devicePanel.BackgroundImage = Properties.Resources.device_panel_normal; devicePanel.BackgroundImageLayout = ImageLayout.Stretch; devicePanel.DeviceIconSize = 40; devicePanel.DeviceIcon = GetCorrentDeviceIcon(device.Type); devicePanel.Font = new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel); devicePanel.DeviceNameTextOffset = devicePanel.DeviceIconSize + 10; string newT = GUITools.FitTextLenghtToWidth(device.Name, devicePanel.Font, devicePanel.Width - devicePanel.DeviceIconSize - devicePanel.DeviceNameTextOffset); devicePanel.DeviceName = newT; devicePanel.MouseClick += (sender, args) => { DeviceIconClicked(devicePanel, device); }; // Cannot update from outside the thread if (panel_FlowLayoutDevices.InvokeRequired) { panel_FlowLayoutDevices.Invoke( new MethodInvoker( delegate() { panel_FlowLayoutDevices.Controls.Add(devicePanel); })); } }