Пример #1
0
        /// <summary>
        /// Used to minimize a DPApp. This is for literally minimizing an app, not temporarially hiding it like when the bar closes.
        /// </summary>
        /// <param name="appKey"></param>
        public void MinimizeApp(string appKey)
        {
            if (!openApps.ContainsKey(appKey))
            {
                return;
            }

            DPApp dpApp = openApps[appKey];

            if (dpApp == null)
            {
                return;
            }

            if (dpApp.isUsingSnapPoint)
            {
                dpApp.snapPoint.ClearAllSnapData();
            }

            dpApp.OnMinimize();
            ToggleDPApp(dpApp, false, true);



            //dpApp.HandleTheBarToggled(false);

            //dpApp.SetAppState(DPAppState.Minimized);
        }
Пример #2
0
        /*public float FindWidthForOverlay(DPOverlayBase newDP) {
         *
         *
         *      if (newDP.currentTexture != null) {
         *              newDP.RequestRendering();
         *      }
         *
         *      float multiplier = (float)newDP.currentTexture.width / newDP.currentTexture.height;
         *
         *
         *      float newWidth = maxOverlayHeight * multiplier;
         *      Debug.Log(newWidth);
         *
         *      return newWidth;
         *
         *
         *
         *
         * }*/



        /// <summary>
        /// Sets a new DPApp that is anchored on this snap point
        /// </summary>
        /// <param name="newDPApp"></param>
        public void SetSnappedApp(DPApp newDPApp)
        {
            dpApp           = newDPApp;
            dpApp.snapPoint = this;

            SetSnappedDP(dpApp.dpMain);
        }
Пример #3
0
        /// <summary>
        /// Changes the visibility of a DPApp
        /// </summary>
        /// <param name="dpApp"></param>
        /// <param name="visible"></param>
        public void ToggleDPApp(DPApp dpApp, bool visible, bool instant = false)
        {
            if (dpApp == null)
            {
                return;
            }

            if (visible && !dpApp.isInitialized)
            {
                dpApp.OnInit();
            }

            dpApp.OnVisibilityChange(visible);

            if (visible)
            {
                if (instant)
                {
                    dpApp.dpMain.overlay.SetVisible(true);
                }
                else
                {
                    DPUIManager.Animate(dpApp.dpMain, "FadeIn");
                }
            }
            else
            {
                if (instant)
                {
                    dpApp.dpMain.overlay.SetVisible(false);
                }
                DPUIManager.Animate(dpApp.dpMain, "FadeOut");
            }
        }
