Exemplo n.º 1
0
 private void buttonClose_Click(object sender, EventArgs e)
 {
     if (activeDocument == null)
     {
         return;
     }
     activeDocument.Close();
     activeDocument = null;
 }
Exemplo n.º 2
0
        public override void Close()
        {
            isClosing = true;
            if (doc != null)
            {
                doc.Close();
            }

            base.Close();
        }
Exemplo n.º 3
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);
                }));
            }
        }