public override void OnButtonUp(DeckDevice deckDevice) { if (OBSUtils.IsConnected && !string.IsNullOrEmpty(SceneName)) { OBSUtils.SwitchScene(SceneName); } }
private void OBSSceneItemVisibilityHelper_Load(object sender, EventArgs e) { comboBox1.Text = ModifiableAction.SceneName; comboBox2.Text = ModifiableAction.SceneItem; Thread th = new Thread(() => { if (!OBSUtils.IsConnected) { OBSUtils.ConnectToServer(); } if (OBSUtils.IsConnected) { Thread th2 = new Thread(() => { var scenes = OBSUtils.GetOBSScenes(); comboBox1.Invoke(new Action(() => { comboBox1.Items.AddRange(scenes.Select(c => c.SceneName).ToArray()); scenes.All(s => { comboBox1.TextChanged += (ss, ee) => { if (comboBox1.Text == s.SceneName) { comboBox2.Items.Clear(); comboBox2.Items.AddRange(s.SceneItems.Select(cc => cc.ItemName).ToArray()); } }; return(true); }); comboBox1.Text = comboBox1.Text; })); }); th2.Start(); } }); th.Start(); }
public override void OnButtonUp(DeckDevice deckDevice) { if (OBSUtils.IsConnected) { switch (StreamAction) { case StreamingState.Start: OBSUtils.StartStreaming(); break; case StreamingState.Stop: OBSUtils.StopStreaming(); break; case StreamingState.Toggle: switch (ToggleStreamingAction) { case StreamingStateToggle.Stopped: ToggleStreamingAction = StreamingStateToggle.Recording; OBSUtils.StartRecording(); IDeckHelper.setVariable(false, atual_item, deckDevice); break; case StreamingStateToggle.Recording: ToggleStreamingAction = StreamingStateToggle.Stopped; OBSUtils.StopRecording(); IDeckHelper.setVariable(true, atual_item, deckDevice); break; } break; } } }
public override void OnButtonUp(DeckDevice deckDevice) { if (string.IsNullOrEmpty(SceneItem) || string.IsNullOrEmpty(SceneName)) { return; } OBSUtils.SetSceneItemVisibility(SceneItem, SceneName, ItemVisibilityStatus == ItemVisibility.Visible); }
public override void OnButtonUp(DeckDevice deckDevice) { if (OBSUtils.IsConnected) { switch (RecordAction) { case RecordingState.Start: OBSUtils.StartRecording(); break; case RecordingState.Stop: OBSUtils.StopRecording(); break; } } }
public override void OnButtonUp(DeckDevice deckDevice) { if (OBSUtils.IsConnected) { switch (StreamAction) { case StreamingState.Start: OBSUtils.StartStreaming(); break; case StreamingState.Stop: OBSUtils.StopStreaming(); break; } } }
private void OBSSceneChangeHelper_Load(object sender, EventArgs e) { comboBox1.Text = ModifiableAction.SceneName; Thread th = new Thread(() => { if (!OBSUtils.IsConnected) { OBSUtils.ConnectToServer(); } if (OBSUtils.IsConnected) { Thread th2 = new Thread(() => { var scenes = OBSUtils.GetScenes(); comboBox1.Invoke(new Action(() => { comboBox1.Items.AddRange(scenes.ToArray()); })); }); th2.Start(); } }); th.Start(); }
static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(errorFileName)); Trace.AutoFlush = true; if (args.Any(c => c.ToLower() == "/armobs")) { if (args.Length == 1) { var obs32List = Process.GetProcessesByName("obs32"); var obs64List = Process.GetProcessesByName("obs64"); if (obs32List.Length == 0 && obs64List.Length == 0) { //No OBS found. Cancel operation. File.Delete(OBSUtils.obswszip); return; } List <Process> obsProcesses = new List <Process>(); obsProcesses.AddRange(obs32List); obsProcesses.AddRange(obs64List); if (obsProcesses.Count != 1) { //Multiple OBS instances found. Cancel operation. File.Delete(OBSUtils.obswszip); return; } var obsProcess = obsProcesses.First(); string path = OBSUtils.GetProcessPath(obsProcess.Id); string zipTempPath = Path.GetFileNameWithoutExtension(OBSUtils.obswszip); OBSUtils.ExtractZip(OBSUtils.obswszip, zipTempPath); OBSUtils.DirectoryCopy(zipTempPath, OBSUtils.GetPathFromOBSExecutable(path), true); File.Delete(OBSUtils.obswszip); Directory.Delete(zipTempPath, true); var obsGlobalFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "obs-studio", "global.ini"); if (File.Exists(obsGlobalFilePath) && !File.ReadAllText(obsGlobalFilePath).Contains("[WebsocketAPI]")) { Trace.WriteLine("File exist and not contain web socket."); while (!obsProcess.HasExited) { StringBuilder sb = new StringBuilder(); sb.AppendLine(Texts.rm.GetString("OBSINTEGRATIONINSTALL", Texts.cultereinfo)); sb.AppendLine(""); sb.AppendLine(Texts.rm.GetString("OBSINTEGRATIONAPPLY", Texts.cultereinfo)); MessageBox.Show(sb.ToString()); } using (StreamWriter outputFile = new StreamWriter(obsGlobalFilePath)) { outputFile.WriteLine(""); outputFile.WriteLine("[WebsocketAPI]"); outputFile.WriteLine("ServerPort=4444"); outputFile.WriteLine("DebugEnabled=false"); outputFile.WriteLine("AlertsEnabled=false"); outputFile.WriteLine("AuthRequired=false"); } bool shouldRepeat = true; while (shouldRepeat) { var obs32List2 = Process.GetProcessesByName("obs32"); var obs64List2 = Process.GetProcessesByName("obs64"); shouldRepeat = obs32List2.Length == 0 && obs64List2.Length == 0; if (!shouldRepeat) { break; } StringBuilder sb = new StringBuilder(); sb.AppendLine(Texts.rm.GetString("OBSINTEGRATIONINSTALLSUCESSFULL", Texts.cultereinfo)); sb.AppendLine(""); sb.AppendLine(Texts.rm.GetString("OBSINTEGRATIONCONFIRMOBS", Texts.cultereinfo)); MessageBox.Show(sb.ToString()); } } return; } } #if FORCE_SILENCE Silent = true; #else Silent = args.Any(c => c.ToLower() == "/s"); #endif const string appName = "DisplayButtons"; bool createdNew; mutex = new Mutex(true, appName, out createdNew); if (!createdNew) { //app is already running! Exiting the application if (MessageBox.Show(Texts.rm.GetString("ALREADYDISPLAYBUTTONISOPEN", Texts.cultereinfo), Texts.rm.GetString("ALREADYDISPLAYBUTTONISOPENTITLE", Texts.cultereinfo), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var myapp = Process.GetProcessesByName(Assembly.GetCallingAssembly().GetName().Name); List <Process> obsProcesses = new List <Process>(); obsProcesses.AddRange(myapp); if (obsProcesses.Count > 1) { var last = obsProcesses.First(); last.Kill(); } } //return; } Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; EventXml.LoadSettings(); ApplicationSettingsManager.LoadSettings(); Texts.initilizeLang(); errorText = String.Format(Texts.rm.GetString("INTEGRATIONERROROCURRED", Texts.cultereinfo), errorFileName); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); OBSUtils.PrepareOBSIntegration(); if (ApplicationSettingsManager.Settings.FirstRun) { FirstSetupForm firstRunForm = new FirstSetupForm(); Application.Run(firstRunForm); if (!firstRunForm.FinishedSetup) { return; } } // EnsureBrowserEmulationEnabled("DisplayButtons.exe"); new WebBrowserInstanceHelper().SetBrowserFeatureControl(); dynamic form = Activator.CreateInstance(FindType("DisplayButtons.Forms.ActionHelperForms.MainFormMenuOption")) as Form; if (form.ShowDialog() == DialogResult.OK) { Initilizator.mode = 0; Initilizator.ServerThread = new ServerThread(); Initilizator.ServerThread.Start(); Debug.WriteLine("MODO SOCKET CLIENT"); } else { // Silent = true; Debug.WriteLine("MODO USB"); Initilizator.mode = 1; Adbserver = new AdbServer(); Adbserver.StartServer(Path.Combine(Application.StartupPath, @"Data\adb\adb.exe"), restartServerIfNewer: true); monitor = new DeviceMonitor(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort))); client = new AdbClient(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort), Factories.AdbSocketFactory); monitor.DeviceConnected += MainForm.DeviceAdbConnected; monitor.DeviceDisconnected += MainForm.DeviceAdbDisconnected; monitor.Start(); if (client.GetDevices().Count == 1) { Debug.WriteLine("ONE DEVICE"); // client.ExecuteRemoteCommand("am start -a android.intent.action.VIEW -e mode 1 net.nickac.DisplayButtons/.MainActivity", client.GetDevices().First(), null); DevicePersistManager.PersistUsbMode(client.GetDevices().First()); // client.CreateForward(client.GetDevices().First(), "tcp:5095", "tcp:5095", true); Initilizator.ClientThread = new ClientThread(); Initilizator.ClientThread.Start(); } else { Initilizator.ClientThread = new ClientThread(); } } Application.Run(new MainForm()); //Application.Run(new MainFormMenuOption()); OBSUtils.Disconnect(); if (Initilizator.mode == 1) { foreach (var device in client.GetDevices().ToList()) { // client.ExecuteRemoteCommand("am force-stop net.nickac.DisplayButtons", device, null); // client.ExecuteRemoteCommand("kill-server", device, null); // client.KillAdb(); } } // client.KillAdb(); EventXml.SaveSettings(); ApplicationSettingsManager.SaveSettings(); DevicePersistManager.SaveDevices(); NetworkChange.NetworkAddressChanged -= NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged -= NetworkChange_NetworkAddressChanged; Trace.Flush(); }
private void ModernButton5_Click(object sender, EventArgs e) { OBSUtils.Disconnect(); }
private void ModernButton6_Click(object sender, EventArgs e) { OBSUtils.ConnectToOBS(); }
static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(errorFileName)); Trace.AutoFlush = true; if (args.Any(c => c.ToLower() == "/armobs")) { if (args.Length == 1) { var obs32List = Process.GetProcessesByName("obs32"); var obs64List = Process.GetProcessesByName("obs64"); if (obs32List.Length == 0 && obs64List.Length == 0) { //No OBS found. Cancel operation. File.Delete(OBSUtils.obswszip); return; } List <Process> obsProcesses = new List <Process>(); obsProcesses.AddRange(obs32List); obsProcesses.AddRange(obs64List); if (obsProcesses.Count != 1) { //Multiple OBS instances found. Cancel operation. File.Delete(OBSUtils.obswszip); return; } var obsProcess = obsProcesses.First(); string path = OBSUtils.GetProcessPath(obsProcess.Id); string zipTempPath = Path.GetFileNameWithoutExtension(OBSUtils.obswszip); OBSUtils.ExtractZip(OBSUtils.obswszip, zipTempPath); OBSUtils.DirectoryCopy(zipTempPath, OBSUtils.GetPathFromOBSExecutable(path), true); File.Delete(OBSUtils.obswszip); Directory.Delete(zipTempPath, true); var obsGlobalFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "obs-studio", "global.ini"); if (File.Exists(obsGlobalFilePath) && !File.ReadAllText(obsGlobalFilePath).Contains("[WebsocketAPI]")) { while (!obsProcess.HasExited) { StringBuilder sb = new StringBuilder(); sb.AppendLine("OBS plugin install completed!"); sb.AppendLine(""); sb.AppendLine("Please close OBS and click OK to apply the final touches."); MessageBox.Show(sb.ToString()); } using (StreamWriter outputFile = new StreamWriter(obsGlobalFilePath)) { outputFile.WriteLine(""); outputFile.WriteLine("[WebsocketAPI]"); outputFile.WriteLine("ServerPort=4444"); outputFile.WriteLine("DebugEnabled=false"); outputFile.WriteLine("AlertsEnabled=false"); outputFile.WriteLine("AuthRequired=false"); } bool shouldRepeat = true; while (shouldRepeat) { var obs32List2 = Process.GetProcessesByName("obs32"); var obs64List2 = Process.GetProcessesByName("obs64"); shouldRepeat = obs32List2.Length == 0 && obs64List2.Length == 0; if (!shouldRepeat) { break; } StringBuilder sb = new StringBuilder(); sb.AppendLine("OBS plugin install successfully!"); sb.AppendLine(""); sb.AppendLine("Please open OBS and click OK to continue to the app."); MessageBox.Show(sb.ToString()); } } return; } } #if FORCE_SILENCE Silent = true; #else Silent = args.Any(c => c.ToLower() == "/s"); #endif errorText = $"An error occured! And it was saved to a file called {errorFileName}." + Environment.NewLine + "Please send this to the developer of the application."; Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; ApplicationSettingsManager.LoadSettings(); DevicePersistManager.LoadDevices(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (ApplicationSettingsManager.Settings.FirstRun) { FirstSetupForm firstRunForm = new FirstSetupForm(); Application.Run(firstRunForm); if (!firstRunForm.FinishedSetup) { return; } } OBSUtils.PrepareOBSIntegration(); NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAddressChanged; ServerThread = new ServerThread(); ServerThread.Start(); Application.Run(new MainForm()); OBSUtils.Disconnect(); ServerThread.Stop(); NetworkChange.NetworkAddressChanged -= NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged -= NetworkChange_NetworkAddressChanged; ApplicationSettingsManager.SaveSettings(); DevicePersistManager.SaveDevices(); Trace.Flush(); }
public override void OnButtonUp(DeckDevice deckDevice) { Thread th = new Thread(() => { //We create a deck folder Size imageSize = new Size(512, 512); DynamicDeckFolder folder = new DynamicDeckFolder(); Font defaultFont = new Font("Arial", 80, GraphicsUnit.Point); folder.SetParent(deckDevice.CurrentFolder); var scenes = OBSUtils.GetScenes(); int index = 0; using (var bmp = new Bitmap(imageSize.Width, imageSize.Height)) { using (var g = Graphics.FromImage(bmp)) { g.DrawString("Exit", defaultFont, Brushes.Black, new RectangleF(Point.Empty, imageSize), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); } folder.Add(++index, new DynamicDeckItem() { DeckImage = new DeckImage(bmp) }); } foreach (var s in scenes) { using (var bmp = new Bitmap(imageSize.Width, imageSize.Height)) { using (var g = Graphics.FromImage(bmp)) { g.DrawString(s, defaultFont, Brushes.Black, new RectangleF(Point.Empty, imageSize), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); } folder.Add(++index, new DynamicDeckItem() { DeckImage = new DeckImage(bmp) }); } } foreach (var s in scenes) { using (var bmp = new Bitmap(imageSize.Width, imageSize.Height)) { using (var g = Graphics.FromImage(bmp)) { g.DrawString(s + previewSuffix, defaultFont, Brushes.Black, new RectangleF(Point.Empty, imageSize), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); } folder.Add(++index, new DynamicDeckItem() { DeckImage = new DeckImage(bmp) }); } } try { var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); Type callType = assemblies.SelectMany(a => a.GetTypes()) .Single(t => t.FullName == "ButtonDeck.Misc.IDeckDeviceExtensions"); var method = callType.GetMethod("GetConnection", BindingFlags.Static | BindingFlags.Public); ConnectionState connection = (ConnectionState)method.Invoke(null, new object[] { deckDevice }); deckDevice.CurrentFolder = folder; //This is a local fuction. Don't be scared, because this can happen. void fakeFolderHandle(object s, ButtonInteractionEventArgs e) { if (deckDevice.CurrentFolder != folder) { return; } if (e.PerformedAction != Networking.Implementation.ButtonInteractPacket.ButtonAction.ButtonUp) { return; } if (deckDevice.CurrentFolder.GetDeckItems().Any(c => deckDevice.CurrentFolder.GetItemIndex(c) == e.SlotID)) { var item = deckDevice.CurrentFolder.GetDeckItems().Where(c => deckDevice.CurrentFolder.GetItemIndex(c) == e.SlotID); if (item is IDeckItem && e.SlotID == 1) { deckDevice.CurrentFolder = folder.ParentFolder; SendFolder(connection, folder.ParentFolder); deckDevice.ButtonInteraction -= fakeFolderHandle; return; } if (e.SlotID - 1 <= scenes.Count) { if (scenes.AsEnumerable().ElementAtOrDefault(e.SlotID - 1) != null) { OBSUtils.SwitchScene(scenes[e.SlotID - 1]); } } else { if (scenes.AsEnumerable().ElementAtOrDefault((e.SlotID - 1) - scenes.Count) != null) { OBSUtils.SwitchPreviewScene(scenes[(e.SlotID - 1) - scenes.Count]); } } } } deckDevice.ButtonInteraction += fakeFolderHandle; SendFolder(connection, folder); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body } catch (Exception) { #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body //Don't trow. Just flow. } }); th.Start(); }