private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if (m_pbData == null) { throw new InvalidOperationException(); } m_bInitializing = true; GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; this.DoubleBuffered = true; string strTitle = KPRes.DataViewerKP; if (m_strDataDesc.Length > 0) { strTitle = m_strDataDesc + " - " + strTitle; } this.Text = strTitle; m_strInitialFormRect = UIUtil.SetWindowScreenRectEx(this, Program.Config.UI.DataViewerRect); m_tssStatusMain.Text = KPRes.Ready; m_ctxText.Attach(m_rtbText, this); m_rtbText.Dock = DockStyle.Fill; m_webBrowser.Dock = DockStyle.Fill; m_pnlImageViewer.Dock = DockStyle.Fill; m_picBox.Dock = DockStyle.Fill; m_tslEncoding.Text = KPRes.Encoding + ":"; foreach (StrEncodingInfo seiEnum in StrUtil.Encodings) { m_tscEncoding.Items.Add(seiEnum.Name); } StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out m_uStartOffset); int iSel = 0; if (seiGuess != null) { iSel = Math.Max(m_tscEncoding.FindStringExact(seiGuess.Name), 0); } m_tscEncoding.SelectedIndex = iSel; m_tslZoom.Text = KPRes.Zoom + ":"; // Required for mouse wheel handling Debug.Assert(m_tscZoom.DropDownStyle == ComboBoxStyle.DropDownList); m_tscZoom.Items.Add(m_strZoomAuto); int[] vZooms = new int[] { 10, 25, 50, 75, 100, 125, 150, 200, 400 }; foreach (int iZoom in vZooms) { m_tscZoom.Items.Add(iZoom.ToString() + "%"); } m_tscZoom.SelectedIndex = 0; KeysConverter kc = new KeysConverter(); m_tsbZoomOut.ToolTipText = KPRes.Zoom + " - (" + KPRes.KeyboardKeyCtrl + "+" + kc.ConvertToString(Keys.Subtract) + ")"; m_tsbZoomIn.ToolTipText = KPRes.Zoom + " + (" + KPRes.KeyboardKeyCtrl + "+" + kc.ConvertToString(Keys.Add) + ")"; m_tslViewer.Text = KPRes.ShowIn + ":"; m_tscViewers.Items.Add(m_strViewerHex); m_tscViewers.Items.Add(m_strViewerText); m_tscViewers.Items.Add(m_strViewerImage); m_tscViewers.Items.Add(m_strViewerWeb); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); if ((m_bdc == BinaryDataClass.Text) || (m_bdc == BinaryDataClass.RichText)) { m_tscViewers.SelectedIndex = 1; } else if (m_bdc == BinaryDataClass.Image) { m_tscViewers.SelectedIndex = 2; } else if (m_bdc == BinaryDataClass.WebDocument) { m_tscViewers.SelectedIndex = 3; } else { m_tscViewers.SelectedIndex = 0; } if (this.DvfInit != null) { this.DvfInit(this, new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers)); } m_picBox.MouseWheel += this.OnPicBoxMouseWheel; m_bInitializing = false; UpdateDataView(); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if (m_pbData == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; this.DoubleBuffered = true; m_strInitialFormRect = UIUtil.SetWindowScreenRectEx(this, Program.Config.UI.DataEditorRect); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); uint uStartOffset; StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out uStartOffset); string strData; try { strData = (seiGuess.Encoding.GetString(m_pbData, (int)uStartOffset, m_pbData.Length - (int)uStartOffset) ?? string.Empty); strData = StrUtil.ReplaceNulls(strData); } catch (Exception) { Debug.Assert(false); strData = string.Empty; } ++m_uBlockEvents; UIUtil.AssignShortcut(m_menuFileSave, Keys.Control | Keys.S); UIUtil.AssignShortcut(m_menuFileExit, Keys.Escape, null, true); UIUtil.AssignShortcut(m_menuEditUndo, Keys.Control | Keys.Z, null, true); UIUtil.AssignShortcut(m_menuEditRedo, Keys.Control | Keys.Y, null, true); UIUtil.AssignShortcut(m_menuEditCut, Keys.Control | Keys.X, null, true); UIUtil.AssignShortcut(m_menuEditCopy, Keys.Control | Keys.C, null, true); UIUtil.AssignShortcut(m_menuEditPaste, Keys.Control | Keys.V, null, true); UIUtil.AssignShortcut(m_menuEditDelete, Keys.Delete, null, true); UIUtil.AssignShortcut(m_menuEditSelectAll, Keys.Control | Keys.A, null, true); UIUtil.AssignShortcut(m_menuEditFind, Keys.Control | Keys.F); UIUtil.ConfigureTbButton(m_tbFileSave, KPRes.Save, null, m_menuFileSave); UIUtil.ConfigureTbButton(m_tbEditCut, KPRes.Cut, null, m_menuEditCut); UIUtil.ConfigureTbButton(m_tbEditCopy, KPRes.Copy, null, m_menuEditCopy); UIUtil.ConfigureTbButton(m_tbEditPaste, KPRes.Paste, null, m_menuEditPaste); UIUtil.ConfigureTbButton(m_tbEditUndo, KPRes.Undo, null, m_menuEditUndo); UIUtil.ConfigureTbButton(m_tbEditRedo, KPRes.Redo, null, m_menuEditRedo); UIUtil.ConfigureTbButton(m_tbFind, null, KPRes.Find, m_menuEditFind); // Formatting keyboard shortcuts are implemented by CustomRichTextBoxEx UIUtil.ConfigureTbButton(m_tbFormatBold, KPRes.Bold, KPRes.Bold + " (" + UIUtil.GetKeysName(Keys.Control | Keys.B) + ")", null); UIUtil.ConfigureTbButton(m_tbFormatItalic, KPRes.Italic, KPRes.Italic + " (" + UIUtil.GetKeysName(Keys.Control | Keys.I) + ")", null); UIUtil.ConfigureTbButton(m_tbFormatUnderline, KPRes.Underline, KPRes.Underline + " (" + UIUtil.GetKeysName(Keys.Control | Keys.U) + ")", null); UIUtil.ConfigureTbButton(m_tbFormatStrikeout, KPRes.Strikeout, null); UIUtil.ConfigureTbButton(m_tbColorForeground, KPRes.TextColor, null); UIUtil.ConfigureTbButton(m_tbColorBackground, KPRes.BackgroundColor, null); UIUtil.ConfigureTbButton(m_tbAlignLeft, KPRes.AlignLeft, KPRes.AlignLeft + " (" + UIUtil.GetKeysName(Keys.Control | Keys.L) + ")", null); UIUtil.ConfigureTbButton(m_tbAlignCenter, KPRes.AlignCenter, KPRes.AlignCenter + " (" + UIUtil.GetKeysName(Keys.Control | Keys.E) + ")", null); UIUtil.ConfigureTbButton(m_tbAlignRight, KPRes.AlignRight, KPRes.AlignRight + " (" + UIUtil.GetKeysName(Keys.Control | Keys.R) + ")", null); string strSearchTr = ((WinUtil.IsAtLeastWindowsVista ? string.Empty : " ") + KPRes.Search); UIUtil.SetCueBanner(m_tbFind, strSearchTr); UIUtil.SetToolTip(m_tbFontCombo, KPRes.Font, true); UIUtil.SetToolTip(m_tbFontSizeCombo, KPRes.Size, true); UIUtil.EnableAutoCompletion(m_tbFontCombo, true); UIUtil.EnableAutoCompletion(m_tbFontSizeCombo, true); m_rtbText.WordWrap = Program.Config.UI.DataEditorWordWrap; m_ctxText.Attach(m_rtbText, this); m_tssStatusMain.Text = KPRes.Ready; InitFormattingToolBar(); bool bSimpleText = true, bDefaultFont = true; if (m_bdc == BinaryDataClass.RichText) { try { if (strData.Length > 0) { m_rtbText.Rtf = StrUtil.RtfFix(strData); bDefaultFont = false; } else { m_rtbText.Text = string.Empty; } bSimpleText = false; } catch (Exception) { } // Show as simple text } if (bSimpleText) { m_rtbText.Text = strData; m_rtbText.SimpleTextOnly = true; // CR is upgraded to CR+LF m_bNewLinesWin = (StrUtil.GetNewLineSeq(strData) != "\n"); } else { m_menuViewFont.Text = KPRes.FontDefault + "..."; } if (bDefaultFont && Program.Config.UI.DataEditorFont.OverrideUIDefault) { m_rtbText.SelectAll(); m_rtbText.SelectionFont = Program.Config.UI.DataEditorFont.ToFont(); } m_rtbText.Select(0, 0); --m_uBlockEvents; UpdateUIState(false, true); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if(m_pbData == null) throw new InvalidOperationException(); m_bInitializing = true; GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; this.DoubleBuffered = true; string strTitle = PwDefs.ShortProductName + " " + KPRes.DataViewer; if(m_strDataDesc.Length > 0) strTitle = m_strDataDesc + " - " + strTitle; this.Text = strTitle; m_strInitialFormRect = UIUtil.SetWindowScreenRectEx(this, Program.Config.UI.DataViewerRect); m_tssStatusMain.Text = KPRes.Ready; m_ctxText.Attach(m_rtbText, this); m_rtbText.Dock = DockStyle.Fill; m_webBrowser.Dock = DockStyle.Fill; m_pnlImageViewer.Dock = DockStyle.Fill; m_picBox.Dock = DockStyle.Fill; m_tslEncoding.Text = KPRes.Encoding + ":"; foreach(StrEncodingInfo seiEnum in StrUtil.Encodings) { m_tscEncoding.Items.Add(seiEnum.Name); } StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out m_uStartOffset); int iSel = 0; if(seiGuess != null) iSel = Math.Max(m_tscEncoding.FindStringExact(seiGuess.Name), 0); m_tscEncoding.SelectedIndex = iSel; m_tslZoom.Text = KPRes.Zoom + ":"; m_tscZoom.Items.Add(KPRes.Auto); int[] vZooms = new int[] { 10, 25, 50, 75, 100, 125, 150, 200, 400 }; foreach(int iZoom in vZooms) m_tscZoom.Items.Add(iZoom.ToString() + @"%"); m_tscZoom.SelectedIndex = 0; m_tslViewer.Text = KPRes.ShowIn + ":"; m_tscViewers.Items.Add(m_strViewerHex); m_tscViewers.Items.Add(m_strViewerText); m_tscViewers.Items.Add(m_strViewerImage); m_tscViewers.Items.Add(m_strViewerWeb); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); if((m_bdc == BinaryDataClass.Text) || (m_bdc == BinaryDataClass.RichText)) m_tscViewers.SelectedIndex = 1; else if(m_bdc == BinaryDataClass.Image) m_tscViewers.SelectedIndex = 2; else if(m_bdc == BinaryDataClass.WebDocument) m_tscViewers.SelectedIndex = 3; else m_tscViewers.SelectedIndex = 0; if(this.DvfInit != null) this.DvfInit(this, new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers)); m_bInitializing = false; UpdateDataView(); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_atConfig != null); if (m_atConfig == null) { throw new InvalidOperationException(); } Debug.Assert(m_vStringDict != null); if (m_vStringDict == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); m_ctxKeySeq.Attach(m_rbKeySeq, this); m_ctxKeyCodes.Attach(m_rtbPlaceholders, this); if (!m_bEditSequenceOnly) { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureAutoTypeItem, KPRes.ConfigureAutoTypeItemDesc); } else // Edit keystrokes only { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureKeystrokeSeq, KPRes.ConfigureKeystrokeSeqDesc); } this.Icon = Properties.Resources.KeePass; // FontUtil.AssignDefaultBold(m_lblTargetWindow); // FontUtil.AssignDefaultBold(m_rbSeqDefault); // FontUtil.AssignDefaultBold(m_rbSeqCustom); UIUtil.EnableAutoCompletion(m_cmbWindow, false); // m_clrOriginalForeground = m_lblOpenHint.ForeColor; // m_clrOriginalBackground = m_cmbWindow.BackColor; // m_strOriginalWindowHint = m_lblTargetWindowInfo.Text; InitPlaceholdersBox(); string strInitSeq = m_atConfig.DefaultSequence; if (m_iAssocIndex >= 0) { AutoTypeAssociation asInit = m_atConfig.GetAt(m_iAssocIndex); m_cmbWindow.Text = asInit.WindowName; if (!m_bEditSequenceOnly) { strInitSeq = asInit.Sequence; } } else if (m_bEditSequenceOnly) { m_cmbWindow.Text = "(" + KPRes.Default + ")"; } else { strInitSeq = string.Empty; } bool bSetDefault = false; m_bBlockUpdates = true; if (strInitSeq.Length > 0) { m_rbSeqCustom.Checked = true; } else { m_rbSeqDefault.Checked = true; bSetDefault = true; } m_bBlockUpdates = false; if (bSetDefault) { m_rbKeySeq.Text = m_strDefaultSeq; } else { m_rbKeySeq.Text = strInitSeq; } try { if (NativeLib.IsUnix()) { PopulateWindowsListUnix(); } else { PopulateWindowsListWin(); } } catch (Exception) { Debug.Assert(false); } EnableControlsEx(); }
public ColorTextBox() : base() { Multiline = false; SimpleTextOnly = true; m_ctx.Attach(this, null); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if (m_pbData == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.DoubleBuffered = true; string strRect = Program.Config.UI.DataEditorRect; if (strRect.Length > 0) { UIUtil.SetWindowScreenRect(this, strRect); } m_strInitialFormRect = UIUtil.GetWindowScreenRect(this); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); uint uStartOffset; StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out uStartOffset); string strData; try { strData = (seiGuess.Encoding.GetString(m_pbData, (int)uStartOffset, m_pbData.Length - (int)uStartOffset) ?? string.Empty); } catch (Exception) { Debug.Assert(false); strData = string.Empty; } BlockUIEvents(true); UIUtil.AssignShortcut(m_menuFileSave, Keys.Control | Keys.S); m_menuFileExit.ShortcutKeyDisplayString = KPRes.KeyboardKeyEsc; UIUtil.ConfigureTbButton(m_tbFileSave, KPRes.Save, null, m_menuFileSave); UIUtil.ConfigureTbButton(m_tbEditCut, KPRes.Cut, null); UIUtil.ConfigureTbButton(m_tbEditCopy, KPRes.Copy, null); UIUtil.ConfigureTbButton(m_tbEditPaste, KPRes.Paste, null); UIUtil.ConfigureTbButton(m_tbEditUndo, KPRes.Undo, null); UIUtil.ConfigureTbButton(m_tbEditRedo, KPRes.Redo, null); UIUtil.ConfigureTbButton(m_tbFormatBold, KPRes.Bold, null); UIUtil.ConfigureTbButton(m_tbFormatItalic, KPRes.Italic, null); UIUtil.ConfigureTbButton(m_tbFormatUnderline, KPRes.Underline, null); UIUtil.ConfigureTbButton(m_tbFormatStrikeout, KPRes.Strikeout, null); UIUtil.ConfigureTbButton(m_tbColorForeground, KPRes.TextColor, null); UIUtil.ConfigureTbButton(m_tbColorBackground, KPRes.BackgroundColor, null); UIUtil.ConfigureTbButton(m_tbAlignCenter, KPRes.AlignCenter, null); UIUtil.ConfigureTbButton(m_tbAlignLeft, KPRes.AlignLeft, null); UIUtil.ConfigureTbButton(m_tbAlignRight, KPRes.AlignRight, null); UIUtil.EnableAutoCompletion(m_tbFontCombo, true); UIUtil.EnableAutoCompletion(m_tbFontSizeCombo, true); m_rtbText.Dock = DockStyle.Fill; m_ctxText.Attach(m_rtbText, this); m_tssStatusMain.Text = KPRes.Ready; m_rtbText.WordWrap = Program.Config.UI.DataEditorWordWrap; InitFormattingToolBar(); bool bSimpleText = true; if (m_bdc == BinaryDataClass.RichText) { try { if (strData.Length > 0) { m_rtbText.Rtf = strData; } else { m_rtbText.Text = string.Empty; } bSimpleText = false; } catch (Exception) { } // Show as simple text } if (bSimpleText) { m_rtbText.Text = strData; m_rtbText.SimpleTextOnly = true; if (Program.Config.UI.DataEditorFont.OverrideUIDefault) { m_rtbText.SelectAll(); m_rtbText.SelectionFont = Program.Config.UI.DataEditorFont.ToFont(); } } m_rtbText.Select(0, 0); BlockUIEvents(false); UpdateUIState(false, true); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if (m_pbData == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; if (m_strDataDesc.Length > 0) { this.Text = m_strDataDesc + " - " + this.Text; } this.DoubleBuffered = true; m_bInitializing = true; m_tssStatusMain.Text = KPRes.Ready; m_ctxText.Attach(m_rtbText, this); m_rtbText.Dock = DockStyle.Fill; m_webBrowser.Dock = DockStyle.Fill; m_pnlImageViewer.Dock = DockStyle.Fill; m_picBox.Dock = DockStyle.Fill; m_tslEncoding.Text = KPRes.Encoding + ":"; foreach (StrEncodingInfo seiEnum in StrUtil.Encodings) { m_tscEncoding.Items.Add(seiEnum.Name); } StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out m_uStartOffset); int iSel = 0; if (seiGuess != null) { iSel = Math.Max(m_tscEncoding.FindStringExact(seiGuess.Name), 0); } m_tscEncoding.SelectedIndex = iSel; m_tslZoom.Text = KPRes.Zoom + ":"; m_tscZoom.Items.Add(KPRes.Auto); int[] vZooms = new int[] { 10, 25, 50, 75, 100, 125, 150, 200, 400 }; foreach (int iZoom in vZooms) { m_tscZoom.Items.Add(iZoom.ToString() + @"%"); } m_tscZoom.SelectedIndex = 0; m_tslViewer.Text = KPRes.ShowIn + ":"; m_tscViewers.Items.Add(KPRes.TextViewer); m_tscViewers.Items.Add(KPRes.ImageViewer); m_tscViewers.Items.Add(KPRes.WebBrowser); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); if ((m_bdc == BinaryDataClass.Text) || (m_bdc == BinaryDataClass.RichText)) { m_tscViewers.SelectedIndex = 0; } else if (m_bdc == BinaryDataClass.Image) { m_tscViewers.SelectedIndex = 1; } else if (m_bdc == BinaryDataClass.WebDocument) { m_tscViewers.SelectedIndex = 2; } else { m_tscViewers.SelectedIndex = 0; } if (this.DvfInit != null) { this.DvfInit(this, new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers)); } m_bInitializing = false; UpdateDataView(); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if (m_pbData == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.DoubleBuffered = true; m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); string strEncodingName; uint uStartOffset; Encoding enc = BinaryDataClassifier.GetStringEncoding(m_pbData, false, out strEncodingName, out uStartOffset); string strData = enc.GetString(m_pbData); BlockUIEvents(true); UIUtil.ConfigureTbButton(m_tbFileSave, KPRes.Save, null); UIUtil.ConfigureTbButton(m_tbEditCut, KPRes.Cut, null); UIUtil.ConfigureTbButton(m_tbEditCopy, KPRes.Copy, null); UIUtil.ConfigureTbButton(m_tbEditPaste, KPRes.Paste, null); UIUtil.ConfigureTbButton(m_tbEditUndo, KPRes.Undo, null); UIUtil.ConfigureTbButton(m_tbEditRedo, KPRes.Redo, null); UIUtil.ConfigureTbButton(m_tbFormatBold, KPRes.Bold, null); UIUtil.ConfigureTbButton(m_tbFormatItalic, KPRes.Italic, null); UIUtil.ConfigureTbButton(m_tbFormatUnderline, KPRes.Underline, null); UIUtil.ConfigureTbButton(m_tbFormatStrikeout, KPRes.Strikeout, null); UIUtil.ConfigureTbButton(m_tbColorForeground, KPRes.TextColor, null); UIUtil.ConfigureTbButton(m_tbColorBackground, KPRes.BackgroundColor, null); UIUtil.ConfigureTbButton(m_tbAlignCenter, KPRes.AlignCenter, null); UIUtil.ConfigureTbButton(m_tbAlignLeft, KPRes.AlignLeft, null); UIUtil.ConfigureTbButton(m_tbAlignRight, KPRes.AlignRight, null); m_rtbText.Dock = DockStyle.Fill; m_ctxText.Attach(m_rtbText); m_tssStatusMain.Text = KPRes.Ready; m_rtbText.WordWrap = Program.Config.UI.DataEditorWordWrap; InitFormattingToolBar(); bool bSimpleText = true; if (m_bdc == BinaryDataClass.RichText) { try { m_rtbText.Rtf = strData; bSimpleText = false; } catch (Exception) { } // Show as simple text } if (bSimpleText) { m_rtbText.Text = strData; m_rtbText.SimpleTextOnly = true; if (Program.Config.UI.DataEditorFont.OverrideUIDefault) { m_rtbText.SelectAll(); m_rtbText.SelectionFont = Program.Config.UI.DataEditorFont.ToFont(); } } m_rtbText.Select(0, 0); BlockUIEvents(false); UpdateUIState(false, true); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_vStringDict != null); if (m_vStringDict == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); m_ctxValue.Attach(m_richStringValue, this); string strTitle, strDesc; if (m_strStringName == null) { strTitle = KPRes.AddStringField; strDesc = KPRes.AddStringFieldDesc; } else { strTitle = KPRes.EditStringField; strDesc = KPRes.EditStringFieldDesc; } BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Font, strTitle, strDesc); this.Icon = AppIcons.Default; UIUtil.EnableAutoCompletion(m_cmbStringName, true); UIUtil.PrepareStandardMultilineControl(m_richStringValue, true, true); if (m_strStringName != null) { m_cmbStringName.Text = m_strStringName; } if (m_psStringInitialValue != null) { m_richStringValue.Text = StrUtil.NormalizeNewLines( m_psStringInitialValue.ReadString(), true); UIUtil.SetChecked(m_cbProtect, m_psStringInitialValue.IsProtected); } ValidateStringNameUI(); PopulateNamesComboBox(); if (m_mvec != null) { m_cmbStringName.Enabled = false; MultipleValuesEx.ConfigureText(m_richStringValue, true); bool bMultiProt; m_mvec.MultiStringProt.TryGetValue(m_cmbStringName.Text, out bMultiProt); if (bMultiProt) { MultipleValuesEx.ConfigureState(m_cbProtect, true); } } if (m_bReadOnly) { m_cmbStringName.Enabled = false; m_richStringValue.ReadOnly = true; m_cbProtect.Enabled = false; // m_btnOK.Enabled = false; // See ValidateStringNameUI } // UIUtil.SetFocus(..., this); // See PopulateNamesComboBox }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_vStringDict != null); if (m_vStringDict == null) { throw new InvalidOperationException(); } Debug.Assert(m_atConfig != null); if (m_atConfig == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); m_ctxKeySeq.Attach(m_rbKeySeq); m_ctxKeyCodes.Attach(m_rtbPlaceholders); if (!m_bEditSequenceOnly) { m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width, m_bannerImage.Height, BannerStyle.Default, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureAutoTypeItem, KPRes.ConfigureAutoTypeItemDesc); } else // Edit keystrokes only { m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width, m_bannerImage.Height, BannerStyle.Default, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureKeystrokeSeq, KPRes.ConfigureKeystrokeSeqDesc); } this.Icon = Properties.Resources.KeePass; // m_clrOriginalForeground = m_lblOpenHint.ForeColor; m_clrOriginalBackground = m_cmbWindow.BackColor; // m_strOriginalWindowHint = m_lblTargetWindowInfo.Text; StringBuilder sbPH = new StringBuilder(); sbPH.Append("<b>"); sbPH.Append(KPRes.StandardFields); sbPH.Append(":</b><br />"); sbPH.Append("{" + PwDefs.TitleField + "} "); sbPH.Append("{" + PwDefs.UserNameField + "} "); sbPH.Append("{" + PwDefs.PasswordField + "} "); sbPH.Append("{" + PwDefs.UrlField + "} "); sbPH.Append("{" + PwDefs.NotesField + "}"); bool bCustomInitialized = false; foreach (KeyValuePair <string, ProtectedString> kvp in m_vStringDict) { if (!PwDefs.IsStandardField(kvp.Key)) { if (bCustomInitialized == false) { sbPH.Append("<br /><br /><b>"); sbPH.Append(KPRes.CustomFields); sbPH.Append(":</b><br />"); bCustomInitialized = true; } sbPH.Append("{" + PwDefs.AutoTypeStringPrefix + kvp.Key + "} "); } } sbPH.Append("<br /><br /><b>" + KPRes.KeyboardKeyModifiers + ":</b><br />"); sbPH.Append(KPRes.KeyboardKeyShift + @": +, "); sbPH.Append(KPRes.KeyboardKeyControl + @": ^, "); sbPH.Append(KPRes.KeyboardKeyAlt + @": %"); sbPH.Append("<br /><br /><b>" + KPRes.SpecialKeys + ":</b><br />"); foreach (string strNav in SpecialKeyCodes) { if (strNav == VkcBreak) { sbPH.Append("<br /><br />"); } else { sbPH.Append("{" + strNav + "} "); } } sbPH.Append("<br /><br /><b>" + KPRes.OtherPlaceholders + ":</b><br />"); foreach (string strPH in SpecialPlaceholders) { if (strPH == VkcBreak) { sbPH.Append("<br /><br />"); } else { sbPH.Append("{" + strPH + "} "); } } m_rtbPlaceholders.Rtf = StrUtil.SimpleHtmlToRtf(sbPH.ToString()); LinkifyRtf(m_rtbPlaceholders); if (m_strOriginalName != null) { m_cmbWindow.Text = m_strOriginalName; if (!m_bEditSequenceOnly) { m_rbKeySeq.Text = m_atConfig.GetSafe(m_strOriginalName); } else { m_rbKeySeq.Text = m_atConfig.DefaultSequence; } } m_bBlockUpdates = true; if (m_rbKeySeq.Text.Length > 0) { m_rbSeqCustom.Checked = true; } else { m_rbSeqDefault.Checked = true; } m_bBlockUpdates = false; try { NativeMethods.EnumWindowsProc procEnum = delegate(IntPtr hWnd, IntPtr lParam) { string strName = NativeMethods.GetWindowText(hWnd); if ((strName != null) && (strName.Length > 0)) { if ((NativeMethods.GetWindowStyle(hWnd) & NativeMethods.WS_VISIBLE) != 0) { m_cmbWindow.Items.Add(strName); } } return(true); }; NativeMethods.EnumWindows(procEnum, IntPtr.Zero); } catch (Exception) { Debug.Assert(false); } EnableControlsEx(); m_cmbWindow.Focus(); }
private void OnFormLoad(object sender, EventArgs e) { if (m_dStrings == null) { Debug.Assert(false); throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); string strTitle, strDesc; if (m_strInitName == null) { strTitle = KPRes.AddStringField; strDesc = KPRes.AddStringFieldDesc; } else { strTitle = KPRes.EditStringField; strDesc = KPRes.EditStringFieldDesc; } BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Font, strTitle, strDesc); this.Icon = AppIcons.Default; UIUtil.ConfigureToolTip(m_ttRect); UIUtil.EnableAutoCompletion(m_cmbName, true); UIUtil.PrepareStandardMultilineControl(m_rtbValue, true, true); m_ctxValue.Attach(m_rtbValue, this); GFunc <PwEntry> fGetContextEntry = delegate() { return(PwEntry.CreateVirtual(((m_pdContext != null) ? m_pdContext.RootGroup : null) ?? new PwGroup(true, true), m_dStrings)); }; m_pgm = new PwGeneratorMenu(m_btnGenPw, m_ttRect, m_rtbValue, fGetContextEntry, m_pdContext, (m_mvec != null)); if (m_strInitName != null) { m_cmbName.Text = m_strInitName; } if (m_psInitValue != null) { m_rtbValue.Text = StrUtil.NormalizeNewLines( m_psInitValue.ReadString(), true); UIUtil.SetChecked(m_cbProtect, m_psInitValue.IsProtected); } ValidateStringNameUI(); PopulateNamesComboBox(); if (m_mvec != null) { m_cmbName.Enabled = false; MultipleValuesEx.ConfigureText(m_rtbValue, true); bool bMultiProt; m_mvec.MultiStringProt.TryGetValue(m_cmbName.Text, out bMultiProt); if (bMultiProt) { MultipleValuesEx.ConfigureState(m_cbProtect, true); } } if (m_bReadOnly) { m_cmbName.Enabled = false; m_rtbValue.ReadOnly = true; m_cbProtect.Enabled = false; m_btnGenPw.Enabled = false; // m_btnOK.Enabled = false; // See ValidateStringNameUI } // UIUtil.SetFocus(..., this); // See PopulateNamesComboBox }