コード例 #1
0
        /// <summary>
        /// 初期化周り
        /// </summary>
        private void MainInit()
        {
            var root = Util.root;

            if (!Directory.Exists(root + "/system"))
            {
                Directory.CreateDirectory(root + "/system");
            }
            if (!Directory.Exists(root + "/data"))
            {
                Directory.CreateDirectory(root + "/data");
            }

            var bundle = Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "Resources", "system");

            if (!File.Exists(root + "/system/config.csm"))
            {
                File.Copy(bundle + "/config.csm", root + "/system/config.csm");
            }

            for (int i = 0; i < 10; i++)
            {
                if (!File.Exists(root + "/system/setting" + i.ToString() + ".csm"))
                {
                    File.Copy(bundle + "/setting" + i.ToString() + ".csm", root + "/system/setting" + i.ToString() + ".csm");
                }
            }

            if (!File.Exists(root + "/system/addr.csv"))
            {
                File.Copy(bundle + "/addr.csv", root + "/system/addr.csv");
            }

            config   = ConfigFromXml.GetConfigFromXml(root + "/system/config.csm");
            settings = new SettingData[10];
            for (int i = 0; i < 10; i++)
            {
                settings[i]       = SettingFromXml.GetSettingFromXml(root + "/system/setting" + i.ToString() + ".csm", i);
                settings[i].bands = 1;
            }
            CommonInstance.getInstance().config              = config;
            CommonInstance.getInstance().settings            = settings;
            CommonInstance.getInstance().currentSetting      = settings[0];
            CommonInstance.getInstance().currentSettingIndex = 0;

            ReSetSettingMenu();

            calc         = new AstroCalc();
            ringsData[0] = ringsData[1] = ringsData[2] = ringsData[3] = ringsData[4] = ringsData[5] = ringsData[6] =
                calc.ReCalc(config, settings[0], new UserData());

            //            Console.WriteLine(config.defaultPlace);

            // aspect calc
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    aspectsData[i, j] = new List <AspectInfo>();
                }
            }
            aspect = new AspectCalc();
            foreach (int i in Enumerable.Range(0, 4))
            {
                aspectsData[i, i] = aspect.AspectCalcSame(ringsData[i].planetData, i);
            }

            int ringIndexFrom = 0;
            int ringIndexTo   = 0;

            for (ringIndexFrom = 0; ringIndexFrom < 5; ringIndexFrom++)
            {
                for (ringIndexTo = 0; ringIndexTo < 5; ringIndexTo++)
                {
                    if (ringIndexFrom == ringIndexTo)
                    {
                        continue;
                    }
                    aspectsData[ringIndexFrom, ringIndexTo] =
                        aspect.AspectCalcOther(ringsData[ringIndexFrom].planetData,
                                               ringsData[ringIndexTo].planetData,
                                               ringIndexFrom,
                                               ringIndexTo);
                }
            }

            ReSetUserBox();

            // cuspList
            CuspListDataSource CDataSource = new CuspListDataSource();

            for (int i = 1; i <= 12; i++)
            {
                CDataSource.list.Add(new CuspListData()
                {
                    Degree1 = ringsData[0].cusps[i],
                    Degree2 = ringsData[1].cusps[i],
                    Degree3 = ringsData[2].cusps[i]
                });
            }

            CuspList.DataSource = CDataSource;
            CuspList.Delegate   = new CuspListDelegate(CDataSource);


/*
 *          SKCanvasView sk = new SKCanvasView(new CGRect(0, 0, 690, 720));
 *          sk.PaintSurface += CanvasPaint;
 *          horoscopeCanvas.AddSubview(sk);
 */

            // time setter
            DateSetterDatePicker.DateValue = new NSDate();
            DateSetterCombo.SelectItem(0);

            ReRender();
        }
コード例 #2
0
        private async Task <bool> CreateConfig()
        {
            var root   = Windows.Storage.ApplicationData.Current.LocalFolder;
            var system = await root.TryGetItemAsync("system");

            if (system == null)
            {
                system = await root.CreateFolderAsync("system");
            }

            StorageFolder systemFolder = await root.GetFolderAsync("system");

            if (await systemFolder.TryGetItemAsync("config.csm") == null)
            {
                var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/config.csm")).AsTask().ConfigureAwait(false);

                await configFile.CopyAsync(systemFolder, "config.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting0.csm") == null)
            {
                var setting0File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting0.csm")).AsTask().ConfigureAwait(false);

                await setting0File.CopyAsync(systemFolder, "setting0.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting1.csm") == null)
            {
                var setting1File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting1.csm")).AsTask().ConfigureAwait(false);

                await setting1File.CopyAsync(systemFolder, "setting1.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting2.csm") == null)
            {
                var setting2File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting2.csm")).AsTask().ConfigureAwait(false);

                await setting2File.CopyAsync(systemFolder, "setting2.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting3.csm") == null)
            {
                var setting3File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting3.csm")).AsTask().ConfigureAwait(false);

                await setting3File.CopyAsync(systemFolder, "setting3.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting4.csm") == null)
            {
                var setting4File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting4.csm")).AsTask().ConfigureAwait(false);

                await setting4File.CopyAsync(systemFolder, "setting4.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting5.csm") == null)
            {
                var setting5File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting5.csm")).AsTask().ConfigureAwait(false);

                await setting5File.CopyAsync(systemFolder, "setting5.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting6.csm") == null)
            {
                var setting6File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting6.csm")).AsTask().ConfigureAwait(false);

                await setting6File.CopyAsync(systemFolder, "setting6.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting7.csm") == null)
            {
                var setting7File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting7.csm")).AsTask().ConfigureAwait(false);

                await setting7File.CopyAsync(systemFolder, "setting7.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting8.csm") == null)
            {
                var setting8File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting8.csm")).AsTask().ConfigureAwait(false);

                await setting8File.CopyAsync(systemFolder, "setting8.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("setting9.csm") == null)
            {
                var setting9File = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/setting9.csm")).AsTask().ConfigureAwait(false);

                await setting9File.CopyAsync(systemFolder, "setting9.csm", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("canvas.html") == null)
            {
                var canvasFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/canvas.html")).AsTask().ConfigureAwait(false);

                await canvasFile.CopyAsync(systemFolder, "canvas.html", NameCollisionOption.FailIfExists);
            }

            if (await systemFolder.TryGetItemAsync("datetime.html") == null)
            {
                var canvasFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/datetime.html")).AsTask().ConfigureAwait(false);

                await canvasFile.CopyAsync(systemFolder, "datetime.html", NameCollisionOption.FailIfExists);
            }

            // data作成
            var dataDir = await root.TryGetItemAsync("data");

            if (dataDir == null)
            {
                await root.CreateFolderAsync("data");
            }

            // config読み込み
            var cfg = await systemFolder.GetFileAsync("config.csm");

            config = ConfigFromXml.GetConfigFromXml(cfg.Path);

            //            UserData udata = UserXml.GetUserDataFromXml(cfg.Path);

            // setting読み込み
            for (int i = 0; i < 10; i++)
            {
                var set = await systemFolder.GetFileAsync("setting" + i.ToString() + ".csm");

                setting[i] = SettingFromXml.GetSettingFromXml(set.Path, i);
            }

            CommonInstance.getInstance().config   = config;
            CommonInstance.getInstance().settings = setting;

            return(true);
        }