コード例 #1
0
        /// <summary>
        /// When the find-user window closes, grab the rights holder that was selected and add it.
        /// </summary>
        /// <param name="sender">The find window.</param>
        /// <param name="eventArgs">The event arguments.</param>
        private void OnFindUserClose(object sender, EventArgs eventArgs)
        {
            WindowFindUser windowAddUserAccess = sender as WindowFindUser;

            if (windowAddUserAccess.SelectedUser != null)
            {
                DependencyObject container = null;

                if (!this.roles.Any(a => a.User == windowAddUserAccess.SelectedUser))
                {
                    this.roles.Add(new AccessControl(windowAddUserAccess.SelectedUser, this.Entity, AccessRight.None, this.Entity.TenantId));
                    this.CanApply = true;
                }

                container = this.RolesAndUsers.ItemContainerGenerator.ContainerFromItem(windowAddUserAccess.SelectedUser);

                if (container != null)
                {
                    container.SetValue(FrameworkElement.VisibilityProperty, Visibility.Visible);
                }
                this.RolesAndUsers.SelectedItem = this.roles.FirstOrDefault(a => a.User == windowAddUserAccess.SelectedUser);
                this.RolesAndUsers.ScrollIntoView(this.RolesAndUsers.SelectedItem);
            }

            Win32Interop.EnableWindow(this);
            this.Activate();
        }
コード例 #2
0
        private AppWindow GetAppWindowForCurrentWindow()
        {
            IntPtr   hWnd  = WindowNative.GetWindowHandle(this);
            WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);

            return(AppWindow.GetFromWindowId(wndId));
        }
コード例 #3
0
        public NetworkAccess(string networkResourcePath, NetworkCredential credentials)
        {
            networkResourceName = networkResourcePath;

            Win32Interop.NETRESOURCE networkResource = new Win32Interop.NETRESOURCE
            {
                Scope        = ResourceScope.GlobalNetwork,
                ResourceType = ResourceType.Disk,
                DisplayType  = ResourceDisplaytype.Share,
                RemoteName   = networkResourceName
            };

            string userName = string.IsNullOrEmpty(credentials.Domain)
                                ? credentials.UserName
                                : string.Format(@"{0}\{1}", credentials.Domain, credentials.UserName);

            int result = Win32Interop.WNetAddConnection2(
                ref networkResource,
                credentials.Password,
                userName,
                0);

            if (result != 0)
            {
                throw new Win32Exception(result, "Error connecting to remote share");
            }
        }
コード例 #4
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            await ApplicationDataMigration.Migrate();

            await DatabaseManager.Instance.InitializeDb();

            await SettingsViewModel.Instance.Load();

            await SearchResultsViewModel.Instance.Load();

            if (!Resources.ContainsKey("settings"))
            {
                Resources.Add("settings", Settings.Instance);
            }

            string[] args            = Environment.GetCommandLineArgs();
            string   launchArguments = args.Length >= 2 ? args[1] : null;

            mainWindow = new MainWindow(launchArguments);

            IntPtr    hWnd      = WindowNative.GetWindowHandle(mainWindow);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);

            mainWindow.Activate();

            appWindow.Closing += AppWindow_Closing;
        }
コード例 #5
0
        /// <summary>
        /// Get's the <see cref="AppWindow"/> that is assigned to the <c>WinUI</c> <see cref="Window"/>
        /// </summary>
        /// <param name="window">Reference to a <c>WinUI</c> <see cref="Microsoft.UI.Xaml.Window"/></param>
        /// <returns></returns>
        public static AppWindow GetAppWindow(this Window window)
        {
            IntPtr hWnd  = window.GetHandle();
            var    winId = Win32Interop.GetWindowIdFromWindow(hWnd);

            return(AppWindow.GetFromWindowId(winId));
        }
