Exemplo n.º 1
0
        public void Execute(string arguments)
        {
            string[] arr = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            switch (arr[0])
            {
            case "ConsoleVerbosity":
            {
                int?value = CommandParser.Int32Parser(arr[1]);
                if (!value.HasValue)
                {
                    throw new ArgumentException();
                }
                Program.Config.ConsoleVerbosity = (LogSeverity)value;
                Program.Connection.SendLine("Set console verbosity to " + value);
                break;
            }

            case "Port":
            {
                if (arr.Length < 2)
                {
                    throw new ArgumentException();
                }
                Program.Config.Port = arr[1];
                Program.Connection.SendLine("Set port to " + arr[1]);
                break;
            }

            case "BaudRate":
            {
                int?value = CommandParser.Int32Parser(arr[1]);
                if (!value.HasValue)
                {
                    throw new ArgumentException();
                }
                Program.Config.BaudRate = value.Value;
                Program.Connection.SendLine("Set baud rate to " + value.Value + "bps");
                break;
            }

            case "ShowIcon":
            {
                var value = CommandParser.BooleanParser(arr[1]);
                if (!value.HasValue)
                {
                    throw new ArgumentException();
                }
                Program.Config.ShowIcon = value.Value;
                Program.Connection.SendLine("Set taskbar icon visibility to " + value.Value);
                break;
            }
            }
            Program.Config.Save("config.json");
        }
Exemplo n.º 2
0
 public void Execute(string arguments)
 {
     string[] arr = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
     if (arr.Length < 2)
     {
         var state = CommandParser.BooleanParser(arguments);
         if (!state.HasValue)
         {
             throw new ArgumentException();
         }
         controller.DefaultPlaybackDevice.Mute(state.Value);
         Program.Connection.SendLine("Mute set to " + state.ToString());
     }
     else
     {
         var number = CommandParser.Int32Parser(arr[0]);
         if (number.HasValue)
         {
             var state = CommandParser.BooleanParser(arr[1]);
             if (!state.HasValue)
             {
                 throw new ArgumentException();
             }
             List <CoreAudioDevice> dev = controller.GetPlaybackDevices().ToList();
             dev[number.Value].Mute(state.Value);
             Program.Connection.SendLine($"Mute of device {number} set to {state}");
         }
         else
         {
             string name = "";
             for (int i = 0; i < arr.Length - 1; i++)
             {
                 name += arr[i] + " ";
             }
             name = name.Remove(name.Length - 1).ToLower();
             var state = CommandParser.BooleanParser(arr[1]);
             if (!state.HasValue)
             {
                 throw new ArgumentException();
             }
             List <CoreAudioDevice> dev = controller.GetPlaybackDevices().ToList();
             foreach (CoreAudioDevice d in dev)
             {
                 if (d.Name.ToLower().Contains(name) || d.Name.ToLower().Contains(name) || d.InterfaceName.ToLower().Contains(name))
                 {
                     d.Mute(state.Value);
                     Program.Connection.SendLine($"Mute of device {d.FullName} set to {state}");
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private void SetWindow(string[] arr)
        {
            switch (arr[0])
            {
            case "Title":
            {
                Window w        = new Window(new IntPtr(CommandParser.Int32Parser(arr[1]).Value));
                string newTitle = string.Join(" ", arr.Skip(2));
                w.Title = newTitle;
                break;
            }

            case "Enabled":
            {
                Window w = new Window(new IntPtr(CommandParser.Int32Parser(arr[1]).Value));
                w.Enabled = CommandParser.BooleanParser(arr[2]).Value;
                break;
            }

            case "Visible":
            {
                Window w = new Window(new IntPtr(CommandParser.Int32Parser(arr[1]).Value));
                w.Visible = CommandParser.BooleanParser(arr[2]).Value;
                break;
            }

            case "TopMost":
            {
                Window w = new Window(new IntPtr(CommandParser.Int32Parser(arr[1]).Value));
                w.TopMost = CommandParser.BooleanParser(arr[2]).Value;
                break;
            }

            case "Opacity":
            {
                Window w = new Window(new IntPtr(CommandParser.Int32Parser(arr[1]).Value));
                w.Opacity = CommandParser.ByteParser(arr[2]).Value;
                break;
            }
            }
            Program.Connection.SendLine("Done!");
        }