public TextItemEditorControl(TextItemViewModel item) { this.item = item; InitializeComponent(); this.DataContext = this.item; this.GeneralItemEditor.SetItem(item); this.SizeComboBox.ItemsSource = SampleFontSize; this.ColorComboBox.ItemsSource = this.colors; foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor))) { if (28 <= (int)knownColor && (int)knownColor <= 167) { string colorName = System.Drawing.Color.FromKnownColor(knownColor).ToString(); colorName = colorName.Replace("Color [", ""); colorName = colorName.Replace("]", ""); this.colors.Add(colorName); } } this.ColorComboBox.Text = this.item.Color; this.FontComboBox.ItemsSource = this.fonts; foreach (System.Windows.Media.FontFamily font in Fonts.SystemFontFamilies.OrderBy(f => f.Source)) { this.fonts.Add(font.Source); } }
public TextItemControl(TextItemViewModel item) : base(item) { this.item = item; InitializeComponent(); this.DataContext = this.item; }
private async Task SaveHTMLFiles() { string htmlFileContents = string.Empty; using (StreamReader reader = new StreamReader(File.OpenRead(CDKProjectViewModel.TemplateIndexHTMLFilePath))) { htmlFileContents = await reader.ReadToEndAsync(); } using (StreamWriter writer = new StreamWriter(File.Open(this.IndexHTMLFilePath, FileMode.Create))) { await writer.WriteAsync(htmlFileContents); } string scriptFileContents = string.Empty; using (StreamReader reader = new StreamReader(File.OpenRead(CDKProjectViewModel.TemplateScriptJSFilePath))) { scriptFileContents = await reader.ReadToEndAsync(); } StringBuilder definedItems = new StringBuilder(); definedItems.AppendLine(); definedItems.AppendLine(); definedItems.AppendLine("function initializeItems()"); definedItems.AppendLine("{"); foreach (SceneViewModel scene in this.Scenes) { foreach (ItemViewModel item in scene.Items) { definedItems.Append("\t"); if (item is TextItemViewModel) { TextItemViewModel textItem = (TextItemViewModel)item; definedItems.Append("addText(\"" + item.Name + "\", \"" + scene.Name + "\", \"" + textItem.Text + "\", " + textItem.Size + ", \"" + textItem.Color.ToLower() + "\", \"" + textItem.Font + "\", " + item.XPosition + ", " + item.YPosition + ", " + item.IsVisible.ToString().ToLower() + ", " + item.IsInteractive.ToString().ToLower() + ");"); } else if (item is ImageItemViewModel) { ImageItemViewModel imageItem = (ImageItemViewModel)item; definedItems.Append("addImage(\"" + item.Name + "\", \"" + scene.Name + "\", \"" + Path.GetFileName(imageItem.SourcePath) + "\", " + imageItem.Width + ", " + imageItem.Height + ", " + item.XPosition + ", " + item.YPosition + ", " + item.IsVisible.ToString().ToLower() + ", " + item.IsInteractive.ToString().ToLower() + ");"); if (File.Exists(imageItem.SourcePath)) { File.Copy(imageItem.SourcePath, Path.Combine(this.SourceFolderPath, Path.GetFileName(imageItem.SourcePath)), overwrite: true); } } else if (item is SoundItemViewModel) { SoundItemViewModel soundItem = (SoundItemViewModel)item; if (File.Exists(soundItem.SourcePath)) { File.Copy(soundItem.SourcePath, Path.Combine(this.SourceFolderPath, Path.GetFileName(soundItem.SourcePath)), overwrite: true); } } else if (item is VideoItemViewModel) { VideoItemViewModel videoItem = (VideoItemViewModel)item; string filename = Path.GetFileName(videoItem.SourcePath); definedItems.Append("videoProperties[\"" + filename + "\"] = { x: " + item.XPosition + ", y: " + item.YPosition + ", width: " + videoItem.Width + ", height: " + videoItem.Height + " };"); if (File.Exists(videoItem.SourcePath)) { File.Copy(videoItem.SourcePath, Path.Combine(this.SourceFolderPath, filename), overwrite: true); } } definedItems.AppendLine(); } } definedItems.AppendLine("}"); using (StreamWriter writer = new StreamWriter(File.Open(this.ScriptJSFilePath, FileMode.Create))) { await writer.WriteAsync(scriptFileContents); await writer.WriteAsync(definedItems.ToString()); } }