-
-
Save VasylBakalets/9940023abd33c885e9fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwitchManager | |
{ | |
public static void InitializeAgentWindow(AgentWindow type) | |
{ | |
Dictionary<int, AgentWindow> temp = new Dictionary<int, AgentWindow>(); | |
if (agentWindows.Count == 0) | |
agentWindows.Add(1, type); | |
else | |
{ | |
temp.Add(1, type); | |
foreach (var window in agentWindows) | |
{ | |
var t = window.Key; | |
temp.Add(++t, window.Value); | |
} | |
agentWindows = temp; | |
} | |
} | |
public static int SwitchToAgent(AgentWindow type) | |
{ | |
var windowToSwitch = agentWindows.First(w => w.Value == type); | |
UpdateIndexesAgent(windowToSwitch); | |
return windowToSwitch.Key; | |
} | |
private static void UpdateIndexesAgent(KeyValuePair<int, AgentWindow> windowToSwitch) | |
{ | |
Dictionary<int, AgentWindow> temp = new Dictionary<int, AgentWindow>(); | |
agentWindows.Remove(windowToSwitch.Key); | |
foreach (var window in agentWindows) | |
{ | |
if (window.Key < windowToSwitch.Key) | |
{ | |
var t = window.Key; | |
temp.Add(++t, window.Value); | |
} | |
else | |
temp.Add(window.Key, window.Value); | |
} | |
temp.Add(1, windowToSwitch.Value); | |
agentWindows = temp; | |
} | |
private static Dictionary<int, AgentWindow> agentWindows = new Dictionary<int, AgentWindow>(); | |
} | |
public enum AgentWindow | |
{ | |
AgentA1, | |
AgentA2, | |
AgentF1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment