Esempio n. 1
0
        internal static void RetrieveFormSettings(frmViewer f)
        {
            if (Utilities.GetAsyncKeyState(0x10) < 0)
            {
                FiddlerApplication._frmSplash.Visible = false;
                if (DialogResult.Yes == MessageBox.Show("SHIFT Key is down. Start with default form layout?", "Safe mode", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    bRevertToDefaultLayout = true;
                    FiddlerApplication._frmSplash.Visible = true;
                    return;
                }
                FiddlerApplication._frmSplash.Visible = true;
            }
            try
            {
                RegistryKey oReg = Registry.CurrentUser.OpenSubKey(GetRegPath("UI"));
                if (oReg != null)
                {
                    bStackedLayout                = Utilities.GetRegistryBool(oReg, "StackedLayout", false);
                    bAutoScroll                   = Utilities.GetRegistryBool(oReg, "AutoScroll", bSmartScroll);
                    bSearchUnmarkOldHits          = Utilities.GetRegistryBool(oReg, "SearchUnmarkOldHits", bSearchUnmarkOldHits);
                    bSmartScroll                  = Utilities.GetRegistryBool(oReg, "SmartScroll", bSmartScroll);
                    bResetCounterOnClear          = Utilities.GetRegistryBool(oReg, "ResetCounterOnClear", bResetCounterOnClear);
                    f.miSessionListScroll.Checked = bAutoScroll;

                    f.Bounds             = new Rectangle(Utilities.GetRegistryInt(oReg, f.Name + "_Left", f.Left), Utilities.GetRegistryInt(oReg, f.Name + "_Top", f.Top), Utilities.GetRegistryInt(oReg, f.Name + "_Width", f.Width), Utilities.GetRegistryInt(oReg, f.Name + "_Height", f.Height));
                    f.pnlSessions.Width  = (int)oReg.GetValue("pnlSessions_Width", f.pnlSessions.Width);
                    f.tabsRequest.Height = (int)oReg.GetValue("tabsRequest_Height", f.tabsRequest.Height);
                }
                new Point(f.Left, f.Top);
                Screen    screen    = Screen.FromRectangle(f.DesktopBounds);
                Rectangle rectangle = Rectangle.Intersect(f.DesktopBounds, screen.WorkingArea);
                if (rectangle.IsEmpty || ((rectangle.Width * rectangle.Height) < ((0.2 * f.Width) * f.Height)))
                {
                    f.SetDesktopLocation(screen.WorkingArea.Left + 20, screen.WorkingArea.Top + 20);
                }
                if (oReg != null)
                {
                    FormWindowState state = (FormWindowState)oReg.GetValue(f.Name + "_WState", f.WindowState);
                    if (state != FormWindowState.Minimized)
                    {
                        f.WindowState = state;
                    }
                    if (f.pnlSessions.Width > (f.Width - 50))
                    {
                        f.pnlSessions.Width = f.Width - 0x2d;
                    }
                    if (f.tabsRequest.Height > (f.Height - 250))
                    {
                        f.tabsRequest.Height = f.Height - 0xf5;
                    }
                    if (f.pnlSessions.Width < 0x19)
                    {
                        f.pnlSessions.Width = 0x19;
                    }
                    if (f.tabsRequest.Height < 0x19)
                    {
                        f.tabsRequest.Height = 0x19;
                    }
                    string[] strArray = null;
                    string   str      = (string)oReg.GetValue("lvSessions_widths");
                    if (str != null)
                    {
                        strArray = str.Split(new char[] { ',' });
                        if ((strArray != null) && (strArray.Length < f.lvSessions.Columns.Count))
                        {
                            strArray = null;
                        }
                    }
                    str = (string)oReg.GetValue("lvSessions_order");
                    if (str != null)
                    {
                        string[] strArray2 = str.Split(new char[] { ',' });
                        int[]    numArray  = new int[strArray2.Length];
                        for (int i = 0; i < strArray2.Length; i++)
                        {
                            numArray[i] = int.Parse(strArray2[i]);
                        }
                        if (numArray.Length >= f.lvSessions.Columns.Count)
                        {
                            for (int j = 0; j < f.lvSessions.Columns.Count; j++)
                            {
                                Utilities.LV_COLUMN lParam = new Utilities.LV_COLUMN {
                                    mask   = 0x20,
                                    iOrder = numArray[j]
                                };
                                Utilities.SendLVMessage(f.lvSessions.Handle, 0x1060, (IntPtr)j, ref lParam);
                                if (strArray != null)
                                {
                                    f.lvSessions.Columns[j].Width = int.Parse(strArray[j]);
                                }
                            }
                        }
                    }
                    oReg.Close();
                }
                if (bStackedLayout)
                {
                    f.actToggleStackedLayout(true);
                }
            }
            catch (Exception)
            {
            }
        }