コード例 #1
0
        internal void OnLoad()
        {
            AceMainWindow aceMainWindow = this.MainWindow;  // m_uiMainWindow might be null
            AceDefaults   aceDef        = this.Defaults;    // m_def might be null

            // aceInt.UrlSchemeOverrides.SetDefaultsIfEmpty();

            ObfuscateCred(false);
            ChangePathsRelAbs(true);

            // Remove invalid columns
            List <AceColumn> vColumns = aceMainWindow.EntryListColumns;
            int i = 0;

            while (i < vColumns.Count)
            {
                if (((int)vColumns[i].Type < 0) || ((int)vColumns[i].Type >=
                                                    (int)AceColumnType.Count))
                {
                    vColumns.RemoveAt(i);
                }
                else
                {
                    ++i;
                }
            }

            SearchUtil.FinishDeserialize(aceDef.SearchParameters);
        }
コード例 #2
0
ファイル: AppConfigEx.cs プロジェクト: mario2100/KeePass2.x
        internal void OnLoad()
        {
            AceMainWindow aceMW  = this.MainWindow;         // m_uiMainWindow might be null
            AceDefaults   aceDef = this.Defaults;           // m_def might be null

            // aceInt.UrlSchemeOverrides.SetDefaultsIfEmpty();

            ObfuscateCred(false);
            ChangePathsRelAbs(true);

            // Remove invalid columns
            List <AceColumn> vColumns = aceMW.EntryListColumns;
            int i = 0;

            while (i < vColumns.Count)
            {
                if (((int)vColumns[i].Type < 0) || ((int)vColumns[i].Type >=
                                                    (int)AceColumnType.Count))
                {
                    vColumns.RemoveAt(i);
                }
                else
                {
                    ++i;
                }
            }

            SearchUtil.FinishDeserialize(aceDef.SearchParameters);
            DpiScale();

            if (aceMW.EscMinimizesToTray)            // For backward compatibility
            {
                aceMW.EscMinimizesToTray = false;    // Default value
                aceMW.EscAction          = AceEscAction.MinimizeToTray;
            }

            if (NativeLib.IsUnix())
            {
                this.Security.MasterKeyOnSecureDesktop = false;

                AceIntegration aceInt = this.Integration;
                aceInt.HotKeyGlobalAutoType   = (ulong)Keys.None;
                aceInt.HotKeySelectedAutoType = (ulong)Keys.None;
                aceInt.HotKeyShowWindow       = (ulong)Keys.None;
            }

            if (MonoWorkarounds.IsRequired(1378))
            {
                AceWorkspaceLocking aceWL = this.Security.WorkspaceLocking;
                aceWL.LockOnSessionSwitch       = false;
                aceWL.LockOnSuspend             = false;
                aceWL.LockOnRemoteControlChange = false;
            }

            if (MonoWorkarounds.IsRequired(1418))
            {
                aceMW.MinimizeAfterOpeningDatabase        = false;
                this.Application.Start.MinimizedAndLocked = false;
            }
        }
コード例 #3
0
ファイル: AppConfigEx.cs プロジェクト: kkato233/KeePass
        private void DpiScale()
        {
            AceMeta aceMeta = this.Meta;             // m_meta might be null
            double  dCfgX = aceMeta.DpiFactorX, dCfgY = aceMeta.DpiFactorY;
            double  dScrX = DpiUtil.FactorX, dScrY = DpiUtil.FactorY;

            if ((dScrX == dCfgX) && (dScrY == dCfgY))
            {
                return;
            }

            // When this method returns, all positions and sizes are in pixels
            // for the current screen DPI
            aceMeta.DpiFactorX = dScrX;
            aceMeta.DpiFactorY = dScrY;

            // Backward compatibility; configuration files created by KeePass
            // 2.37 and earlier do not contain DpiFactor* values, they default
            // to 0.0 and all positions and sizes are in pixels for the current
            // screen DPI; so, do not perform any DPI scaling in this case
            if ((dCfgX == 0.0) || (dCfgY == 0.0))
            {
                return;
            }

            double           sX = dScrX / dCfgX, sY = dScrY / dCfgY;
            GFunc <int, int> fX = delegate(int x)
            {
                return((int)Math.Round((double)x * sX));
            };
            GFunc <int, int> fY = delegate(int y)
            {
                return((int)Math.Round((double)y * sY));
            };
            GFunc <string, string> fWsr = delegate(string strRect)
            {
                return(UIUtil.ScaleWindowScreenRect(strRect, sX, sY));
            };
            GFunc <string, string> fVX = delegate(string strArray)
            {
                if (string.IsNullOrEmpty(strArray))
                {
                    return(strArray);
                }

                try
                {
                    int[] v = StrUtil.DeserializeIntArray(strArray);
                    if (v == null)
                    {
                        Debug.Assert(false); return(strArray);
                    }

                    for (int i = 0; i < v.Length; ++i)
                    {
                        v[i] = (int)Math.Round((double)v[i] * sX);
                    }

                    return(StrUtil.SerializeIntArray(v));
                }
                catch (Exception) { Debug.Assert(false); }

                return(strArray);
            };
            Action <AceFont> fFont = delegate(AceFont f)
            {
                if (f == null)
                {
                    Debug.Assert(false); return;
                }

                if (f.GraphicsUnit == GraphicsUnit.Pixel)
                {
                    f.Size = (float)(f.Size * sY);
                }
            };

            AceMainWindow mw = this.MainWindow;
            AceUI         ui = this.UI;

            if (mw.X != AppDefs.InvalidWindowValue)
            {
                mw.X = fX(mw.X);
            }
            if (mw.Y != AppDefs.InvalidWindowValue)
            {
                mw.Y = fY(mw.Y);
            }
            if (mw.Width != AppDefs.InvalidWindowValue)
            {
                mw.Width = fX(mw.Width);
            }
            if (mw.Height != AppDefs.InvalidWindowValue)
            {
                mw.Height = fY(mw.Height);
            }

            foreach (AceColumn c in mw.EntryListColumns)
            {
                if (c.Width >= 0)
                {
                    c.Width = fX(c.Width);
                }
            }

            ui.DataViewerRect          = fWsr(ui.DataViewerRect);
            ui.DataEditorRect          = fWsr(ui.DataEditorRect);
            ui.CharPickerRect          = fWsr(ui.CharPickerRect);
            ui.AutoTypeCtxRect         = fWsr(ui.AutoTypeCtxRect);
            ui.AutoTypeCtxColumnWidths = fVX(ui.AutoTypeCtxColumnWidths);

            fFont(ui.StandardFont);
            fFont(ui.PasswordFont);
            fFont(ui.DataEditorFont);
        }
コード例 #4
0
 private void SaveDisplayIndex(AceMainWindow mw, string strColID,
     AppDefs.ColumnId colID)
 {
     mw.ColumnsDict[strColID].DisplayIndex =
         m_lvEntries.Columns[(int)colID].DisplayIndex;
 }
コード例 #5
0
        private void RestoreDisplayIndex(AceMainWindow mw, string strColID,
            AppDefs.ColumnId colID)
        {
            try
            {
                int nIndex = mw.ColumnsDict[strColID].DisplayIndex;

                if((nIndex >= 0) && (nIndex < (int)AppDefs.ColumnId.Count))
                    m_lvEntries.Columns[(int)colID].DisplayIndex = nIndex;
            }
            catch(Exception) { Debug.Assert(false); }
        }