コード例 #6
0
        public MainWindow(MainViewModel viewModel, NotifyIconService notifyIconService)
        {
            InitializeComponent();

            this.viewModel   = viewModel;
            this.DataContext = this.viewModel;

            notifyIconService.Clicked        += (s, e) => this.ToggleWindow();
            notifyIconService.CloseRequested += (s, e) => this.Close();

            this.Loaded += (s, e) =>
            {
                var windowHandle = new WindowInteropHelper(this).Handle;
                Win32Interop.HideWindowFromAltTab(windowHandle);
                Win32Interop.PowerSchemeChanged += this.OnPowerPlanChanged;
                Win32Interop.RegisterForPowerSettingNotification(windowHandle);

                this.viewModel.UpdatePowerPlans();
            };

            this.Closing += (s, e) =>
            {
                var windowHandle = new WindowInteropHelper(this).Handle;
                Win32Interop.PowerSchemeChanged -= this.OnPowerPlanChanged;
                Win32Interop.UnregisterForPowerSettingNotification(windowHandle);
            };
        }
コード例 #7
0
ファイル: WinInput.cs プロジェクト: McChicken2020/Remotely
        public uint SendMouseWheel(int deltaY, Viewer viewer)
        {
            Win32Interop.SwitchToInputDesktop();
            if (deltaY < 0)
            {
                deltaY = -120;
            }
            else if (deltaY > 0)
            {
                deltaY = 120;
            }
            var union = new User32.InputUnion()
            {
                mi = new User32.MOUSEINPUT()
                {
                    dwFlags = MOUSEEVENTF.WHEEL, dx = 0, dy = 0, time = 0, mouseData = deltaY, dwExtraInfo = GetMessageExtraInfo()
                }
            };
            var input = new User32.INPUT()
            {
                type = InputType.MOUSE, U = union
            };

            return(SendInput(1, new User32.INPUT[] { input }, INPUT.Size));
        }
コード例 #8
0
        public void GetNextFrame()
        {
            try
            {
                if (NeedsInit)
                {
                    Logger.Write("Init needed in DXCapture.  Switching desktops.");
                    if (Win32Interop.SwitchToInputDesktop())
                    {
                        Win32Interop.GetCurrentDesktop(out var desktopName);
                        Logger.Write($"Switch to desktop {desktopName} after capture error in DXCapture.");
                    }
                    Init();
                }

                Win32Interop.SwitchToInputDesktop();

                PreviousFrame?.Dispose();
                PreviousFrame = (Bitmap)CurrentFrame.Clone();

                if (directxScreens.ContainsKey(SelectedScreen))
                {
                    GetDirectXFrame();
                }
                else
                {
                    GetBitBltFrame();
                }
            }
            catch (Exception e)
            {
                Logger.Write(e);
                NeedsInit = true;
            }
        }
コード例 #9
0
        private static async Task HandleConnection(Conductor conductor)
        {
            while (true)
            {
                if (Win32Interop.GetCurrentDesktop(out var currentDesktopName))
                {
                    if (currentDesktopName.ToLower() != CurrentDesktopName.ToLower() && conductor.Viewers.Count > 0)
                    {
                        Logger.Write($"Switching desktops to {currentDesktopName}.");
                        if (Win32Interop.SwitchToInputDesktop())
                        {
                            CurrentDesktopName = currentDesktopName;
                        }
                        else
                        {
                            Logger.Write("Failed to switch desktops.");
                        }
                    }
                }
                else
                {
                    Logger.Write("Failed to get current desktop name.");
                }

                await Task.Delay(1000);
            }
        }
コード例 #10
0
        public GfxTabletTestdialog()
        {
            InitializeComponent();
            bool ok = Win32Interop.InitializeTouchInjection(10, Win32Interop.enInitTouchInjectionModes.TOUCH_FEEDBACK_DEFAULT);

            System.Diagnostics.Trace.Assert(ok);
        }
