public void AddProcess(Process p, KeySwitchMethod switchmethod)
        {
            if (p != null && p.processKeyActions != null)
            {

                if (switchmethod.In(KeySwitchMethod.Switch, KeySwitchMethod.TempOverwrite, KeySwitchMethod.TempSwitch))
                {
                    throw new NotImplementedException("Don't make a fus, implement your bus.");
                }

                foreach (KeyAction a in p.processKeyActions.Keys)
                {
                    Keybinds[p.processKeyActions[a]] = a;
                }
            }
        }
        public void AddProcess(ProcessManager pm, Process p, bool Temporary = true)
        {
            if (p == null) throw new SystemException("Process parameter was null"); //well ya see kids...
            if (p.processKeyActions == null) throw new SystemException("Process parameter had no keyactions");
            p.active = true;
            if (Temporary)
            {
                if (TemporaryProcess != p)
                {
                    //remove current temporary process and reinstate the keybinds it had replaced when it was added
                    RemoveTemporaryProcess(pm);

                    ReplacedBundles[p] = new List<Tuple<KeyBundle, KeyAction>>();
                    foreach (KeyAction a in p.processKeyActions.Keys)
                    {

                        //store previous keyaction in replacedbundles
                        if (Keybinds.ContainsKey(p.processKeyActions[a]))
                        {
                            ReplacedBundles[p].Add(new Tuple<KeyBundle, KeyAction>(p.processKeyActions[a], Keybinds[p.processKeyActions[a]]));
                        }
                        //insert new keybind
                        Keybinds[p.processKeyActions[a]] = a;
                    }
                    TemporaryProcess = p;
                    if (!pm.activeProcesses.Contains(p))
                        pm.activeProcesses.Add(p);
                }
            }
            else //permanent process
            {
                if (!PermanentProcesses.Contains(p))
                {
                    PermanentProcesses.Add(p);
                    foreach (KeyAction a in p.processKeyActions.Keys)
                    {
                        //insert new keybind
                        Keybinds[p.processKeyActions[a]] = a;
                    }
                }
            }
            if (ui.sidebar != null) ui.sidebar.UpdateProcessView();
        }
        public void RemoveTemporaryProcess(ProcessManager pm)
        {
            if (TemporaryProcess == null) return;//throw new SystemException("Temporary process was null");
            TemporaryProcess.active = false;
            foreach(KeyAction ka in TemporaryProcess.processKeyActions.Keys)
            {
                KeyBundle kb = TemporaryProcess.processKeyActions[ka];
                if (Keybinds.ContainsKey(kb) && ka == Keybinds[kb])
                {
                    Keybinds.Remove(TemporaryProcess.processKeyActions[ka]);
                }
            }
            if (ReplacedBundles.ContainsKey(TemporaryProcess))
            {
                List<Tuple<KeyBundle, KeyAction>> list = ReplacedBundles[TemporaryProcess];
                foreach(Tuple<KeyBundle, KeyAction> tup in list)
                {
                    if (Keybinds.ContainsKey(tup.Item1)) continue; //maybe shouldn't do this; doesn't replace if something took the slot
                    Keybinds.Add(tup.Item1, tup.Item2);
                }
            }
            pm.activeProcesses.Remove(TemporaryProcess);

            ReplacedBundles.Remove(TemporaryProcess);
            TemporaryProcess = null; //maybe disable temporary process? or should we let caller do that
        }