private void enableUpDown(PNTreeItem item) { try { if (item == null) { cmdUp.IsEnabled = cmdDown.IsEnabled = false; } else { var index = item.Index; cmdUp.IsEnabled = index > 0; var parent = ItemsControl.ItemsControlFromItemContainer(item); cmdDown.IsEnabled = index < parent.Items.Count - 1; } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdOK_Click(object sender, RoutedEventArgs e) { try { if (MailRecipientsChosen != null) { var selected = _MailContacts.Where(mc => mc.Selected); var list = selected.Select(s => new PNMailContact { DisplayName = s.DispName, Address = s.Address }); MailRecipientsChosen(this, new MailRecipientsChosenEventArgs(list)); } DialogResult = true; } catch (Exception ex) { PNStatic.LogException(ex); } }
private void loadSkinsList() { try { if (!Directory.Exists(PNPaths.Instance.SkinsDir)) { return; } var di = new DirectoryInfo(PNPaths.Instance.SkinsDir); var fi = di.GetFiles("*.pnskn"); var image = TryFindResource("skins") as BitmapImage;// new BitmapImage(new Uri(PNStrings.RESOURCE_PREFIX + "skins.png")); foreach (var f in fi) { lstSkins.Items.Add(new PNListBoxItem(image, Path.GetFileNameWithoutExtension(f.Name), f.FullName)); } } catch (Exception ex) { PNStatic.LogException(ex); } }
internal static int ConvertFromLogfontHeight(int lfHeight) { IntPtr hdc = Fonts.GetDC(IntPtr.Zero); try { return(-(lfHeight * 96) / Fonts.GetDeviceCaps(hdc, LOGPIXELSY)); } catch (Exception ex) { PNStatic.LogException(ex); return(0); } finally { if (!Equals(hdc, IntPtr.Zero)) { Fonts.ReleaseDC(IntPtr.Zero, hdc); } } }
private bool insertToLinkedNotes(SQLiteDataObject dataDest, DataRow r, KeyValuePair <string, List <_FieldData> > tableData) { try { var sb = new StringBuilder(); sb.Append("DELETE FROM LINKED_NOTES WHERE NOTE_ID = '"); sb.Append(r["NOTE_ID"]); sb.Append("' AND LINK_ID = '"); sb.Append(r["LINK_ID"]); sb.Append("'; "); sb.Append(createInsert(r, tableData)); return(executeTransaction(dataDest, sb.ToString())); } catch (Exception ex) { PNStatic.LogException(ex); return(false); } }
internal static List <Tuple <string, string> > GetLotusContacts(Window owner) { try { var dlgLotus = new WndLotusCredentials { Owner = owner }; dlgLotus.LotusCredentialSet += dlgLotus_LotusCredentialSet; var showDialog = dlgLotus.ShowDialog(); if (showDialog == null || !showDialog.Value) { dlgLotus.LotusCredentialSet -= dlgLotus_LotusCredentialSet; } return(_contacts); } catch (Exception ex) { PNStatic.LogException(ex); return(null); } }
private void Thumbnail_Click(object sender, RoutedEventArgs e) { try { if (PNStatic.Settings.Behavior.PanelRemoveMode != PanelRemoveMode.SingleClick) { return; } var thb = sender as ThumbnailButton; if (thb == null) { return; } removeThumbnail(thb); allButtonsToNormalSize(); } catch (Exception ex) { PNStatic.LogException(ex); } }
void block_Click(object sender, RoutedEventArgs e) { try { var t = sender as TextBlock; if (t == null) { return; } if (SpecialSymbolSelected == null) { return; } SpecialSymbolSelected(this, new SpecialSymbolSelectedEventArgs(t.Text)); DialogResult = true; } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdFontSknls_Click(object sender, RoutedEventArgs e) { try { var fc = new WndFontChooser(m_Group.Skinless.CaptionFont, m_Group.Skinless.CaptionColor) { Owner = this }; var showDialog = fc.ShowDialog(); if (showDialog != null && showDialog.Value) { m_Group.Skinless.CaptionFont = fc.SelectedFont; m_Group.Skinless.CaptionColor = fc.SelectedColor; PNStatic.DrawSkinlessPreview(m_Group, brdFrame, blkCaption, brdBody, blkBody); } } 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); } }
private void cmdOK_Click(object sender, RoutedEventArgs e) { try { _SelectedFont.FontFamily = lblFontSample.FontFamily; _SelectedFont.FontSize = lblFontSample.FontSize; _SelectedFont.FontStretch = lblFontSample.FontStretch; _SelectedFont.FontStyle = lblFontSample.FontStyle; _SelectedFont.FontWeight = lblFontSample.FontWeight; var solidColorBrush = lblFontSample.Foreground as SolidColorBrush; if (solidColorBrush != null) { _SelectedColor = solidColorBrush.Color; } DialogResult = true; } catch (Exception ex) { PNStatic.LogException(ex); } }
void FormMain_NoteBooleanChanged(object sender, NoteBooleanChangedEventArgs e) { try { var note = sender as PNote; if (note == null || _Notes.Count == 0) { return; } var item = _Notes.FirstOrDefault(n => n.Id == note.ID); if (item == null) { return; } item.IconSource = PNNotesOperations.GetNoteImage(note); } catch (Exception ex) { PNStatic.LogException(ex); } }
void FormMain_NoteNameChanged(object sender, NoteNameChangedEventArgs e) { try { var note = sender as PNote; if (note == null || _Notes.Count == 0) { return; } var item = _Notes.FirstOrDefault(n => n.Id == note.ID); if (item == null) { return; } item.Name = note.Name; } catch (Exception ex) { PNStatic.LogException(ex); } }
internal static void CheckAndApplyNewMenusOrder(ContextMenu ctm) { try { var sb = new StringBuilder("SELECT COUNT(MENU_NAME) FROM MENUS_ORDER WHERE CONTEXT_NAME = '"); sb.Append(ctm.Name); sb.Append("' AND ORDER_ORIGINAL <> ORDER_NEW"); using (var oData = new SQLiteDataObject(PNData.ConnectionString)) { var obj = oData.GetScalar(sb.ToString()); if (obj != null && !PNData.IsDBNull(obj) && Convert.ToInt32(obj) > 0) { RearrangeMenus(ctm); } } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void DlgAddTable_Loaded(object sender, RoutedEventArgs e) { try { PNLang.Instance.ApplyControlLanguage(this); cboTableColumnWidth.SelectedItem = 2000; cboTableTextIndent.SelectedItem = 144; cboTableBorders.Items.Add(new _Thickness { Text = "0", Value = 0 }); cboTableBorders.Items.Add(new _Thickness { Text = "1", Value = 1 }); cboTableBorders.Items.Add(new _Thickness { Text = "2", Value = 3 }); cboTableBorders.Items.Add(new _Thickness { Text = "3", Value = 4 }); cboTableBorders.Items.Add(new _Thickness { Text = "4", Value = 6 }); cboTableBorders.Items.Add(new _Thickness { Text = "5", Value = 7 }); cboTableBorders.Items.Add(new _Thickness { Text = "6", Value = 9 }); cboTableBorders.Items.Add(new _Thickness { Text = "7", Value = 10 }); cboTableBorders.SelectedIndex = 1; _Loaded = true; applyTableLook(); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdResetCurrent_Click(object sender, RoutedEventArgs e) { try { switch (tabMenus.SelectedIndex) { case 0: foreach (var pti in tvwMain.Items.OfType <PNTreeItem>()) { resetChecks(pti); } break; case 1: foreach (var pti in tvwNote.Items.OfType <PNTreeItem>()) { resetChecks(pti); } break; case 2: foreach (var pti in tvwEdit.Items.OfType <PNTreeItem>()) { resetChecks(pti); } break; case 3: foreach (var pti in tvwCP.Items.OfType <PNTreeItem>()) { resetChecks(pti); } break; } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdDBDir_Click(object sender, RoutedEventArgs e) { try { var fbd = new System.Windows.Forms.FolderBrowserDialog { Description = PNLang.Instance.GetCaptionText("choose_dir", "Choose directory") }; if (txtDBDir.Text.Trim().Length > 0) { fbd.SelectedPath = txtDBDir.Text.Trim(); } if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtDBDir.Text = fbd.SelectedPath; } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void findNotes() { try { _Notes.Clear(); var tags = _Tags.Where(t => t.Selected).Select(t => t.Tag); var notes = PNStatic.Notes.Where(n => n.GroupID != (int)SpecialGroups.RecycleBin); foreach (var note in notes) { if (!note.Tags.Any(nt => tags.Any(t => t == nt))) { continue; } var key = PNNotesOperations.GetNoteImage(note); _Notes.Add(new FoundNote(key, note.Name, note.Tags.ToCommaSeparatedString(), note.ID)); } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void applyLanguage() { try { var criteria = cboSearchСriteria.SelectedIndex; var scope = cboSearchScope.SelectedIndex; PNLang.Instance.ApplyControlLanguage(this); Title = PNLang.Instance.GetCaptionText("search_in_notes", "Search in notes"); _Line = PNLang.Instance.GetMiscText("line", "Line:"); _Column = PNLang.Instance.GetMiscText("column", "Column:"); _TextAndTitle = PNLang.Instance.GetMiscText("text_and_title", "(text and title)"); _TitleOnly = PNLang.Instance.GetMiscText("title_only", "(title only)"); _TextOnly = PNLang.Instance.GetMiscText("text_only", "(text_only)"); cboSearchСriteria.SelectedIndex = criteria == -1 ? 0 : criteria; cboSearchScope.SelectedIndex = scope == -1 ? 0 : scope; } catch (Exception ex) { PNStatic.LogException(ex); } }
private void DlgGroups_Loaded(object sender, RoutedEventArgs e) { try { PNLang.Instance.ApplyControlLanguage(this); if (m_Mode == AddEditMode.Add) { Title = PNLang.Instance.GetCaptionText("group_new", "New group of contacts"); } else { Title = PNLang.Instance.GetCaptionText("group_edit", "Edit group of contacts"); txtGroupName.Text = m_Group.Name; } txtGroupName.SelectAll(); txtGroupName.Focus(); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void Orient_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { PNStatic.Settings.Behavior.NotesPanelOrientation = PNStatic.Settings.Behavior.NotesPanelOrientation == NotesPanelOrientation.Left ? NotesPanelOrientation.Top : NotesPanelOrientation.Left; PNData.SaveBehaviorSettings(); SetPanelPlacement(); UpdateOrientationImageBinding(); if (PNStatic.FormSettings == null) { return; } PNStatic.FormSettings.PanelOrientationChanged(); } catch (Exception ex) { PNStatic.LogException(ex); } }
internal static int ConvertToLogfontHeight(int height) { IntPtr hdc = Fonts.GetDC(IntPtr.Zero); try { var result = -Fonts.MulDiv(height, Fonts.GetDeviceCaps(hdc, (int)VariableParams.LOGPIXELSY), 72);// -(height * Fonts.GetDeviceCaps(hdc, LOGPIXELSY)) / 96; return(result); } catch (Exception ex) { PNStatic.LogException(ex); return(0); } finally { if (!Equals(hdc, IntPtr.Zero)) { Fonts.ReleaseDC(IntPtr.Zero, hdc); } } }
private void CheckBoxChecked(object sender, RoutedEventArgs e) { try { var checkBox = sender as CheckBox; if (checkBox == null) { return; } var item = grdMailContacts.GetObjectAtPoint <ListViewItem>(Mouse.GetPosition(grdMailContacts)) as MailC; if (item == null) { return; } grdMailContacts.SelectedItem = item; cmdOK.IsEnabled = _MailContacts.Any(c => c.Selected); } catch (Exception ex) { PNStatic.LogException(ex); } }
private bool exchangeCustomNotesSettings(SQLiteDataObject dataSrc, SQLiteDataObject dataDest, string id, KeyValuePair <string, List <_FieldData> > tableData) { try { using (var t1 = dataSrc.FillDataTable("SELECT * FROM CUSTOM_NOTES_SETTINGS WHERE NOTE_ID = '" + id + "'")) { using (var t2 = dataDest.FillDataTable("SELECT * FROM CUSTOM_NOTES_SETTINGS WHERE NOTE_ID = '" + id + "'")) { if (t1.Rows.Count > 0 && t2.Rows.Count > 0) { var d1 = Convert.ToInt64(t1.Rows[0]["UPD_DATE"]); var d2 = Convert.ToInt64(t2.Rows[0]["UPD_DATE"]); if (d1 > d2) { return(insertToCustomNotesSettings(dataDest, t1.Rows[0], tableData)); } if (d2 > d1) { return(insertToCustomNotesSettings(dataSrc, t2.Rows[0], tableData)); } } else if (t1.Rows.Count > 0) { return(insertToCustomNotesSettings(dataDest, t1.Rows[0], tableData)); } else if (t2.Rows.Count > 0) { return(insertToCustomNotesSettings(dataSrc, t2.Rows[0], tableData)); } } } return(true); } catch (Exception ex) { PNStatic.LogException(ex); return(false); } }
private object getUpdateValue(string tableName, string columnName) { try { switch (tableName) { case "GROUPS": switch (columnName) { case "IS_DEFAULT_IMAGE": return(1); } break; } return(null); } catch (Exception ex) { PNStatic.LogException(ex); return(null); } }
private void criticalOpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { try { if (e.Error != null || e.Cancelled) { return; } var xdoc = XDocument.Load(e.Result); var productVersion = e.UserState as string; if (productVersion == null) { return; } parsCriticalUpdate(xdoc, productVersion); } catch (Exception ex) { PNStatic.LogException(ex, false); PNSingleton.Instance.CriticalChecking = false; } }
private void loadSmilies() { try { for (var i = 1; i <= 121; i++) { var image = new Image { Source = new BitmapImage(new Uri(PNStrings.SMILIES_PREFIX + i + ".png")), Cursor = Cursors.Hand, Margin = new Thickness(2), Stretch = Stretch.None }; image.MouseLeftButtonDown += image_MouseLeftButtonDown; grdSmilies.Children.Add(image); } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void applyLanguage() { try { PNLang.Instance.ApplyControlLanguage(this); Title += @" - " + _Note.Name; _TransCaption = PNLang.Instance.GetCaptionText("transparency", "Transparency"); if (_CustomOpacity) { lblTransPerc.Text = _TransCaption + @": " + (100.0 - (_Note.Opacity * 100)).ToString("0%"); } else { lblTransPerc.Text = _TransCaption + @": " + (100.0 - (PNStatic.Settings.Behavior.Opacity * 100)).ToString("0%"); } blkCaption.Text = PNLang.Instance.GetControlText("previewCaption", "Caption"); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdOK_Click(object sender, RoutedEventArgs e) { try { var paths = new string[2]; paths[0] = txtDataDir.Text.Trim(); paths[1] = ""; if (chkUseDataDir.IsChecked != null && chkUseDataDir.IsChecked.Value) { paths[1] = txtDBDir.Text.Trim(); } var ds = new WndSync(paths) { Owner = this }; DialogResult = ds.ShowDialog(); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void enableOK() { try { if (!_Loaded) { return; } if (chkUseDataDir.IsChecked != null && chkUseDataDir.IsChecked.Value) { cmdOK.IsEnabled = txtDataDir.Text.Trim().Length > 0; } else { cmdOK.IsEnabled = txtDataDir.Text.Trim().Length > 0 && txtDBDir.Text.Trim().Length > 0; } } catch (Exception ex) { PNStatic.LogException(ex); } }