/// <summary> /// Called when selected index of lVUnits changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lVUnits_SelectedIndexChanged(object sender, EventArgs e) { if (0 == lVUnits.SelectedIndices.Count) { ClearDeviceInfo(); btnBrowseFeatureList.Enabled = false; mSelectedUnitIndex = -1; return; } mSelectedUnitIndex = lVUnits.SelectedIndices[0]; var selectedUnit = UnitSet.GetUnitAt(mSelectedUnitIndex) as BaseUnit; if (null == selectedUnit) { return; } bool isDevice = UnitType.Device == selectedUnit.Type; btnBrowseFeatureList.Enabled = isDevice; tBFeatureList.Enabled = isDevice; tBNetworkTrace.Text = selectedUnit.GetTracesString(); FillClientInfo(selectedUnit as Client); FillDeviceInfo(selectedUnit as Device); }
private void lVUnits_MouseClick(object sender, MouseEventArgs e) // TODO { if (MouseButtons.Right != e.Button) { return; } ListView lVSender = sender as ListView; if (null == lVSender) { return; } var selectedUnits = (from int index in lVSender.SelectedIndices select UnitSet.GetUnitAt(index)).ToList(); if (selectedUnits.All(item => UnitType.Client == item.Type) && selectedUnits.Count > 1) { var menu = new ContextMenuStrip(); menu.Items.Add("Merge"); menu.Items[0].Click += (o, args) => new SystemCreatorForm(selectedUnits.Cast <Client>()).ShowDialog(); menu.Show(sender as Control, e.Location); } else if (selectedUnits.All(item => UnitType.System == item.Type)) { var menu = new ContextMenuStrip(); menu.Items.Add("Split"); menu.Items[0].Click += (o, args) => selectedUnits.Cast <ClientSystem>().ToList().ForEach(UnitSet.Split); menu.Show(sender as Control, e.Location); } }
/// <summary> /// Browse FeatureList button handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBrowseFeatureList_Click(object sender, EventArgs e) { DialogResult result = oFDFeatureList.ShowDialog(); if (DialogResult.OK != result) { return; } IUnit unit = UnitSet.GetUnitAt(mSelectedUnitIndex); var device = unit as Device; if (null == device) { return; } device.FeatureList = oFDFeatureList.FileName; var deviceInfo = new DeviceFeatureListParser(device).GetDeviceInformation(); if (!String.IsNullOrEmpty(device.Info.Model) && deviceInfo.Model != device.Info.Model) { var warningResult = DialogHelper.ShowWarning(Resources.Message_Device_Info_Different); if (warningResult == DialogResult.Cancel) { device.FeatureList = String.Empty; return; } } device.SetInformation(deviceInfo); tBFeatureList.Text = device.FeatureList; UpdateUnitList(); lVUnits.Focus(); lVUnits.Items[mSelectedUnitIndex].Selected = true; }