Example #1
0
        internal static void SaveSettings(frmViewer f)
        {
            if (!bIsViewOnly)
            {
                RegistryKey oReg = Registry.CurrentUser.CreateSubKey(GetRegPath("UI"));
                oReg.SetValue("StackedLayout", bStackedLayout);
                oReg.SetValue("AutoScroll", bAutoScroll);
                oReg.SetValue("SmartScroll", bSmartScroll);
                oReg.SetValue("SearchUnmarkOldHits", bSearchUnmarkOldHits);
                oReg.SetValue("ResetCounterOnClear", bResetCounterOnClear);
                oReg.SetValue(f.Name + "_WState", (int)f.WindowState);
                if (f.WindowState != FormWindowState.Normal)
                {
                    if (!f.Visible)
                    {
                        f.Visible = true;
                    }
                    f.WindowState = FormWindowState.Normal;
                }
                oReg.SetValue(f.Name + "_Top", f.Top);
                oReg.SetValue(f.Name + "_Left", f.Left);
                oReg.SetValue(f.Name + "_Height", f.Height);
                oReg.SetValue(f.Name + "_Width", f.Width);

                oReg.SetValue("tabsRequest_Height", f.tabsRequest.Height);
                string str = string.Empty;
                foreach (ColumnHeader header in f.lvSessions.Columns)
                {
                    Utilities.LV_COLUMN lParam = new Utilities.LV_COLUMN {
                        mask = 0x20
                    };
                    Utilities.SendLVMessage(f.lvSessions.Handle, 0x105f, (IntPtr)header.Index, ref lParam);
                    str = str + lParam.iOrder.ToString() + ",";
                }
                oReg.SetValue("lvSessions_order", str.Substring(0, str.Length - 1));
                str = string.Empty;
                foreach (ColumnHeader header2 in f.lvSessions.Columns)
                {
                    str = str + header2.Width.ToString() + ",";
                }
                oReg.SetValue("lvSessions_widths", str.Substring(0, str.Length - 1));
                oReg.Close();
                oReg = Registry.CurrentUser.CreateSubKey(sRootKey);
                oReg.SetValue("StartupCount", iStartupCount);
                Utilities.SetRegistryString(oReg, "FontSize", flFontSize.ToString(CultureInfo.InvariantCulture));
                oReg.SetValue("colorDisabledEdit", colorDisabledEdit.ToArgb());
                oReg.SetValue("AttachOnBoot", bAttachOnBoot);
                oReg.SetValue("AllowRemote", m_bAllowRemoteConnections);
                oReg.SetValue("ReuseServerSockets", bReuseServerSockets);
                oReg.SetValue("ReuseClientSockets", bReuseClientSockets);
                Utilities.SetRegistryString(oReg, "FiddlerBypass", sHostsThatBypassFiddler);
                oReg.SetValue("ReportHTTPErrors", bReportHTTPErrors);
                oReg.SetValue("UseGateway", bForwardToGateway);
                oReg.SetValue("CaptureCONNECT", bCaptureCONNECT);
                oReg.SetValue("CaptureFTP", bCaptureFTP);
                oReg.SetValue("EnableIPv6", bEnableIPv6);
                oReg.SetValue("BreakOnImages", bBreakOnImages);
                oReg.SetValue("MapSocketToProcess", bMapSocketToProcess);
                oReg.SetValue("UseAESForSaz", bUseAESForSAZ);
                oReg.SetValue("AutoStreamAudioVideo", bStreamAudioVideo);
                oReg.SetValue("CaptureHTTPS", bMITM_HTTPS);
                oReg.SetValue("IgnoreServerCertErrors", bIgnoreServerCertErrors);
                oReg.SetValue("CheckForUpdates", bVersionCheck);
                oReg.SetValue("HookAllConnections", bHookAllConnections);
                oReg.SetValue("HookWithPAC", bHookWithPAC);
                oReg.SetValue("ShowProcessFilter", (int)iShowProcessFilter);
                oReg.SetValue("AutoReloadScript", bAutoLoadScript);
                oReg.SetValue("HideOnMinimize", bHideOnMinimize);
                oReg.SetValue("AlwaysShowTrayIcon", bAlwaysShowTrayIcon);
                if (!bUsingPortOverride)
                {
                    oReg.SetValue("ListenPort", m_ListenPort);
                }
                oReg.SetValue("HotkeyMod", iHotkeyMod);
                oReg.SetValue("Hotkey", iHotkey);
                oReg.SetValue("CheckForISA", m_bCheckForISA);
                Utilities.SetRegistryString(oReg, "ScriptReferences", m_sAdditionalScriptReferences);
                Utilities.SetRegistryString(oReg, "JSEditor", m_JSEditor);
            }
        }
Example #2
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)
            {
            }
        }