/// <summary> /// Handles the ActiveInteractionControllerChanged event of VisualTool object. /// </summary> private void VisualTool_ActiveInteractionControllerChanged(object sender, Vintasoft.Imaging.PropertyChangedEventArgs <IInteractionController> e) { OfficeDocumentVisualEditor visualEditor = null; if (e.NewValue != null) { visualEditor = CompositeInteractionController.FindInteractionController <OfficeDocumentVisualEditor>(e.NewValue); } VisualEditor = visualEditor; }
/// <summary> /// Returns an information about interaction controller. /// </summary> /// <param name="controller">The controller.</param> /// <returns> /// The information about interaction controller. /// </returns> private string GetInteractionControllerInfo(IInteractionController controller) { CompositeInteractionController compositeController = controller as CompositeInteractionController; if (compositeController != null) { StringBuilder sb = new StringBuilder(string.Format("CompositeInteractionController ({0}", GetInteractionControllerInfo(compositeController.Items[0]))); for (int i = 1; i < compositeController.Items.Count; i++) { sb.Append(string.Format(", {0}", GetInteractionControllerInfo(compositeController.Items[i]))); } sb.Append(")"); return(sb.ToString()); } object controllerObject = (object)controller; return(controllerObject.GetType().Name); }
/// <summary> /// Handles the Interaction event of the OfficeDocumentInteractionController. /// </summary> private void _officeDocumentInteractionController_Interaction(object sender, InteractionEventArgs e) { // if mouse is double clicked if (e.MouseClickCount == 2) { // find visual editor OfficeDocumentVisualEditor visualEditor = CompositeInteractionController.FindInteractionController <OfficeDocumentVisualEditor>(e.InteractionController); // if visual editor is found and has charts if (visualEditor != null && visualEditor.HasCharts) { // create document editor using (DocxDocumentEditor editor = visualEditor.CreateDocumentEditor()) { // if document has chart(s) and don't have text if (editor.Charts.Length > 0 && string.IsNullOrEmpty(editor.Body.Text.Trim('\n'))) { // open chart editor form ShowChartForm(visualEditor); e.InteractionOccured(false); } } } } }
/// <summary> /// Handles the ActiveInteractionControllerChanged event of the VisualTool. /// </summary> private void VisualTool_ActiveInteractionControllerChanged(object sender, Vintasoft.Imaging.PropertyChangedEventArgs <IInteractionController> e) { // if interaction controller exists if (e.NewValue != null) { // find visual editor in current interaction controller VisualEditor = CompositeInteractionController.FindInteractionController <OfficeDocumentVisualEditor>(e.NewValue); } else { VisualEditor = null; } // if visual editor exists if (VisualEditor != null) { // set current OfficeDocumentInteractionController OfficeDocumentInteractionController = e.NewValue; } else { OfficeDocumentInteractionController = null; } // if visual editor is not found or disabled if (VisualEditor == null || !VisualEditor.IsEnabled) { // if this form is visible if (Visible) { // hide this form Hide(); } } else { // if this form is not visible if (!Visible) { try { // if owner form is specified if (Owner != null) { // if owner form is moved if (_ownerLastLocation != Owner.Location) { // reset location _ownerLastLocation = Owner.Location; int x = LocationOffsetFromOwnerForm.X; if (x < 0) { x += Owner.Size.Width - Size.Width; } int y = LocationOffsetFromOwnerForm.Y; if (y < 0) { y += Owner.Size.Height - Size.Height; } Location = new Point(Owner.Location.X + x, Owner.Location.Y + y); } // show form Show(); // set focus to owner form Owner.Focus(); } else { // show form Show(); } } catch { } } } }