Beispiel #1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            Debug.Assert((m_pwDatabaseInfo != null) || (m_pgRootInfo != null));
            if((m_pwDatabaseInfo == null) && (m_pgRootInfo == null))
                throw new InvalidOperationException();

            GlobalWindowManager.AddWindow(this);

            string strWndTitle = (m_bExport ? KPRes.ExportFileTitle : KPRes.ImportFileTitle);
            string strWndDesc = (m_bExport ? KPRes.ExportFileDesc : KPRes.ImportFileDesc);
            Bitmap bmpBanner = (m_bExport ? Properties.Resources.B48x48_Folder_Txt :
                Properties.Resources.B48x48_Folder_Download);
            m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width,
                m_bannerImage.Height, BannerStyle.Default, bmpBanner, strWndTitle, strWndDesc);
            this.Icon = Properties.Resources.KeePass;

            this.Text = strWndTitle;

            if(m_bExport)
            {
                m_lblFile.Text = KPRes.ExportToPrompt;
                UIUtil.SetButtonImage(m_btnSelFile,
                    Properties.Resources.B16x16_FileSaveAs, false);

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

            m_lvFormats.ShowGroups = true;
            m_lvFormats.Columns.Add(string.Empty);
            m_lvFormats.Columns[0].Width = m_lvFormats.ClientRectangle.Width -
                UIUtil.GetVScrollBarWidth() - 1;

            ImageList ilFormats = new ImageList();
            ilFormats.ColorDepth = ColorDepth.Depth32Bit;
            ilFormats.ImageSize = new Size(16, 16);

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

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

                string strDisplayName = f.DisplayName;
                if((strDisplayName == null) || (strDisplayName.Length == 0))
                    continue;

                string strAppGroup = f.ApplicationGroup;
                if((strAppGroup == null) || (strAppGroup.Length == 0))
                    strAppGroup = KPRes.General;

                FormatGroupEx grp;
                if(!dictGroups.TryGetValue(strAppGroup, out grp))
                {
                    grp = new FormatGroupEx(strAppGroup);
                    dictGroups.Add(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;

                ilFormats.Images.Add(imgSmallIcon);
                lvi.ImageIndex = ilFormats.Images.Count - 1;

                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_lvFormats.SmallImageList = ilFormats;

            CustomizeForScreenReader();
            UpdateUIState();
        }
Beispiel #2
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            Debug.Assert((m_pwDatabaseInfo != null) || (m_pgRootInfo != null));
            if ((m_pwDatabaseInfo == null) && (m_pgRootInfo == null))
            {
                throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            string strWndTitle = (m_bExport ? KPRes.ExportFileTitle : KPRes.ImportFileTitle);
            string strWndDesc  = (m_bExport ? KPRes.ExportFileDesc : KPRes.ImportFileDesc);
            Bitmap bmpBanner   = (m_bExport ? Properties.Resources.B48x48_Folder_Txt :
                                  Properties.Resources.B48x48_Folder_Download);

            m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width,
                                                             m_bannerImage.Height, BannerStyle.Default, bmpBanner, strWndTitle, strWndDesc);
            this.Icon = Properties.Resources.KeePass;

            this.Text = strWndTitle;

            if (m_bExport)
            {
                m_lblFile.Text = KPRes.ExportToPrompt;
                UIUtil.SetButtonImage(m_btnSelFile,
                                      Properties.Resources.B16x16_FileSaveAs, false);

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

            m_lvFormats.ShowGroups = true;
            m_lvFormats.Columns.Add(string.Empty);
            m_lvFormats.Columns[0].Width = m_lvFormats.ClientRectangle.Width -
                                           UIUtil.GetVScrollBarWidth() - 1;

            ImageList ilFormats = new ImageList();

            ilFormats.ColorDepth = ColorDepth.Depth32Bit;
            ilFormats.ImageSize  = new Size(16, 16);

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

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

                string strDisplayName = f.DisplayName;
                if ((strDisplayName == null) || (strDisplayName.Length == 0))
                {
                    continue;
                }

                string strAppGroup = f.ApplicationGroup;
                if ((strAppGroup == null) || (strAppGroup.Length == 0))
                {
                    strAppGroup = KPRes.General;
                }

                FormatGroupEx grp;
                if (!dictGroups.TryGetValue(strAppGroup, out grp))
                {
                    grp = new FormatGroupEx(strAppGroup);
                    dictGroups.Add(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;
                }

                ilFormats.Images.Add(imgSmallIcon);
                lvi.ImageIndex = ilFormats.Images.Count - 1;

                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_lvFormats.SmallImageList = ilFormats;

            CustomizeForScreenReader();
            UpdateUIState();
        }
Beispiel #3
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();
        }