Exemple #1
0
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("WebsiteNodeContentControl::Dispose({0}) @{1}", disposing, dispose_count);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                WPFDoEvents.SafeExec(() =>
                {
                    if (dispose_count == 0)
                    {
                        // Get rid of managed resources / get rid of cyclic references:
                        fader?.Dispose();
                    }
                    fader = null;
                });

                WPFDoEvents.SafeExec(() =>
                {
                    website_node_content = null;
                    DataContext          = null;
                });

                ++dispose_count;
            });
        }
Exemple #2
0
        private void ReevaluateDataContext()
        {
            bool have_pdf_to_render = false;

            GridPreview.Children.Clear();

            if (null != DataContext)
            {
                AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;
                if (null != pdf_document_bindable)
                {
                    if (pdf_document_bindable.Underlying.DocumentExists)
                    {
                        PDFRendererControl pdf_renderer_control = new PDFRendererControl(pdf_document_bindable.Underlying, false, PDFRendererControl.ZoomType.Zoom1Up);
                        GridPreview.Children.Add(pdf_renderer_control);
                        pdf_renderer_control.SelectedPageChanged += pdf_renderer_control_SelectedPageChanged;
                        have_pdf_to_render = true;
                    }
                }

                TxtNullDataContext.Visibility = Visibility.Collapsed;
                ObjDocumentInfo.Visibility    = Visibility.Visible;
                if (!have_pdf_to_render)
                {
                    ObjAbstract.Expand();
                }
                IsEnabled = true;
            }
            else
            {
                TxtNullDataContext.Visibility = Visibility.Visible;
                ObjDocumentInfo.Visibility    = Visibility.Collapsed;
                IsEnabled = false;
            }
        }
        /// <summary>
        /// NB: only call this as part of document creation.
        /// </summary>
        public void CloneMetaData(PDFDocument existing_pdf_document)
        {
            // prevent deadlock due to possible incorrect use of this API:
            if (existing_pdf_document != this)
            {
                Logging.Warn("TODO: CloneMetaData: MERGE metadata for existing document and document which was copied/moved into this library. Target Document: {0}, Source Document: {1}", this.Fingerprint, existing_pdf_document.Library);

                lock (existing_pdf_document.access_lock)
                {
                    lock (access_lock)
                    {
                        bindable = null;

                        doc.CloneMetaData(existing_pdf_document.doc);

                        doc.GetAnnotations().OnPDFAnnotationListChanged += annotations_OnPDFAnnotationListChanged;
                        doc.Highlights.OnPDFHighlightListChanged += highlights_OnPDFHighlightListChanged;
                        doc.Inks.OnPDFInkListChanged             += inks_OnPDFInkListChanged;

                        // Copy the citations
                        PDFDocumentCitationManager.CloneFrom(existing_pdf_document.PDFDocumentCitationManager);

                        QueueToStorage();
                    }
                }
            }
        }
        private void Rebuild()
        {
            WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

            ObjDocumentViewer.Document             = null;
            ObjTooManyAnnotationsButton.Visibility = Visibility.Collapsed;

            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                PDFDocument pdf_document = pdf_document_bindable.Underlying;

                SafeThreadPool.QueueUserWorkItem(o =>
                {
                    // TODO: [GHo] what are these 'heuristic' conditions good for?!?!
                    if (pdf_document.GetAnnotations().Count > 50 || pdf_document.Highlights.Count > 1000)
                    {
                        WPFDoEvents.InvokeAsyncInUIThread(() =>
                        {
                            ObjTooManyAnnotationsButton.Visibility = Visibility.Visible;
                            ObjTooManyAnnotationsButton.Tag        = pdf_document;
                        });
                    }
                    else
                    {
                        PopulateWithAnnotationReport(pdf_document);
                    }
                });
            }
        }
