private void LoadAlignment() { try { AlignStar[] stars = settings_.AlignmentStars; if (stars == null) { alignment_ = null; } else { alignment_ = new DSCAlignment(settings_.AlignmentEquAxis, Precisions.Default); for (int i = 0; i < stars.Length; ++i) { alignment_.AddStar(stars[i]); } alignment_.ForceAlignment(); alignmentConnectionAltAzm_ = settings_.AlignmentConnectionAltAzm; alignmentConnectionEqu_ = settings_.AlignmentConnectionEqu; } } catch (Exception) { alignment_ = null; } AlignmentChanged(); }
private void buttonAddObject_Click(object sender, EventArgs e) { if (!init_) { return; } double d = ClientCommonAPI.CalcTime(); SkyObjectPosCalc.SkyPosition obj = GetObject(); double azm, alt; obj.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt); try { DSCAlignment alignmentNew = (DSCAlignment)alignment_.Clone(); alignmentNew.AddStar(new AlignStar(obj.Name, new Vect3(azm * Const.toRad, alt * Const.toRad), new PairA(host_.AzmAngle, host_.AltAngle), host_.EquAngle)); alignmentNew.ForceAlignment(); alignment_ = alignmentNew; } catch (Exception ex) { MessageBox.Show(ex.Message, "Alignment Error", MessageBoxButtons.OK); return; } AlignmentChanged(); }
private void buttonLoadAlignment_Click(object sender, EventArgs e) { OpenFileDialog openfile = new OpenFileDialog(); openfile.InitialDirectory = Application.StartupPath + @"\"; openfile.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; openfile.FilterIndex = 1; openfile.RestoreDirectory = true; try { DialogResult res = openfile.ShowDialog(); if (res != DialogResult.OK) { return; } XmlProfile profile = new XmlProfile(openfile.FileName); AlignStar[] stars = (AlignStar[])profile.GetValue("entries", "AlignmentStars", null, typeof(AlignStar[])); Vect3 alignmentEquAxis = (Vect3)profile.GetValue("entries", "AlignmentEquAxis", new Vect3()); if (stars != null) { alignment_ = new DSCAlignment(alignmentEquAxis, Precisions.Default); for (int i = 0; i < stars.Length; ++i) { alignment_.AddStar(stars[i]); } alignment_.ForceAlignment(); AlignmentChanged(); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }