Example #1
0
        private static IPromptItemProvider <ITreeNode> CreateRootTreeNodeProvider()
        {
            var treeNodeBuilder           = new TreeNodeBuilder();
            var treeNodeCollectionBuilder = CreateTreeNodeCollectionBuilder(treeNodeBuilder);

            treeNodeBuilder.ChildTreeNodeService = CreateChildTreeNodeService(treeNodeCollectionBuilder);
            return(new RootTreeNodeProvider(CreateChildTreeNodeService(treeNodeCollectionBuilder)));
        }
        private static IPromptItemProvider <ITreeNode> InjectRootTreeNodeProvider()
        {
            var treeNodeBuilder           = new TreeNodeBuilder();
            var treeNodeCollectionBuilder = InjectTreeNodeCollectionBuilder(treeNodeBuilder);

            treeNodeBuilder.ChildTreeNodeService = InjectChildTreeNodeService(treeNodeCollectionBuilder);
            return(new RootTreeNodeProvider(InjectChildTreeNodeService(treeNodeCollectionBuilder)));
        }
Example #3
0
        void TokensToTree(TreeNodeCollection Tree, Tokenizer.Token Tokens)
        {
            Tree.Clear();
            TreeNodeBuilder visitor = new TreeNodeBuilder(Tree);

            Tokens.InspectNodes(visitor);

            /*
             * LinkedList<Tokenizer.Token>.Enumerator x =Tokens.GetEnumerator();
             * while (x.MoveNext()) {
             *      x.Current.InspectNodes(visitor);
             * }*/
        }
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            DTE2          dte           = (DTE2)GetService(typeof(SDTE));
            ProjectLoader projectLoader = new ProjectLoader(dte);

            IViewBuilder treeNodeBuilder = new TreeNodeBuilder();

            treeNodeBuilder.Build(dte.ActiveDocument.ProjectItem.ContainingProject.Name, WizardResources.ReflectedTypes);
            TreeItemVM tree = treeNodeBuilder.GetTreeVM();

            WizardResources.MainWPF = new MainWindow();
            var scopeVM = new ScopeFormVM(tree);

            WizardResources.MainWPF.DataContext = new MainWindowVM(scopeVM);
            WizardResources.MainWPF.Show();
        }
Example #5
0
        private void ReceiveMails()
        {
            // Disable buttons while working
            connectAndRetrieveButton.Enabled = false;
            uidlButton.Enabled = false;
            progressBar.Value = 0;

            try
            {
                if (pop3Client.Connected)
                    pop3Client.Disconnect();
                pop3Client.Connect(popServerTextBox.Text, int.Parse(portTextBox.Text), useSslCheckBox.Checked);
                pop3Client.Authenticate(loginTextBox.Text, passwordTextBox.Text);
                int count = pop3Client.GetMessageCount();
                totalMessagesTextBox.Text = count.ToString();
                messageTextBox.Text = "";
                messages.Clear();
                listMessages.Nodes.Clear();
                listAttachments.Nodes.Clear();

                int success = 0;
                int fail = 0;
                for (int i = count; i >= 1; i -= 1)
                {
                    // Check if the form is closed while we are working. If so, abort
                    if (IsDisposed)
                        return;

                    // Refresh the form while fetching emails
                    // This will fix the "Application is not responding" problem
                    Application.DoEvents();

                    try
                    {
                        Message message = pop3Client.GetMessage(i);

                        // Add the message to the dictionary from the messageNumber to the Message
                        messages.Add(i, message);

                        // Create a TreeNode tree that mimics the Message hierarchy
                        TreeNode node = new TreeNodeBuilder().VisitMessage(message);

                        // Set the Tag property to the messageNumber
                        // We can use this to find the Message again later
                        node.Tag = i;

                        // Show the built node in our list of messages
                        listMessages.Nodes.Add(node);

                        success++;
                    } catch (Exception e)
                    {
                        DefaultLogger.Log.LogError(
                            "TestForm: Message fetching failed: " + e.Message + "\r\n"+
                            "Stack trace:\r\n" +
                            e.StackTrace);
                        fail++;
                    }

                    progressBar.Value = (int)(((double)(count-i)/count) * 100);
                }

                MessageBox.Show(this, "Mail received!\nSuccesses: " + success + "\nFailed: " + fail, "Message fetching done");

                if(fail > 0)
                {
                    MessageBox.Show(this,
                                    "Since some of the emails were not parsed correctly (exceptions were thrown)\r\n" +
                                    "please consider sending your log file to the developer for fixing.\r\n" +
                                    "If you are able to include any extra information, please do so.",
                                    "Help improve OpenPop!");
                }
            } catch (InvalidLoginException)
            {
                MessageBox.Show(this, "The server did not accept the user credentials!", "POP3 Server Authentication");
            } catch (PopServerNotFoundException)
            {
                MessageBox.Show(this, "The server could not be found", "POP3 Retrieval");
            } catch(PopServerLockedException)
            {
                MessageBox.Show(this, "The mailbox is locked. It might be in use or under maintenance. Are you connected elsewhere?", "POP3 Account Locked");
            } catch (LoginDelayException)
            {
                MessageBox.Show(this, "Login not allowed. Server enforces delay between logins. Have you connected recently?", "POP3 Account Login Delay");
            } catch (Exception e)
            {
                MessageBox.Show(this, "Error occurred retrieving mail. " + e.Message, "POP3 Retrieval");
            } finally
            {
                // Enable the buttons again
                connectAndRetrieveButton.Enabled = true;
                uidlButton.Enabled = true;
                progressBar.Value = 100;
            }
        }
Example #6
0
 public Handler(TreeNodeBuilder builder, TreeNodeCollection nodes)
 {
     parent       = nodes;
     this.builder = builder;
 }
Example #7
0
 public Handler(TreeNodeBuilder builder, TreeNodeCollection nodes)
 {
     parent = nodes;
     this.builder = builder;
 }