示例#1
0
        private void TileConfigurator_DialogButtonClicked(object sender, TileDialogButtonClickedEventArgs e)
        {
            TileManagerViewModel vm = DataContext as TileManagerViewModel;

            if (e.DialogResult == DialogResult.OK)
            {
                FileInfo imageFileInfo = !string.IsNullOrWhiteSpace(e.Tile.ImagePath) ? new FileInfo(e.Tile.ImagePath) : null;
                if (imageFileInfo != null && imageFileInfo.Exists)
                {
                    string localResourcePath = Path.Combine(vm.SelectedCollection.FilePath, "tiles", "resources");
                    if (!Directory.Exists(localResourcePath))
                    {
                        Directory.CreateDirectory(localResourcePath);
                    }

                    string localImagePath = Path.Combine(localResourcePath, imageFileInfo.Name);
                    if (!new FileInfo(localImagePath).Exists)
                    {
                        File.Copy(imageFileInfo.FullName, localImagePath);
                    }
                    e.Tile.ImagePath = localImagePath;
                }

                if (!vm.IsEditTile)
                {
                    vm.SelectedCollection.TileFile.Data.Add(e.Tile);
                }
            }

            vm.IsTileConfiguratorOpen = false;
        }
 protected virtual void OnDialogButtonClicked(TileDialogButtonClickedEventArgs e)
 {
     DialogButtonClicked?.Invoke(this, e);
 }