Exemple #5
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            // base.OnClosed() invokes this class' Closed() code, so we flipped the order of exec to reduce the number of surprises for yours truly.
            // This NULLing stuff is really the last rites of Dispose()-like so we stick it at the end here.

            pdf_document_bindable = null;
        }
Exemple #6
0
        private void ButtonThemeSwatch_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = PDFDocumentBindable;

            if (null != pdf_document_bindable)
            {
                MainWindowServiceDispatcher.Instance.OpenExpedition(pdf_document_bindable.Underlying.LibraryRef, pdf_document_bindable.Underlying);
            }
        }
Exemple #7
0
        private void TextLabelAuthors_OnClick(object sender, MouseButtonEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                MainWindowServiceDispatcher.Instance.SearchWeb(pdf_document_bindable.Underlying.AuthorsCombined);
                e.Handled = true;
            }
        }
        public void Show(AugmentedBindable <PDFDocument> pdf_document_bindable)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Document_MetadataCommentEditor);

            Show();
            this.pdf_document_bindable = pdf_document_bindable;
            DataContext = pdf_document_bindable;

            Keyboard.Focus(ObjBibTeXEditorControl);
        }
Exemple #9
0
 private void ForgetPassword()
 {
     if (MessageBoxes.AskQuestion("Are you sure you want to forget this password?"))
     {
         AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;
         PDFDocument pdf_document = pdf_document_bindable.Underlying;
         pdf_document.RemovePassword();
         ReBind();
     }
 }
Exemple #10
0
        public static void Test()
        {
            TestData td = new TestData();
            AugmentedBindable <TestData> bindable = new AugmentedBindable <TestData>(td);

            TestControl tc = new TestControl();

            tc.DataContext = bindable;
            ControlHostingWindow w = new ControlHostingWindow("Tag editor", tc);

            w.Show();
        }
Exemple #11
0
        private void DisplayNotification(NotificationManager.Notification notification)
        {
            if (!CheckAccess())
            {
                Dispatcher.Invoke(((Action) (() => DisplayNotification(notification))));
                return;
            }

            ImageSource = string.IsNullOrEmpty(notification.ImageName) ? null : Icons.GetAppIcon(notification.ImageName);
            DataContext = new AugmentedBindable<NotificationManager.Notification>(notification);
            Visibility = Visibility.Visible;
        }
Exemple #12
0
        void ObjPopupButton_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                MainWindowServiceDispatcher.Instance.GenerateAnnotationReport(pdf_document_bindable.Underlying.Library, new List <PDFDocument>()
                {
                    pdf_document_bindable.Underlying
                });
            }
        }
Exemple #13
0
        public void Show(AugmentedBindable <PDFDocument> pdf_document_bindable)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Document_MetadataCommentEditor);

            Show();
            this.pdf_document_bindable = pdf_document_bindable;
            DataContext = pdf_document_bindable;

            Keyboard.Focus(TextComments);
            TextComments.ScrollToEnd();
            TextComments.SelectionStart = TextComments.Text.Length;
        }
Exemple #14
0
        private void TxtTitle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                PDFDocument pdf_document = pdf_document_bindable.Underlying;
                MainWindowServiceDispatcher.Instance.OpenDocument(pdf_document);
            }

            e.Handled = true;
        }
Exemple #15
0
        private void HyperlinkRestore_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                pdf_document_bindable.Underlying.Deleted = false;
                pdf_document_bindable.NotifyPropertyChanged(() => pdf_document_bindable.Underlying.Deleted);
            }

            e.Handled = true;
        }
 private void PrepareBindables()
 {
     if (null == pdf_annotation_bindable || null == pdf_document_bindable)
     {
         PDFDocument   out_pdf_document;
         PDFAnnotation out_pdf_annotation;
         if (WebLibraryDocumentLocator.LocateFirstPDFDocumentWithAnnotation(library_fingerprint, pdf_document_fingerprint, pdf_annotation_guid, out out_pdf_document, out out_pdf_annotation))
         {
             pdf_annotation_bindable = out_pdf_annotation.Bindable;
             pdf_document_bindable   = out_pdf_document.Bindable;
         }
     }
 }
