Esempio n. 1
0
        public static async Task AddFromServer(List <string> serverDesktopNames)
        {
            if (!Config.Instance.Desktops.SequenceEqual(serverDesktopNames))
            {
                Config.Instance.Desktops = serverDesktopNames;
                await Config.Save();

                DesktopsChanged?.Invoke(null, new EventArgs());
            }
        }
Esempio n. 2
0
 static Desktop()
 {
     Config.SettingsReloaded += (s, e) =>
     {
         if (!Config.Instance.Desktops.SequenceEqual(lastDesktops))
         {
             lastDesktops = Config.Instance.Desktops.ToList();
             DesktopsChanged?.Invoke(null, new EventArgs());
         }
     };
 }
Esempio n. 3
0
        private async void OnDesktopsChanged(object?sender, EventArgs e)
        {
            if (onDesktopsChangedDebounce != null)
            {
                onDesktopsChangedDebounce.Cancel();
                onDesktopsChangedDebounce.Dispose();
            }

            onDesktopsChangedDebounce = new CancellationTokenSource();
            try
            {
                await Task.Delay(DesktopsChangedDebounceTimeout, onDesktopsChangedDebounce.Token);

                DesktopsChanged?.Invoke(this, new DesktopsChangedEventArgs(Configuration.Config.Instance.Desktops));
            }
            catch (TaskCanceledException) { }
        }
Esempio n. 4
0
        public static async Task AddFromClient(List <string> clientDesktopNames)
        {
            bool added = false;

            foreach (var n in clientDesktopNames)
            {
                if (!Config.Instance.Desktops.Any(d => string.Compare(d, n, StringComparison.InvariantCultureIgnoreCase) == 0))
                {
                    Config.Instance.Desktops.Add(n.NormalizeDesktopName());
                    added = true;
                }
            }

            if (added)
            {
                await Config.Save();

                DesktopsChanged?.Invoke(null, new EventArgs());
            }
        }