public void CreateConfig(string name, string category, string author) { // Build the base config structure var settings = new ConfigSettings(); settings.Name = name; settings.Author = author; var newConfig = new ConfigViewModel(string.Empty, name, category, new Config(settings, string.Empty)); // Add it to the collection and persistent storage vm.Add(newConfig); vm.CurrentConfig = newConfig; var newStackerVM = new StackerViewModel(vm.CurrentConfig); if (SB.MainWindow.ConfigsPage.StackerPage != null) // Maintain the previous stacker settings { newStackerVM.TestData = SB.Stacker.TestData; newStackerVM.TestProxy = SB.Stacker.TestProxy; newStackerVM.ProxyType = SB.Stacker.ProxyType; } SB.Stacker = newStackerVM; SB.MainWindow.ConfigsPage.StackerPage = new Stacker(); // Create a Stacker instance SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance"); SB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance"); SB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null); // Switch to Stacker }
public void LoadConfig(ConfigViewModel config) { if (config == null) { SB.Logger.LogError(Components.ConfigManager, "The config to load cannot be null", true); return; } try { SBIOManager.CheckRequiredPlugins(SB.BlockPlugins.Select(b => b.Name), config.Config); } catch (Exception ex) { SB.Logger.LogError(Components.ConfigManager, ex.Message, true); return; } // Set the config as current vm.CurrentConfig = config; if (vm.CurrentConfig.Remote) { SB.Logger.LogError(Components.ConfigManager, "The config was pulled from a remote source and cannot be edited!", true); vm.CurrentConfig = null; return; } SB.Logger.LogInfo(Components.ConfigManager, "Loading config: " + vm.CurrentConfig.Name); SB.MainWindow.ConfigsPage.menuOptionStacker.IsEnabled = true; SB.MainWindow.ConfigsPage.menuOptionOtherOptions.IsEnabled = true; var newStackerVM = new StackerViewModel(vm.CurrentConfig); // Preserve the old stacker test data and proxy if (SB.MainWindow.ConfigsPage.StackerPage != null) { newStackerVM.TestData = SB.Stacker.TestData; newStackerVM.TestProxy = SB.Stacker.TestProxy; newStackerVM.ProxyType = SB.Stacker.ProxyType; } SB.Stacker = newStackerVM; SB.MainWindow.ConfigsPage.StackerPage = new Stacker(); // Create a Stacker instance SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance"); SB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance"); SB.MainWindow.ConfigsPage.ConfigOcrSettings = new ConfigOcrSettings(); // Create an Ocr Testing instance SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Ocr Testing instance"); SB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null); // Switch to Stacker // Save the last state of the config SB.MainWindow.ConfigsPage.StackerPage.SetScript(); SaveState(); }
public Stacker() { vm = OB.Stacker; DataContext = vm; InitializeComponent(); // Style the LoliScript editor loliScriptEditor.ShowLineNumbers = true; loliScriptEditor.TextArea.Foreground = new SolidColorBrush(Colors.Gainsboro); loliScriptEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue); using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd")) { loliScriptEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } // Load the Syntax Helper XML XmlDocument doc = new XmlDocument(); try { doc.Load("SyntaxHelper.xml"); var main = doc.DocumentElement.SelectSingleNode("/doc"); syntaxHelperItems = main.ChildNodes; // Only bind the keydown event if the XML was successfully loaded loliScriptEditor.KeyDown += loliScriptEditor_KeyDown; } catch { } // Make the Avalon Editor for Syntax Helper and style it toolTipEditor = new TextEditor(); toolTipEditor.TextArea.Foreground = Utils.GetBrush("ForegroundMain"); toolTipEditor.Background = new SolidColorBrush(Color.FromArgb(22, 22, 22, 50)); toolTipEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue); toolTipEditor.FontSize = 11; toolTipEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; toolTipEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd")) { toolTipEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } toolTip = new ToolTip { Placement = PlacementMode.Relative, PlacementTarget = loliScriptEditor }; toolTip.Content = toolTipEditor; loliScriptEditor.ToolTip = toolTip; // Load the script vm.LS = new LoliScript(OB.ConfigManager.CurrentConfig.Config.Script); loliScriptEditor.Text = vm.LS.Script; // If the user prefers Stack view, switch to it if (!OB.OBSettings.General.DisplayLoliScriptOnLoad) { stackButton_Click(this, null); } // Style the logRTB logRTB.Font = new System.Drawing.Font("Consolas", 10); logRTB.BackColor = System.Drawing.Color.FromArgb(22, 22, 22); // Hook the context menu to the logRTB System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu(); System.Windows.Forms.MenuItem item = new System.Windows.Forms.MenuItem(); item.Text = "Clear"; item.Click += ClearDebuggerLog; menu.MenuItems.Add(item); logRTB.ContextMenu = menu; logRTB.MouseClick += DebuggerLogRightClick; foreach (string i in Enum.GetNames(typeof(ProxyType))) { if (i != "Chain") { proxyTypeCombobox.Items.Add(i); } } proxyTypeCombobox.SelectedIndex = 0; foreach (var t in OB.Settings.Environment.GetWordlistTypeNames()) { testDataTypeCombobox.Items.Add(t); } testDataTypeCombobox.SelectedIndex = 0; // Initialize debugger debugger.WorkerSupportsCancellation = true; debugger.Status = WorkerStatus.Idle; debugger.DoWork += new DoWorkEventHandler(debuggerCheck); debugger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(debuggerCompleted); this.SaveConfig += OB.MainWindow.ConfigsPage.ConfigManagerPage.OnSaveConfig; }
public Stacker() { vm = SB.Stacker; DataContext = vm; if (!Cef.IsInitialized) { App.InitializeCefSharp(null); } InitializeComponent(); htmlViewBrowser.MenuHandler = new CustomMenuHandler(); htmlViewBrowser.FrameLoadEnd += htmlViewBrowser_FrameLoadEnd; htmlViewBrowser.LoadingStateChanged += htmlViewBrowser_LoadingStateChanged; htmlViewBrowser.StatusMessage += htmlViewBrowser_StatusMessage; // Style the LoliScript editor loliScriptEditor.ShowLineNumbers = true; loliScriptEditor.TextArea.Foreground = new SolidColorBrush(Colors.Gainsboro); loliScriptEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue); using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd")) { loliScriptEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } // Load the Syntax Helper XML XmlDocument doc = new XmlDocument(); try { doc.Load("SyntaxHelper.xml"); var main = doc.DocumentElement.SelectSingleNode("/doc"); syntaxHelperItems = main.ChildNodes; // Only bind the keydown event if the XML was successfully loaded loliScriptEditor.KeyDown += loliScriptEditor_KeyDown; } catch { } // Make the Avalon Editor for Syntax Helper and style it toolTipEditor = new TextEditor(); toolTipEditor.TextArea.Foreground = Utils.GetBrush("ForegroundMain"); toolTipEditor.Background = new SolidColorBrush(Color.FromArgb(22, 22, 22, 50)); toolTipEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue); toolTipEditor.FontSize = 11; toolTipEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; toolTipEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd")) { toolTipEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } toolTip = new ToolTip { Placement = PlacementMode.Relative, PlacementTarget = loliScriptEditor }; toolTip.Content = toolTipEditor; loliScriptEditor.ToolTip = toolTip; // Load the script vm.LS = new LoliScript(SB.ConfigManager.CurrentConfig.Config.Script); loliScriptEditor.Text = vm.LS.Script; // If the user prefers Stack view, switch to it if (!SB.OBSettings.General.DisplayLoliScriptOnLoad) { stackButton_Click(this, null); } logRTB.TextArea.TextView.LinkTextUnderline = false; logRTB.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue); logRTB.Options.EnableEmailHyperlinks = false; logRTB.Options.EnableImeSupport = false; logRTB.Options.CutCopyWholeLine = false; logRTB.Options.EnableTextDragDrop = false; logRTB.Options.EnableVirtualSpace = false; logRTB.Options.ShowTabs = false; logRTB.TextArea.TextView.Triggers.Clear(); logRTB.Options.EnableRectangularSelection = false; searchTextEditor = SearchTextEditor.Install(logRTB); foreach (string i in Enum.GetNames(typeof(ProxyType))) { if (i != "Chain") { proxyTypeCombobox.Items.Add(i); } } proxyTypeCombobox.SelectedIndex = 0; foreach (var t in SB.Settings.Environment.GetWordlistTypeNames()) { testDataTypeCombobox.Items.Add(t); } testDataTypeCombobox.SelectedIndex = 0; // Initialize debugger debugger.WorkerSupportsCancellation = true; debugger.Status = WorkerStatus.Idle; debugger.DoWork += new DoWorkEventHandler(DebuggerCheck); debugger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(debuggerCompleted); SaveConfig += SB.MainWindow.ConfigsPage.ConfigManagerPage.OnSaveConfig; //Any CefSharp references have to be in another method with NonInlining // attribute so the assembly rolver has time to do it's thing. // loliScriptEditor.TextArea.TextEntered += TextArea_TextEntered; }