Пример #4
0
        public Texture2D GetAppIconForAppKey(string appKey)
        {
            DPApp dpApp = loadedApps[appKey];

            if (dpApp != null)
            {
                return(dpApp.iconTex);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// Called when the app isn't in the "openApps" dictionary.
        /// Spawns a button on the window list for this app
        /// </summary>
        /// <param name="appKey"></param>
        public void AddOpenAppWindowListIcon(DPApp dpApp)
        {
            if (builtInApps.Contains(dpApp))
            {
                return;
            }

            WindowListButton button = Instantiate(windowListButtonPF, windowListTrans).GetComponent <WindowListButton>();

            button.icon.texture = dpApp.iconTex;
            button.appKey       = dpApp.appKey;

            dpApp.windowListButtonGO = button.gameObject;
        }
Пример #6
0
        public void AddOpenApp(DPApp dpApp, bool addWindowListButton = true)
        {
            if (openApps.ContainsKey(dpApp.appKey))
            {
                return;
            }

            TheBarManager.openApps[dpApp.appKey] = dpApp;

            if (addWindowListButton)
            {
                AddOpenAppWindowListIcon(dpApp);
            }
        }
Пример #7
0
        public void ClearAllSnapData()
        {
            //if (!isOccupied) return;

            if (dpApp != null)
            {
                dpApp.snapPoint = null;
                dpApp           = null;
            }

            if (dpBase != null)
            {
                dpBase.snapPoint = null;
                dpBase           = null;
            }

            tempPreviewDP = null;
        }
Пример #8
0
        /// <summary>
        /// Used to close a DPApp. This is for literally closing an app, not for temporarially hiding it.
        /// </summary>
        /// <param name="appKey"></param>
        public void CloseApp(string appKey)
        {
            if (!loadedApps.ContainsKey(appKey))
            {
                return;
            }

            DPApp dpApp = loadedApps[appKey];

            if (dpApp == null)
            {
                return;
            }

            if (dpApp.snapPoint != null)
            {
                dpApp.snapPoint.ClearAllSnapData();
            }


            if (!builtInApps.Contains(dpApp))
            {
                //Move the toolbar so we don't destroy it
                //DPToolbar.I.ResetToolbar();

                dpApp.OnClose();

                Destroy(dpApp.windowListButtonGO);

                dpApp.dpMain.OnPreDestroy();
                Destroy(dpApp.dpMain.gameObject);
                Destroy(dpApp.gameObject);

                loadedApps.Remove(appKey);
            }
            else
            {
                ToggleDPApp(dpApp, false);
            }

            openApps.Remove(appKey);
        }
Пример #9
0
        /// <summary>
        /// Gets the current state of a DPApp and puts it in a serializable form
        /// </summary>
        /// <param name="dpApp">The DPApp to get the state of</param>
        /// <returns></returns>
        public static DPAppSerialized GetState(DPApp dpApp)
        {
            var dpBase = dpApp.dpMain;

            DPAppSerialized state = new DPAppSerialized()
            {
                isVisible = dpApp.isVisible,

                isMinimized = dpApp.isMinimized,

                pos = dpBase.transform.localPosition,
                rot = dpBase.transform.localEulerAngles,

                width = dpBase.overlay.width,

                curvature = dpBase.overlay.curvature,

                trackedDevice = dpBase.overlay.trackedDevice,
                smoothAnchoringTrackedDevice = dpBase.smoothAnchoringTrackedDevice,
                snapAnchoringTrackedDevice   = dpBase.snapAnchoringTrackedDevice,
                isAnchoredToTheBar           = dpBase.isAnchoredToTheBar,

                useSmoothAnchoring      = dpBase.useSmoothAnchoring,
                smoothAnchoringStrength = dpBase.smoothAnchoringStrength,

                useSnapAnchoring      = dpBase.useSnapAnchoring,
                snapAnchoringDistance = dpBase.snapAnchoringDistance,

                isPinned = dpBase.isPinned,

                captureFPS = dpBase.fpsToCaptureAt,

                forceCaptureRate = dpBase.forceHighCaptureFramerate,

                opacity = dpBase.overlay.targetOpacity,

                useLookHiding         = dpBase.useLookHiding,
                lookHidingStrength    = dpBase.lookHidingStrength,
                lookHidingHideOpacity = dpBase.lookHidingOpacity,

                useDistanceHiding      = dpBase.useDistanceHiding,
                distanceHidingDistance = dpBase.distanceHidingDistance,
                distanceHidingOpacity  = dpBase.distanceHidingOpacity,

                useWindowCropping = dpBase.useWindowCropping,
                cropAmount        = dpBase.cropAmount,

                useSBS         = dpBase.overlay.useSBS,
                sbsCrossedMode = dpBase.overlay.sbsCrossedMode,

                useTouchInput = dpBase.useTouchInput,

                alwaysInteract           = dpBase.alwaysInteract,
                alwaysInteractBlockInput = dpBase.alwaysInteractBlockInput,

                disableInteraction = dpBase.isInteractable,

                disableDragging = dpBase.isDraggable
            };


            //If it's smooth/snap anchored, get the position of the target object instead
            if (state.useSmoothAnchoring)
            {
                state.pos = dpApp.dpMain.smoothAnchoringDummyObject.transform.localPosition;
                state.rot = dpApp.dpMain.smoothAnchoringDummyObject.transform.localEulerAngles;
            }
            else if (state.useSnapAnchoring)
            {
                state.pos = dpApp.dpMain.snapAnchoringDummyObject.transform.localPosition;
                state.rot = dpApp.dpMain.snapAnchoringDummyObject.transform.localEulerAngles;
            }


            //Special code if it's a desktop capture
            if (dpApp.isCapture && dpBase is DPDesktopOverlay desktopDP)
            {
                state.isCapture = true;

                if (desktopDP.isTargetingWindow)
                {
                    //If the title is long enough, store the last characters
                    if (desktopDP.window.title.Length > I.partialWindowTitleCharacters)
                    {
                        state.partialWindowTitle = desktopDP.window.title.Substring(desktopDP.window.title.Length - I.partialWindowTitleCharacters);
                    }
                    else
                    {
                        state.partialWindowTitle = desktopDP.window.title;
                    }

                    state.exePath = WinNative.GetFilePath(desktopDP.window.handle);
                }
                else
                {
                    //Store the name of the display
                    state.displayName = desktopDP.monitor.name;
                }
            }

            else
            {
                state.isCapture = false;
            }


            return(state);
        }
Пример #10
0
 public void AddLoadedApp(DPApp dpApp)
 {
     loadedApps[dpApp.appKey] = dpApp;
 }
Пример #11
0
        private IEnumerator C_JoinDiscord()
        {
            //Clipboard.SetText("https://discord.gg/adVEQmY");

            Process.Start("https://discord.gg/adVEQmY");

            yield break;

            UwcWindow        discordWindow = null;
            DPDesktopOverlay discordDP     = null;
            DPApp            discordDPApp  = null;

            //See if discord is opened already
            foreach (DPDesktopOverlay desktopDP in DPDesktopOverlay.overlays)
            {
                if (desktopDP.isTargetingWindow && desktopDP.window.title.EndsWith("- Discord"))
                {
                    discordDP     = desktopDP;
                    discordWindow = desktopDP.window;

                    break;
                }
            }

            //If the overlay isn't already opened, we try to spawn a new one
            if (discordWindow == null)
            {
                //See if discord is opened
                foreach (UwcWindow window in UwcManager.windows.Values)
                {
                    if (window.title.EndsWith("- Discord"))
                    {
                        discordWindow = window;

                        discordDP = OverlayManager.I.NewDPWindowOverlay(discordWindow);

                        break;
                    }
                }
            }

//TODO: Launch discord
            //if (discordWindow == null || discordDP == null) {

            Process.Start("https://discord.gg/adVEQmY");

            yield break;
            //}


            //Find the DPApp
            foreach (DPApp app in TheBarManager.openApps.Values)
            {
                if (app.dpMain == discordDP)
                {
                    discordDPApp = app;
                    break;
                }
            }


            if (discordWindow.isIconic)
            {
                WinNative.ShowWindow(discordWindow.handle, ShowWindowCommands.Restore);
            }

            TheBarManager.I.LaunchAppToMainSnap(discordDPApp.appKey);

            WinNative.SetForegroundWindow(discordWindow.handle);

            yield return(new WaitForSeconds(0.2f));

            yield return(new WaitForSeconds(0.2f));

            //const int WM_KEYDOWN = 0x100;
            //const int WM_KEYUP = 0x101;

            //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LCONTROL, 0);
            //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LSHIFT, 0);
            //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_N, 0);

            InputSimulator inputSimulator = new InputSimulator();

            //inputSimulator.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
            inputSimulator.Keyboard.ModifiedKeyStroke(new[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LSHIFT }, new[] { VirtualKeyCode.VK_N });

            yield return(new WaitForSeconds(0.2f));

            inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
            inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
            inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB);

            inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN);

            yield return(new WaitForSeconds(0.2f));

            inputSimulator.Keyboard.TextEntry("https://discord.gg/adVEQmY");



            /*//Tab 3 times to the join server button:
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0);
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0);
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0);
             *
             * yield return null;
             *
             * //Enter
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_RETURN, 0);
             *
             * yield return new WaitForSeconds(0.2f);
             *
             * //Paste in the join link
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LCONTROL, 0);
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_V, 0);
             * yield return null;
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYUP, (int)KeysEx.VK_V, 0);
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYUP, (int)KeysEx.VK_LCONTROL, 0);
             *
             * yield return null;
             *
             * //Enter to join:
             * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_RETURN, 0);*/
        }