/// <summary>
 /// Handles when the user request to delete a layout.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The event arguments.</param>
 private void LayoutListControl_LayoutDelete(object sender, LayoutItemEventArgs e)
 {
     if (this.LayoutDelete != null)
     {
         this.LayoutDelete(this, e);
     }
 }
        /// <summary>
        /// Handles the <see cref="ComboBox.SelectedIndexChanged"/> event for the layouts combo box.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event data.</param>
        private void HandleLayoutSelectedIndexChanged(object sender, LayoutItemEventArgs e)
        {
            double scaleFactor = (double)this.pictureBoxPreview.Width / (double)e.LayoutItem.PreviewImage.Width;
            Size   scaledSize  = new Size(Convert.ToInt32(e.LayoutItem.PreviewImage.Width * scaleFactor), Convert.ToInt32(e.LayoutItem.PreviewImage.Height * scaleFactor));

            this.pictureBoxPreview.Image = new Bitmap(e.LayoutItem.PreviewImage, scaledSize);
            if (this.LayoutSelected != null)
            {
                this.LayoutSelected(this, e);
            }

            this.SelectedLayout = e.LayoutItem;
        }
Exemple #3
0
        /// <summary>
        /// Handles the <see cref="ILayoutDesignerView.LayoutDelete"/> event.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void HandleLayoutDelete(object sender, LayoutItemEventArgs e)
        {
            IMessageBoxView  messageBox = this.container.Resolve <IMessageBoxView>();
            MessageBoxResult result     = messageBox.Show(string.Format(CultureInfo.InvariantCulture, PresenterResources.ConfirmLayoutDeletion, this.SaveLayoutName()), PresenterResources.MicrosoftWord, MessageBoxViewButtons.YesNo, MessageBoxViewIcon.Warning);

            if (result == MessageBoxResult.Yes)
            {
                int index = 0;
                LayoutInformation[] layouts = this.GetLayoutList().ToArray();
                for (int i = 0; i < layouts.Length; i++)
                {
                    if (e.LayoutItem.Name == layouts[i].Name)
                    {
                        index = i;
                        break;
                    }
                }

                int nextIndex = -1;
                if (index < layouts.Length - 1)
                {
                    nextIndex = index + 1;
                }
                else if (index >= layouts.Length - 1)
                {
                    nextIndex = index - 1;
                }

                this.manager.SystemTemplate.DeleteLayout(e.LayoutItem.Name);
                this.manager.SystemTemplate.Save();
                if (this.CurrentLayoutIsTemporary())
                {
                    this.RemoveTemporaryLayout();
                }

                this.SetDocumentClean();
                this.SetViewLayoutList();

                if (nextIndex != -1)
                {
                    this.ChangeDisplayedLayout(layouts[nextIndex]);
                }

                this.SetEditorControls();
            }
        }
        /// <summary>
        /// Handles when a new layout is selected from the grid.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void ListViewLayouts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listViewLayouts.SelectedItems.Count > 0 && this.lastSelectedIndex != this.listViewLayouts.SelectedItems[0].Index)
            {
                int selectedItemIndex = this.listViewLayouts.SelectedItems[0].Index; // need to get it here, the SelectedItems collection can become empty later.

                LayoutInformation layout = this.GetSelectedLayout();
                if (layout != null)
                {
                    LayoutItemEventArgs args = new LayoutItemEventArgs(layout);

                    // When cancelling a selection the event is raised twice, not just when deselecting old and selecting new, but twice to select the new value. So must ignore
                    // second raise.
                    if (this.cancellingSelection)
                    {
                        // This was the second time the change was attempted, ignore it and don't prompt again.
                        this.cancellingSelection = false;
                        args.Cancel = true;
                    }
                    else
                    {
                        if (this.LayoutSelected != null)
                        {
                            this.LayoutSelected(this, args);
                        }

                        if (args.Cancel)
                        {
                            this.cancellingSelection = true;
                        }
                    }

                    if (args.Cancel)
                    {
                        this.listViewLayouts.Items[this.lastSelectedIndex].Selected = true;
                    }
                    else
                    {
                        this.lastSelectedIndex = selectedItemIndex;
                    }

                    this.SelectLayout(this.GetSelectedLayout().Name); // Ensures selected layout is highlighted correctly.
                }
            }
        }
Exemple #5
0
        private void HandleLayoutSelected(object sender, LayoutItemEventArgs e)
        {
            try
            {
                bool confirmed = this.CheckForChangesAndConfirmDisposition(e);
                if (confirmed)
                {
                    if (this.CurrentLayoutIsTemporary() && e.LayoutItem != this.temporaryLayout)
                    {
                        this.RemoveTemporaryLayout();
                    }

                    this.ChangeDisplayedLayout(e.LayoutItem);
                }
                else
                {
                    e.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                this.DisplayError(this.view, ex);
            }
        }
Exemple #6
0
 /// <summary>
 /// Handles the <see cref="ILayoutPickerWizardPageView.LayoutSelected"/> event and sets the button state according to the state of the query selection.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The event data</param>
 private void HandleLayoutSelected(object sender, LayoutItemEventArgs e)
 {
     this.SelectedLayout = e.LayoutItem;
     this.IsValid        = true;
     this.OnValidityChanged();
 }