private void SetupBindingCombos() { if (Properties.Settings.Default.XboxCustomMapping && MapsView.SelectedItems.Count > 0) { ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; MapsView.EndUpdate(); TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)binding.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)binding.BindingType; RepeatCheckbox.Checked = binding.Parent.AutoRepeat; UpdatePropertyCombo(); } else { TargetTypeCombo.Items.Clear(); BindTypeCombo.Items.Clear(); TargetPropertyCombo.Items.Clear(); } }
private void OK_Click(object sender, EventArgs e) { bool failed = false; target.StartTime = startDate.DateTimeValue; target.EndTime = endDate.DateTimeValue; double days = UiTools.ParseAndValidateDouble(fadeTime, target.FadeSpan.Days, ref failed); try { target.FadeSpan = TimeSpan.FromDays(Convert.ToDouble(fadeTime.Text)); } catch { fadeTime.BackColor = Color.Red; failed = true; } target.FadeType = (FadeType)fadeType.SelectedIndex; if (!failed) { DialogResult = DialogResult.OK; this.Close(); } }
private void Scale_TextChanged(object sender, EventArgs e) { bool valid = false; Properties.Settings.Default.ScreenOverlayScale = UiTools.ParseAndValidateDouble(Scale, Properties.Settings.Default.ScreenOverlayScale, ref valid); Dirty = true; }
private void SetupBindingCombos() { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)binding.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)binding.BindingType; RepeatCheckbox.Checked = binding.Parent.AutoRepeat; UpdatePropertyCombo(); DeviceImage.Invalidate(); } else { TargetTypeCombo.Items.Clear(); BindTypeCombo.Items.Clear(); TargetPropertyCombo.ClearText(); } }
private void StartLat_TextChanged(object sender, EventArgs e) { bool failed = false; Layer.LatStart = UiTools.ParseAndValidateCoordinate(StartLat, Layer.LatStart, ref failed); Layer.CleanUp(); }
private void timeHold_TextChanged(object sender, EventArgs e) { bool failed = false; Target.TransitionHoldTime = UiTools.ParseAndValidateCoordinate(TimeHold, Target.TransitionHoldTime, ref failed); ProcessChange(); }
private void PasteFromTle_Click(object sender, EventArgs e) { if (Clipboard.ContainsText() && Clipboard.GetText().Length > 0) { string data = Clipboard.GetText(TextDataFormat.UnicodeText); string[] lines = data.Split(new char[] { '\n', '\r' }); string line1 = ""; string line2 = ""; for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].Trim(); if (lines[i].Length == 69 && ReferenceFrame.IsTLECheckSumGood(lines[i])) { if (line1.Length == 0 && lines[i].Substring(0, 1) == "1") { line1 = lines[i]; } if (line2.Length == 0 && lines[i].Substring(0, 1) == "2") { line2 = lines[i]; } } } if (line1.Length == 69 && line2.Length == 69) { frame.FromTLE(line1, line2, 398600441800000); SyncToFrame(); return; } } UiTools.ShowMessageBox(Language.GetLocalizedText(756, "The clipbboard does not appear to contain a valid TLE set. Copy the contents of a Two Line Elements (TLE) set from your source to the clipboard in plain text and click paste again"), Language.GetLocalizedText(755, "Paste Orbital Elements from TLE")); }
private void OK_Click(object sender, EventArgs e) { purgeImagery = imagery.Checked; purgeCatalogs = catalogs.Checked; purgeTours = tours.Checked; if (purgeCatalogs || purgeImagery || purgeTours) { if (purgeCatalogs) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(149, "This will delete custom constellation figures as well as other selected data and close the application. Do you want to continue?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } else { if (UiTools.ShowMessageBox(Language.GetLocalizedText(150, "This will delete cached data and close the application. Do you want to continue?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } purgeMode = true; timer.Enabled = true; progressText.Text = Language.GetLocalizedText(151, "Purging Cache"); progressBar.Value = 0; Purge.Enabled = false; backgroundWorker.RunWorkerAsync(); } }
private void EndLng_TextChanged(object sender, EventArgs e) { bool failed = false; Layer.LngEnd = UiTools.ParseAndValidateCoordinate(EndLng, Layer.LngEnd, ref failed); Layer.CleanUp(); }
private void Percentage_TextChanged(object sender, EventArgs e) { bool failed = false; Layer.PercentComplete = UiTools.ParseAndValidateCoordinate(Percentage, Layer.PercentComplete, ref failed); Layer.CleanUp(); }
private void LineWidth_TextChanged(object sender, EventArgs e) { bool failed = false; Layer.Width = UiTools.ParseAndValidateCoordinate(LineWidth, Layer.Width, ref failed); Layer.CleanUp(); }
private void ImportAuthorImage_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = Language.GetLocalizedText(486, "Image Files") + "(*.BMP;*.JPG;*.PNG;*.TIF)|*.BMP;*.JPG;*.PNG;*.TIF;*.TIFF|All files (*.*)|*.*"; if (openFile.ShowDialog() == DialogResult.OK) { Bitmap bmpTemp = null; try { bmpTemp = Thumbnailer.MakeThumbnail(UiTools.LoadBitmap(openFile.FileName), 72, 96); } catch { bmpTemp = null; } if (bmpTemp != null) { this.authorImagePicturebox.Image = bmpTemp; ValidateDataComplete(); } } }
private void Import_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Language.GetLocalizedText(821, "Trajectory files") + " (*.xyz)|*.xyz"; bool tryAgain = true; while (tryAgain) { try { if (ofd.ShowDialog() == DialogResult.OK) { string fileName = ofd.FileName; frame.ImportTrajectory(fileName); tryAgain = false; } else { tryAgain = false; } } catch { UiTools.ShowMessageBox(Language.GetLocalizedText(947, "The File does not appear to be a Vaild Trajectory File."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); } } }
private void ClearAccept_Click(object sender, EventArgs e) { if (UiTools.ShowMessageBox("This will clear the Accept List. Are you sure you want to continue?", "Application Access List", MessageBoxButtons.YesNo) == DialogResult.Yes) { AcceptList.Items.Clear(); } }
private void CurrentValue_Validating(object sender, CancelEventArgs e) { if (initializing || CurrentValue.Text == Language.GetLocalizedText(1351, "Multiple") || dirtyEdit == false) { return; } bool failed = false; double newValue = UiTools.ParseAndValidateDouble(CurrentValue, propValue, ref failed); if (newValue != propValue && !failed) { if (keys != null) { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1352, "Key Properties Edit"), Earth3d.MainWindow.TourEdit.Tour)); foreach (VisibleKey vk in keys.Values) { Key key = vk.Target.GetKey(vk.ParameterIndex, vk.Time); if (key != null) { key.Value = newValue; } } } TimeLine.RefreshUi(false); RefreshTween(); } }
private void ValidateDataComplete() { bool okEnabled = true; if (String.IsNullOrEmpty(tourTitleTextbox.Text) || tourTitleTextbox.Text == Language.GetLocalizedText(485, "Please enter a title for the tour...")) { okEnabled = false; tourTitleTextbox.BackColor = highlightNeeded ? Color.Red : OrganizationName.BackColor; } else { tourTitleTextbox.BackColor = OrganizationName.BackColor; } // if (string.IsNullOrEmpty(authorEmailText.Text) || UiTools.IsEmail(authorEmailText.Text)) if (Strict && !UiTools.IsEmail(authorEmailText.Text)) { okEnabled = false; authorEmailText.BackColor = highlightNeeded ? Color.Red : OrganizationName.BackColor; } else { authorEmailText.BackColor = OrganizationName.BackColor; } //todo validate URLS's if (Strict && string.IsNullOrEmpty(this.authorNameTextbox.Text)) { okEnabled = false; this.authorNameTextbox.BackColor = highlightNeeded ? Color.Red : OrganizationName.BackColor; } else { this.authorNameTextbox.BackColor = OrganizationName.BackColor; } if (Strict && string.IsNullOrEmpty(this.tourDescriptionTextbox.Text)) { okEnabled = false; this.tourDescriptionTextbox.BackColor = highlightNeeded ? Color.Red : OrganizationName.BackColor; } else { this.tourDescriptionTextbox.BackColor = OrganizationName.BackColor; } if (authorImageNeeded && authorImagePicturebox.Image == null) { okEnabled = false; authorImagePicturebox.BackColor = highlightNeeded ? Color.Red : OrganizationName.BackColor; } else { authorImagePicturebox.BackColor = OrganizationName.BackColor; } OK.Enabled = okEnabled; }
public void InstallNewFigureFile(string launchTourFile) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(514, "Do you want to add these constellation figures to your Figure Library?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo) == DialogResult.Yes) { String newName = launchTourFile.ToLower().Replace(".wwtfig", ""); newName = newName.Substring(newName.LastIndexOf("\\") + 1); SimpleInput input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), newName, 32); bool retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(Constellations.GetFigurePath(input.ResultText))) { int index = figureLibrary.Items.IndexOf(input.ResultText); if (index > -1) { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } else { try { File.Copy(launchTourFile, Constellations.GetFigurePath(input.ResultText)); Constellations newFigures = new Constellations(input.ResultText, null, false, false); newFigures.Save(input.ResultText); figureLibrary.Items.Add(input.ResultText); figureLibrary.SelectedIndex = figureLibrary.Items.IndexOf(input.ResultText); retry = false; } catch { if (File.Exists(Constellations.GetFigurePath(input.ResultText))) { File.Delete(Constellations.GetFigurePath(input.ResultText)); } UiTools.ShowMessageBox(Language.GetLocalizedText(517, "The file is not a valid WorldWide Telescope Constellation Figure File"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); return; } } } else { MessageBox.Show(Language.GetLocalizedText(518, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } } else { return; } } while (retry); } }
private void TabForm_MouseHover(object sender, EventArgs e) { if (!this.ContainsFocus) { if (UiTools.IsAppFocused()) { Focus(); } } }
private void sizeY_TextChanged(object sender, EventArgs e) { bool failed = false; double val = UiTools.ParseAndValidateDouble(sender as TextBox, Overlay.Height, ref failed); if (!failed) { Overlay.Height = (float)val; } }
private void Rotation_TextChanged(object sender, EventArgs e) { bool failed = false; double val = UiTools.ParseAndValidateDouble(sender as TextBox, Overlay.RotationAngle, ref failed); if (!failed) { Overlay.RotationAngle = (float)val; } }
private void positionY_TextChanged(object sender, EventArgs e) { bool failed = false; double val = UiTools.ParseAndValidateDouble(sender as TextBox, Overlay.Position.X, ref failed); if (!failed) { Overlay.Position = new PointF(Overlay.Position.X, (float)val); } }
static public Bitmap LoadThumbnailFromWeb(string url, string filename) { try { DataSetManager.DownloadFile(CacheProxy.GetCacheUrl(url), Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename, true, true); return(UiTools.LoadBitmap(Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename)); } catch { return(null); } }
public void LoadFromString(string data, bool isUpdate, bool purge, bool hasHeader) { StringReader sr = new StringReader(data); if (!isUpdate || hasHeader) { if (sr.Peek() >= 0) { string headerLine = sr.ReadLine(); if (!headerLine.Contains("\t") && headerLine.Contains(",")) { Delimiter = ','; } if (!isUpdate) { Rows.Clear(); } Header = UiTools.SplitString(headerLine, Delimiter); } else { Header = new string[0]; } } List <string[]> temp = new List <string[]>(); if (!purge) { temp = Rows; } int count = 0; while (sr.Peek() >= 0) { string line = sr.ReadLine(); string[] rowData = UiTools.SplitString(line, Delimiter); if (rowData.Length < 1) { break; } temp.Add(rowData); count++; } if (purge) { Rows = temp; } }
public static void DownloadNewMPSCoreFile() { string filename = Properties.Settings.Default.CahceDirectory + "\\data\\MPCCORB.DAT.gz"; string url = "http://www.minorplanetcenter.net/iau/MPCORB/MPCORB.DAT.gz"; if (!FileDownload.DownloadFile(url, filename, true)) { return; } try { Stream fs = File.OpenRead(filename); Stream s = new GZipStream(fs, CompressionMode.Decompress); MPCList.Clear(); StreamReader sr = new StreamReader(s); bool dataFound = false; while (!sr.EndOfStream) { string data = sr.ReadLine(); if (dataFound && data.Length > 150) { CAAEllipticalObjectElements ee = new CAAEllipticalObjectElements(); ee.a = Convert.ToDouble(data.Substring(92, 11)); ee.e = Convert.ToDouble(data.Substring(70, 9)); ee.i = Convert.ToDouble(data.Substring(59, 9)); ee.omega = Convert.ToDouble(data.Substring(48, 9)); ee.w = Convert.ToDouble(data.Substring(37, 9)); ee.JDEquinox = UnpackEpoch(data.Substring(20, 5)); double M = Convert.ToDouble(data.Substring(26, 9)); double n = Convert.ToDouble(data.Substring(80, 11)); ee.T = ee.JDEquinox - (M / n); MPCList.Add(ee); } else { if (data.Length > 3 && data.Substring(0, 4) == "----") { dataFound = true; } } } sr.Close(); WriteBinaryMPCData(Properties.Settings.Default.CahceDirectory + "\\data\\mpc.bin"); } catch { UiTools.ShowMessageBox(Language.GetLocalizedText(1003, "The image file did not download or is invalid."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); } }
//todo this stuff below is too tightly coupled to implementtion for winforms public static void GotoLookAt(KmlFeature feature) { //todo add sky support CameraParameters camera = new CameraParameters(); camera.Lat = feature.LookAt.latitude; camera.Lng = feature.LookAt.longitude; camera.Rotation = feature.LookAt.heading / 180 * Math.PI; camera.Angle = -feature.LookAt.tilt / 180 * Math.PI; camera.Zoom = UiTools.MetersToZoom(feature.LookAt.range); TourPlace p = new TourPlace(feature.Name, camera, Classification.Unidentified, "", ImageSetType.Earth, SolarSystemObjects.Earth); Earth3d.MainWindow.GotoTarget(p, false, false, true); }
private void Delete_Click(object sender, EventArgs e) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(1171, "This will remove this control map. Are you sure you want to do this?"), Language.GetLocalizedText(1172, "Remove Control Map"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; midiMap.ControlMaps.Remove(binding.Parent); LoadControlMaps(); midiMap.Dirty = true; } }
private void SetupBidingCombos() { TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)ButtonMap.BindingA.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)ButtonMap.BindingA.BindingType; buttonTypeCombo.Items.Clear(); buttonTypeCombo.Items.AddRange(Enum.GetNames(typeof(ButtonType))); buttonTypeCombo.SelectedIndex = (int)ButtonMap.ButtonType; UpdatePropertyCombo(); }
private void DurrationEditor_FormClosed(object sender, FormClosedEventArgs e) { try { if (target.Duration != TimeText) { if (target.KeyFramed) { if (TimeText.TotalSeconds < target.Duration.TotalSeconds) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(1361, "Do you want to trim the timeline and delete keys past the new duration (Yes) or scale keys to the new duration (No)?"), Language.GetLocalizedText(1362, "Trim or scale timeline"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1365, "Trim Timeline"), target.Owner)); target.ExtendTimeline(target.Duration, TimeText); } else { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1366, "Scale Timeline"), target.Owner)); target.Duration = TimeText; } } else { if (UiTools.ShowMessageBox(Language.GetLocalizedText(1364, "Do you want to extend the timeline (Yes) or scale it (No)?"), Language.GetLocalizedText(1363, "Extend or scale timeline"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1367, "Extend Timeline"), target.Owner)); target.ExtendTimeline(target.Duration, TimeText); } else { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1366, "Scale Timeline"), target.Owner)); target.Duration = TimeText; } } } else { Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(1368, "Edit Duration"), target.Owner)); target.Duration = TimeText; } } Earth3d.NoStealFocus = false; } catch { } }
public void Append(string data) { StringReader sr = new StringReader(data); int count = 0; while (sr.Peek() >= 0) { string line = sr.ReadLine(); string[] rowData = UiTools.SplitString(line, Delimiter); if (rowData.Length < 2) { break; } Rows.Add(rowData); count++; } }
private void search_Click(object sender, EventArgs e) { // The following line will not work with localized strings for low, medium, high // VerbosityTypes verb = (VerbosityTypes)Enum.Parse(typeof(VerbosityTypes), verbosity.SelectedItem.ToString()); // Low = 1, Medium = 2, High = 3 if (baseUrl.Text.Length > 0) { string adjustedBase = baseUrl.Text; if (!adjustedBase.EndsWith(@"&") && !adjustedBase.EndsWith(@"?")) { if (adjustedBase.Contains(@"?")) { adjustedBase += "&"; } else { adjustedBase += "?"; } } int verb = verbosity.SelectedIndex + 1; string tempURL = ""; if (coneSearch) { tempURL = string.Format("{0}RA={1}&DEC={2}&SR={3}&VERB={4}", adjustedBase, ra.Text, dec.Text, searchRadius.Text, verb); } else { tempURL = string.Format("{0}POS={1},{2}&SIZE={3}&VERB={4}", adjustedBase, ra.Text, dec.Text, searchRadius.Text, verb); } if (!Uri.IsWellFormedUriString(tempURL, UriKind.Absolute)) { UiTools.ShowMessageBox(Language.GetLocalizedText(914, "The URL does not appear to be well formed")); return; } lastBaseUrl = baseUrl.Text; URL = tempURL; DialogResult = DialogResult.OK; Close(); } }