Exemplo n.º 1
0
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            int    x        = int.Parse(textBoxX.Text);
            int    y        = int.Parse(textBoxY.Text);
            int    width    = int.Parse(textBoxWidth.Text);
            int    height   = int.Parse(textBoxHeight.Text);
            string filename = textBoxFilename.Text;

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }

            Rectangle rect = new Rectangle(x, y, width, height);

            try
            {
                activeDocument               = PowerpointViewerController.Open(filename, rect, thumbnailWidth: 200);
                activeDocument.Loaded       += new EventHandler(activeDocument_Loaded);
                activeDocument.SlideChanged += new EventHandler(activeDocument_SlideChanged);
                activeDocument.Closed       += new EventHandler(activeDocument_Closed);
                activeDocument.HiddenSlide  += new EventHandler(activeDocument_HiddenSlide);
                openDocuments.Add(activeDocument);
                listBoxDocuments.SelectedIndex = listBoxDocuments.Items.Add("Document #" + (counter++));
                this.UpdateStats();
                SetForegroundWindow(this.Handle);
            }
            catch (PowerpointViewerController.PowerpointViewerOpenException)
            {
                MessageBox.Show("Loading failed.");
            }
        }
Exemplo n.º 2
0
 private void buttonClose_Click(object sender, EventArgs e)
 {
     if (activeDocument == null)
     {
         return;
     }
     activeDocument.Close();
     activeDocument = null;
 }
Exemplo n.º 3
0
 private void listBoxDocuments_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxDocuments.SelectedIndex == -1)
     {
         activeDocument = null;
     }
     else
     {
         activeDocument = openDocuments[listBoxDocuments.SelectedIndex];
     }
     UpdateStats();
 }
Exemplo n.º 4
0
        private void PerformLoad()
        {
            if (File == null)
            {
                throw new InvalidOperationException("file has not been set");
            }

            try
            {
                doc        = PowerpointViewerController.Open(this.File.FullName, new Rectangle(Area.WindowLocation.X, Area.WindowLocation.Y, Area.WindowSize.Width, Area.WindowSize.Height), openHidden: true, thumbnailWidth: 200);
                doc.Error += (sender, args) =>
                {
                    if (!doc.HasLoaded)
                    {
                        Controller.Dispatcher.Invoke(new Action(() => OnLoaded(false)));
                    }
                    else
                    {
                        base.OnClosedExternally();
                    }
                };

                doc.Loaded += (sender, args) =>
                {
                    Controller.Dispatcher.Invoke(new Action(() =>
                    {
                        if (!isClosing)
                        {
                            WordsLive.Presentation.Wpf.Interop.RemoveFromAeroPeek(doc.WindowHandle);
                            if (showOnLoaded)
                            {
                                doc.Move(Area.WindowLocation.X, Area.WindowLocation.Y);
                                isShown = true;
                            }
                            OnLoaded(true);
                            Controller.FocusMainWindow(true);
                        }
                        else
                        {
                            doc.Close();
                        }
                    }));
                };

                doc.Closed += (sender, args) =>
                {
                    if (!isClosing)
                    {
                        base.OnClosedExternally();
                    }
                };

                doc.SlideChanged += (sender, args) =>
                {
                    base.OnSlideIndexChanged();
                };

                doc.HiddenSlide += (sender, args) =>
                {
                    Controller.Dispatcher.Invoke(new Action(() =>
                    {
                        if (!hasShownHiddenWarning)
                        {
                            MessageBox.Show(Resource.slideErrorMsgHiddenSlides, Resource.slideErrorMsgHiddenSlidesTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                            hasShownHiddenWarning = true;
                        }
                    }));
                };

                LoadPreviewProvider();
            }
            catch (PowerpointViewerController.PowerpointViewerOpenException)
            {
                Controller.Dispatcher.Invoke(new Action(() =>
                {
                    OnLoaded(false);
                }));
            }
        }