Example #1
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var name = txtSPName.Text.Trim();
         if (_Mode == AddEditMode.Add && _Prefs.SearchProviderExists(name))
         {
             var message = PNLang.Instance.GetMessageText("sp_exists", "Search provider with this name already exists");
             PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             if (_Mode == AddEditMode.Add)
             {
                 _SearchProviders = new PNSearchProvider {
                     Name = name, QueryString = txtSPQuery.Text.Trim()
                 };
                 _Prefs.SearchProviderAdd(_SearchProviders);
             }
             else
             {
                 _SearchProviders.QueryString = txtSPQuery.Text.Trim();
                 _Prefs.SearchProviderReplace(_SearchProviders);
             }
             DialogResult = true;
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtEnterPwrd.Password != txtConfirmPwrd.Password)
         {
             var message = PNLang.Instance.GetMessageText("pwrd_not_identical", "Both password strings should be identical. Please, check the spelling.");
             PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             txtEnterPwrd.Focus();
             txtEnterPwrd.SelectAll();
             return;
         }
         string hash = PNEncryptor.GetHashString(txtEnterPwrd.Password.Trim());
         if (hash != null)
         {
             if (PasswordChanged != null)
             {
                 PasswordChanged(this, new PasswordChangedEventArgs(hash));
             }
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #3
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (_Mode == AddEditMode.Add && _Prefs.SyncCompExists(txtCompName.Text.Trim()))
         {
             string message = PNLang.Instance.GetMessageText("sync_comp_exists", "Local synchronization target with this name already exists");
             PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
             //_PreventUnload = true;
         }
         else
         {
             var sc = new PNSyncComp {
                 CompName = txtCompName.Text.Trim(), DataDir = txtDataDir.Text.Trim(), UseDataDir = chkUseDataDir.IsChecked != null && chkUseDataDir.IsChecked.Value
             };
             if (chkUseDataDir.IsChecked != null && !chkUseDataDir.IsChecked.Value)
             {
                 sc.DBDir = txtDBDir.Text.Trim();
             }
             if (_Mode == AddEditMode.Add)
             {
                 _Prefs.SyncCompAdd(sc);
             }
             else
             {
                 _Prefs.SyncCompReplace(sc);
             }
             DialogResult = true;
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #4
0
 private void cmdReplaceAll_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         _FoundItems.Clear();
         if (chkIncludeHidden.IsChecked != null && chkIncludeHidden.IsChecked.Value)
         {
             string message = PNLang.Instance.GetMessageText("replace_hidden_1", "You have selected option");
             message += " \"" + chkIncludeHidden.Content + "\"\n";
             message += PNLang.Instance.GetMessageText("replace_hidden_2",
                                                       "All matched entries in hidden notes will be replaced and saved. Continue?");
             if (
                 PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                 MessageBoxResult.No)
             {
                 return;
             }
         }
         saveSettings();
         startReplace();
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #5
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var name = txtExtName.Text.Trim();
         if (m_Mode == AddEditMode.Add && m_Prefs.ExternalExists(name))
         {
             var message = PNLang.Instance.GetMessageText("ext_exists", "External program with this name already exists");
             PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             if (m_Mode == AddEditMode.Add)
             {
                 m_Ext = new PNExternal {
                     Name = name, Program = txtExtProg.Text.Trim(), CommandLine = txtCommandLine.Text.Trim()
                 };
                 m_Prefs.ExternalAdd(m_Ext);
             }
             else
             {
                 m_Ext.Program     = txtExtProg.Text.Trim();
                 m_Ext.CommandLine = txtCommandLine.Text.Trim();
                 m_Prefs.ExternalReplace(m_Ext);
             }
             DialogResult = true;
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #6
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var rg    = new Regex(PNStrings.MAIL_PATTERN, RegexOptions.IgnoreCase);
         var match = rg.Match(txtMailAddress.Text.Trim());
         if (!match.Success)
         {
             PNMessageBox.Show(PNLang.Instance.GetMessageText("invalid_email", "Invalid e-mail address"),
                               PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             txtMailAddress.SelectAll();
             txtMailAddress.Focus();
             return;
         }
         _Contact.DisplayName = txtMailDisplayName.Text.Trim();
         _Contact.Address     = txtMailAddress.Text.Trim();
         if (MailContactChanged != null)
         {
             var en = new MailContactChangedEventArgs(_Contact, _Mode);
             MailContactChanged(this, en);
             if (!en.Accepted)
             {
                 return;
             }
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var hash      = PNEncryptor.GetHashString(txtEnterPwrd.Password.Trim());
         var hashCheck = (m_Mode == PasswordDlgMode.DeleteMain || m_Mode == PasswordDlgMode.LoginMain)
             ? PNStatic.Settings.Protection.PasswordString
             : m_Hash;
         if (hash != null)
         {
             if (hash != hashCheck)
             {
                 var message = PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password");
                 PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                 txtEnterPwrd.Focus();
                 txtEnterPwrd.SelectAll();
                 return;
             }
         }
         if (m_Mode == PasswordDlgMode.DeleteMain || m_Mode == PasswordDlgMode.DeleteGroup || m_Mode == PasswordDlgMode.DeleteNote)
         {
             if (PasswordDeleted != null)
             {
                 PasswordDeleted(this, new EventArgs());
             }
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #8
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var hostNameType = Uri.CheckHostName(txtSmtpHost.Text.Trim());
         if (hostNameType == UriHostNameType.Unknown)
         {
             PNMessageBox.Show(PNLang.Instance.GetMessageText("invalid_host", "Invalid host name"),
                               PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             txtSmtpHost.SelectAll();
             txtSmtpHost.Focus();
             return;
         }
         var rg    = new Regex(PNStrings.MAIL_PATTERN, RegexOptions.IgnoreCase);
         var match = rg.Match(txtSmtpAddress.Text.Trim());
         if (!match.Success)
         {
             PNMessageBox.Show(PNLang.Instance.GetMessageText("invalid_email", "Invalid e-mail address"),
                               PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             txtSmtpAddress.SelectAll();
             txtSmtpAddress.Focus();
             return;
         }
         if (txtSmtpPort.Text.Trim().StartsWith("0") || Convert.ToInt32(txtSmtpPort.Text.Trim()) > 65535)
         {
             PNMessageBox.Show(PNLang.Instance.GetMessageText("invalid_port", "Invalid port number"),
                               PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             txtSmtpPort.SelectAll();
             txtSmtpPort.Focus();
             return;
         }
         _Client.HostName      = txtSmtpHost.Text.Trim();
         _Client.SenderAddress = txtSmtpAddress.Text.Trim();
         using (var encryptor = new PNEncryptor(PNKeys.ENC_KEY))
         {
             _Client.Password = encryptor.EncryptString(txtSmtpPassword.Password);
         }
         _Client.Port        = Convert.ToInt32(txtSmtpPort.Text.Trim());
         _Client.DisplayName = txtSmtpDisplayName.Text.Trim().Length > 0 ? txtSmtpDisplayName.Text.Trim() : _Client.SenderAddress;
         if (SmtpChanged != null)
         {
             var ev = new SmtpChangedEventArgs(_Client, _Mode);
             SmtpChanged(this, ev);
             if (!ev.Accepted)
             {
                 txtSmtpAddress.SelectAll();
                 txtSmtpAddress.Focus();
                 return;
             }
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #9
0
        private void plugin_PostPerformed(object sender, PostPerformedEventArgs e)
        {
            var p = sender as IPostPlugin;

            if (p == null)
            {
                return;
            }
            if (!e.Result)
            {
                return;
            }
            var message =
                PNLang.Instance.GetMessageText("message_posted", "Successfully posted on") + " " +
                p.Name;

            PNMessageBox.Show(message);
        }
Example #10
0
        private void sync_SyncComplete(object sender, SyncCompleteEventArgs e)
        {
            var caption = PNStrings.PROG_NAME;
            var plugin  = sender as ISyncPlugin;

            if (plugin != null)
            {
                caption = plugin.Name;
            }

            switch (e.Result)
            {
            case SyncResult.None:
                PNMessageBox.Show(PNLang.Instance.GetMessageText("sync_complete", "Synchronization completed successfully"), caption, MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case SyncResult.Reload:
                PNMessageBox.Show(PNLang.Instance.GetMessageText("sync_complete_reload", "Synchronization completed successfully. The program has to be restarted for applying all changes."), caption, MessageBoxButton.OK, MessageBoxImage.Information);
                PNData.UpdateTablesAfterSync();
                PNStatic.FormMain.ApplyAction(MainDialogAction.Restart, null);
                break;

            case SyncResult.AbortVersion:
                PNMessageBox.Show(PNLang.Instance.GetMessageText("diff_versions", "Current version of database is different from previously synchronized version. Synchronization cannot be performed."), caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                break;

            case SyncResult.Error:
                var sb =
                    new StringBuilder(PNLang.Instance.GetMessageText("sync_error_1",
                                                                     "An error occurred during synchronization."));
                sb.Append(" (");
                sb.Append(caption);
                sb.Append(")");
                sb.AppendLine();
                sb.Append(PNLang.Instance.GetMessageText("sync_error_2",
                                                         "Please, refer to log file of appropriate plugin."));
                var baloon = new Baloon(BaloonMode.Error)
                {
                    BaloonText = sb.ToString()
                };
                PNStatic.FormMain.ntfPN.ShowCustomBalloon(baloon, PopupAnimation.Slide, 10000);
                break;
            }
        }
 private void cmdReplace_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         setFindOptions();
         saveFind();
         saveReplace();
         PNStatic.FindString    = cboFind.Text.Trim();
         PNStatic.ReplaceString = cboReplace.Text.Trim();
         if (replaceEditString() == -1)
         {
             PNMessageBox.Show(PNLang.Instance.GetMessageText("nothing_found", "Nothing found"), PNStrings.PROG_NAME, MessageBoxButton.OK);
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #12
0
        private void sync_SyncComplete(object sender, LocalSyncCompleteEventArgs e)
        {
            try
            {
                if (!Dispatcher.CheckAccess())
                {
                    SyncCompleteDelegate d = sync_SyncComplete;
                    Dispatcher.Invoke(d, sender, e);
                }
                else
                {
                    Topmost = false;
                    var sync = (PNSync)sender;
                    sync.SyncComplete -= sync_SyncComplete;
                    switch (e.Result)
                    {
                    case LocalSyncResult.None:
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("sync_complete", "Syncronization completed successfully"), PNStrings.PROG_NAME, MessageBoxButton.OK);
                        DialogResult = false;
                        break;

                    case LocalSyncResult.Reload:
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("sync_complete_reload", "Syncronization completed successfully. The program has to be restarted for applying all changes."), PNStrings.PROG_NAME, MessageBoxButton.OK);
                        PNData.UpdateTablesAfterSync();
                        DialogResult = true;
                        break;

                    case LocalSyncResult.AbortVersion:
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("diff_versions", "Current version of database is different from previously synchronized version. Synchronization cannot be performed."), PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        DialogResult = false;
                        break;

                    case LocalSyncResult.Error:
                        DialogResult = false;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
Example #13
0
 private void cmdOK_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var enc = new PNEncryptor(txtKey.Text.Trim()))
         {
             _Note.Dialog.Edit.Text = _Mode == ScrambleMode.Scramble
                 ? enc.EncryptStringWithTrim(_Note.Dialog.Edit.Text.Trim())
                 : enc.DecryptStringWithTrim(_Note.Dialog.Edit.Text);
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex, false);
         PNMessageBox.Show(this, PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password"),
                           PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void cmdFindNext_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                setFindOptions();
                saveFind();
                PNStatic.FindString = cboFind.Text.Trim();
                int position;
                switch (PNStatic.SearchMode)
                {
                case SearchMode.Normal:
                    position = _Edit.SelectionStart == _Edit.TextLength
                            ? PNStatic.FindEditString(_Edit, 0)
                            : PNStatic.FindEditString(_Edit, _Edit.SelectionStart + 1);
                    if (position == -1)
                    {
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("nothing_found", "Nothing found"), PNStrings.PROG_NAME, MessageBoxButton.OK);
                    }
                    break;

                case SearchMode.RegularExp:
                    position = _Edit.SelectionStart == _Edit.TextLength
                            ? PNStatic.FindEditStringByRegExp(_Edit, 0,
                                                              (PNStatic.FindOptions & System.Windows.Forms.RichTextBoxFinds.Reverse) ==
                                                              System.Windows.Forms.RichTextBoxFinds.Reverse)
                            : PNStatic.FindEditStringByRegExp(_Edit, _Edit.SelectionStart + 1,
                                                              (PNStatic.FindOptions & System.Windows.Forms.RichTextBoxFinds.Reverse) ==
                                                              System.Windows.Forms.RichTextBoxFinds.Reverse);
                    if (position == -1)
                    {
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("nothing_found", "Nothing found"),
                                          PNStrings.PROG_NAME, MessageBoxButton.OK);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
 private void cmdReplaceAll_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         setFindOptions();
         saveFind();
         saveReplace();
         PNStatic.FindString    = cboFind.Text.Trim();
         PNStatic.ReplaceString = cboReplace.Text.Trim();
         var count   = replaceAllEditStrings();
         var message = PNLang.Instance.GetMessageText("replace_complete", "Search and replace complete.");
         message += '\n';
         message += PNLang.Instance.GetMessageText("matches_replaced", "Matches replaced:");
         message += " " + count.ToString(CultureInfo.InvariantCulture);
         PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK);
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #16
0
 private void cmdFromFile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var ofd = new OpenFileDialog
         {
             Filter =
                 "Image files (*.bmp;*.png;*.gif;*.jpg;*.jpeg;*.ico;*;tif)|*.bmp;*.png;*.gif;*.jpg;*.jpeg;*.ico;*.tif"
         };
         if (!ofd.ShowDialog(this).Value)
         {
             return;
         }
         var bitmapImage = new BitmapImage();
         bitmapImage.BeginInit();
         bitmapImage.CacheOption   = BitmapCacheOption.OnLoad;
         bitmapImage.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
         bitmapImage.UriSource     = new Uri(ofd.FileName, UriKind.Relative);
         bitmapImage.EndInit();
         if (Math.Abs(bitmapImage.Width - 16) > double.Epsilon || Math.Abs(bitmapImage.Height - 16) > double.Epsilon)
         {
             PNMessageBox.Show(
                 PNLang.Instance.GetMessageText("image_size_message", "The size of image has to be 16x16"),
                 PNStrings.PROG_NAME);
             return;
         }
         if (GroupPropertyChanged == null)
         {
             return;
         }
         GroupPropertyChanged(this, new GroupPropertyChangedEventArgs(bitmapImage, GroupChangeType.Image));
         DialogResult = true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #17
0
        internal static bool ExportToOutlookNote(string text)
        {
            dynamic outlook = null;

            try
            {
                try
                {
                    // if Outlook already runs
                    outlook = Marshal.GetActiveObject("Outlook.Application");
                }
                catch
                {
                    PNMessageBox.Show(PNLang.Instance.GetMessageText("outlook_not_running", "MS Outlook application is not running. Please, start the application and try again."), PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return(false);
                }

                var note = outlook.CreateItem(5);
                note.Body = text;
                note.Save();
                return(true);
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
                return(false);
            }
            finally
            {
                if (outlook != null)
                {
                    Marshal.ReleaseComObject(outlook);
                    GC.GetTotalMemory(true);
                }
            }
        }
Example #18
0
 private void clearSearchHistory()
 {
     try
     {
         var message = PNLang.Instance.GetMessageText("clear_search_history", "Clear search history?");
         if (PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.YesNo, MessageBoxImage.Question) !=
             MessageBoxResult.Yes)
         {
             return;
         }
         using (var oData = new SQLiteDataObject(PNData.ConnectionString))
         {
             oData.Execute("UPDATE FIND_REPLACE SET FIND = NULL, REPLACE = NULL");
             cboFind.Items.Clear();
             cboReplace.Items.Clear();
             cboFind.Text    = "";
             cboReplace.Text = "";
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #19
0
        private void plugin_GotPostsPartial(object sender, GotPostsEventArgs e)
        {
            var plugin = sender as IPostPlugin;

            if (plugin != null && e.Details != null && e.Details.Count > 0)
            {
                _TempTextBox = _Host.ActiveTextBox;
                var dInsPost = new WndPosts(e.Details.OrderByDescending(p => p.PostDate), plugin.Name, _Host.ActiveNoteName);
                dInsPost.PostSelected += dInsPost_PostSelected;
                var showDialog = dInsPost.ShowDialog();
                if (showDialog == null || !showDialog.Value)
                {
                    dInsPost.PostSelected -= dInsPost_PostSelected;
                    _TempTextBox           = null;
                }
            }
            else
            {
                var name = plugin != null ? plugin.Name : "";
                PNMessageBox.Show(
                    PNLang.Instance.GetMessageText("no_posts", "There are no posts available") + @" [" + name + @"]",
                    PNStrings.PROG_NAME);
            }
        }
Example #20
0
        /// <summary>
        /// Sends the mail message.
        /// </summary>
        private void showMail()
        {
            var message = new MAPIHelperInterop.MapiMessage();

            using (var interopRecipients = _RecipientCollection.GetInteropRepresentation())
            {
                message.Subject  = Subject;
                message.NoteText = Body;

                message.Recipients     = interopRecipients.Handle;
                message.RecipientCount = _RecipientCollection.Count;

                // Check if we need to add attachments
                if (_Files.Count > 0)
                {
                    // Add attachments
                    message.Files = allocAttachments(out message.FileCount);
                }

                // Signal the creating thread (make the remaining code async)
                _ManualResetEvent.Set();

                const int MAPI_DIALOG = 0x8;

                var error = MAPIHelperInterop.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, MAPI_DIALOG, 0);

                if (_Files.Count > 0)
                {
                    // Deallocate the files
                    deallocFiles(message);
                }

                // Check for error
                string errorDescription = getErrorDescription(error);
                switch ((MAPIErrorCode)error)
                {
                case MAPIErrorCode.MAPI_SUCCESS:
                case MAPIErrorCode.MAPI_USER_ABORT:
                    //do nothing
                    break;

                case MAPIErrorCode.MAPI_E_NO_MAIL_CLIENT:
                {
                    //todo - add description to lang file in next version
                    var msg = PNLang.Instance.GetMessageText("mail_error", "MAPI error:") + '\n' +
                              error.ToString(CultureInfo.InvariantCulture) + '\n' + "No default mail client installed";
                    Task.Factory.StartNew(
                        () =>
                        {
                            PNMessageBox.Show(msg, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        },
                        CancellationToken.None,
                        TaskCreationOptions.None,
                        _TaskScheduler);
                    break;
                }

                default:
                {
                    var msg = PNLang.Instance.GetMessageText("mail_error", "MAPI error:") + '\n' +
                              error.ToString(CultureInfo.InvariantCulture) + '\n' + errorDescription;
                    Task.Factory.StartNew(
                        () =>
                        {
                            PNMessageBox.Show(msg, PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        },
                        CancellationToken.None,
                        TaskCreationOptions.None,
                        _TaskScheduler);
                    break;
                }
                }
            }
        }
Example #21
0
        private void cmdOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_LocalNotesSession == null)
                {
                    _LocalNotesSession = new NotesSessionClass();
                    //Initializing Lotus Notes Session
                    try
                    {
                        _LocalNotesSession.Initialize(txtPassword.Password);
                    }
                    catch (COMException cex)
                    {
                        if (cex.ErrorCode != -2147217504)
                        {
                            throw;
                        }
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password"),
                                          PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
                //Creating Lotus Notes DataBase Object
                var localDatabase = _LocalNotesSession.GetDatabase("", "names.nsf", false);

                if (_ServerNotesSession == null)
                {
                    _ServerNotesSession = new NotesSessionClass();
                    //Initializing Lotus Notes Session
                    try
                    {
                        _ServerNotesSession.Initialize(txtPassword.Password);
                    }
                    catch (COMException cex)
                    {
                        if (cex.ErrorCode != -2147217504)
                        {
                            throw;
                        }
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password"),
                                          PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
                //Creating Lotus Notes DataBase Object
                var serverDatabase = _ServerNotesSession.GetDatabase(txtServer.Text.Trim(), "names.nsf", false);

                //creating Lotus Notes Contact View
                NotesView contactsView = null, peopleView = null;
                if (localDatabase != null)
                {
                    contactsView = localDatabase.GetView("Contacts");
                }
                if (serverDatabase != null)
                {
                    peopleView = serverDatabase.GetView("$People");
                }

                if (LotusCredentialSet != null)
                {
                    LotusCredentialSet(this, new LotusCredentialSetEventArgs(contactsView, peopleView));
                }
                DialogResult = true;
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
Example #22
0
        private void startFind()
        {
            try
            {
                var searchString = saveFind();
                var options      = System.Windows.Forms.RichTextBoxFinds.NoHighlight;
                var total        = 0;

                _FoundItems.Clear();

                if (!PNStatic.Settings.GeneralSettings.AutoHeight ||
                    PNStatic.Settings.GeneralSettings.UseSkins)
                {
                    _HiddenEdit.ScrollBars = PNStatic.Settings.GeneralSettings.ShowScrollbar;
                }
                else
                {
                    _HiddenEdit.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
                }
                _HiddenEdit.WordWrap = _HiddenEdit.ScrollBars != System.Windows.Forms.RichTextBoxScrollBars.Horizontal &&
                                       _HiddenEdit.ScrollBars != System.Windows.Forms.RichTextBoxScrollBars.Both;

                if (!PNStatic.Settings.GeneralSettings.UseSkins)
                {
                    _HiddenEdit.SetMargins(PNStatic.Settings.GeneralSettings.MarginWidth);
                }

                if (chkMatchCase.IsChecked != null && chkMatchCase.IsChecked.Value)
                {
                    options |= System.Windows.Forms.RichTextBoxFinds.MatchCase;
                }
                if (chkWholeWord.IsChecked != null && chkWholeWord.IsChecked.Value)
                {
                    options |= System.Windows.Forms.RichTextBoxFinds.WholeWord;
                }

                var notes = chkIncludeHidden.IsChecked != null && chkIncludeHidden.IsChecked.Value
                                        ? PNStatic.Notes.Where(n => n.GroupID != (int)SpecialGroups.RecycleBin)
                                        : PNStatic.Notes.Where(n => n.GroupID != (int)SpecialGroups.RecycleBin && n.Visible);
                foreach (var note in notes)
                {
                    var count = 0;
                    switch (_Criteria)
                    {
                    case SearchCriteria.EntireString:
                        findInNoteEntireString(note, searchString, options, ref count);
                        break;

                    case SearchCriteria.EveryWord:
                        findInNoteEveryWord(note, searchString, options, ref count);
                        break;

                    case SearchCriteria.AtLeastOneWord:
                        findInNoteAtLeastOneWord(note, searchString, options, ref count);
                        break;
                    }
                    total += count;
                }
                var message = PNLang.Instance.GetMessageText("search_complete", "Search complete.");
                if (total > 0)
                {
                    message += '\n' + PNLang.Instance.GetMessageText("matches_found", "Matches found:") + " " +
                               total.ToString(CultureInfo.InvariantCulture);
                    tvwResults.ExpandAll();
                }
                else
                {
                    message += '\n' + PNLang.Instance.GetMessageText("nothing_found", "Nothing found.");
                }
                PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
Example #23
0
        private void txtHotKey_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                var check     = false;
                var modString = "";
                var keyString = "";
                var hk        = new PNHotKey
                {
                    Modifiers = HotkeysStatic.GetModifiers(ref modString),
                    VK        = HotkeysStatic.GetKey(ref keyString),
                    Shortcut  = modString + keyString
                };

                if (hk.Modifiers == HotkeyModifiers.MOD_NONE)
                {
                    if (hk.VK >= HotkeysStatic.VK_F1 && hk.VK <= HotkeysStatic.VK_F24)
                    {
                        check = true;
                    }
                }
                else
                {
                    if (hk.VK > 0)
                    {
                        check = true;
                    }
                }
                if (!check)
                {
                    return;
                }
                string message, caption;
                if (PNStrings.RestrictedHotkeys.Contains(hk.Shortcut) ||
                    PNStatic.HotKeysEdit.Any(h => h.Modifiers == hk.Modifiers && h.VK == hk.VK) ||
                    PNStatic.HotKeysGroups.Any(h => h.Modifiers == hk.Modifiers && h.VK == hk.VK) ||
                    PNStatic.HotKeysNote.Any(h => h.Modifiers == hk.Modifiers && h.VK == hk.VK) ||
                    hk.Modifiers == HotkeyModifiers.MOD_SHIFT && (hk.VK >= HotkeysStatic.VK_A && hk.VK <= HotkeysStatic.VK_Z))
                {
                    message  = hk.Shortcut + '\n';
                    message += PNLang.Instance.GetMessageText("hk_registered_1", "This combination of keys is already registered.");
                    message += '\n';
                    message += PNLang.Instance.GetMessageText("hk_registered_2", "Choose another one, please.");
                    caption  = PNLang.Instance.GetCaptionText("restricted_keys", "Invalid keys");
                    PNMessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    e.Handled = true;
                    return;
                }
                if (HotkeysStatic.RegisterHK(_HwndSource.Handle, hk))
                {
                    HotkeysStatic.UnregisterHK(_HwndSource.Handle, hk.ID);
                }
                else
                {
                    message  = hk.Shortcut + '\n';
                    message += PNLang.Instance.GetMessageText("hk_registered_1", "This combination of keys is already registered.");
                    message += '\n';
                    message += PNLang.Instance.GetMessageText("hk_registered_2", "Choose another one, please.");
                    caption  = PNLang.Instance.GetCaptionText("restricted_keys", "Invalid keys");
                    PNMessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    e.Handled = true;
                    return;
                }
                PNTreeItem tvi       = null;
                PNHotKey   hkCurrent = null;
                switch (tabHK.SelectedIndex)
                {
                case 0:
                    tvi = tvwHKMain.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hkCurrent = m_KeysMain.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 1:
                    tvi = tvwHKNote.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hkCurrent = m_KeysNote.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 2:
                    tvi = tvwHKEdit.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hkCurrent = m_KeysEdit.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 3:
                    tvi = tvwHKGroups.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hkCurrent = m_KeysGroups.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;
                }
                if (hkCurrent != null)
                {
                    hkCurrent.Modifiers = hk.Modifiers;
                    hkCurrent.Shortcut  = hk.Shortcut;
                    hkCurrent.VK        = hk.VK;
                    setButtonsEnabled(tvi);
                    txtHotKey.Text = hk.Shortcut;
                    var defKey = new DefKey(hkCurrent.ID, hkCurrent.Type, hkCurrent.MenuName)
                    {
                        Icon =
                            isHotkeyInDatabase(
                                tabHK.SelectedIndex == 0
                                    ? PNStatic.HotKeysMain
                                    : (tabHK.SelectedIndex == 1
                                        ? PNStatic.HotKeysNote
                                        : (tabHK.SelectedIndex == 2 ? PNStatic.HotKeysEdit : PNStatic.HotKeysGroups)),
                                hk)
                                ? (BitmapSource)TryFindResource("check")
                                : null,
                        MenuRange =
                            tabHK.SelectedIndex == 0
                                ? tbpHKMain.Header.ToString()
                                : (tabHK.SelectedIndex == 1
                                    ? tbpHKNote.Header.ToString()
                                    : (tabHK.SelectedIndex == 2
                                        ? tbpHKEdit.Header.ToString()
                                        : tbpHKGroups.Header.ToString())),
                        MenuText =
                            tabHK.SelectedIndex < 3
                                ? PNLang.Instance.GetMenuText(
                                tabHK.SelectedIndex == 0
                                        ? "main_menu"
                                        : (tabHK.SelectedIndex == 1 ? "note_menu" : "edit_menu"), hkCurrent.MenuName,
                                hkCurrent.MenuName)
                                : hkCurrent.MenuName,
                        Shortcut = hkCurrent.Shortcut
                    };
                    if (tabHK.SelectedIndex == 3)
                    {
                        var arr = hkCurrent.MenuName.Split('_');
                        if (arr.Length == 2)
                        {
                            var gr = PNStatic.Groups.GetGroupByID(Convert.ToInt32(arr[0]));
                            if (gr != null)
                            {
                                var defCap = arr[1] == "show"
                                    ? PNLang.Instance.GetCaptionText("show_group", "Show group")
                                    : PNLang.Instance.GetCaptionText("hide_group", "Hide group");
                                defKey.MenuText = gr.Name + "/" + defCap;
                            }
                        }
                    }
                    //remove existing key
                    var existingKey = _DefKeys.FirstOrDefault(k => k.Id == defKey.Id);
                    if (existingKey != null)
                    {
                        _DefKeys.Remove(existingKey);
                    }
                    _DefKeys.Add(defKey);
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
Example #24
0
        private void cmdDeleteHK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var message = PNLang.Instance.GetMessageText("delete_hot_keys", "Delete selected hot keys combination?");
                if (PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.YesNo, MessageBoxImage.Question) !=
                    MessageBoxResult.Yes)
                {
                    return;
                }
                PNHotKey   hk  = null;
                PNTreeItem tvi = null;
                switch (tabHK.SelectedIndex)
                {
                case 0:
                    tvi = tvwHKMain.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hk = m_KeysMain.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 1:
                    tvi = tvwHKNote.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hk = m_KeysNote.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 2:
                    tvi = tvwHKEdit.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hk = m_KeysEdit.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;

                case 3:
                    tvi = tvwHKGroups.SelectedItem as PNTreeItem;
                    if (tvi == null)
                    {
                        break;
                    }
                    hk = m_KeysGroups.FirstOrDefault(h => h.MenuName == (string)tvi.Tag);
                    setButtonsEnabled(tvi);
                    break;
                }
                if (hk == null)
                {
                    return;
                }
                var defKey = _DefKeys.FirstOrDefault(dk => dk.Id == hk.ID);
                if (defKey != null)
                {
                    _DefKeys.Remove(defKey);
                }
                hk.Clear();
                txtHotKey.Text = "";
                setButtonsEnabled(tvi);
                if (txtHotKey.IsFocused)
                {
                    PNStatic.SendKey(Key.Tab);
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }