Exemplo n.º 1
0
        /// <summary>
        /// Delete all folder, with the option of only content, or not.
        /// </summary>
        /// <param name="targetFolder">Path of directory</param>
        /// <param name="options">Type of deleting folder</param>
        ///
        public static void DeleteFolder(string targetFolder, FolderOptions options = FolderOptions.IncludeMainFolder)
        {
            try
            {
                var files = Directory.EnumerateFiles(targetFolder);
                var dirs  = Directory.EnumerateDirectories(targetFolder);

                foreach (string file in files)
                {
                    File.SetAttributes(file, FileAttributes.Normal);
                    File.Delete(file);
                }

                foreach (string dir in dirs)
                {
                    DeleteFolder(dir, FolderOptions.IncludeMainFolder);
                }
                if (options == FolderOptions.IncludeMainFolder)
                {
                    Directory.Delete(targetFolder, false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
 public MultiFolderStorage(string issueSource, string dataKind, IIssueReceiver sink, string[] candidateFolders, FolderOptions options)
 {
     this.dataKind         = dataKind;
     this.issueSource      = issueSource;
     this.candidateFolders = candidateFolders;
     this.sink             = sink;
     this.options          = options;
 }
Exemplo n.º 3
0
        private static void Main()
        {
            try
            {
                Log.Initialize();
                SingleAppInstance.Initialize();
                Translator.Initialize();

                Config.UpgradeIfNotUpgraded();
                if (Config.LoadOrSetByUser())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.ThreadException += ThreadException;
                    void ThreadException(object s, ThreadExceptionEventArgs t)
                    {
                        AskUserSendError(t.Exception);
                    }

                    Scaling.Initialize();
                    FolderOptions.Initialize();

                    using (new App())
                    {
                        Log.WriteApplicationRuns();
                        Application.Run();
                    }
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
#pragma warning restore CA1031 // => Represents ThreadException during attached to process
            {
                AskUserSendError(ex);
            }
            finally
            {
                Log.Close();
            }

            void AskUserSendError(Exception ex)
            {
                Log.Error("Application Crashed", ex);

#warning [Feature] When Error ask user to send us #47, todo own dialog, lines here too long
                if (MessageBox.Show("A problem has been encountered and the application needs to restart. " +
                                    "Reporting this error will help us make our product better. Press yes to open your standard email app.",
                                    "SystemTrayMenu BugSplat", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Log.ProcessStart("mailto:" + "*****@*****.**" +
                                     "?subject=SystemTrayMenu Bug reported " +
                                     Assembly.GetEntryAssembly().GetName().Version +
                                     "&body=" + ex.ToString());
                }

                AppRestart.ByThreadException();
            }
        }
        public FoldersAndLabelsPage DeleteThirdFolder()
        {
            FolderOptions.Click();

            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(3));

            wait.Until(ExpectedConditions.ElementToBeClickable(DeleteFolderWait));
            DeleteFolder.Click();
            ConfirmDeletionOfFolderButton.Click();
            return(this);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     if (_welcomePage == null)
     {
         FillCanvas();
     }
     if (CIX.Online)
     {
         CIX.RefreshOnlineUsers();
         FolderCollection.RefreshInterestingThreads();
     }
     return(true);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Locate and select the first unread mail message after the given row.
 /// </summary>
 private bool FirstUnreadAfterRow(int row, FolderOptions options)
 {
     while (row < _conversations.Count)
     {
         InboxConversation conversation = _conversations[row];
         if ((options & FolderOptions.NextUnread) == FolderOptions.NextUnread && conversation.UnreadCount > 0)
         {
             SelectedRow = row;
             break;
         }
         row++;
     }
     return(row != _conversations.Count);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Display the directory for the specified CategoryFolder
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
        {
            CategoryFolder category = folder as CategoryFolder;

            if (category != null)
            {
                if (flags.HasFlag(FolderOptions.ClearFilter))
                {
                    _currentFilterString = null;
                }
                _currentCategory = category;
                _items           = ItemsForView();
                SortItems();
            }
            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Display the page for the specified forum.
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
        {
            if (folder is TopicFolder)
            {
                _currentFolder = (TopicFolder)folder;
                _thisForum     = CIX.DirectoryCollection.ForumByName(_currentFolder.Name);

                FoldersTree.SetTopicName(folder.Name);

                if (CIX.Online)
                {
                    CIX.DirectoryCollection.RefreshForum(folder.Name);
                }

                FillCanvas();
            }
            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Locate and display the next folder, after the selected one, that contains
        /// unread messages. Then select the first message in that folder that is unread.
        ///
        /// Options are a combination of:
        /// FolderOption.Priority - only display the next unread priority message
        /// FolderOption.Reset - when displaying the next unread in a folder, start scan
        ///                      from the top of the list rather than from the current
        ///                      selection in that folder.
        /// 
        /// </summary>
        /// <param name="options">Flags that control the next unread behaviour</param>
        public void NextUnread(FolderOptions options)
        {
            if (frmList.Nodes.Count == 0)
            {
                return;
            }
            TreeNode currentNode = frmList.SelectedNode ?? frmList.Nodes[0];
            TreeNode startingNode = currentNode;
            bool resetLoop = false;

            _isRBut = false;

            bool acceptSmartFolders = currentNode.Tag is SmartFolder;
            bool priorityOnly = options.HasFlag(FolderOptions.Priority);

            do
            {
                FolderBase folder = (FolderBase)currentNode.Tag;
                if (folder.ViewForFolder == AppView.AppViewForum)
                {
                    TopicFolder topicFolder = (TopicFolder)folder;
                    if (priorityOnly ? topicFolder.UnreadPriority > 0 : topicFolder.Unread > 0)
                    {
                        frmList.BeginUpdate();
                        if (startingNode.Tag is TopicFolder)
                        {
                            TreeNode parentNode = startingNode.Parent;
                            if (parentNode != null && parentNode.Parent != null)
                            {
                                parentNode.Collapse();
                            }
                        }
                        currentNode.ExpandAll();
                        frmList.EndUpdate();
                    }
                }
                else if (folder is MailGroup && !priorityOnly)
                {
                    MailGroup group = (MailGroup)folder;
                    if (group.Unread > 0)
                    {
                        currentNode.Expand();
                    }
                }
                else if (folder is ForumGroup)
                {
                    ForumGroup group = (ForumGroup)folder;
                    if (group.Unread > 0)
                    {
                        currentNode.Expand();
                    }
                }
                else
                {
                    if ((acceptSmartFolders && folder is SmartFolder) || (priorityOnly ? folder.UnreadPriority > 0 : folder.Unread > 0))
                    {
                        if (SelectViewForFolder(currentNode, null, options))
                        {
                            MoveSelection(currentNode);
                            return;
                        }
                    }
                }

                if (currentNode.Nodes.Count > 0)
                {
                    currentNode = currentNode.Nodes[0];
                }
                else if (currentNode.NextNode != null)
                {
                    currentNode = currentNode.NextNode;
                }
                else if (currentNode.Parent != null)
                {
                    currentNode = currentNode.Parent;
                    currentNode = currentNode.NextNode;
                    if (currentNode == null)
                    {
                        if (resetLoop)
                        {
                            break;
                        }
                        currentNode = frmList.Nodes[0];
                        resetLoop = true;
                    }
                }
                else
                {
                    break;
                }
                acceptSmartFolders = false;
                options |= FolderOptions.Reset;
            } while (true);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Display the folder referenced by the given node, passing through the address and options.
 /// </summary>
 public bool SelectViewForFolder(TreeNode node, Address address, FolderOptions options)
 {
     FolderBase folder = (FolderBase)node.Tag;
     return SelectView(folder.ViewForFolder, folder, address, options);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Select a folder and display all messages in that folder.
        /// TODO: make this call MoveSelection to remove the duplicate logic! 
        /// </summary>
        private void SelectFolder(TreeNode node, FolderOptions flags)
        {
            _selectedNode = node;
            if (_selectedNode != null)
            {
                TreeNode lastSelectedNode = frmList.SelectedNode;
                frmList.SelectedNode = _selectedNode;

                if (lastSelectedNode != null)
                {
                    frmList.InvalidateNode(lastSelectedNode);
                }
                frmList.InvalidateNode(_selectedNode);
                RefreshFolder(node, flags);

                UpdateContextMenu();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Display the selected view with the given folder, passing through the address and options.
        /// </summary>
        /// <param name="requestedView">The ID of the type of the view requested</param>
        /// <param name="folder">The folder to be displayed in the view</param>
        /// <param name="address">The address of the item within the folder to be selected</param>
        /// <param name="options">Options controlling the folder selection</param>
        /// <returns>True if the view was successfully selected, false otherwise</returns>
        private bool SelectView(AppView requestedView, FolderBase folder, Address address, FolderOptions options)
        {
            ViewBaseView newView = _allViews[requestedView];

            if (newView != _currentView)
            {
                if (_currentView != null)
                {
                    _currentView.Visible = false;
                    frmSplitContainer.Panel2.Controls.Remove(_currentView);
                }
                if (newView != null)
                {
                    frmSplitContainer.Panel2.Controls.Add(newView);

                    _currentView = newView;
                    SetSubviewSize();
                    newView.Visible = true;
                    newView.Update();
                }
            }

            ShowSearchBar(SearchBarVisibility.FastHide);

            if (folder != null)
            {
                string placeholder = folder.AllowsScopedSearch
                    ? string.Format(Resources.SearchForTextIn, folder.Name)
                    : Resources.Search;
                MainForm.SetSearchFieldPlaceholder(placeholder);

                SetTopicName(folder.FullName);
            }
            return (_currentView != null) && _currentView.ViewFromFolder(folder, address, options);
        }
Exemplo n.º 13
0
        internal static MenuData GetData(BackgroundWorker worker, string path, int level)
        {
            MenuData menuData = new MenuData
            {
                RowDatas = new List <RowData>(),
                Validity = MenuDataValidity.Invalid,
                Level    = level
            };

            if (!worker.CancellationPending)
            {
                string[] directories = Array.Empty <string>();

                try
                {
                    directories = Directory.GetDirectories(path);
                    Array.Sort(directories, new WindowsExplorerSort());
                }
                catch (UnauthorizedAccessException ex)
                {
                    Log.Warn($"path:'{path}'", ex);
                    menuData.Validity = MenuDataValidity.NoAccess;
                }
                catch (IOException ex)
                {
                    Log.Warn($"path:'{path}'", ex);
                }

                foreach (string directory in directories)
                {
                    if (worker != null && worker.CancellationPending)
                    {
                        break;
                    }

                    bool hiddenEntry = false;
                    if (FolderOptions.IsHidden(directory, ref hiddenEntry))
                    {
                        continue;
                    }

                    RowData rowData = ReadRowData(directory, false);
                    rowData.ContainsMenu = true;
                    rowData.HiddenEntry  = hiddenEntry;
                    string resolvedLnkPath = string.Empty;
                    rowData.ReadIcon(true, ref resolvedLnkPath);
                    menuData.RowDatas.Add(rowData);
                }
            }

            if (!worker.CancellationPending)
            {
                string[] files = Array.Empty <string>();

                try
                {
                    files = Directory.GetFiles(path);
                    Array.Sort(files, new WindowsExplorerSort());
                }
                catch (UnauthorizedAccessException ex)
                {
                    Log.Warn($"path:'{path}'", ex);
                    menuData.Validity = MenuDataValidity.NoAccess;
                }
                catch (IOException ex)
                {
                    Log.Warn($"path:'{path}'", ex);
                }

                foreach (string file in files)
                {
                    if (worker != null && worker.CancellationPending)
                    {
                        break;
                    }

                    bool hiddenEntry = false;
                    if (FolderOptions.IsHidden(file, ref hiddenEntry))
                    {
                        continue;
                    }

                    RowData rowData         = ReadRowData(file, false);
                    string  resolvedLnkPath = string.Empty;
                    if (rowData.ReadIcon(false, ref resolvedLnkPath))
                    {
                        rowData = ReadRowData(resolvedLnkPath, true, rowData);
                        rowData.ContainsMenu = true;
                        rowData.HiddenEntry  = hiddenEntry;
                    }

                    menuData.RowDatas.Add(rowData);
                }
            }

            if (!worker.CancellationPending)
            {
                if (menuData.Validity == MenuDataValidity.Invalid)
                {
                    menuData.Validity = MenuDataValidity.Valid;
                }
            }

            return(menuData);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Refresh the view for the folder at the given node.
 /// </summary>
 /// <param name="node">The node of the folder to refresh</param>
 /// <param name="options">Options to be passed to the view</param>
 private void RefreshFolder(TreeNode node, FolderOptions options)
 {
     if (node != null)
     {
         SelectViewForFolder(node, _lastAddress, options);
         _lastAddress = null;
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Display the directory for the specified CategoryFolder
 /// </summary>
 public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     CategoryFolder category = folder as CategoryFolder;
     if (category != null)
     {
         if (flags.HasFlag(FolderOptions.ClearFilter))
         {
             _currentFilterString = null;
         }
         _currentCategory = category;
         _items = ItemsForView();
         SortItems();
     }
     return true;
 }
Exemplo n.º 16
0
 protected SetImageCommandHandler(FolderOptions folderOptions, TempFileService tempFileService, IImageService imageService)
 {
     _tempFileService = tempFileService;
     ImageService     = imageService;
     _imageFolder     = folderOptions.Images;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     if (_welcomePage == null)
     {
         FillCanvas();
     }
     CIX.RefreshOnlineUsers();
     FolderCollection.RefreshInterestingThreads();
     return true;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Display the directory for the specified CategoryFolder
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options)
        {
            if (folder != _currentFolder)
            {
                _currentFolder = folder;
                SortConversations();
            }

            // If an address is specified then it refers to a conversation ID that
            // needs to be selected. If it is not found, the first message is selected
            // instead.
            if (address != null && address.Scheme == "cixmailbox")
            {
                int selectedID;

                Int32.TryParse(address.Data, out selectedID);

                int selectedIndex;
                for (selectedIndex = 0; selectedIndex < _conversations.Count; ++selectedIndex)
                {
                    InboxConversation conversation = _conversations[selectedIndex];
                    if (conversation.RemoteID == selectedID)
                    {
                        break;
                    }
                }
                if (selectedIndex == _conversations.Count)
                {
                    selectedIndex = 0;
                }
                SelectedRow = selectedIndex;
                if (address.Unread)
                {
                    SelectedMessage.MarkUnread();
                }
                return(true);
            }

            // If options are specified then search for the next unread
            // in the list otherwise set the initial selection to something
            // useful.
            if (options == 0 && SelectedRow == -1)
            {
                SetInitialSelection();
            }
            else
            {
                int row = inboxConversations.SearchRow;
                if (row < 0 || options.HasFlag(FolderOptions.Reset))
                {
                    row = 0;
                }
                else if (_conversations.Count > 0)
                {
                    InboxConversation conversation = _conversations[row];
                    if (conversation.UnreadCount > 0)
                    {
                        conversation.MarkRead();
                    }
                }
                if (!FirstUnreadAfterRow(row, options))
                {
                    inboxConversations.SearchRow = 0;
                    return(false);
                }
            }

            FoldersTree.SetTopicName(_currentFolder.FullName);

            ActiveControl = inboxConversations;
            inboxConversations.Focus();
            return(true);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Display the page for the specified forum.
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
        {
            if (folder is TopicFolder)
            {
                _currentFolder = folder as TopicFolder;
                _thisForum = CIX.DirectoryCollection.ForumByName(_currentFolder.Name);

                FoldersTree.SetTopicName(folder.Name);

                CIX.DirectoryCollection.RefreshForum(folder.Name);

                FillCanvas();
            }
            return true;
        }
Exemplo n.º 20
0
        /// <summary>
        /// Display the specified topic folder in the thread list.
        /// </summary>
        /// <param name="folder">The folder whose topic is to be displayed</param>
        /// <param name="address"></param>
        /// <param name="options">Folder display flags</param>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options)
        {
            if (folder.ViewForFolder == AppView.AppViewTopic)
            {
                if ((_currentFolder != folder) || options.HasFlag(FolderOptions.ClearFilter))
                {
                    _currentFolder = folder;
                    _currentFilterString = null;
                    _isFiltering = false;
                    _isTopicFolder = IsTopicFolder();

                    tsvMessages.SelectedIndices.Clear();
                    ShowMessage(null);

                    if (FoldersTree.MainForm.RunEvent(EventID.FolderSelected,
                        _isTopicFolder ? ((TopicFolder) folder).Folder : null))
                    {
                        if (_isTopicFolder)
                        {
                            // Attempt to make topic switches cleaner by removing the old messages from display
                            // when switching to a new topic will involve a delay caused by loading the messages
                            // from the DB, sorting, etc.
                            if (!((TopicFolder)_currentFolder).Folder.HasMessages && _messages != null && _messages.Count > 0)
                            {
                                _messages = new List<CIXMessage>();
                                InitialiseList();
                                RedrawAllItems();
                            }
                        }
                        SortConversations();
                    }

                    UpdateFromFlags();
                }

                // Load this topic from the server only if we're empty.
                if (_messages != null && _messages.Count == 0)
                {
                    if (address != null && address.Scheme == "cix")
                    {
                        Int32.TryParse(address.Data, out _lastIndex);
                    }
                    folder.Refresh();
                    return false;
                }

                if (options.HasFlag(FolderOptions.ClearFilter))
                {
                    options &= ~FolderOptions.ClearFilter;
                    _currentFilterString = null;
                    _isFiltering = false;
                }

                if (address != null && address.Scheme == "cix")
                {
                    int selectedID;
                    Int32.TryParse(address.Data, out selectedID);
                    if (!GoToMessage(selectedID))
                    {
                        SetInitialSelection();
                    }
                    if (address.Unread)
                    {
                        SelectedMessage.MarkUnread();
                    }
                }
                else if (options == 0)
                {
                    SetInitialSelection();
                }
                else
                {
                    int row = SelectedRow;
                    if (row < 0 || options.HasFlag(FolderOptions.Reset))
                    {
                        row = -1;
                    }
                    else
                    {
                        CIXMessage selectedMessage = SelectedMessage;
                        if (selectedMessage != null && selectedMessage.Unread)
                        {
                            selectedMessage.MarkRead();
                        }
                    }
                    if (!FirstUnreadAfterRow(row, options))
                    {
                        return false;
                    }
                }

                ActiveControl = tsvMessages;
            }
            return true;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Display the first unread message after the specified row.
        /// </summary>
        /// <param name="row">Row after which we begin searching</param>
        /// <param name="options">FolderOptions flags that control the search</param>
        /// <returns>True if we found an unread message</returns>
        private bool FirstUnreadAfterRow(int row, FolderOptions options)
        {
            while (++row < _messages.Count)
            {
                CIXMessage message = _messages[row];

                if (IsCollapsed(message) && message.UnreadChildren > 0)
                {
                    ExpandThread(message);
                }
                if (options.HasFlag(FolderOptions.Priority))
                {
                    if (message.Priority && message.Unread)
                    {
                        SelectedRow = row;
                        break;
                    }
                }
                else if (options.HasFlag(FolderOptions.NextUnread) && message.Unread)
                {
                    if (options.HasFlag(FolderOptions.Root))
                    {
                        while (message.CommentID > 0 && row > 0)
                        {
                            message = _messages[--row];
                        }
                    }
                    SelectedRow = row;
                    break;
                }
            }
            return (row != _messages.Count);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Display the directory for the specified CategoryFolder
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options)
        {
            if (folder != _currentFolder)
            {
                _currentFolder = folder;
                SortConversations();
            }

            // If an address is specified then it refers to a conversation ID that
            // needs to be selected. If it is not found, the first message is selected
            // instead.
            if (address != null && address.Scheme == "cixmailbox")
            {
                int selectedID;

                Int32.TryParse(address.Data, out selectedID);

                int selectedIndex;
                for (selectedIndex = 0; selectedIndex < _conversations.Count; ++selectedIndex)
                {
                    InboxConversation conversation = _conversations[selectedIndex];
                    if (conversation.RemoteID == selectedID)
                        break;
                }
                if (selectedIndex == _conversations.Count)
                {
                    selectedIndex = 0;
                }
                SelectedRow = selectedIndex;
                if (address.Unread)
                {
                    SelectedMessage.MarkUnread();
                }
                return true;
            }

            // If options are specified then search for the next unread
            // in the list otherwise set the initial selection to something
            // useful.
            if (options == 0 && SelectedRow == -1)
            {
                SetInitialSelection();
            }
            else
            {
                int row = inboxConversations.SearchRow;
                if (row < 0 || options.HasFlag(FolderOptions.Reset))
                {
                    row = 0;
                }
                else if (_conversations.Count > 0)
                {
                    InboxConversation conversation = _conversations[row];
                    if (conversation.UnreadCount > 0)
                    {
                        conversation.MarkRead();
                    }
                }
                if (!FirstUnreadAfterRow(row, options))
                {
                    inboxConversations.SearchRow = 0;
                    return false;
                }
            }

            FoldersTree.SetTopicName(_currentFolder.FullName);

            ActiveControl = inboxConversations;
            inboxConversations.Focus();
            return true;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Locate and select the first unread mail message after the given row.
 /// </summary>
 private bool FirstUnreadAfterRow(int row, FolderOptions options)
 {
     while (row < _conversations.Count)
     {
         InboxConversation conversation = _conversations[row];
         if ((options & FolderOptions.NextUnread) == FolderOptions.NextUnread && conversation.UnreadCount > 0)
         {
             SelectedRow = row;
             break;
         }
         row++;
     }
     return (row != _conversations.Count);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public virtual bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     return(true);
 }
Exemplo n.º 25
0
 public SetLogoImageCommandHandler(FolderOptions folderOptions, TempFileService tempFileService, IImageService imageService)
     : base(folderOptions, tempFileService, imageService)
 {
 }
Exemplo n.º 26
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public virtual bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     return true;
 }
Exemplo n.º 27
0
 public ImageController(FolderOptions folderOptions)
 {
     _imageFolder = folderOptions.Images;
 }