public PropertyForm(RadarWindow window) { this.window = window; InitializeComponent(); Xmargin = Width - propertyGrid1.Width; Ymargin = Height - propertyGrid1.Height; }
static RadarWindow TryLoad(string settingsPath) { try { return(XmlSerializer <RadarWindow> .DeserializeFromFile(settingsPath)); } catch (Exception ex) { RadarWindow radarWindow = new RadarWindow(); Console.WriteLine(ex.StackTrace); var mboxresult = MessageBox.Show("Error reading settings file.\n" + ex.Message + "\nPress Abort to exit, Retry to try again, or Ignore to destroy the file and start a new config.", "Error reading settings file", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); if (mboxresult == DialogResult.Abort) { Environment.Exit(1); } else if (mboxresult == DialogResult.Retry) { return(TryLoad(settingsPath)); } else { radarWindow = new RadarWindow(); PropertyForm propertyForm = new PropertyForm(radarWindow); propertyForm.ShowDialog(); return(radarWindow); } } return(new RadarWindow()); }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { if (radar != null) { radar.Close(); radar = null; } base.OnClosing(e); //if (radar != null && radar.IsLoaded) //{ // radar.Close(); //} }
void RadarButton_Click(object sender, RoutedEventArgs e) { if (radar != null && radar.IsLoaded) { radar.Focus(); } else { radar = new RadarWindow(ArcheBuddyCore); radar.Top = this.Top; radar.Left = this.Left + this.ActualWidth; radar.Show(); radar.Focus(); } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LoadReceiverPlugins(); if (args.Length > 0) { string arg = args[0].ToUpper().Trim(); if (arg.Contains("/C")) { string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "DGScope.xml"); RadarWindow radarWindow; if (File.Exists(settingsPath)) { radarWindow = TryLoad(settingsPath); } else { radarWindow = new RadarWindow(); } PropertyForm propertyForm = new PropertyForm(radarWindow); propertyForm.ShowDialog(); radarWindow.SaveSettings(settingsPath); } else if (arg.Contains("/S")) { Start(true); } else if (arg.Contains("/P")) { //do nothing } else { Start(false); } } else { Start(false); } }
static void Start(bool screensaver = false) { string settingsPath = screensaver? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "DGScope.xml") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "DGScope.xml"); RadarWindow radarWindow; if (File.Exists(settingsPath)) { radarWindow = TryLoad(settingsPath); } else { radarWindow = new RadarWindow(); if (!screensaver) { MessageBox.Show("No config file found. Starting a new config."); PropertyForm propertyForm = new PropertyForm(radarWindow); propertyForm.ShowDialog(); radarWindow.SaveSettings(settingsPath); } } radarWindow.Run(screensaver); }