Esempio n. 1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            GlobalWindowManager.AddWindow(this);

            this.Icon = Properties.Resources.KeePass;
            this.Text = PwDefs.ShortProductName;

            m_pbProgress.Minimum = 0;
            m_pbProgress.Maximum = 100;

            List <Image> lImages = new List <Image>();

            lImages.Add(Properties.Resources.B16x16_MessageBox_Info);
            lImages.Add(Properties.Resources.B16x16_MessageBox_Warning);
            lImages.Add(Properties.Resources.B16x16_MessageBox_Critical);
            lImages.Add(Properties.Resources.B16x16_Transparent);

            m_ilIcons = UIUtil.BuildImageListUnscaled(lImages,
                                                      DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_lvMessages.SmallImageList = m_ilIcons;

            m_lvMessages.Columns.Add(KPRes.Status);

            ProcessResize();
        }
Esempio n. 2
0
		private void RebuildFolderImageList()
		{
			ImageList imgNew = UIUtil.BuildImageListUnscaled(
				m_vFolderImages, m_nIconDim, m_nIconDim);
			m_tvFolders.ImageList = imgNew;

			if(m_ilFolders != null) m_ilFolders.Dispose();
			m_ilFolders = imgNew;
		}
Esempio n. 3
0
        private void BuildFilesList(DirectoryInfo di)
        {
            m_lvFiles.BeginUpdate();
            m_lvFiles.Items.Clear();

            DirectoryInfo[] vDirs;
            FileInfo[]      vFiles;
            try
            {
                vDirs  = di.GetDirectories();
                vFiles = di.GetFiles();
            }
            catch (Exception) { m_lvFiles.EndUpdate(); return; }            // Unauthorized

            foreach (Image imgFile in m_vFileImages)
            {
                imgFile.Dispose();
            }
            m_vFileImages.Clear();

            List <ListViewItem> lDirItems  = new List <ListViewItem>();
            List <ListViewItem> lFileItems = new List <ListViewItem>();

            foreach (DirectoryInfo diSub in vDirs)
            {
                AddFileItem(diSub, m_vFileImages, lDirItems, -1);
            }
            foreach (FileInfo fi in vFiles)
            {
                AddFileItem(fi, m_vFileImages, lFileItems, fi.Length);
            }

            m_lvFiles.SmallImageList = null;
            if (m_ilFiles != null)
            {
                m_ilFiles.Dispose();
            }
            m_ilFiles = UIUtil.BuildImageListUnscaled(m_vFileImages, m_nIconDim, m_nIconDim);
            m_lvFiles.SmallImageList = m_ilFiles;

            lDirItems.Sort(new FbfPrivLviComparer());
            m_lvFiles.Items.AddRange(lDirItems.ToArray());
            lFileItems.Sort(new FbfPrivLviComparer());
            m_lvFiles.Items.AddRange(lFileItems.ToArray());
            m_lvFiles.EndUpdate();

            EnableControlsEx();
        }
Esempio n. 4
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            GlobalWindowManager.AddWindow(this, this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Keyboard_Layout,
                                         KPRes.SelectLanguage, KPRes.SelectLanguageDesc);
            this.Icon = AppIcons.Default;
            this.Text = KPRes.SelectLanguage;

            UIUtil.SetExplorerTheme(m_lvLanguages, true);

            List <Image> lImg = new List <Image>();

            lImg.Add(Properties.Resources.B16x16_Browser);

            m_ilIcons = UIUtil.BuildImageListUnscaled(lImg,
                                                      DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_lvLanguages.SmallImageList = m_ilIcons;

            m_lvLanguages.Columns.Add(KPRes.AvailableLanguages);
            m_lvLanguages.Columns.Add(KPRes.Version);
            m_lvLanguages.Columns.Add(KPRes.Author);
            m_lvLanguages.Columns.Add(KPRes.Contact);

            ListViewItem lvi = m_lvLanguages.Items.Add("English", 0);

            lvi.SubItems.Add(PwDefs.VersionString);
            lvi.SubItems.Add(AppDefs.DefaultTrlAuthor);
            lvi.SubItems.Add(AppDefs.DefaultTrlContact);
            lvi.Tag = string.Empty;
            // UIUtil.SetFocusedItem(m_lvLanguages, lvi, true);

            // The configuration stores the file name only; filter duplicates
            List <string> lNames = new List <string>();

            GetAvailableTranslations(AppConfigSerializer.AppDataDirectory, lNames);
            GetAvailableTranslations(AppConfigSerializer.LocalAppDataDirectory, lNames);

            string strExe  = WinUtil.GetExecutable();
            string strPath = UrlUtil.GetFileDirectory(strExe, false, true);

            GetAvailableTranslations(strPath, lNames);

            UIUtil.ResizeColumns(m_lvLanguages, true);
            UIUtil.SetFocus(m_lvLanguages, this);
        }
