/// <summary> /// Sets the machine IP if the machine address is valid in following scenarios /// 1. WWT is running /// 2. It has version more than base version /// </summary> /// <param name="machineAddresses">Collection of IP address for the name provided</param> /// <param name="machineName">Machine display name</param> private void SetMachineIPIfValid(Collection <IPAddress> machineAddresses, string machineName) { if (machineAddresses != null && machineAddresses.Count > 0) { int count = 0; foreach (IPAddress machineAddress in machineAddresses) { try { count++; // Checks if the machine is valid and latest WWT running on it. if (WWTManager.IsValidMachine(machineAddress.ToString(), false)) { MachineIP = machineAddress; DisplayValue = machineName; break; } } catch (CustomException ex) { switch (ex.ErrorCode) { case ErrorCodes.Code100001: // If the error code is for WWT not running and is the last IP address in the loop // then throw exception else continue with the looping if (count == machineAddresses.Count) { throw new CustomException(ex.HasCustomMessage ? ex.Message : Properties.Resources.DefaultErrorMessage, ex, true); } else { continue; } case ErrorCodes.Code100003: case ErrorCodes.Code100005: case ErrorCodes.Code100002: // If WWT is running on the machine but it not latest version then throw the exception { throw new CustomException(ex.HasCustomMessage ? ex.Message : Properties.Resources.DefaultErrorMessage, ex, true); } default: break; } } } } }
private void OnCaptureViewpointButtonClick(object sender, RibbonControlEventArgs e) { try { Utility.IsWWTInstalled(); WWTManager.IsValidMachine(Common.Globals.TargetMachine.MachineIP.ToString(), false); Perspective perspective = WWTManager.GetCameraView(); if (perspective != null) { var dialog = new CaptureViewpoint(); System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(dialog); helper.Owner = (IntPtr)ThisAddIn.ExcelApplication.Hwnd; perspective.Name = Resources.DefaultViewpointText; var viewModel = new ViewpointViewModel(perspective); viewModel.IsButtonEnabled = true; viewModel.RequestClose += new EventHandler(dialog.OnRequestClose); dialog.DataContext = viewModel; dialog.ShowDialog(); // WPF dialog does not have dialog result if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { if (!string.IsNullOrWhiteSpace(perspective.Name)) { // Fire it only when valid value set this.GetViewpointClicked.OnFire(perspective, new EventArgs()); } } viewModel.RequestClose -= new EventHandler(dialog.OnRequestClose); dialog.Close(); } } catch (CustomException ex) { Ribbon.ShowError(ex.HasCustomMessage ? ex.Message : Resources.LayerOperationError); } catch (Exception exception) { Logger.LogException(exception); Ribbon.ShowError(Resources.DefaultErrorMessage); } }
/// <summary> /// Sets the machine IP if the machine address is valid in following scenarios /// 1. WWT is running /// 2. It has version more than base version /// </summary> /// <param name="machineAddress">Machine Address</param> /// <param name="displayName">Machine display name</param> private void SetMachineIPIfValid(IPAddress machineAddress, string displayName) { if (machineAddress != null) { try { // Checks if the machine is valid and latest WWT running on it. if (WWTManager.IsValidMachine(machineAddress.ToString(), false)) { MachineIP = machineAddress; DisplayValue = displayName; } } catch (CustomException ex) { throw new CustomException(ex.HasCustomMessage ? ex.Message : Properties.Resources.DefaultErrorMessage, ex, true); } } }
private void btnGetLocation_Click(object sender, RibbonControlEventArgs e) { try { Utility.IsWWTInstalled(); WWTManager.IsValidMachine(Common.Globals.TargetMachine.MachineIP.ToString(), false); WorkflowController.Instance.UpdateCurrentLocation(); } catch (CustomException ex) { Ribbon.ShowError(ex.HasCustomMessage ? ex.Message : Resources.LayerOperationError); } catch (Exception exception) { Logger.LogException(exception); Ribbon.ShowError(Resources.DefaultErrorMessage); } }