private ImageItem GenerateImageItem(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight, bool isMockPreviewImages, int index) { var styleOption = _styleOptions[index]; PreviewInfo previewInfo; if (isMockPreviewImages) { previewInfo = new PreviewInfo { PreviewApplyStyleImagePath = StoragePath.NoPicturePlaceholderImgPath }; } else { previewInfo = Designer.PreviewApplyStyle( IsInPictureVariation() ? _8PicturesInPictureVariation[index] : source, contentSlide, slideWidth, slideHeight, styleOption); } return(new ImageItem { ImageFile = previewInfo.PreviewApplyStyleImagePath, Tooltip = styleOption.OptionName }); }
public void ToolBarsTestDefultValue() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); string expectedResult = "true"; //Act string actualResult = previewInfo.Properties["ToolBars"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void NavigationPaneDockingStyleTestDefultValue() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); string expectedResult = "None"; //Act string actualResult = previewInfo.Properties["NavigationPaneDockingStyle"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void CaptionTestDefultValue() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); string expectedResult = "PrintPreview Window"; //Act string actualResult = previewInfo.Properties["Caption"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void ZoomFactorTestDefultValue() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); string expectedResult = "75D"; //Act string actualResult = previewInfo.Properties["ZoomFactor"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void SizeTestDefultValue() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); string expectedResult = "new System.Drawing.Size(0, 0)"; //Act string actualResult = previewInfo.Properties["Size"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void DontRemoveLineTestToolBars() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); previewInfo.Properties["ToolBars"] = "false"; //Act bool actualResult = PreviewInfoPropertyReader.MustRemoveLine(previewInfo, "ToolBars"); //Assert Assert.IsFalse(actualResult); }
public void ProcessPreviewInfoPropertyTestToolBars() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); PreviewInfoPropertyReader.ProcessPreviewInfoProperty(previewInfo, "ToolBars", "false"); string expectedResult = "false"; //Act string actualResult = previewInfo.Properties["ToolBars"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void ProcessPreviewInfoPropertyTestNavigationPaneDockingStyle() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); PreviewInfoPropertyReader.ProcessPreviewInfoProperty(previewInfo, "NavigationPaneDockingStyle", "Bottom"); string expectedResult = "Bottom"; //Act string actualResult = previewInfo.Properties["NavigationPaneDockingStyle"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
public void ProcessPreviewInfoPropertyTestCaption() { //Arrange PreviewInfo previewInfo = new PreviewInfo(); PreviewInfoPropertyReader.ProcessPreviewInfoProperty(previewInfo, "Caption", "ABC"); string expectedResult = "ABC"; //Act string actualResult = previewInfo.Properties["Caption"]; //Assert Assert.AreEqual(expectedResult, actualResult); }
private void UpdateStylesVariationImages(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight, bool isMockPreviewImages = false) { Logger.Log("UpdateStylesVariationImages begins"); var copiedPicture = LoadClipboardPicture(); try { if (isMockPreviewImages) { Logger.Log("Generate mock images for Picture aspect"); } Logger.Log("Number of styles: " + _styleOptions.Count); for (var i = 0; i < _styleOptions.Count; i++) { var styleOption = _styleOptions[i]; PreviewInfo previewInfo; if (isMockPreviewImages) { previewInfo = new PreviewInfo { PreviewApplyStyleImagePath = StoragePath.NoPicturePlaceholderImgPath }; } else { previewInfo = Designer.PreviewApplyStyle( IsInPictureVariation() ? _8PicturesInPictureVariation[i] : source, contentSlide, slideWidth, slideHeight, styleOption); } StylesVariationList.Add(new ImageItem { ImageFile = previewInfo.PreviewApplyStyleImagePath, Tooltip = styleOption.OptionName }); } GC.Collect(); } catch (Exception e) { View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorImageCorrupted, e); Logger.LogException(e, "UpdateStylesVariationImages"); } SaveClipboardPicture(copiedPicture); Logger.Log("UpdateStylesVariationImages done"); }
private void Tv_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; PreviewInfo p = node.Tag as PreviewInfo; if (p == null) { return; } lv.Items.Clear(); lv.Items.AddRange(p.v.ToArray()); //richTextBox1.Text = "Type \n\r " + p.description; //SetAsBold("Type ", rb); }
private async Task ImportFile( IFileSource source, IFileInfo file, CancellationToken token) { var fileName = Path.GetFileName(file.Path); try { var scale = source.Config.Scale; var rotation = source.Config.Rotation; var(hash, geoInfo, resolution) = await RebuildPreview(source, file.Path, rotation, scale); var tags = source.GetTags(file.Path); var previewInfo = new PreviewInfo { ItemName = fileName, FileHash = hash, Tags = tags.ToHashSet(), Resolution = resolution }; _lock.Write(() => { if (token.IsCancellationRequested) { return; } _tagManager.Add(tags); var model = _previewModels.AddOrUpdate(source, file, previewInfo, geoInfo); _previewStreams.ForEach(stream => stream.AddFiltered(model)); _relay.Send(this, new ProgressMessage { Text = $"Imported `{fileName}`" }); }); } catch (Exception ex) { var text = $"Error while importing `{fileName}`"; _relay.Send <ProgressMessage>(new ProgressMessage { Text = text }); Logger.Error(ex, text); } }
public ItemPreviewModel AddOrUpdate(IFileSource source, IFileInfo file, PreviewInfo info, GeometryInfo geoInfo) { var hash = info.FileHash; if (!_modelsByHash.TryGetValue(hash, out var model)) { model = _modelsByHash[hash] = new ItemPreviewModel(_store, _relay, info); model.GeometryInfo.Value = geoInfo; _models.Add(model); } _sources[source.DisplayName] = source; model.AddSourceFile(source.DisplayName, file); return(model); }
public ListViewItem LoadListViewItems(string file, PreviewInfo p) { ListViewItem v = new ListViewItem(); v.Text = Path.GetFileName(file); //int i = AddImageIfAny(new DirectoryInfo(file)); //if (i < 0) // i = 0; //v.ImageIndex = i; v.SubItems.Add(file); v.Tag = p; return(v); }
public void LoadAndroid(TreeNode node, string folder, PreviewInfo p) { string folders = AppDomain.CurrentDomain.BaseDirectory + templates + "\\Extensions\\Xamarin.VisualStudio\\T\\PT\\CSharp\\Android"; string[] d = Directory.GetFiles(folders); foreach (string s in d) { TreeNode vsc = new TreeNode(); vsc.Text = Path.GetFileName(s); //node.Nodes.Add(vsc); PreviewInfo c = LoadTemplateXml(vsc, s); ListViewItem v = LoadListViewItems(s, c); p.v.Add(v); } }
public void LoadWindowsUniversal(TreeNode node, string folder, PreviewInfo p) { string folders = folder + "\\1033"; string[] d = Directory.GetDirectories(folders); foreach (string s in d) { TreeNode vsc = new TreeNode(); vsc.Text = Path.GetFileName(s); //node.Nodes.Add(vsc); PreviewInfo c = LoadTemplateXml(vsc, s); ListViewItem v = LoadListViewItems(s, c); p.v.Add(v); } }
private void Lv_SelectedIndexChanged(object sender, EventArgs e) { if (lv.SelectedItems == null || lv.SelectedItems.Count <= 0) { return; } ListViewItem b = lv.SelectedItems[0]; if (b == null) { return; } PreviewInfo p = b.Tag as PreviewInfo; if (p == null) { return; } richTextBox1.Text = p.description; }
public void LoadJavascriptTemplates(TreeNode node) { string folder = AppDomain.CurrentDomain.BaseDirectory + templates + "\\ProjectTemplates\\Javascript"; string[] d = Directory.GetDirectories(folder); PreviewInfo p = new PreviewInfo(); PreviewInfo pp = new PreviewInfo(); TreeNode vsc = new TreeNode(); foreach (string s in d) { pp = new PreviewInfo(); vsc = new TreeNode(); vsc.Text = Path.GetFileName(s); if (s.Contains("Windows 10")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Mobile Apps")) { LoadWindowsUniversal(vsc, s, pp); } else { continue; } node.Nodes.Add(vsc); vsc.Tag = pp; p.v.AddRange(pp.v); } node.Tag = p; }
private PreviewInfo LoadTemplateXml(TreeNode node, string folder) { PreviewInfo p = new PreviewInfo(); p.folder = folder; string file = new DirectoryInfo(folder).Name; string filename = folder + "\\" + file + ".vstemplate"; if (!File.Exists(filename)) { return(p); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(filename); XmlNode xml = FindNode(xmlDocument.ChildNodes, "TemplateData"); if (xml != null) { XmlNode a = FindNode(xml.ChildNodes, "PreviewImage"); XmlNode b = FindNode(xml.ChildNodes, "Description"); if (a != null) { p.image = a.InnerText; } if (b != null) { p.description = b.InnerText; } } node.Tag = p; return(p); }
public ItemPreviewModel( [NotNull] IPreviewImageStore previewImageStore, [NotNull] IMessageRelay relay, [NotNull] PreviewInfo previewInfo) { _previewImageStore = previewImageStore ?? throw new ArgumentNullException(nameof(previewImageStore)); if (previewInfo is null) { throw new ArgumentNullException(nameof(previewInfo)); } if (relay is null) { throw new ArgumentNullException(nameof(relay)); } Name = previewInfo.ItemName; FileHash = previewInfo.FileHash; FileSize = previewInfo.FileSize; GeometryInfo.Value = new GeometryInfo { Rotation = previewInfo.Rotation ?? Vector3.zero, Scale = previewInfo.Scale ?? Vector3.one, Size = previewInfo.Size, Volume = previewInfo.Volume, TriangleCount = previewInfo.VertexCount / 3, VertexCount = previewInfo.VertexCount }; Tags.AddRange(previewInfo.Tags); Sources = previewInfo.Sources?.ToList() ?? new List <ImportedFileInfo>(); PreviewResolution = previewInfo.Resolution; Selected.ValueChanged += value => relay.Send(this, new SelectionChangedMessage { Sender = this }); }
private static bool TryGetInMemoryPreview(string guid, out PreviewInfo info) { lock (s_Lock) { return(s_LoadedAssetPreviews.TryGetValue(guid, out info)); } }
public static Texture2D GetAssetPreview(Object targetObject) { // No target object means no preview :) if (targetObject == null) { return(null); } string assetPath = AssetDatabase.GetAssetPath(targetObject); string guid = AssetDatabase.AssetPathToGUID(assetPath); string cacheFilePath = GetAssetPreviewCacheFilePath(targetObject); if (File.Exists(cacheFilePath)) { DateTime cacheFileTime = File.GetLastWriteTime(cacheFilePath); DateTime assetFileTime = File.GetLastWriteTime(assetPath); if (cacheFileTime < assetFileTime) { ClearCachedAssetPreviewFile(guid); } } var previewInfo = new PreviewInfo(); try { if (TryGetInMemoryPreview(guid, out previewInfo) && !previewInfo.HasBeenDestroyed) { // Already loaded asset preview into memory; let's use that! return(previewInfo.PreviewTexture); } // Attempt to load asset preview from cache file inside "Library" folder. //Debug.Log(string.Format("Loading preview for asset '{0}' ({1}).", targetObject.name, guid)); if (File.Exists(cacheFilePath)) { previewInfo.PreviewTexture = InternalEditorUtility.LoadSerializedFileAndForget(cacheFilePath).OfType <Texture2D>().FirstOrDefault(); return(previewInfo.PreviewTexture); } // Attempt to generate asset preview. //Debug.Log(string.Format("Generating preview for asset '{0}' ({1}).", targetObject.name, guid)); var generatedPreviewTexture = GenerateAssetPreview(targetObject); if (generatedPreviewTexture != null) { //Debug.Log(string.Format("Saving preview for asset '{0}' ({1}).", targetObject.name, guid)); EnsurePathExists(cacheFilePath); InternalEditorUtility.SaveToSerializedFileAndForget(new Object[] { generatedPreviewTexture }, cacheFilePath, false); } previewInfo.PreviewTexture = generatedPreviewTexture; return(previewInfo.PreviewTexture); } finally { if (previewInfo.PreviewTexture != null) { previewInfo.PreviewTexture.hideFlags = HideFlags.HideAndDontSave; } previewInfo.ExpireTime = EditorApplication.timeSinceStartup + PreviewLifetimeInSeconds; SetInMemoryPreview(guid, previewInfo); } }
public void LoadCSharpTemplates(TreeNode node) { string folder = AppDomain.CurrentDomain.BaseDirectory + templates + "\\ItemTemplates\\CSharp"; string[] d = Directory.GetDirectories(folder); PreviewInfo p = new PreviewInfo(); PreviewInfo pp = new PreviewInfo(); TreeNode vsc = new TreeNode(); foreach (string s in d) { pp = new PreviewInfo(); vsc = new TreeNode(); vsc.Text = Path.GetFileName(s); if (s.Contains("Code")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Data")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("General")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("SQL Server")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Test")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Web")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Windows Forms")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("WPF")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("XAML")) { LoadWindowsUniversal(vsc, s, pp); } else { continue; } node.Nodes.Add(vsc); vsc.Tag = pp; p.v.AddRange(pp.v); } //pp = new PreviewInfo(); //vsc = new TreeNode(); //vsc.Text = "Android"; //node.Nodes.Add(vsc); //LoadAndroid(vsc, "", pp); //vsc.Tag = pp; //p.v.AddRange(pp.v); node.Tag = p; }
public void PreviewInfo_Update(ResourceType stype, string engine, string hash, PreviewType type, PreviewInfo info) { var pinfo = _connection.Query <PreviewInfoStore>("SELECT * FROM PreviewInfo WHERE SType=@stype, Hash=@hash AND Source=@source", new { stype = (int)stype, hash, source = engine }).FirstOrDefault(); if (info != null && type != PreviewType.None) { if (pinfo == null) { //INSERT _connection.Execute("INSERT INTO PreviewInfo (SType, Hash,PreviewSource,PreviewType, WebUrl, ImageUrl, Description) VALUES (@hash, @source, @previewType, @weburl, @imageurl, @desc)", new { stype = (int)stype, hash, source = engine, prevewType = (int)type, weburl = info.WebUrl, imageurl = info.ImageUrl, description = info.Description }); } else if (pinfo.WebUrl != info.WebUrl || pinfo.PreviewType != type || pinfo.ImageUrl != info.ImageUrl || pinfo.Description != info.Description) { _connection.Execute("UPDATE PreviewInfo SET PreviewType=@type, WebUrl=@weburl, ImageUrl=@imageurl, Description=@description WHERE SType=@stype AND Hash=@hash AND PreviewSource=@source", new { stype = (int)stype, hash, source = engine, prevewType = (int)type, weburl = info.WebUrl, imageurl = info.ImageUrl, description = info.Description }); } } else { if (pinfo != null) { //DELETE _connection.Execute("DELETE FROM PreviewInfo WHERE SType=@stype AND Hash=@hash AND Source=@source", new { stype = (int)stype, hash, source = engine }); } } }
public void LoadVisualBasicTemplates(TreeNode node) { string folder = AppDomain.CurrentDomain.BaseDirectory + templates + "\\ProjectTemplates\\VisualBasic"; string[] d = Directory.GetDirectories(folder); PreviewInfo p = new PreviewInfo(); PreviewInfo pp = new PreviewInfo(); TreeNode vsc = new TreeNode(); foreach (string s in d) { pp = new PreviewInfo(); vsc = new TreeNode(); vsc.Text = Path.GetFileName(s); if (s.Contains("Windows UAP")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Windows")) { LoadWindowsUniversal(vsc, s, pp); vsc.Text = "Windows Classic Desktop"; } else if (s.EndsWith("Web")) { LoadWindowsUniversal(vsc, s, pp); } //else if (s.EndsWith(".NET Core")) //{ // LoadWindowsUniversal(vsc, s, pp); //} else if (s.EndsWith("Cloud")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Extensibility")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("WCF")) { LoadWindowsUniversal(vsc, s, pp); } else if (s.EndsWith("Test")) { LoadWindowsUniversal(vsc, s, pp); } else { continue; } node.Nodes.Add(vsc); vsc.Tag = pp; p.v.AddRange(pp.v); } //pp = new PreviewInfo(); //vsc = new TreeNode(); //vsc.Text = "Android"; //node.Nodes.Add(vsc); //LoadAndroid(vsc, "", pp); //vsc.Tag = pp; //p.v.AddRange(pp.v); node.Tag = p; }
private static void SetInMemoryPreview(string guid, PreviewInfo info) { lock (s_Lock) { s_LoadedAssetPreviews[guid] = info; } }