protected void SaveConfig(Configuration newConfig) { Configuration.Save(newConfig); Reload(); var temp = Volatile.Read(ref ConfigChanged); temp?.Invoke(this, new EventArgs()); }
public void Reload() { _config = Configuration.Load(); if (_syncTask != null && !_syncTask.IsCanceled && !_syncTask.IsCompleted) { _cancellationTokenSource.Cancel(); } if (!_config.Enabled) return; _cancellationTokenSource = new CancellationTokenSource(); _syncTask = new Task(() => { SyncProcess(_cancellationTokenSource.Token); }, _cancellationTokenSource.Token); _syncTask.Start(); }
public static void Save(Configuration config) { try { using (StreamWriter sw = new StreamWriter(File.Open(Constants.CONFIG_FILENAME, FileMode.Create))) { string jsonString = SimpleJson.SimpleJson.SerializeObject(config); sw.Write(jsonString); sw.Flush(); } } catch (IOException e) { Console.Error.WriteLine(e); } }
private void UpdateTrayText(Configuration config) { var ip = string.IsNullOrEmpty(_controller.CurrentIp) ? "loading..." : _controller.CurrentIp; _notifyIcon.Text = $"Ipsync \n{(config.Enabled ? ("Stared: " + ip) : "Stopped")}"; }
private void UpdateTrayIcon(Configuration config) { var icon = Resources.icon76; if (!config.Enabled) { var iconCopy = new Bitmap(icon); for (var x = 0; x < iconCopy.Width; x++) { for (var y = 0; y < iconCopy.Height; y++) { var color = icon.GetPixel(x, y); iconCopy.SetPixel(x, y, Color.FromArgb((byte)(color.A / 1.25), color.R, color.G, color.B)); } } icon = iconCopy; } _notifyIcon.Icon = Icon.FromHandle(icon.GetHicon()); }
private void LoadConfiguration(Configuration config) { _enableItem.Checked = config.Enabled; _autoStartupItem.Checked = AutoStartup.Check(); if (!config.Initialized || string.IsNullOrEmpty(config.DropbopxPath)) { ShowConfigForm(); } }