Esempio n. 5
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            GlobalWindowManager.AddWindow(this, this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Keyboard_Layout,
                                         KPRes.SelectLanguage, KPRes.SelectLanguageDesc);
            this.Icon = AppIcons.Default;
            this.Text = KPRes.SelectLanguage;

            UIUtil.SetExplorerTheme(m_lvLanguages, true);

            List <Image> lImg = new List <Image>();

            lImg.Add(Properties.Resources.B16x16_Browser);

            m_ilIcons = UIUtil.BuildImageListUnscaled(lImg,
                                                      DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_lvLanguages.SmallImageList = m_ilIcons;

            m_lvLanguages.Columns.Add(KPRes.InstalledLanguages);
            m_lvLanguages.Columns.Add(KPRes.Version);
            m_lvLanguages.Columns.Add(KPRes.Author);
            m_lvLanguages.Columns.Add(KPRes.Contact);
            m_lvLanguages.Columns.Add(KPRes.File);

            KPTranslation trlEng = new KPTranslation();

            trlEng.Properties.NameEnglish        = "English";
            trlEng.Properties.NameNative         = "English";
            trlEng.Properties.ApplicationVersion = PwDefs.VersionString;
            trlEng.Properties.AuthorName         = AppDefs.DefaultTrlAuthor;
            trlEng.Properties.AuthorContact      = AppDefs.DefaultTrlContact;

            string strDirA    = AceApplication.GetLanguagesDir(AceDir.App, false);
            string strDirASep = UrlUtil.EnsureTerminatingSeparator(strDirA, false);
            string strDirU    = AceApplication.GetLanguagesDir(AceDir.User, false);

            List <KeyValuePair <string, KPTranslation> > lTrls =
                new List <KeyValuePair <string, KPTranslation> >();

            lTrls.Add(new KeyValuePair <string, KPTranslation>(string.Empty, trlEng));
            AddTranslations(strDirA, lTrls);
            if (WinUtil.IsAppX)
            {
                AddTranslations(strDirU, lTrls);
            }
            lTrls.Sort(LanguageForm.CompareTrlItems);

            foreach (KeyValuePair <string, KPTranslation> kvp in lTrls)
            {
                KPTranslationProperties p = kvp.Value.Properties;
                string strName            = p.NameEnglish + " (" + p.NameNative + ")";
                string strVer             = PwDefs.GetTranslationDisplayVersion(p.ApplicationVersion);
                bool   bBuiltIn           = ((kvp.Key.Length == 0) || (WinUtil.IsAppX &&
                                                                       kvp.Key.StartsWith(strDirASep, StrUtil.CaseIgnoreCmp)));

                ListViewItem lvi = m_lvLanguages.Items.Add(strName, 0);
                lvi.SubItems.Add(strVer);
                lvi.SubItems.Add(p.AuthorName);
                lvi.SubItems.Add(p.AuthorContact);
                lvi.SubItems.Add(bBuiltIn ? KPRes.BuiltInU : kvp.Key);
                lvi.Tag = kvp.Key;

                // try
                // {
                //	string nl = MessageService.NewLine;
                //	lvi.ToolTipText = strName + " " + strVer + nl + p.AuthorName +
                //		nl + p.AuthorContact + nl + nl + kvp.Key;
                // }
                // catch(Exception) { Debug.Assert(false); } // Too long?

                // if(kvp.Key.Equals(Program.Config.Application.GetLanguageFilePath(),
                //	StrUtil.CaseIgnoreCmp))
                //	UIUtil.SetFocusedItem(m_lvLanguages, lvi, true);
            }

            UIUtil.ResizeColumns(m_lvLanguages, new int[] { 5, 2, 5, 5, 3 }, true);
            UIUtil.SetFocus(m_lvLanguages, this);
        }
