Пример #1
0
        public void Setup()
        {
            File.WriteAllText(Path.Combine(this.BasePath, "embedded.txt"), this.DataPath);
            this.SetSetting("CULTURE", this.GuessLocalization());
            this.SetSetting("BASE_URL", "/");
            this.SetSetting("CURRENCY", new RegionInfo(CultureInfo.CurrentCulture.LCID).ISOCurrencySymbol);

            IOHelper.CopyFolder(Path.Combine(this.BasePath, "data"), this.DataPath);
            File.Copy(Path.Combine(this.BasePath, "config-dist.php"), Path.Combine(this.DataPath, "config.php"), true);
            File.Copy(Path.Combine(this.BasePath, "config-dist.php"), Path.Combine(this.BasePath, "data", "config.php"), true);             // Dummy

            foreach (string item in Directory.GetFiles(Path.Combine(this.DataPath, "viewcache")))
            {
                File.Delete(item);
            }
        }
Пример #2
0
        private void ToolStripMenuItem_ConfigureChangeDataLocationBarcodeBuddy_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
            {
                dialog.RootFolder   = Environment.SpecialFolder.Desktop;
                dialog.SelectedPath = this.UserSettings.BarcodeBuddyDataLocation;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (MessageBox.Show(this.ResourceManager.GetString("STRING_GrocyDesktopWillRestartToApplyTheChangedSettingsContinue.Text"), this.ResourceManager.GetString("STRING_ChangeDataLocation.Text"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        IOHelper.CopyFolder(this.UserSettings.BarcodeBuddyDataLocation, dialog.SelectedPath);
                        Directory.Delete(this.UserSettings.BarcodeBuddyDataLocation, true);
                        this.UserSettings.BarcodeBuddyDataLocation = dialog.SelectedPath;
                        this.UserSettings.Save();
                        ApplicationHelper.RestartApp();
                    }
                }
            }
        }
        public static async Task <WallpaperModel> CreateLocalPack(string sourceFile, string previewPath, WallpaperInfo info, string destDir)
        {
            string oldInfoPath = Path.Combine(sourceFile, "project.json");

            if (File.Exists(oldInfoPath))
            {
                var existInfo = await JsonHelper.JsonDeserializeFromFileAsync <WallpaperInfo>(oldInfoPath);

                info.Description ??= existInfo.Description;
                info.File ??= existInfo.File;
                info.Preview ??= existInfo.Preview;
                info.Tags ??= existInfo.Tags;
                info.Title ??= existInfo.Title;
                info.Type ??= existInfo.Type;
                info.Visibility ??= existInfo.Visibility;
                await Task.Run(() =>
                {
                    IOHelper.CopyFolder(sourceFile, destDir);
                });
            }
            else
            {
                await Task.Run(() =>
                {
                    IOHelper.CopyFileToDir(sourceFile, destDir);
                    info.Preview = Path.GetFileName(previewPath);
                    IOHelper.CopyFileToDir(previewPath, destDir);
                });
            }

            await WriteInfo(info, destDir);

            return(new WallpaperModel()
            {
                Path = Path.Combine(destDir, info.File),
                Info = info
            });
        }