示例#1
0
        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>
        /// Event is raised when rename Viewpoint is clicked from the grid.
        /// </summary>
        /// <param name="sender">Ribbon control</param>
        /// <param name="e">Routed event</param>
        private void OnRenameViewpointEvent(object sender, EventArgs e)
        {
            var viewModel = sender as ViewpointViewModel;
            if (viewModel != null)
            {
                CaptureViewpoint dialog = new CaptureViewpoint();
                System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(dialog);
                helper.Owner = (IntPtr)ThisAddIn.ExcelApplication.Hwnd;

                viewModel.RequestClose += new EventHandler(dialog.OnRequestClose);
                dialog.DataContext = viewModel;
                dialog.UpdateLayout();

                dialog.ShowDialog();

                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    if (!string.IsNullOrWhiteSpace(viewModel.Name))
                    {
                        viewModel.CurrentPerspective.Name = viewModel.Name;
                        SaveViewpointMap(ThisAddIn.ExcelApplication.ActiveWorkbook);
                        this.ribbonInstance.BuildViewpointMenu(this.currentViewpointMap.SerializablePerspective);
                    }
                }

                viewModel.RequestClose -= new EventHandler(dialog.OnRequestClose);
                dialog.Close();
            }
        }
示例#3
0
        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);
            }
        }