Exemple #17
0
        void ButtonComments_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = this.DataContext as AugmentedBindable <PDFDocument>;

            if (null == pdf_document_bindable)
            {
                return;
            }

            MetadataCommentEditorControl editor = new MetadataCommentEditorControl();

            editor.Show(pdf_document_bindable);
        }
        private void ButtonSniffer_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null == pdf_document_bindable)
            {
                return;
            }

            GoogleBibTexSnifferControl sniffer = new GoogleBibTexSnifferControl();

            sniffer.Show(pdf_document_bindable.Underlying);
        }
Exemple #19
0
        private void ButtonBibTexEditor_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null == pdf_document_bindable)
            {
                return;
            }

            MetadataBibTeXEditorControl editor = new MetadataBibTeXEditorControl();

            editor.Show(pdf_document_bindable);
        }
Exemple #20
0
        private void TopicOverviewControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            // Clear the old
            ObjPDFRendererControlPlaceholder.Children.Clear();

            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null == pdf_document_bindable)
            {
                return;
            }

            PDFDocument pdf_document = pdf_document_bindable.Underlying;

            if (null == pdf_document.Library.ExpeditionManager.ExpeditionDataSource)
            {
                return;
            }

            ExpeditionDataSource eds          = pdf_document.Library.ExpeditionManager.ExpeditionDataSource;
            LDAAnalysis          lda_analysis = eds.LDAAnalysis;

            try
            {
                if (!pdf_document.Library.ExpeditionManager.ExpeditionDataSource.docs_index.ContainsKey(pdf_document.Fingerprint))
                {
                    MessageBoxes.Warn("Expedition doesn't have any information about this paper.  Please Refresh your Expedition.");
                    return;
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem with Expedition for document {0}", pdf_document.Fingerprint);
            }



            if (pdf_document_bindable.Underlying.DocumentExists)
            {
                ObjPDFRendererControlPlaceholderBorder.Visibility = Visibility.Visible;
                ObjPDFRendererControlPlaceholderRow.Height        = new GridLength(1, GridUnitType.Star);

                PDFRendererControl pdf_renderer_control = new PDFRendererControl(pdf_document_bindable.Underlying, false, PDFRendererControl.ZoomType.Zoom1Up);
                ObjPDFRendererControlPlaceholder.Children.Add(pdf_renderer_control);
            }
            else
            {
                ObjPDFRendererControlPlaceholderBorder.Visibility = Visibility.Collapsed;
                ObjPDFRendererControlPlaceholderRow.Height        = new GridLength(0, GridUnitType.Pixel);
            }
        }
Exemple #21
0
        private void ButtonBibTexClear_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBoxes.AskQuestion("Are you sure you wish to clear this BibTeX?"))
            {
                AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;
                if (null == pdf_document_bindable)
                {
                    return;
                }

                pdf_document_bindable.Underlying.BibTex = "";
                pdf_document_bindable.NotifyPropertyChanged(nameof(pdf_document_bindable.Underlying.BibTex));
            }
        }
Exemple #22
0
        public LibraryNodeContentControl(NodeControl node_control, LibraryNodeContent library_node_content)
        {
            InitializeComponent();

            this.node_control         = node_control;
            this.library_node_content = new AugmentedBindable <LibraryNodeContent>(library_node_content);

            this.DataContext = this.library_node_content;

            Focusable = true;

            this.ImageIcon.Source = Icons.GetAppIcon(Icons.BrainstormLibrary);

            TextBorder.CornerRadius = NodeThemes.corner_radius;
        }
        public NotificationBar()
        {
            InitializeComponent();

            RenderOptions.SetBitmapScalingMode(NotificationImage, BitmapScalingMode.HighQuality);

            CloseButton.Source = Icons.GetAppIcon(Icons.NotificationBarClose);

            //  register for new events from the NotificationManager, don't bother deregistering since this will live for the life of the app
            NotificationManager.Instance.NewNotificationFired += Instance_NewNotificationFired;

            // set up a fake binding for the time we don't have a real binding yet:
            DataContext = new AugmentedBindable <NotificationManager.Notification>(new NotificationManager.Notification("", "", NotificationManager.NotificationType.Info, ""));
            Visibility  = Visibility.Collapsed;
        }
Exemple #24
0
        private void SetPassword()
        {
            string password = TxtPassword.Password;

            if (String.IsNullOrEmpty(password))
            {
                ForgetPassword();
            }
            else
            {
                AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;
                PDFDocument pdf_document = pdf_document_bindable.Underlying;
                pdf_document.AddPassword(password);
                ReBind();
            }
        }
        private void ResetConfigurationRecord(string user_guid_, bool is_guest_)
        {
            Logging.Info("Resetting configuration settings to {0}", user_guid_);

            if (null != configuration_record_bindable)
            {
                configuration_record_bindable.PropertyChanged -= configuration_record_bindable_PropertyChanged;
            }

            // Create the new user_guid
            user_guid = user_guid_;
            is_guest  = is_guest_;

            // Create the base directory in case it doesnt exist
            Directory.CreateDirectory(BaseDirectoryForUser);

            // Try loading any pre-existing config file
            try
            {
                if (File.Exists(ConfigFilenameForUser))
                {
                    Logging.Info("Loading configuration file {0}", ConfigFilenameForUser);
                    configuration_record = (ConfigurationRecord)ObjectSerializer.LoadObject(ConfigFilenameForUser);
                    Logging.Info("Loaded configuration file {0}", ConfigFilenameForUser);
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem loading configuration file {0}", ConfigFilenameForUser);
            }

            if (null == configuration_record)
            {
                Logging.Info("There is no existing configuration, so creating one from scratch. Is configuration file {0} missing?", ConfigFilenameForUser);
                configuration_record = new ConfigurationRecord();
            }

            // Attach a bindable to the configuration record so that GUIs can update it
            configuration_record_bindable = new AugmentedBindable <ConfigurationRecord>(configuration_record);
            configuration_record_bindable.PropertyChanged += configuration_record_bindable_PropertyChanged;

            // Make sure we have a GA tracking ID
            if (String.IsNullOrEmpty(configuration_record.Feedback_GATrackingCode))
            {
                configuration_record.Feedback_GATrackingCode = Guid.NewGuid().ToString();
            }
        }
        public ThemeNodeContentControl(NodeControl node_control_, ThemeNodeContent theme_node_content)
        {
            InitializeComponent();

            node_control            = node_control_;
            this.theme_node_content = new AugmentedBindable <ThemeNodeContent>(theme_node_content);

            DataContextChanged += ThemeNodeContentControl_DataContextChanged;
            DataContext         = this.theme_node_content;

            Focusable = true;

            ImageIcon.Source = Icons.GetAppIcon(Icons.BrainstormAttractorTheme);
            RenderOptions.SetBitmapScalingMode(ImageIcon, BitmapScalingMode.HighQuality);

            TextBorder.CornerRadius = NodeThemes.corner_radius;
        }
Exemple #27
0
        private void ReBind()
        {
            TxtPassword.Clear();
            TxtDescription.Text = "You have no password associated with this PDF.  If it is a password protected PDF, enter the password in the box below.";

            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null != pdf_document_bindable)
            {
                PDFDocument pdf_document = pdf_document_bindable.Underlying;

                string password = pdf_document.GetPassword();
                if (!String.IsNullOrEmpty(password))
                {
                    TxtDescription.Text = "You have a password associated with this PDF.  Enter a new one in the box below or clear it with the Forget button.";
                }
            }
        }
