Exemple #1
0
        public FastTaggerForm(BrainForm _owner) : base(_owner)
        {
            InitializeComponent();

            this.richTextBoxTags.ApplicationForm = _owner;
            this.richTextBoxTags.OwnerForm       = this;
        }
        public ModelessForm(BrainForm _owner)
        {
            m_owner = _owner;

            InitializeComponent();
            KeyPreview = true;
        }
        void    LocateBookmarks()
        {
            try {
                listViewBookmarks.SuspendLayout();
                listViewBookmarks.Clear();
                buttonImportBookmarks.Enabled = false;

                // List Chrome bookmarks
                const string chromeRootPath = @"appdata\local\google\chrome\user data\";

                Everything.Search.MatchPath = true;
//				Everything.Search.SearchExpression = @"parent:" + chromeRootPath + " bookmark";
                Everything.Search.SearchExpression = chromeRootPath + " bookmarks";
                Everything.Search.ExecuteQuery();

                foreach (Everything.Search.Result result in Everything.Search.Results)
                {
                    try {
                        FileInfo bookmarkFile = new FileInfo(result.FullName);
                        if (!bookmarkFile.Exists || bookmarkFile.Name.ToLower() != "bookmarks")
                        {
                            continue;                                   // Not a valid bookmark file...
                        }
                        // Retrieve profile name from path
                        int pathStartIndex = bookmarkFile.DirectoryName.ToLower().IndexOf(chromeRootPath);
                        if (pathStartIndex == -1)
                        {
                            throw new Exception("Failed to retrieve Chrome path in bookmark file path!");
                        }
                        string profileName = bookmarkFile.DirectoryName.Substring(pathStartIndex + chromeRootPath.Length);                              // Strip relative path

                        // Add a successfully recognized bookmark file to the list
                        ListViewItem bookmarkItem = new ListViewItem("Chrome - " + profileName);
                        bookmarkItem.Tag = new BookmarkFile()
                        {
                            m_fileName = bookmarkFile, m_type = BookmarkFile.BOOKMARK_TYPE.CHROME
                        };
                        listViewBookmarks.Items.Add(bookmarkItem);


// if ( bookmarkFile.FullName.IndexOf( "Profile 2" ) != -1 )
//  ImportBookmarksChrome( bookmarkFile );
                    } catch (Exception _e) {
                        BrainForm.Debug("Error while listing bookmark file for result " + result.FullName + ": " + _e.Message);
                    }
                }

                if (listViewBookmarks.Items.Count == 0)
                {
                    listViewBookmarks.Items.Add("No bookmarks found");
                }
            } catch (Exception _e) {
                listViewBookmarks.Items.Add("Error " + _e.Message);
            } finally {
                listViewBookmarks.ResumeLayout();
            }
        }
        public FicheWebPageEditorForm(BrainForm _owner) : base(_owner)
        {
            InitializeComponent();

            tagEditBox.ApplicationForm = m_owner;
            tagEditBox.OwnerForm       = this;

//          webEditor.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.webEditor_PreviewKeyDown);
//          webEditor.DocumentUpdated += WebEditor_DocumentUpdated;
        }