Esempio n. 6
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_lInfo == null)
            {
                throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this, this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_WWW, KPRes.UpdateCheck,
                                         KPRes.UpdateCheckResults);
            this.Icon = Properties.Resources.KeePass;
            this.Text = KPRes.UpdateCheck + " - " + PwDefs.ShortProductName;

            UIUtil.SetExplorerTheme(m_lvInfo, true);

            m_lvInfo.Columns.Add(KPRes.Component);
            m_lvInfo.Columns.Add(KPRes.Status);
            m_lvInfo.Columns.Add(KPRes.Installed);
            m_lvInfo.Columns.Add(KPRes.Available);

            List <Image> lImages = new List <Image>();

            lImages.Add(Properties.Resources.B16x16_Help);
            lImages.Add(Properties.Resources.B16x16_Apply);
            lImages.Add(Properties.Resources.B16x16_Redo);
            lImages.Add(Properties.Resources.B16x16_History);
            lImages.Add(Properties.Resources.B16x16_Error);
            m_ilIcons = UIUtil.BuildImageListUnscaled(lImages,
                                                      DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));

            m_lvInfo.SmallImageList = m_ilIcons;

            string        strCat   = string.Empty;
            ListViewGroup lvg      = null;
            const uint    uMinComp = 2;

            foreach (UpdateComponentInfo uc in m_lInfo)
            {
                if (uc.Category != strCat)
                {
                    lvg = new ListViewGroup(uc.Category);
                    m_lvInfo.Groups.Add(lvg);
                    strCat = uc.Category;
                }

                ListViewItem lvi = new ListViewItem(uc.Name);

                string strStatus = KPRes.Unknown + ".";
                if (uc.Status == UpdateComponentStatus.UpToDate)
                {
                    strStatus      = KPRes.UpToDate + ".";
                    lvi.ImageIndex = 1;
                }
                else if (uc.Status == UpdateComponentStatus.NewVerAvailable)
                {
                    strStatus      = KPRes.NewVersionAvailable + "!";
                    lvi.ImageIndex = 2;
                }
                else if (uc.Status == UpdateComponentStatus.PreRelease)
                {
                    strStatus      = KPRes.PreReleaseVersion + ".";
                    lvi.ImageIndex = 3;
                }
                else if (uc.Status == UpdateComponentStatus.DownloadFailed)
                {
                    strStatus      = KPRes.UpdateCheckFailedNoDl;
                    lvi.ImageIndex = 4;
                }
                else
                {
                    lvi.ImageIndex = 0;
                }

                lvi.SubItems.Add(strStatus);
                lvi.SubItems.Add(StrUtil.VersionToString(uc.VerInstalled, uMinComp));

                if ((uc.Status == UpdateComponentStatus.UpToDate) ||
                    (uc.Status == UpdateComponentStatus.NewVerAvailable) ||
                    (uc.Status == UpdateComponentStatus.PreRelease))
                {
                    lvi.SubItems.Add(StrUtil.VersionToString(uc.VerAvailable, uMinComp));
                }
                else
                {
                    lvi.SubItems.Add("?");
                }

                if (lvg != null)
                {
                    lvi.Group = lvg;
                }
                m_lvInfo.Items.Add(lvi);
            }

            UIUtil.ResizeColumns(m_lvInfo, new int[] { 2, 2, 1, 1 }, true);
        }
