Пример #1
0
 public AstroCalc(ConfigData config)
 {
     this.config = config;
     s = new SwissEph();
     // http://www.astro.com/ftp/swisseph/ephe/archive_zip/ からDL
     s.swe_set_ephe_path(config.ephepath);
     s.OnLoadFile += (sender, ev) => {
         if (File.Exists(ev.FileName))
             ev.File = new FileStream(ev.FileName, FileMode.Open);
     };
 }
Пример #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // コンフィグ読み込み
            config = new ConfigData();
            setting = new Settings();
            aspectSettingList = new AspectSetting[10];
            for (int i = 0; i< 9; i++)
            {
                aspectSettingList[i] = new AspectSetting();
            }

            // 表示設定
            for (int i = 0; i < 10; i++)
            {
                if (File.Exists(aspect_filename + i.ToString() + ".xml"))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(AspectSetting));
                    FileStream fs = new FileStream(aspect_filename + i.ToString() + ".xml", FileMode.Open);
                    aspectSettingList[i] = (AspectSetting)serializer.Deserialize(fs);
                    fs.Close();
                    if (aspectSettingList[i].dispname == null)
                    {
                        aspectSelect.Items.Add("表示設定" + i.ToString());
                    } else
                    {
                        aspectSelect.Items.Add(aspectSettingList[i].dispname);
                    }
                } else
                {
                    aspectSettingList[i] = new AspectSetting() { dispname = "表示設定" + i.ToString() };
                    if (!Directory.Exists(Path.GetDirectoryName(aspect_filename + i.ToString() + ".xml")))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(aspect_filename));
                    }
                    XmlSerializer serializer = new XmlSerializer(typeof(AspectSetting));
                    FileStream fs = new FileStream(aspect_filename + i.ToString() + ".xml", FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    serializer.Serialize(sw, aspectSettingList[i]);
                    sw.Close();
                    fs.Close();

                    aspectSelect.Items.Add("表示設定" + i.ToString());
                }
            }

            string name = "現在";
            int year = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int day = DateTime.Now.Day;
            int hour = DateTime.Now.Hour;
            int minute = DateTime.Now.Minute;
            int second = DateTime.Now.Second;
            string birth = String.Format("{0}年{1}月{2}日 {3:00}:{4:00}:{5:00}",
                        year.ToString(),
                        month.ToString(),
                        day.ToString(),
                        hour.ToString(),
                        minute.ToString(),
                        second.ToString()
                    );
            string place = "東京都中央区";
            double lat = 35.670587;
            double lng = 139.772003;
            if (!File.Exists(filename))
            {
                // 初期データ
                setMainData(name, birth, place, lat, lng);
                setMainEventData(name, birth, place, lat, lng);
            }
            else
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ConfigData));
                FileStream fs = new FileStream(filename, FileMode.Open);
                config = (ConfigData)serializer.Deserialize(fs);
                fs.Close();

                if (config.lat == 0 || config.lng == 0)
                {
                    // 初期データ
                    setMainData(name, birth, place, lat, lng);
                } else
                {
                    place = config.defaultPlace;
                    lat = config.lat;
                    lng = config.lng;
                    setMainData(name,
                        birth,
                        place,
                        lat,
                        lng);
                }
                setMainEventData(name, birth, place, lat, lng);

            }
            if (config.ephepath == null)
            {
                config.ephepath = System.Windows.Forms.Application.StartupPath + @"\ephe"; ;
            }

            // デフォルトデータ
            setNatalData(year, month, day, hour, minute, second, lat, lng);
            setTransitData(year, month, day, hour, minute, second, lat, lng);
            // 計算
            calc = new AstroCalc(config);

            // 表示(comboBoxのindexChangeで再描画)
            aspectSelect.SelectedIndex = 0;
            aspectSetting = aspectSettingList[0];

        }
Пример #3
0
        // オプション→設定
        private void ConfigToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.config == null)
                this.config = new ConfigData();

            ConfigForm config = new ConfigForm(this);
            config.Show();
        }