Exemple #28
0
        /// <summary>
        /// NB: only call this as part of document creation.
        /// </summary>
        public void CloneMetaData(PDFDocument existing_pdf_document)
        {
            bindable = null;

            Logging.Info("Cloning metadata from {0}", existing_pdf_document.Title);
            dictionary  = (DictionaryBasedObject)existing_pdf_document.dictionary.Clone();
            annotations = (PDFAnnotationList)existing_pdf_document.Annotations.Clone();
            highlights  = (PDFHightlightList)existing_pdf_document.Highlights.Clone();
            inks        = (PDFInkList)existing_pdf_document.Inks.Clone();
            SaveToMetaData();

            // Copy the citations
            PDFDocumentCitationManager.CloneFrom(existing_pdf_document.PDFDocumentCitationManager);

            //  Now clear out the references for the annotations and highlights, so that when they are reloaded the events are resubscribed
            annotations = null;
            highlights  = null;
            inks        = null;
        }
Exemple #29
0
        private void ButtonUseSummary_Click(object sender, RoutedEventArgs e)
        {
            AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>;

            if (null == pdf_document_bindable)
            {
                return;
            }

            if (!String.IsNullOrEmpty(pdf_document_bindable.Underlying.BibTex))
            {
                if (!MessageBoxes.AskQuestion("You already have BibTeX associated with this record.  Are you sure you want to overwrite it?"))
                {
                    return;
                }
            }

            BibTexItem bibtem_item = new BibTexItem();

            bibtem_item.Type = "article";
            bibtem_item.Key  = String.Format(
                "{0}{1}{2}"
                , Constants.UNKNOWN_AUTHORS != pdf_document_bindable.Underlying.AuthorsCombined ? StringTools.GetFirstWord(pdf_document_bindable.Underlying.AuthorsCombined) : ""
                , Constants.UNKNOWN_YEAR != pdf_document_bindable.Underlying.YearCombined ? StringTools.GetFirstWord(pdf_document_bindable.Underlying.YearCombined) : ""
                , Constants.TITLE_UNKNOWN != pdf_document_bindable.Underlying.TitleCombined ? StringTools.GetFirstWord(pdf_document_bindable.Underlying.TitleCombined) : ""
                );

            if (Constants.TITLE_UNKNOWN != pdf_document_bindable.Underlying.TitleCombined)
            {
                bibtem_item["title"] = pdf_document_bindable.Underlying.TitleCombined;
            }
            if (Constants.UNKNOWN_AUTHORS != pdf_document_bindable.Underlying.AuthorsCombined)
            {
                bibtem_item["author"] = pdf_document_bindable.Underlying.AuthorsCombined;
            }
            if (Constants.UNKNOWN_YEAR != pdf_document_bindable.Underlying.YearCombined)
            {
                bibtem_item["year"] = pdf_document_bindable.Underlying.YearCombined;
            }

            pdf_document_bindable.Underlying.BibTex = bibtem_item.ToBibTex();
            pdf_document_bindable.NotifyPropertyChanged(nameof(pdf_document_bindable.Underlying.BibTex));
        }
Exemple #30
0
        public WebsiteNodeContentControl(NodeControl node_control, WebsiteNodeContent website_node_content)
        {
            this.website_node_content = new AugmentedBindable <WebsiteNodeContent>(website_node_content);
            DataContext = this.website_node_content;

            InitializeComponent();

            Focusable = true;

            ImageDocumentIcon.Source = Icons.GetAppIcon(Icons.BrainstormWebsite);

            TextUrl.FontWeight            = FontWeights.Bold;
            TextTitle.TextWrapping        = TextWrapping.Wrap;
            TextLastVisited.TextTrimming  = TextTrimming.CharacterEllipsis;
            TextVisitedCount.TextTrimming = TextTrimming.CharacterEllipsis;

            MouseDoubleClick += WebsiteNodeContentControl_MouseDoubleClick;

            fader = new BackgroundFader(this);
        }