Esempio n. 7
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_pgDataSource == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            ++m_iBlockPreviewRefresh;

            GlobalWindowManager.AddWindow(this);

            this.Icon = AppIcons.Default;
            CreateDialogBanner();

            List <Image> lTabImg = new List <Image>();

            lTabImg.Add(Properties.Resources.B16x16_XMag);
            lTabImg.Add(Properties.Resources.B16x16_Configure);

            m_ilTabIcons = UIUtil.BuildImageListUnscaled(lTabImg,
                                                         DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_tabMain.ImageList = m_ilTabIcons;

            m_tabPreview.ImageIndex    = 0;
            m_tabDataLayout.ImageIndex = 1;

            UIUtil.SetButtonImage(m_btnConfigPrinter,
                                  Properties.Resources.B16x16_EditCopy, true);
            UIUtil.SetButtonImage(m_btnPrintPreview,
                                  Properties.Resources.B16x16_FileQuickPrint, true);

            FontUtil.AssignDefaultBold(m_rbTabular);
            FontUtil.AssignDefaultBold(m_rbDetails);

            Debug.Assert(!m_cmbSpr.Sorted);
            m_cmbSpr.Items.Add(KPRes.ReplaceNo);
            m_cmbSpr.Items.Add(KPRes.Replace + " (" + KPRes.Slow + ")");
            m_cmbSpr.Items.Add(KPRes.BothForms + " (" + KPRes.Slow + ")");
            m_cmbSpr.SelectedIndex = 0;

            if (!m_bPrintMode)
            {
                m_btnOK.Text = KPRes.Export;
            }

            m_rbTabular.Checked = true;

            m_cmbSortEntries.Items.Add("(" + KPRes.None + ")");
            m_cmbSortEntries.Items.Add(KPRes.Title);
            m_cmbSortEntries.Items.Add(KPRes.UserName);
            m_cmbSortEntries.Items.Add(KPRes.Password);
            m_cmbSortEntries.Items.Add(KPRes.Url);
            m_cmbSortEntries.Items.Add(KPRes.Notes);

            AceColumnType    colType = AceColumnType.Count;
            List <AceColumn> vCols   = Program.Config.MainWindow.EntryListColumns;

            if ((m_nDefaultSortColumn >= 0) && (m_nDefaultSortColumn < vCols.Count))
            {
                colType = vCols[m_nDefaultSortColumn].Type;
            }

            int nSortSel = 0;

            if (colType == AceColumnType.Title)
            {
                nSortSel = 1;
            }
            else if (colType == AceColumnType.UserName)
            {
                nSortSel = 2;
            }
            else if (colType == AceColumnType.Password)
            {
                nSortSel = 3;
            }
            else if (colType == AceColumnType.Url)
            {
                nSortSel = 4;
            }
            else if (colType == AceColumnType.Notes)
            {
                nSortSel = 5;
            }
            m_cmbSortEntries.SelectedIndex = nSortSel;

            if (!m_bPrintMode)            // Export to HTML
            {
                m_btnConfigPrinter.Visible = m_btnPrintPreview.Visible = false;
                m_lblPreviewHint.Visible   = false;
            }

            Program.TempFilesPool.AddWebBrowserPrintContent();

            --m_iBlockPreviewRefresh;
            UpdateWebBrowser(true);
            UpdateUIState();
        }
Esempio n. 8
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            Debug.Assert(m_pgDataSource != null); if (m_pgDataSource == null)
            {
                throw new ArgumentException();
            }

            GlobalWindowManager.AddWindow(this);

            this.Icon = Properties.Resources.KeePass;
            CreateDialogBanner();

            List <Image> lTabImg = new List <Image>();

            lTabImg.Add(Properties.Resources.B16x16_XMag);
            lTabImg.Add(Properties.Resources.B16x16_Configure);

            m_ilTabIcons = UIUtil.BuildImageListUnscaled(lTabImg,
                                                         DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_tabMain.ImageList = m_ilTabIcons;

            m_tabPreview.ImageIndex    = 0;
            m_tabDataLayout.ImageIndex = 1;

            UIUtil.SetButtonImage(m_btnConfigPrinter,
                                  Properties.Resources.B16x16_EditCopy, true);
            UIUtil.SetButtonImage(m_btnPrintPreview,
                                  Properties.Resources.B16x16_FileQuickPrint, true);

            FontUtil.AssignDefaultBold(m_rbTabular);
            FontUtil.AssignDefaultBold(m_rbDetails);

            if (!m_bPrintMode)
            {
                m_btnOK.Text = KPRes.Export;
            }

            m_bBlockPreviewRefresh = true;
            m_rbTabular.Checked    = true;

            m_cmbSortEntries.Items.Add("(" + KPRes.None + ")");
            m_cmbSortEntries.Items.Add(KPRes.Title);
            m_cmbSortEntries.Items.Add(KPRes.UserName);
            m_cmbSortEntries.Items.Add(KPRes.Password);
            m_cmbSortEntries.Items.Add(KPRes.Url);
            m_cmbSortEntries.Items.Add(KPRes.Notes);

            AceColumnType    colType = AceColumnType.Count;
            List <AceColumn> vCols   = Program.Config.MainWindow.EntryListColumns;

            if ((m_nDefaultSortColumn >= 0) && (m_nDefaultSortColumn < vCols.Count))
            {
                colType = vCols[m_nDefaultSortColumn].Type;
            }

            int nSortSel = 0;

            if (colType == AceColumnType.Title)
            {
                nSortSel = 1;
            }
            else if (colType == AceColumnType.UserName)
            {
                nSortSel = 2;
            }
            else if (colType == AceColumnType.Password)
            {
                nSortSel = 3;
            }
            else if (colType == AceColumnType.Url)
            {
                nSortSel = 4;
            }
            else if (colType == AceColumnType.Notes)
            {
                nSortSel = 5;
            }
            m_cmbSortEntries.SelectedIndex = nSortSel;
            m_bBlockPreviewRefresh         = false;

            if (!m_bPrintMode)            // Export to HTML
            {
                m_btnConfigPrinter.Visible = m_btnPrintPreview.Visible = false;
                m_lblPreviewHint.Visible   = false;
            }

            if (!NativeLib.IsUnix())
            {
                // MSHTML may create and forget temporary files under
                // C:\\Users\\USER\\AppData\\Local\\Temp\\*.htm
                // (e.g. when printing fails); we delete these later
                Program.TempFilesPool.AddContent("*.htm", false);
            }

            UpdateHtmlDocument();
            UpdateUIState();
        }