コード例 #11
0
        public async Task <Device> CreateDevice(string deviceId, string orgId)
        {
            var device = GetDeviceBase(deviceId, orgId);

            try
            {
                var(usedStorage, totalStorage) = GetSystemDriveInfo();
                var(usedMemory, totalMemory)   = GetMemoryInGB();

                device.CurrentUser    = Win32Interop.GetActiveSessions().LastOrDefault()?.Username;
                device.Drives         = GetAllDrives();
                device.UsedStorage    = usedStorage;
                device.TotalStorage   = totalStorage;
                device.UsedMemory     = usedMemory;
                device.TotalMemory    = totalMemory;
                device.CpuUtilization = await GetCpuUtilization();

                device.AgentVersion = GetAgentVersion();
            }
            catch (Exception ex)
            {
                Logger.Write(ex, "Error getting device info.");
            }

            return(device);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: resonancellc/Remotely
        private static void StartScreenCasting()
        {
            CursorIconWatcher = Services.GetRequiredService <CursorIconWatcher>();

            Conductor.Connect().ContinueWith(async(task) =>
            {
                await Conductor.CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
                if (Win32Interop.GetCurrentDesktop(out var currentDesktopName))
                {
                    Logger.Write($"Setting initial desktop to {currentDesktopName}.");
                    if (Win32Interop.SwitchToInputDesktop())
                    {
                        CurrentDesktopName = currentDesktopName;
                    }
                    else
                    {
                        Logger.Write("Failed to set initial desktop.");
                    }
                }
                else
                {
                    Logger.Write("Failed to get initial desktop name.");
                }
                await CheckForRelaunch();
                Services.GetRequiredService <IdleTimer>().Start();
                CursorIconWatcher.OnChange += CursorIconWatcher_OnChange;
                Services.GetRequiredService <IClipboardService>().BeginWatching();
            });

            Thread.Sleep(Timeout.Infinite);
        }
コード例 #13
0
ファイル: WinInput.cs プロジェクト: tylerrbrown/Remotely
        private void TryOnInputDesktop(Action inputAction)
        {
            InputActions.Enqueue(() =>
            {
                if (!Win32Interop.SwitchToInputDesktop())
                {
                    if (IsInputBlocked)
                    {
                        BlockInput(false);
                    }

                    Task.Run(() =>
                    {
                        Win32Interop.SwitchToInputDesktop();
                        inputAction();
                    }).Wait();

                    if (IsInputBlocked)
                    {
                        BlockInput(true);
                    }
                }
                else
                {
                    inputAction();
                }
            });
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: zuimei100/Remotely
        private static async Task StartScreenCasting()
        {
            CursorIconWatcher = Services.GetRequiredService <ICursorIconWatcher>();

            await CasterSocket.Connect(Conductor.Host);

            await CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);

            if (Win32Interop.GetCurrentDesktop(out var currentDesktopName))
            {
                Logger.Write($"Setting initial desktop to {currentDesktopName}.");
            }
            else
            {
                Logger.Write("Failed to get initial desktop name.");
            }

            if (!Win32Interop.SwitchToInputDesktop())
            {
                Logger.Write("Failed to set initial desktop.");
            }

            await SendReadyNotificationToViewers();

            Services.GetRequiredService <IdleTimer>().Start();
            CursorIconWatcher.OnChange += CursorIconWatcher_OnChange;
            Services.GetRequiredService <IClipboardService>().BeginWatching();
            Services.GetRequiredService <IKeyboardMouseInput>().Init();
        }
コード例 #15
0
        public async Task <int> LaunchChatService(string orgName, string requesterID, HubConnection hubConnection)
        {
            try
            {
                if (!File.Exists(_rcBinaryPath))
                {
                    await hubConnection.SendAsync("DisplayMessage", "Chat executable not found on target device.", "Executable not found on device.", "bg-danger", requesterID);
                }


                // Start Desktop app.
                await hubConnection.SendAsync("DisplayMessage", $"Starting chat service.", "Starting chat service.", "bg-success", requesterID);

                if (WindowsIdentity.GetCurrent().IsSystem)
                {
                    var result = Win32Interop.OpenInteractiveProcess($"{_rcBinaryPath} " +
                                                                     $"-mode Chat " +
                                                                     $"-requester \"{requesterID}\" " +
                                                                     $"-organization \"{orgName}\" " +
                                                                     $"-host \"{ConnectionInfo.Host}\" " +
                                                                     $"-orgid \"{ConnectionInfo.OrganizationID}\"",
                                                                     targetSessionId: -1,
                                                                     forceConsoleSession: false,
                                                                     desktopName: "default",
                                                                     hiddenWindow: false,
                                                                     out var procInfo);
                    if (!result)
                    {
                        await hubConnection.SendAsync("DisplayMessage",
                                                      "Chat service failed to start on target device.",
                                                      "Failed to start chat service.",
                                                      "bg-danger",
                                                      requesterID);
                    }
                    else
                    {
                        return(procInfo.dwProcessId);
                    }
                }
                else
                {
                    return(Process.Start(_rcBinaryPath,
                                         $"-mode Chat " +
                                         $"-requester \"{requesterID}\" " +
                                         $"-organization \"{orgName}\" " +
                                         $"-host \"{ConnectionInfo.Host}\" " +
                                         $"-orgid \"{ConnectionInfo.OrganizationID}\"").Id);
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                await hubConnection.SendAsync("DisplayMessage",
                                              "Chat service failed to start on target device.",
                                              "Failed to start chat service.",
                                              "bg-danger",
                                              requesterID);
            }
            return(-1);
        }
コード例 #16
0
        protected void UpdateLayered()
        {
            IntPtr dC      = Win32Interop.GetDC(IntPtr.Zero);
            IntPtr hDC     = Win32Interop.CreateCompatibleDC(dC);
            IntPtr zero    = IntPtr.Zero;
            IntPtr hObject = IntPtr.Zero;

            Render(Graphics.FromImage(feedbackImage));
            try
            {
                zero    = feedbackImage.GetHbitmap(Color.FromArgb(0));
                hObject = Win32Interop.SelectObject(hDC, zero);
                Win32Interop.SIZE          psize  = new Win32Interop.SIZE(Width, Height);
                Win32Interop.POINT         pprSrc = new Win32Interop.POINT(0, 0);
                Win32Interop.POINT         pptDst = new Win32Interop.POINT(Left, Top);
                Win32Interop.BLENDFUNCTION pblend = new Win32Interop.BLENDFUNCTION();
                pblend.BlendOp             = 0;
                pblend.BlendFlags          = 0;
                pblend.SourceConstantAlpha = 255;
                pblend.AlphaFormat         = 1;
                Win32Interop.UpdateLayeredWindow(Handle, dC, ref pptDst, ref psize, hDC, ref pprSrc, 0, ref pblend, 2);
            }
            finally
            {
                Win32Interop.ReleaseDC(IntPtr.Zero, dC);
                if (zero != IntPtr.Zero)
                {
                    Win32Interop.SelectObject(hDC, hObject);
                    Win32Interop.DeleteObject(zero);
                }
                Win32Interop.DeleteDC(hDC);
            }
        }
コード例 #17
0
        public static AppWindow GetAppWindowForCurrentWindow(this Window window)
        {
            var hWnd  = WindowNative.GetWindowHandle(window);
            var winId = Win32Interop.GetWindowIdFromWindow(hWnd);

            return(AppWindow.GetFromWindowId(winId));
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: jasonsch/WindowsCLI
        static void Main(string[] args)
        {
            int  Timeout = 300; // In milliseconds
            bool EnableActiveWindowTracking  = true;
            bool EnableActiveWindowZordering = true;
            bool PersistSystemSettings       = false;
            bool ArgumentsPassed             = false;

            OptionSet options = new OptionSet();

            options.Add("?|h|help", value => { PrintUsage(); });
            options.Add("t", value => { EnableActiveWindowTracking = (value != null); ArgumentsPassed = true; });
            options.Add("timeout=", value => { Timeout = Int32.Parse(value); ArgumentsPassed = true; });
            options.Add("z", value => { EnableActiveWindowZordering = (value != null); ArgumentsPassed = true; });
            options.Add("p", value => { PersistSystemSettings = (value != null); ArgumentsPassed = true; });
            options.Parse(args);

            if (ArgumentsPassed)
            {
                Win32Interop.SetSystemParameter(YellowLab.Windows.Win32.Win32Interop.SPI_SETACTIVEWINDOWTRACKING, EnableActiveWindowTracking, PersistSystemSettings);
                Win32Interop.SetSystemParameter(YellowLab.Windows.Win32.Win32Interop.SPI_SETACTIVEWNDTRKZORDER, EnableActiveWindowZordering, PersistSystemSettings);
                Win32Interop.SetSystemParameter(YellowLab.Windows.Win32.Win32Interop.SPI_SETACTIVEWNDTRKTIMEOUT, Timeout, PersistSystemSettings);
            }
            else
            {
                PrintFocusFollowsMouseSettings();
            }
        }
コード例 #19
0
        public object InvokeScript(HTMLDocument htmlDocument_, string scriptName, params object[] args)
        {
            var    htmlDocument = htmlDocument_ as IHTMLDocument2;
            object invokeScript = null;
            var    pDispParams  = new DispParams
            {
                rgvarg = IntPtr.Zero
            };

            try
            {
                var script = htmlDocument.Script as IDispatch;
                if (script == null)
                {
                    return(null);
                }
                var      empty      = Guid.Empty;
                string[] rgszNames  = { scriptName };
                int[]    rgDispId   = { -1 };
                var      iDsOfNames = script.GetIDsOfNames(ref empty, rgszNames, 1,
                                                           Win32Interop.GetThreadLCID(), rgDispId);
                if (!MsHtmlNativeUtility.Succeeded(iDsOfNames) || rgDispId[0] == -1)
                {
                    return(null);
                }
                if (args != null)
                {
                    Array.Reverse(args);
                }
                pDispParams.rgvarg            = args == null ? IntPtr.Zero : MsHtmlNativeUtility.ArrayToVariantVector(args);
                pDispParams.cArgs             = args?.Length ?? 0;
                pDispParams.rgdispidNamedArgs = IntPtr.Zero;
                pDispParams.cNamedArgs        = 0;
                var pVarResult = new object[1];
                var pExcepInfo = new ExcepInfo();
                if (script.Invoke(rgDispId[0], ref empty, Win32Interop.GetThreadLCID(), 1, pDispParams, pVarResult,
                                  pExcepInfo, null) == 0)
                {
                    invokeScript = pVarResult[0];
                }
            }
            catch (Exception exception)
            {
                if (MsHtmlNativeUtility.IsSecurityOrCriticalException(exception))
                {
                    throw;
                }
            }
            finally
            {
                if (pDispParams.rgvarg != IntPtr.Zero)
                {
                    if (args != null)
                    {
                        MsHtmlNativeUtility.FreeVariantVector(pDispParams.rgvarg, args.Length);
                    }
                }
            }
            return(invokeScript);
        }
コード例 #20
0
        private void WatchClipboard(CancellationToken cancelToken)
        {
            while (!cancelToken.IsCancellationRequested &&
                   !Environment.HasShutdownStarted)
            {
                var thread = new Thread(() =>
                {
                    try
                    {
                        Win32Interop.SwitchToInputDesktop();


                        if (Clipboard.ContainsText() && Clipboard.GetText() != ClipboardText)
                        {
                            ClipboardText = Clipboard.GetText();
                            ClipboardTextChanged?.Invoke(this, ClipboardText);
                        }
                    }
                    catch { }
                });
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                Thread.Sleep(500);
            }
        }
コード例 #21
0
        public bool TrySetWindowOwner(DependencyObject source, Window target)
        {
            bool result = false;

            Fx.Assert(target != null, "Target window cannot be null");
            if (null != target)
            {
                if (source != null)
                {
                    //try the easy way first
                    Window owner = Window.GetWindow(source);
                    if (null != owner)
                    {
                        target.Owner = owner;
                        result       = true;
                    }
                }
                //no - it didn't work
                if (!result)
                {
                    IntPtr ownerHwnd = Win32Interop.GetActiveWindow();
                    if (ownerHwnd == IntPtr.Zero)
                    {
                        ownerHwnd = this.ParentWindowHwnd;
                    }
                    WindowInteropHelper interopHelper = new WindowInteropHelper(target);
                    interopHelper.Owner = ownerHwnd;
                    result = true;
                }
            }

            return(result);
        }
コード例 #22
0
        private void TryOnInputDesktop(Action inputAction)
        {
            if (!_inputBlocked)
            {
                if (!Win32Interop.SwitchToInputDesktop())
                {
                    Logger.Write("Desktop switch failed while sending input.");
                }
                inputAction();
            }
            else
            {
                InputActions.Enqueue(() =>
                {
                    try
                    {
                        if (!Win32Interop.SwitchToInputDesktop())
                        {
                            Logger.Write("Desktop switch failed during input processing.");

                            // Thread likely has hooks in current desktop.  SendKeys will create one with no way to unhook it.
                            // Start a new thread for processing input.
                            StartInputProcessingThread();
                            return;
                        }
                        inputAction();
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(ex);
                    }
                });
            }
        }
コード例 #23
0
ファイル: Viewer.cs プロジェクト: xickwy/Remotely
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         await SendToViewer(() => RtcSession.SendWindowsSessions(Win32Interop.GetActiveSessions()),
                            () => CasterSocket.SendWindowsSessions(Win32Interop.GetActiveSessions(), ViewerConnectionID));
     }
 }
コード例 #24
0
        private static void DoCreateProcessA()
        {
            var si = new StartupInfoA();
            var pi = new ProcessInformation();

            Win32Interop.CreateProcessA("c:\\windows\\system32\\Notepad.exe", "", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero,
                                        null, ref si, ref pi);
        }
コード例 #25
0
 public VlcControlWpfRendererContext(int width, int height)
 {
     Size   = width * height * 32 / 8;
     Data   = Win32Interop.LocalAlloc(0, (IntPtr)Size);
     Width  = width;
     Height = height;
     Stride = width * 32 / 8;
 }
コード例 #26
0
        /// <summary>
        /// Launch an icon/image selector dialog box and set the entity's icon to the result.
        /// </summary>
        /// <param name="sender">The changeIconButton.</param>
        /// <param name="eventArgs">The event arguments</param>
        private void OnChangeIconButtonClick(object sender, RoutedEventArgs eventArgs)
        {
            WindowIconChooser iconChooser = new WindowIconChooser();

            iconChooser.Closed += this.OnIconChooserClosed;
            iconChooser.Show();
            Win32Interop.DisableWindow(this);
        }
コード例 #27
0
ファイル: AppLauncherWin.cs プロジェクト: zuimei100/Remotely
        public async Task RestartScreenCaster(List <string> viewerIDs, string serviceID, string requesterID, HubConnection hubConnection, int targetSessionID = -1)
        {
            try
            {
                // Start Desktop app.
                Logger.Write("Restarting screen caster.");
                if (WindowsIdentity.GetCurrent().IsSystem)
                {
                    // Give a little time for session changing, etc.
                    await Task.Delay(1000);

                    var result = Win32Interop.OpenInteractiveProcess(_rcBinaryPath +
                                                                     $" -mode Unattended" +
                                                                     $" -requester \"{requesterID}\"" +
                                                                     $" -serviceid \"{serviceID}\"" +
                                                                     $" -deviceid {ConnectionInfo.DeviceID}" +
                                                                     $" -host {ConnectionInfo.Host}" +
                                                                     $" -orgid \"{ConnectionInfo.OrganizationID}\"" +
                                                                     $" -relaunch true" +
                                                                     $" -viewers {String.Join(",", viewerIDs)}",

                                                                     targetSessionId: targetSessionID,
                                                                     forceConsoleSession: Shlwapi.IsOS(OsType.OS_ANYSERVER) && targetSessionID == -1,
                                                                     desktopName: "default",
                                                                     hiddenWindow: true,
                                                                     out _);

                    if (!result)
                    {
                        Logger.Write("Failed to relaunch screen caster.");
                        await hubConnection.SendAsync("SendConnectionFailedToViewers", viewerIDs);

                        await hubConnection.SendAsync("DisplayMessage", "Remote control failed to start on target device.", "Failed to start remote control.", requesterID);
                    }
                }
                else
                {
                    // SignalR Connection IDs might start with a hyphen.  We surround them
                    // with quotes so the command line will be parsed correctly.
                    Process.Start(_rcBinaryPath,
                                  $"-mode Unattended " +
                                  $"-requester \"{requesterID}\" " +
                                  $"-serviceid \"{serviceID}\" " +
                                  $"-deviceid {ConnectionInfo.DeviceID} " +
                                  $"-host {ConnectionInfo.Host} " +
                                  $" -orgid \"{ConnectionInfo.OrganizationID}\"" +
                                  $"-relaunch true " +
                                  $"-viewers {String.Join(",", viewerIDs)}");
                }
            }
            catch (Exception ex)
            {
                await hubConnection.SendAsync("SendConnectionFailedToViewers", viewerIDs);

                Logger.Write(ex);
                throw;
            }
        }
コード例 #28
0
        public static string GetClassName(IntPtr hWnd)
        {
            var title       = new StringBuilder(MaxTitle);
            var titleLength = Win32Interop.GetClassName(hWnd, title, title.Capacity + 1);

            title.Length = titleLength;

            return(title.ToString());
        }
コード例 #29
0
ファイル: OobeWindow.xaml.cs プロジェクト: royvou/PowerToys
        public OobeWindow(PowerToysModules initialModule)
        {
            this.InitializeComponent();

            // Set window icon
            _hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            _windowId  = Win32Interop.GetWindowIdFromWindow(_hWnd);
            _appWindow = AppWindow.GetFromWindowId(_windowId);
            _appWindow.SetIcon("icon.ico");

            OverlappedPresenter presenter = _appWindow.Presenter as OverlappedPresenter;

            presenter.IsResizable   = false;
            presenter.IsMinimizable = false;
            presenter.IsMaximizable = false;

            var dpi = NativeMethods.GetDpiForWindow(_hWnd);

            _currentDPI = dpi;
            float scalingFactor = (float)dpi / DefaultDPI;
            int   width         = (int)(ExpectedWidth * scalingFactor);
            int   height        = (int)(ExpectedHeight * scalingFactor);

            SizeInt32 size;

            size.Width  = width;
            size.Height = height;
            _appWindow.Resize(size);

            this.initialModule = initialModule;

            this.SizeChanged += OobeWindow_SizeChanged;

            ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();

            Title = loader.GetString("OobeWindow_Title");

            if (shellPage != null)
            {
                shellPage.NavigateToModule(this.initialModule);
            }

            OobeShellPage.SetRunSharedEventCallback(() =>
            {
                return(Constants.PowerLauncherSharedEvent());
            });

            OobeShellPage.SetColorPickerSharedEventCallback(() =>
            {
                return(Constants.ShowColorPickerSharedEvent());
            });

            OobeShellPage.SetOpenMainWindowCallback((Type type) =>
            {
                App.OpenSettingsWindow(type);
            });
        }
コード例 #30
0
ファイル: Viewer.cs プロジェクト: zuimei100/Remotely
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         var dto = new WindowsSessionsDto(Win32Interop.GetActiveSessions());
         await SendToViewer(() => RtcSession.SendDto(dto),
                            () => CasterSocket.SendDtoToViewer(dto, ViewerConnectionID));
     }
 }