Exemple #5
0
        public FicheWebPageAnnotatorForm(BrainForm _owner) : base(_owner)
        {
            InitializeComponent();

            tagEditBox.ApplicationForm = m_owner;
            tagEditBox.OwnerForm       = this;

            panelHost.m_childPanel = panelWebPage;

            panelHost.Focus();
        }
        private void richTextBoxURL_LinkClicked(object sender, LinkClickedEventArgs e)
        {
            if (m_fiche == null || m_fiche.URL == null)
            {
                return;
            }

            try {
                System.Diagnostics.Process.Start(m_fiche.URL.AbsoluteUri);
            } catch (Exception _e) {
                BrainForm.MessageBox("Failed to open URL \"" + m_fiche.URL.AbsoluteUri + "\": ", _e);
            }
        }
 public void     UnRegisterHotKeys()
 {
     foreach (Shortcut S in m_shortcuts)
     {
         try {
             if (S.m_ID >= 0)
             {
                 Interop.UnregisterHotKey(m_owner.Handle, S.m_ID);
             }
         } catch (Exception _e) {
             BrainForm.LogError(new Exception("Failed to unregister " + S.m_type + " hotkey", _e));
         }
     }
 }
        public void     RegisterHotKeys()
        {
            int keyID = 0;

            foreach (Shortcut S in m_shortcuts)
            {
                try {
                    Interop.RegisterHotKey(m_owner, keyID, S.m_modifier, S.m_key);
                    S.m_ID = keyID++;
                } catch (Exception _e) {
                    // Maybe already hooked?
                    BrainForm.LogError(new Exception("Failed to register " + S.m_type + " hotkey", _e));
                }
            }
        }
        public NotificationForm(BrainForm _owner)
        {
            m_owner = _owner;
            InitializeComponent();

            m_backgroundBrush    = new SolidBrush(this.TransparencyKey);
            m_counterBrush       = new SolidBrush(Color.FromArgb(255, 0, 34));                  // Facebook red
            m_counterTextBrush   = new SolidBrush(Color.White);                                 // Facebook white
            m_pathCounter1Digit  = CreateRoundedBoxPath("8");
            m_pathCounter2Digits = CreateRoundedBoxPath("88");

// https://twitter.com/aras_p/status/1235462825256136705/photo/1
//return false sur WM_INITDIALOG;

            SetStyle(ControlStyles.ResizeRedraw, true);
        }
        private void buttonImportBookmarks_Click(object sender, EventArgs e)
        {
            int          totalImportedBookmarksCount = 0;
            List <Fiche> createdTags     = new List <Fiche>();
            List <Fiche> complexNameTags = new List <Fiche>();

            foreach (ListViewItem item in listViewBookmarks.SelectedItems)
            {
                try {
                    BookmarkFile bookmark = item.Tag as BookmarkFile;

                    switch (bookmark.m_type)
                    {
                    case BookmarkFile.BOOKMARK_TYPE.CHROME:
                        totalImportedBookmarksCount += ImportBookmarksChrome(bookmark.m_fileName, createdTags, complexNameTags);
                        break;
                    }
                } catch (Exception _e) {
                    BrainForm.MessageBox("An error occurred while attempting to import bookmark file!", _e);
                }
            }

            if (totalImportedBookmarksCount == 0)
            {
                BrainForm.MessageBox("No bookmarks were imported...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (complexNameTags.Count == 0)
            {
                BrainForm.MessageBox((totalImportedBookmarksCount - createdTags.Count).ToString() + " bookmarks were successfully imported.\r\n" + createdTags.Count + " tags have been discovered.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Ask the user to rename the tags that were marked as "too complex"
            BrainForm.MessageBox((totalImportedBookmarksCount - createdTags.Count).ToString() + " bookmarks were successfully imported.\r\n" + createdTags.Count + " tags have been discovered but " + complexNameTags.Count + " of them have names that are deemed too complex."
                                 + "\r\n\r\nClick OK to open the list where you can rename them into easier-to-read tags (this is totally optional, you can use long tag names if they seem okay to you!).", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            // Ask the user to rename complex names
            ComplexTagNamesForm F = new ComplexTagNamesForm(Bookmark.ms_complexNameTags.ToArray());

            F.ShowDialog(this);
        }
        public PreferencesForm(BrainForm _owner) : base(_owner)
        {
            m_appKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\GodComplex\Brain2");

            InitializeComponent();

            // Fetch default values from registry
//			string	defaultDBFolder = Path.Combine( Path.GetDirectoryName( Application.ExecutablePath ), "BrainFiches" );
            string defaultDBFolder = Path.Combine(Directory.GetCurrentDirectory(), "BrainFiches");

            textBoxDatabaseRoot.Text = GetRegKey("RootDBFolder", defaultDBFolder);

            // Display shortcuts
            labelShortcutToggle.Text = m_shortcuts[0].ToString();
            labelShortcutPaste.Text  = m_shortcuts[1].ToString();
            labelShortcutNew.Text    = m_shortcuts[2].ToString();

            // Attempt to locate known browsers' bookmarks
            LocateBookmarks();
        }
Exemple #12
0
        public BrainForm()
        {
            ms_singleton = this;

            InitializeComponent();


            this.TopMost = false;



            DEFAULT_OPACITY = this.Opacity;

            try {
                m_database = new FichesDB();
                m_database.FicheSuccessOccurred += database_FicheSuccessOccurred;
                m_database.FicheWarningOccurred += database_FicheWarningOccurred;
                m_database.FicheErrorOccurred   += database_FicheErrorOccurred;
                m_database.Log += database_Log;

                // Setup the fiches' default dimensions to the primary monitor's dimensions
                Rectangle primaryScreenRect = Screen.PrimaryScreen.Bounds;
                Fiche.ChunkWebPageSnapshot.ms_defaultWebPageWidth  = (uint)primaryScreenRect.Width;
                Fiche.ChunkWebPageSnapshot.ms_defaultWebPageHeight = (uint)primaryScreenRect.Height;
                Fiche.ChunkWebPageSnapshot.ms_maxWebPagePieces     = (uint)Math.Ceiling(20000.0 / primaryScreenRect.Height);

                Rectangle desktopBounds = Interop.GetDesktopBounds();

                // Create the modeless forms
                m_logForm          = new LogForm();
                m_logForm.Location = new Point(desktopBounds.Right - m_logForm.Width, desktopBounds.Bottom - m_logForm.Height);                         // Spawn in bottom-right corner of the desktop to avoid being annoying...

                m_preferenceForm = new PreferencesForm(this);
                m_preferenceForm.RootDBFolderChanged += preferenceForm_RootDBFolderChanged;
                m_preferenceForm.Visible              = false;

                m_ficheWebPageEditorForm                 = new FicheWebPageEditorForm(this);
                m_ficheWebPageEditorForm.Visible         = false;
                m_ficheWebPageEditorForm.VisibleChanged += ficheWebPageEditorForm_VisibleChanged;

                m_ficheWebPageAnnotatorForm                 = new FicheWebPageAnnotatorForm(this);
                m_ficheWebPageAnnotatorForm.Visible         = false;
                m_ficheWebPageAnnotatorForm.VisibleChanged += ficheWebPageAnnotatorForm_VisibleChanged;

                m_fastTaggerForm         = new FastTaggerForm(this);
                m_fastTaggerForm.Visible = false;

                m_notificationForm         = new NotificationForm(this);
                m_notificationForm.Visible = false;

                // Parse fiches and load database
                DirectoryInfo rootDBFolder = new DirectoryInfo(m_preferenceForm.RootDBFolder);
                if (!rootDBFolder.Exists)
                {
                    rootDBFolder.Create();
                    rootDBFolder.Refresh();

                    int waitCount = 0;
                    while (!rootDBFolder.Exists)
                    {
                        System.Threading.Thread.Sleep(100);
                        if (waitCount++ > 10)                           // Wait for a full second
                        {
                            throw new Exception("Failed to create root DB folder \"" + rootDBFolder + "\"! Time elapsed...");
                        }
                    }
                }

                m_database.LoadFichesDescriptions(rootDBFolder);


//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://twitter.com/HMaler/status/1217484876372480008" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://twitter.com/SylvieGaillard/status/1211726353726394379" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://twitter.com/MFrippon/status/1134377488233226245" ) );	// OK!

//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://stackoverflow.com/questions/4964205/non-transparent-click-through-form-in-net" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "http://www.patapom.com/" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://www.monde-diplomatique.fr/2020/03/HOLLAR/61546" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://docs.google.com/document/d/1_iJeEDcoDJS8EUyaprAL4Eu67Tbox_DnYnzQPFiTsa0/edit#heading=h.bktvm5f5g3wf" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://www.breakin.se/mc-intro/" ) );	// OK!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://www.frontiersin.org/articles/10.3389/fpsyg.2017.02124/full" ) );	// OK!

// Ici on a un crash de temps en temps quand la fiche est sauvée et que les images sont disposed alors que l'éditeur tente de les lire pour en faire des bitmaps! C'est très très chiant à repro!
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "https://en.wikipedia.org/wiki/Quantum_mind" ) );	// Crash bitmap copy

// Content rectangles still off
// Sur le premier lien c'est un bandeau dynamique qui doit foutre la merde
// Sur mediapart aussi apparemment (ça se voit uniquement en mode "incognito" sinon je suis loggé avec mon compte et l'article est complet)
//SelectedFiche = URLHandler.CreateURLFiche( m_database, null, WebHelpers.CreateCanonicalURL( "http://variances.eu/?p=3221" ) );
                SelectedFiche = URLHandler.CreateURLFiche(m_database, null, WebHelpers.CreateCanonicalURL("https://www.mediapart.fr/journal/economie/040320/la-banque-publique-d-investissement-va-eponger-les-pertes-du-cac-40"));

/*
 * Essayer ça:
 * https://www.republicain-lorrain.fr/edition-thionville-hayange/2020/03/05/ces-frontaliers-qui-laissent-tomber-le-train?preview=true&amp;fbclid=IwAR3jgJaj0wjepYYTEHNiXbJzQ4B9giZ4htO6gge4q7BwXUGQrvSpql8Sh9M
 *
 * Exemple d'article "parfait" avec un court résumé au début et des liens "bio" sur les gens et les organisations:
 * (pourrait-on tenter de créer ce genre de digests automatiquement?)
 * https://www.ftm.nl/dutch-multinationals-funded-climate-sceptic
 *
 * Tester blog jean Chon "questions à charge" où la page se charge au fur
 *
 *
 * Tester ça avec les trucs à droite qui s'updatent bizarrement + cleanup d'URL
 * https://www.huffingtonpost.fr/entry/agnes-buzyn-livre-des-confessions-accablantes-sur-le-coronavirus_fr_5e70b8cec5b6eab7793c6642?ncid=other_twitter_cooo9wqtham&utm_campaign=share_twitter
 */

                m_logForm.Show();
            }
            catch (FichesDB.DatabaseLoadException _e) {
                // Log errors...
                foreach (Exception e in _e.m_errors)
                {
                    LogError(e);
                }
            } catch (Exception _e) {
                MessageBox("Error when creating forms!\r\n\n", _e);
//              Close();
//				Application.Exit();
            }

            try {
                // Attempt to retrieve containing monitor
                IntPtr hMonitor;
                Screen screen;
                Interop.GetMonitorFromPosition(Control.MousePosition, out screen, out hMonitor);

                // Rescale window to fullscreen overlay
                this.SetDesktopBounds(screen.Bounds.X, screen.Bounds.Y, screen.Bounds.Width, screen.Bounds.Height);

                // Create fullscreen windowed device
                m_device.Init(this.Handle, false, true);

                m_CB_main   = new ConstantBuffer <CB_Main>(m_device, 0);
                m_CB_camera = new ConstantBuffer <CB_Camera>(m_device, 1);
                m_CB_camera.m._camera2World = new float4x4();
                m_CB_camera.m._camera2Proj  = new float4x4();

                // Create primitives and shaders
                m_shader_displayCube = new Shader(m_device, new System.IO.FileInfo("./Shaders/DisplayCube.hlsl"), VERTEX_FORMAT.P3N3, "VS", null, "PS", null);

                BuildCube();

                m_startTime       = DateTime.Now;
                Application.Idle += Application_Idle;

                // Register global shortcuts
                m_preferenceForm.RegisterHotKeys();

                Focus();
            } catch (Exception _e) {
                MessageBox("Error when creating D3D device!\r\n\n", _e);
                Close();
//				Application.Exit();
            }
        }