Esempio n. 9
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if ((m_pd == null) && (m_pg == null))
            {
                Debug.Assert(false);
                throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            string strTitle = (m_bExport ? KPRes.ExportFileTitle : KPRes.ImportFileTitle);
            string strDesc  = (m_bExport ? KPRes.ExportFileDesc : KPRes.ImportFileDesc);
            Image  img      = (m_bExport ? Properties.Resources.B48x48_Folder_Txt :
                               Properties.Resources.B48x48_Folder_Download);

            BannerFactory.CreateBannerEx(this, m_bannerImage, img, strTitle, strDesc);

            this.Icon = AppIcons.Default;
            this.Text = strTitle;

            m_lvFormats.ShowGroups = true;

            int w = m_lvFormats.ClientSize.Width - UIUtil.GetVScrollBarWidth();

            m_lvFormats.Columns.Add(string.Empty, w - 1);

            List <Image> lImages = new List <Image>();
            Dictionary <string, FormatGroupEx> dictGroups =
                new Dictionary <string, FormatGroupEx>();

            foreach (FileFormatProvider f in Program.FileFormatPool)
            {
                if (m_bExport && !f.SupportsExport)
                {
                    continue;
                }
                if (!m_bExport && !f.SupportsImport)
                {
                    continue;
                }

                string strDisplayName = f.DisplayName;
                if (string.IsNullOrEmpty(strDisplayName))
                {
                    Debug.Assert(false); continue;
                }

                string strAppGroup = f.ApplicationGroup;
                if (string.IsNullOrEmpty(strAppGroup))
                {
                    strAppGroup = KPRes.General;
                }

                FormatGroupEx grp;
                if (!dictGroups.TryGetValue(strAppGroup, out grp))
                {
                    grp = new FormatGroupEx(strAppGroup);
                    dictGroups[strAppGroup] = grp;
                }

                ListViewItem lvi = new ListViewItem(strDisplayName);
                lvi.Group = grp.Group;
                lvi.Tag   = f;

                Image imgSmallIcon = f.SmallIcon;
                if (imgSmallIcon == null)
                {
                    imgSmallIcon = Properties.Resources.B16x16_Folder_Inbox;
                }

                lvi.ImageIndex = lImages.Count;
                lImages.Add(imgSmallIcon);

                grp.Items.Add(lvi);
            }

            foreach (FormatGroupEx formatGroup in dictGroups.Values)
            {
                m_lvFormats.Groups.Add(formatGroup.Group);
                foreach (ListViewItem lvi in formatGroup.Items)
                {
                    m_lvFormats.Items.Add(lvi);
                }
            }

            m_ilFormats = UIUtil.BuildImageListUnscaled(lImages,
                                                        DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_lvFormats.SmallImageList = m_ilFormats;

            if (m_bExport)
            {
                m_grpFiles.Text = KPRes.Destination;
                UIUtil.SetText(m_lblFiles, KPRes.File + ":");
                UIUtil.SetButtonImage(m_btnSelFile,
                                      Properties.Resources.B16x16_FileSaveAs, false);

                m_lnkFileFormats.Enabled = false;
                m_lnkFileFormats.Visible = false;
            }
            else             // Import
            {
                m_grpFiles.Text = KPRes.Source;
                UIUtil.SetButtonImage(m_btnSelFile,
                                      Properties.Resources.B16x16_Folder_Yellow_Open, false);

                m_grpExport.Enabled     = false;
                m_grpExportPost.Enabled = false;
            }

            m_cbExportMasterKeySpec.Checked = Program.Config.Defaults.ExportMasterKeySpec;
            m_cbExportParentGroups.Checked  = Program.Config.Defaults.ExportParentGroups;
            m_cbExportPostOpen.Checked      = Program.Config.Defaults.ExportPostOpen;
            m_cbExportPostShow.Checked      = Program.Config.Defaults.ExportPostShow;

            CustomizeForScreenReader();
            UpdateUIState();
        }