Exemplo n.º 1
0
        private void GenerateLivelyInfo(WallpaperLayout wpLayout)
        {
            LivelyInfo tmpInfo = new LivelyInfo()
            {
                IsAbsolutePath = true, //absolute filepath, wp files will be located outside of lively folder.
                FileName       = wpLayout.FilePath,
                Title          = textboxTitle.Text,
                Desc           = textboxDesc.Text,
                Contact        = textboxContact.Text,
                Author         = textboxAuthor.Text,
                Arguments      = wpLayout.Arguments,
                Type           = wpLayout.Type,
                Thumbnail      = "lively_t.jpg",
                Preview        = "lively_p.gif"
            };

            /*
             * if (SaveData.config.PreviewGIF.CaptureGif)
             * {
             *  tmpInfo.Preview = "lively_p.gif";
             * }
             * else
             * {
             *  tmpInfo.Preview = null;
             * }
             */
            SaveData.SaveWallpaperMetaData(tmpInfo, saveDirectory);
        }
Exemplo n.º 2
0
        private async void Button_Create_Click(object sender, RoutedEventArgs e)
        {
            tmpInfo.Title   = textboxTitle.Text;
            tmpInfo.Author  = textboxAuthor.Text;
            tmpInfo.Desc    = textboxDesc.Text;
            tmpInfo.Contact = textboxWebsite.Text;
            tmpInfo.License = textboxLicense.Text;
            //tmpInfo.Type = (SetupDesktop.WallpaperType)comboBoxType.SelectedItem;
            tmpInfo.Type      = wallpaperTypes[comboBoxType.SelectedIndex].Type;
            tmpInfo.Arguments = textboxArgs.Text;

            if (folderContents.Count == 0 || String.IsNullOrWhiteSpace(tmpInfo.FileName))
            {
                MessageBox.Show(Properties.Resources.txtMsgSelectWallpaperFile);
                return;
            }

            if (String.IsNullOrEmpty(tmpInfo.Title) || String.IsNullOrEmpty(tmpInfo.Desc) || String.IsNullOrEmpty(tmpInfo.Author)
                )    //|| String.IsNullOrEmpty(tmpInfo.contact) )
            {
                MessageBox.Show(Properties.Resources.txtMsgFillAllFields);
                return;
            }

            /*
             * //Optional
             * if( !File.Exists(tmpInfo.Thumbnail) || !File.Exists(tmpInfo.Preview) )
             * {
             *  MessageBox.Show(Properties.Resources.txtSelectPreviewThumb);
             *  return;
             * }
             */

            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                Title           = "Select location to save the file",
                Filter          = "Lively/zip file|*.zip",
                OverwritePrompt = true
            };

            if (saveFileDialog1.ShowDialog() == true)
            {
                if (!String.IsNullOrEmpty(saveFileDialog1.FileName))
                {
                    //to write to Livelyinfo.json file only, tmp object.
                    SaveData.LivelyInfo tmp = new SaveData.LivelyInfo(tmpInfo);
                    tmp.FileName  = Path.GetFileName(tmp.FileName);
                    tmp.Preview   = Path.GetFileName(tmp.Preview);
                    tmp.Thumbnail = Path.GetFileName(tmp.Thumbnail);

                    SaveData.SaveWallpaperMetaData(tmp, Path.Combine(App.PathData, "tmpdata"));

                    /*
                     * //if previous livelyinfo.json file(s) exists in wallpaper directory, remove all of them.
                     * folderContents.RemoveAll(x => Path.GetFileName(x).Equals(Path.GetFileName(folderContents[folderContents.Count - 1]),
                     *                  StringComparison.InvariantCultureIgnoreCase));
                     */
                    folderContents.Add(Path.Combine(App.PathData, "tmpdata", "LivelyInfo.json"));

                    //btnCreateWallpaer.IsEnabled = false;
                    await CreateZipFile(saveFileDialog1.FileName, folderContents);

                    string folderPath = System.IO.Path.GetDirectoryName(saveFileDialog1.FileName);
                    if (Directory.Exists(folderPath))
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo
                        {
                            Arguments = folderPath,
                            FileName  = "explorer.exe"
                        };
                        Process.Start(startInfo);
                    }

                    //clearing temp files if any.
                    FileOperations.EmptyDirectory(Path.Combine(App.PathData, "SaveData", "wptmp"));
                    //this.NavigationService.GoBack(); //won't work, since prev is window, not page.
                    var wnd = Window.GetWindow(this);
                    wnd.Close();
                }
            }
            else
            {
                return;
            }
        }