internal static bool LoginToNote(PNote note)
 {
     try
     {
         var text = " [" + PNLang.Instance.GetCaptionText("note", "Note") + " \"" + note.Name + "\"]";
         var pwrdDelete = new WndPasswordDelete(PasswordDlgMode.LoginNote, text, note.PasswordString)
         {
             Topmost = true,
             Owner = PNStatic.FormMain
         };
         var showDialog = pwrdDelete.ShowDialog();
         if (showDialog == null || !showDialog.Value)
         {
             return false;
         }
         return true;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
         return false;
     }
 }
 private void cmdRemovePwrd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // if new password has been applied or old password has not been changed - show standard password removing dialog
         if (PNStatic.Settings.Protection.PasswordString == _TempSettings.Protection.PasswordString)
         {
             var dpd = new WndPasswordDelete(PasswordDlgMode.DeleteMain);
             dpd.PasswordDeleted += dpd_PasswordDeleted;
             var showDialog = dpd.ShowDialog();
             if (showDialog == null || !showDialog.Value)
             {
                 dpd.PasswordDeleted -= dpd_PasswordDeleted;
             }
         }
         else
         {
             // if new password has not been applied and old password is empty - just remove new password
             if (PNStatic.Settings.Protection.PasswordString.Trim().Length == 0)
             {
                 dpd_PasswordDeleted(this, new EventArgs());
             }
             else
             {
                 // otherwise show standard password removing dialog using old password
                 var dpd = new WndPasswordDelete(PasswordDlgMode.DeleteMain);
                 dpd.PasswordDeleted += dpd_PasswordDeleted;
                 var showDialog = dpd.ShowDialog();
                 if (showDialog == null || !showDialog.Value)
                 {
                     dpd.PasswordDeleted -= dpd_PasswordDeleted;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
 internal static bool LoginToGroup(PNGroup group, ref List<int> loggedGroups)
 {
     try
     {
         var result = true;
         if (group.ParentID != -1)
         {
             var parent = PNStatic.Groups.GetGroupByID(group.ParentID);
             if (parent != null)
             {
                 result &= LoginToGroup(parent, ref loggedGroups);
             }
         }
         if (!loggedGroups.Contains(group.ID))
         {
             if (group.PasswordString.Trim().Length > 0)
             {
                 var text = " [" + PNLang.Instance.GetCaptionText("group", "Group") + " \"" + group.Name + "\"]";
                 var pwrdDelete = new WndPasswordDelete(PasswordDlgMode.LoginGroup, text, group.PasswordString)
                 {
                     Topmost = true,
                     Owner = PNStatic.FormMain
                 };
                 var showDialog = pwrdDelete.ShowDialog();
                 if (showDialog == null || !showDialog.Value)
                 {
                     return false;
                 }
                 loggedGroups.Add(@group.ID);
             }
             else
             {
                 loggedGroups.Add(group.ID);
             }
         }
         return result;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
         return false;
     }
 }
Exemple #4
0
 private void ntfPN_TrayMouseDoubleClick(object sender, RoutedEventArgs e)
 {
     try
     {
         bool? result = true;
         if (PNStatic.Settings.Protection.PasswordString != "" && PNSingleton.Instance.IsLocked)
         {
             var d = new WndPasswordDelete(PasswordDlgMode.LoginMain);
             result = d.ShowDialog();
         }
         if (result == null || !result.Value)
         {
             return;
         }
         _InDblClick = true;
         _TmrDblClick.Stop();
         _Elapsed = 0;
         actionDoubleSingle(PNStatic.Settings.Behavior.DoubleClickAction);
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Exemple #5
0
 private void ntfPN_TrayRightMouseDown(object sender, RoutedEventArgs e)
 {
     try
     {
         if (PNStatic.Settings.Protection.PasswordString == "" || !PNSingleton.Instance.IsLocked) return;
         var d = new WndPasswordDelete(PasswordDlgMode.LoginMain);
         var result = d.ShowDialog();
         if (result != null && result.Value)
         {
             PNSingleton.Instance.IsLocked = lockProgram(false);
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Exemple #6
0
 private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     switch (msg)
     {
         case WM_HOTKEY:
             var id = wParam.ToInt32();
             var hk = PNStatic.HotKeysMain.FirstOrDefault(h => h.ID == id);
             if (hk != null)
             {
                 if (PNStatic.HiddenMenus.Any(hm => hm.Type == MenuType.Main && hm.Name == hk.MenuName))
                     return IntPtr.Zero;
                 switch (hk.MenuName)
                 {
                     case "mnuNewNote":
                         if (mnuNewNote.IsEnabled)
                         {
                             mnuNewNote.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuNewNoteInGroup":
                         if (mnuNewNoteInGroup.IsEnabled)
                         {
                             mnuNewNoteInGroup.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuNoteFromClipboard":
                         if (mnuNoteFromClipboard.IsEnabled)
                         {
                             mnuNoteFromClipboard.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuLoadNote":
                         if (mnuLoadNote.IsEnabled)
                         {
                             mnuLoadNote.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuTodayDiary":
                         if (mnuTodayDiary.IsEnabled)
                         {
                             mnuTodayDiary.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuPrefs":
                         if (mnuPrefs.IsEnabled)
                         {
                             mnuPrefs.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuCP":
                         if (mnuCP.IsEnabled)
                         {
                             mnuCP.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuHotkeys":
                         if (mnuHotkeys.IsEnabled)
                         {
                             mnuHotkeys.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuMenusManagement":
                         if (mnuMenusManagement.IsEnabled)
                         {
                             mnuMenusManagement.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuShowAll":
                         if (mnuShowAll.IsEnabled)
                         {
                             mnuShowAll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuShowIncoming":
                         if (mnuShowIncoming.IsEnabled)
                         {
                             mnuShowIncoming.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuHideAll":
                         if (mnuHideAll.IsEnabled)
                         {
                             mnuHideAll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuHideIncoming":
                         if (mnuHideIncoming.IsEnabled)
                         {
                             mnuHideIncoming.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuTodayLast":
                         if (mnuTodayLast.IsEnabled)
                         {
                             mnuTodayLast.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuAllToFront":
                         if (mnuAllToFront.IsEnabled)
                         {
                             mnuAllToFront.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSaveAll":
                         if (mnuSaveAll.IsEnabled)
                         {
                             mnuSaveAll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuBackupCreate":
                         if (mnuBackupCreate.IsEnabled)
                         {
                             mnuBackupCreate.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuBackupRestore":
                         if (mnuBackupRestore.IsEnabled)
                         {
                             mnuBackupRestore.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSyncLocal":
                         if (mnuSyncLocal.IsEnabled)
                         {
                             mnuSyncLocal.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuImportFromOld":
                         if (mnuImportNotes.IsEnabled)
                         {
                             mnuImportNotes.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuReloadAll":
                         if (mnuReloadAll.IsEnabled)
                         {
                             mnuReloadAll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuDAllNone":
                         if (mnuDAllNone.IsEnabled)
                         {
                             mnuDAllNone.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuDAllLeft":
                         if (mnuDAllLeft.IsEnabled)
                         {
                             mnuDAllLeft.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuDAllTop":
                         if (mnuDAllTop.IsEnabled)
                         {
                             mnuDAllTop.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuDAllRight":
                         if (mnuDAllRight.IsEnabled)
                         {
                             mnuDAllRight.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuDAllBottom":
                         if (mnuDAllBottom.IsEnabled)
                         {
                             mnuDAllBottom.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOnHighPriority":
                         if (mnuSOnHighPriority.IsEnabled)
                         {
                             mnuSOnHighPriority.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOnProtection":
                         if (mnuSOnProtection.IsEnabled)
                         {
                             mnuSOnProtection.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOnComplete":
                         if (mnuSOnComplete.IsEnabled)
                         {
                             mnuSOnComplete.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOnRoll":
                         if (mnuSOnRoll.IsEnabled)
                         {
                             mnuSOnRoll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOnOnTop":
                         if (mnuSOnOnTop.IsEnabled)
                         {
                             mnuSOnOnTop.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOffHighPriority":
                         if (mnuSOffHighPriority.IsEnabled)
                         {
                             mnuSOffHighPriority.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOffProtection":
                         if (mnuSOffProtection.IsEnabled)
                         {
                             mnuSOffProtection.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOffComplete":
                         if (mnuSOffComplete.IsEnabled)
                         {
                             mnuSOffComplete.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOffUnroll":
                         if (mnuSOffUnroll.IsEnabled)
                         {
                             mnuSOffUnroll.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSOffOnTop":
                         if (mnuSOffOnTop.IsEnabled)
                         {
                             mnuSOffOnTop.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSearchInNotes":
                         if (mnuSearchInNotes.IsEnabled)
                         {
                             mnuSearchInNotes.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSearchByTags":
                         if (mnuSearchByTags.IsEnabled)
                         {
                             mnuSearchByTags.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSearchByDates":
                         if (mnuSearchByDates.IsEnabled)
                         {
                             mnuSearchByDates.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuShowAllFavorites":
                         if (mnuShowAllFavorites.IsEnabled)
                         {
                             mnuShowAllFavorites.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuLockProg":
                         if (mnuLockProg.IsEnabled)
                         {
                             mnuLockProg.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuHelp":
                         if (mnuHelp.IsEnabled)
                         {
                             mnuHelp.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuAbout":
                         if (mnuAbout.IsEnabled)
                         {
                             mnuAbout.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuHomepage":
                         if (mnuHomepage.IsEnabled)
                         {
                             mnuHomepage.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuSupport":
                         if (mnuSupport.IsEnabled)
                         {
                             mnuSupport.PerformClick();
                             handled = true;
                         }
                         break;
                     case "mnuExit":
                         if (mnuExit.IsEnabled)
                         {
                             mnuExit.PerformClick();
                             handled = true;
                         }
                         break;
                 }
             }
             else
             {
                 hk = PNStatic.HotKeysNote.FirstOrDefault(h => h.ID == id);
                 if (hk != null)
                 {
                     var d = Application.Current.Windows.OfType<WndNote>().FirstOrDefault(w => w.Active);
                     if (d == null) return IntPtr.Zero;
                     d.HotKeyClick(hk);
                     handled = true;
                 }
                 else
                 {
                     hk = PNStatic.HotKeysEdit.FirstOrDefault(h => h.ID == id);
                     if (hk != null)
                     {
                         var d = Application.Current.Windows.OfType<WndNote>().FirstOrDefault(w => w.Active);
                         if (d == null) return IntPtr.Zero;
                         d.HotKeyClick(hk);
                         handled = true;
                     }
                     else
                     {
                         hk = PNStatic.HotKeysGroups.FirstOrDefault(h => h.ID == id);
                         if (hk == null) return IntPtr.Zero;
                         if (!hk.MenuName.Contains('_')) return IntPtr.Zero;
                         var pos = hk.MenuName.IndexOf('_');
                         var groupId = int.Parse(hk.MenuName.Substring(0, pos), PNStatic.CultureInvariant);
                         var action = hk.MenuName.Substring(pos + 1);
                         PNNotesOperations.ShowHideSpecificGroup(groupId, action.ToUpper() == "SHOW");
                         handled = true;
                     }
                 }
             }
             break;
         case PNInterop.WM_ACTIVATEAPP:
             if (wParam.ToInt32() == 0)
             {
                 PNStatic.DeactivateNotesWindows();
             }
             handled = true;
             break;
         case PNInterop.WPM_CLOSE_PROG:
             mnuExit.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_CLOSE_SILENT_SAVE:
             PNSingleton.Instance.DoNotAskIfSave = true;
             mnuExit.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_CLOSE_SILENT_WO_SAVE:
             PNSingleton.Instance.ExitWithoutSaving = true;
             mnuExit.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_NEW_NOTE:
             mnuNewNote.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_NEW_NOTE_FROM_CB:
             mnuNoteFromClipboard.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_NEW_DIARY:
             mnuTodayDiary.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_RELOAD_NOTES:
             mnuReloadAll.PerformClick();
             handled = true;
             break;
         case PNInterop.WPM_START_FROM_ANOTHER_INSTANCE:
             bool? result = true;
             if (PNStatic.Settings.Protection.PasswordString != "" && PNSingleton.Instance.IsLocked)
             {
                 var d = new WndPasswordDelete(PasswordDlgMode.LoginMain);
                 result = d.ShowDialog();
             }
             if (result == null || !result.Value) return IntPtr.Zero;
             actionDoubleSingle(PNStatic.Settings.Behavior.DoubleClickAction);
             handled = true;
             break;
         case PNInterop.WM_COPYDATA:
             var m = Message.Create(hWnd, msg, wParam, lParam);
             var cpdata =
                 (PNInterop.COPYDATASTRUCT)m.GetLParam(typeof(PNInterop.COPYDATASTRUCT));
             switch ((CopyDataType)cpdata.dwData.ToInt32())
             {
                 case CopyDataType.NewNote:
                     var note = newNote();
                     if (note != null && note.Dialog != null)
                     {
                         var arr = cpdata.lpData.Split(new[] { PNStrings.DEL_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                         note.Dialog.Edit.Text = arr[0];
                         if (arr.Length >= 2)
                         {
                             note.Name = arr[1];
                             note.Dialog.PHeader.Title = note.Dialog.Title = note.Name;
                             note.Dialog.SaveNoteFile(note);
                             PNNotesOperations.SaveNewNote(note);
                             note.Dialog.ApplyTooltip();
                             note.Changed = false;
                         }
                         if (arr.Length >= 3)
                         {
                             note.Tags.AddRange(arr[2].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                             PNData.AddNewTags(note.Tags);
                             PNNotesOperations.SaveNoteTags(note);
                             note.RaiseTagsChangedEvent();
                         }
                     }
                     handled = true;
                     break;
                 case CopyDataType.LoadNotes:
                     if (cpdata.cbData == 0)
                     {
                         handled = true;
                         break;
                     }
                     var files = cpdata.lpData.Split(new[] { PNStrings.DEL_CHAR },
                         StringSplitOptions.RemoveEmptyEntries);
                     loadNotesFromFilesList(files);
                     handled = true;
                     break;
                 case CopyDataType.ShowNoteById:
                     if (cpdata.cbData == 0)
                     {
                         handled = true;
                         break;
                     }
                     if (PNSingleton.Instance.IsMainWindowLoaded)
                     {
                         var noteToShow = PNStatic.Notes.FirstOrDefault(n => n.ID == cpdata.lpData);
                         if (noteToShow != null)
                         {
                             PNNotesOperations.ShowHideSpecificNote(noteToShow, true);
                         }
                     }
                     else
                     {
                         PNSingleton.Instance.NoteFromShortcut = cpdata.lpData;
                     }
                     handled = true;
                     break;
             }
             break;
         case PNInterop.WPM_BACKUP:
             createFullBackup(true);
             handled = true;
             break;
     }
     return IntPtr.Zero;
 }
Exemple #7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (PNStatic.Settings.Protection.PasswordString != "")
                {
                    var d = new WndPasswordDelete(PasswordDlgMode.LoginMain);
                    var result = d.ShowDialog();
                    if (result == null || !result.Value)
                    {
                        PNStatic.HideSplash = true;
                        Close();
                    }
                }

                PNStatic.FormPanel = new WndPanel();

                //set double click timer handler
                _TmrDblClick.Tick += tmrDblClick_Tick;

                PNSingleton.Instance.FontUser.PropertyChanged += FontUser_PropertyChanged;
                //save monitors count
                PNSingleton.Instance.MonitorsCount = Screen.AllScreens.Length;

                //save screens rectangle
                PNSingleton.Instance.ScreenRect = PNStatic.AllScreensBounds();

                ApplyNewDefaultMenu();

                // get local ip address
                PNSingleton.Instance.IpAddress = PNStatic.GetLocalIPv4(NetworkInterfaceType.Wireless80211) ??
                                                 PNStatic.GetLocalIPv4(NetworkInterfaceType.Ethernet);

                //var ips = Dns.GetHostEntry(Dns.GetHostName());
                //// Select the first entry. I hope it's this maschines IP
                //var ipAddress =
                //    ips.AddressList.FirstOrDefault(
                //        ip => ip.AddressFamily == AddressFamily.InterNetwork);
                //if (ipAddress != null)
                //{
                //    _IpAddress = ipAddress.ToString();
                //}

                //check startup shortcut
                checkStartUpShortcut();

                //subscribe to system events
                SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
                SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

                createPaths();
                applyLanguage();
                //load/create database
                loadDatabase();

                //#if !DEBUG
                if (PNStatic.Settings.GeneralSettings.CheckCriticalOnStart)
                {
                    //check for critical updates (synchronously)
                    PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("critical_check",
                        "Checking for critical updates");
                    var result = checkCriticalUpdates();
                    if (result != CriticalUpdateAction.None)
                    {
                        PNStatic.HideSplash = true;
                        if ((result & CriticalUpdateAction.Program) == CriticalUpdateAction.Program)
                        {
                            Close();
                            return;
                        }
                        ApplyAction(MainDialogAction.Restart, null);
                        return;
                    }
                }
                //#endif
                PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("load_hotkeys", "Applying hot keys");
                //apply possible hot keys
                ApplyNewHotkeys();
                //register hot keys
                registerMainHotkeys();
                // register custom fonts
                if (PNStatic.Settings.GeneralSettings.UseCustomFonts)
                {
                    PNInterop.AddCustomFonts();
                }
                PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("load_spellchecker",
                    "Initializaing spell checker");
                //init spell checker
                initSpeller();

                //prepare docking collections
                PNStatic.DockedNotes.Add(DockStatus.Left, new List<PNote>());
                PNStatic.DockedNotes.Add(DockStatus.Top, new List<PNote>());
                PNStatic.DockedNotes.Add(DockStatus.Right, new List<PNote>());
                PNStatic.DockedNotes.Add(DockStatus.Bottom, new List<PNote>());
                //init dock arrows
                initDockArrows();

                // check exit flag and autosaved notes
                if (PNStatic.Settings.Config.ExitFlag != 0)
                {
                    restoreAutosavedNotes();
                }
                // clear all autosaved notes
                clearAutosavedNotes();

                //execute possible synchronization
                if (PNStatic.Settings.Network.SyncOnStart)
                {
                    PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("sync_in_progress",
                        "Synchronization in progress...");
                    var plugins = PNPlugins.Instance.SyncPlugins.Where(p => PNStatic.SyncPlugins.Contains(p.Name));
                    foreach (var p in plugins)
                    {
                        switch (p.Synchronize())
                        {
                            case SyncResult.Reload:
                                PNData.UpdateTablesAfterSync();
                                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."),
                                    p.Name, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                break;
                        }
                    }
                }

                // define autosave timer procedures
                _TimerAutosave.Elapsed += TimerAutosave_Elapsed;
                if (PNStatic.Settings.GeneralSettings.Autosave)
                {
                    _TimerAutosave.Interval = PNStatic.Settings.GeneralSettings.AutosavePeriod * 60000;
                    _TimerAutosave.Start();
                }

                //check skins existance
                if (PNStatic.Settings.GeneralSettings.UseSkins)
                {
                    PNStatic.Settings.GeneralSettings.UseSkins = PNStatic.CheckSkinsExistance();
                }

                if (PNStatic.Settings.Behavior.ShowNotesPanel)
                {
                    PNStatic.FormPanel.Show();
                }

                PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("load_notes", "Loading notes");
                loadNotes();

                PNStatic.HideSplash = true;

                showPriorityOnStart();

                // define clean bin timer procedures
                _TimerCleanBin.Elapsed += TimerCleanBin_Elapsed;
                if (PNStatic.Settings.GeneralSettings.RemoveFromBinPeriod > 0)
                {
                    _TimerCleanBin.Start();
                }

                PNStatic.StartTime = DateTime.Now;

                adjustStartTimes();

                // start listening thread
                if (PNStatic.Settings.Network.EnableExchange)
                {
                    //StartListening();
                    StartWCFHosting();
                }

                // check overdue notes
                checkOverdueNotes();

                ntfPN.Visibility = Visibility.Visible;

                if (_FirstRun)
                {
                    var sb =
                        new StringBuilder(PNLang.Instance.GetMessageText("first_baloon_caption",
                            "Thank you for using PNotes.NET!"));
                    sb.AppendLine();
                    sb.Append(PNLang.Instance.GetMessageText("first_baloon_message",
                        "Right click on system tray icon to begin the work."));
                    var baloon = new Baloon(BaloonMode.FirstRun) { BaloonText = sb.ToString() };
                    baloon.BaloonLinkClicked += baloon_BaloonLinkClicked;
                    ntfPN.ShowCustomBalloon(baloon, PopupAnimation.Slide, 15000);
                }
                else if (PNSingleton.Instance.PlatformChanged)
                {
                    var sb =
                        new StringBuilder(PNLang.Instance.GetMessageText("new_edition",
                            "You have started the new edition of PNotes.NET. All your notes and settings from previous edition have been saved as  ZIP archive at:"));
                    sb.AppendLine();
                    sb.Append(System.Windows.Forms.Application.StartupPath);
                    sb.Append(@"\");
                    sb.Append(PNStrings.OLD_EDITION_ARCHIVE);
                    var baloon = new Baloon(BaloonMode.Information) { BaloonText = sb.ToString() };
                    baloon.BaloonLinkClicked += baloon_BaloonLinkClicked;
                    ntfPN.ShowCustomBalloon(baloon, PopupAnimation.Slide, 15000);
                }
                //show Control Panel
                if (PNStatic.Settings.GeneralSettings.ShowCPOnStart)
                {
                    mnuCP.PerformClick();
                }

                //enable pin timer
                _TimerPin.Elapsed += TimerPin_Elapsed;
                _TimerPin.Start();

                //enable backup timer
                _TimerBackup.Elapsed += TimerBackup_Elapsed;
                _TimerBackup.Start();

                //enable monitor timer
                _TimerMonitor.Elapsed += _TimerMonitor_Elapsed;
                _TimerMonitor.Start();

                //hide possible hidden menus
                PNStatic.HideMenus(ctmPN, PNStatic.HiddenMenus.Where(hm => hm.Type == MenuType.Main).ToArray());

                //check for new version
                if (PNStatic.Settings.GeneralSettings.CheckNewVersionOnStart)
                {
                    checkForNewVersion();
                }

                //create dropper cursor
                PNSingleton.Instance.DropperCursor = PNStatic.CreateCursorFromResource("cursors/dropper.cur");

                var criticalLog = Path.Combine(Path.GetTempPath(), PNStrings.CRITICAL_UPDATE_LOG);
                if (File.Exists(criticalLog))
                {
                    using (var sr = new StreamReader(criticalLog))
                    {
                        while (sr.Peek() != -1)
                        {
                            PNStatic.LogThis("Critical udate has been applied for " + sr.ReadLine());
                        }
                    }
                    File.Delete(criticalLog);
                    var sb =
                        new StringBuilder(PNLang.Instance.GetMessageText("critical_applied",
                            "The program has restarted for applying critical updates."));
                    sb.AppendLine();
                    sb.Append(PNLang.Instance.GetMessageText("send_error_2",
                        "Please, refer to log file for details."));
                    var baloon = new Baloon(BaloonMode.CriticalUpdates) { BaloonText = sb.ToString() };
                    baloon.BaloonLinkClicked += baloon_BaloonLinkClicked;
                    ntfPN.ShowCustomBalloon(baloon, PopupAnimation.Slide, 10000);
                }
                if (PNSingleton.Instance.NoteFromShortcut != "")
                {
                    showNoteFromShortcut(PNSingleton.Instance.NoteFromShortcut);
                    PNSingleton.Instance.NoteFromShortcut = "";
                }
                restoreNotesShortcuts();
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
            finally
            {
                PNSingleton.Instance.IsMainWindowLoaded = true;
            }
        }
Exemple #8
0
 private void groupsActionPasswordRemove()
 {
     try
     {
         _LastTreeItem = _RightSelectedItem ?? tvwGroups.SelectedItem as PNTreeItem;
         if (_LastTreeItem == null) return;
         var gr = _RightSelectedItem != null ? _RightSelectedItem.Tag as PNGroup : getSelectedGroup();
         if (gr == null) return;
         var text = " [" + PNLang.Instance.GetCaptionText("group", "Group") + " \"" + gr.Name + "\"]";
         var pwrdDelete = new WndPasswordDelete(PasswordDlgMode.DeleteGroup, text, gr.PasswordString)
         {
             Owner = this
         };
         pwrdDelete.PasswordDeleted += pwrdDelete_PasswordDeleted;
         _SelectedGroup = gr.ID;
         var showDialog = pwrdDelete.ShowDialog();
         if (showDialog == null || !showDialog.Value)
         {
             pwrdDelete.PasswordDeleted -= pwrdDelete_PasswordDeleted;
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
     finally
     {
         _LastTreeItem = null;
         _SelectedGroup = 0;
     }
 }
Exemple #9
0
 private void actionDeletePassword()
 {
     try
     {
         var dpd = new WndPasswordDelete(PasswordDlgMode.DeleteMain) { Owner = this };
         dpd.PasswordDeleted += dpd_PasswordDeleted;
         var showDialog = dpd.ShowDialog();
         if (showDialog == null || !showDialog.Value)
         {
             dpd.PasswordDeleted -= dpd_PasswordDeleted;
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Exemple #10
0
 private void actionRemovePassword()
 {
     try
     {
         var note = getSelectedNote();
         if (note == null) return;
         var text = " [" + PNLang.Instance.GetCaptionText("note", "Note") + " \"" + note.Name + "\"]";
         var pwrdDelete = new WndPasswordDelete(PasswordDlgMode.DeleteNote, text, note.PasswordString)
         {
             Owner = this,
             WindowStartupLocation = WindowStartupLocation.CenterOwner
         };
         pwrdDelete.PasswordDeleted += notePasswordRemoved;
         var showDialog = pwrdDelete.ShowDialog();
         if (showDialog == null || !showDialog.Value)
         {
             pwrdDelete.PasswordDeleted -= notePasswordRemoved;
         }
         loadNotePreview(note);
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }