Esempio n. 1
0
 public SettingsViewModel(
     IAudioPlayer audioService,
     ISettingsService settingsService
     )
 {
     settings             = settingsService.settings;
     this.audioService    = audioService;
     this.settingsService = settingsService;
     audioDevices.AddRange(audioService.Devices);
     Push2TalkKeys    = Hotkey.Create(settings.generalSettings.Push2TalkKey);
     AppPush2TalkKeys = Hotkey.Create(settings.generalSettings.AppPush2TalkKey);
 }
Esempio n. 2
0
        public Form1()
        {
            InitializeComponent();

            hotkeys = new Hotkey[]
            {
                Hotkey.Create(Handle, 0, FSModifiers.Alt, Keys.T),
                Hotkey.Create(Handle, 1, FSModifiers.Alt, Keys.M),
            };

            foreach (Hotkey hotkey in hotkeys)
            {
                hotkey.Hook();
            }

            UrMomForm.Instance.ShowDialog();
        }
 private void playFile(string audioFileName)
 {
     hotkeys = Hotkey.Create(settings.generalSettings.AppPush2TalkKey);
     AudioPlayer
     .OnPlay(() => { hotkeys.BroadcastDown(); })
     .OnPlayStopped(() =>
     {
         if (settings.generalSettings.IsAppPush2Talk)
         {
             Task.Run(async() =>
             {
                 await Task.Delay(settings.generalSettings.KeyUpDelay);
                 hotkeys.BroadcastUp();
             });
         }
     })
     .Play(audioFileName, settings.generalSettings.AudioOutDevice);
 }
Esempio n. 4
0
        public static async Task Preview(Window window, int fps, Action <HAction> mButtonAction = null)
        {
            if (window == null || !window.Exists)
            {
                return;
            }

            Edge corner = new Edge(EdgeType.BottomRight, Monitor.Primary.Area.BottomRight - new Coord(60, 60));
            var  area   = new Area(0, 0, 576, 324).SetEdge(corner);

            var gui = new ImageBox(window.GetImage(), area);

            gui.Launch(form => form.ShowInTaskbar = false);
            await gui.WaitForForm();

            gui.Window.SetAlwaysOnTop(true);
            //try { gui.Window.Pin(true); } catch { }

            var t = new TaskCompletionSource <object>();

            bool Context() => Window.FromMouse == gui.Window;

            var focus  = Hotkey.Create(Key.LButton, HAction.Single(a => window.Activate()), priority: 100, context: Context);
            var hotkey = Hotkey.Create(Key.RButton, HAction.Single(a => t.TrySetResult(null)), priority: 100, context: Context);
            var mba    = Hotkey.Create(Key.MButton, HAction.Single(mButtonAction), priority: 100, context: Context);

            bool hidden = false;
            bool trans  = false;

            while (!t.Task.IsCompleted)
            {
                await Task.Delay(1000 / fps);

                if (!window.Exists)
                {
                    break;
                }
                else if (window.IsActive)
                {
                    if (!hidden)
                    {
                        gui.Window.SetOpacity(0);
                        gui.Window.SetClickThrough(true);
                        hidden = true;
                    }
                }
                else
                {
                    if (hidden)
                    {
                        gui.Window.SetOpacity(100);
                        gui.Window.SetClickThrough(false);
                        hidden = false;
                    }

                    gui.SetImage(window.GetImagePrint(true));

                    var newArea  = gui.Window.Area;
                    var contains = newArea.Contains(Mouse.Position);

                    if (contains && !trans)
                    {
                        trans = true;
                        gui.Window.SetOpacity(50);
                    }
                    else if (!contains && trans)
                    {
                        trans = false;
                        gui.Window.SetOpacity(100);
                    }

                    if (newArea != area)
                    {
                        newArea.SetEdge(corner);
                        area = newArea;
                        gui.Window.Move(area);
                    }
                }
            }

            gui.Close();
            hotkey.Remove();
            mba.Remove();
            focus.Remove();
            Console.WriteLine("Preview closed");
        }