void DrawPreviewControls() { GUIStyle foldoutStyle = EditorStyles.foldout; foldoutStyle.fontStyle = FontStyle.Bold; // Preview settings. GUILayout.Space(5); previewSettingsFoldout = EditorGUILayout.Foldout(previewSettingsFoldout, "Preview settings", foldoutStyle); if (previewSettingsFoldout) { EditorGUI.indentLevel++; previewType = (PreviewType)EditorGUILayout.EnumPopup("Preview type", previewType); EditorGUI.indentLevel++; if (currentWindowTab == 0) { textureModule.DrawPreviewControls(previewType); } else { toolsModule.DrawPreviewControls(previewType); } EditorGUI.indentLevel--; previewMode = (PreviewMode)EditorGUILayout.Popup("Live preview", (int)previewMode, previewModeStrings); EditorGUI.indentLevel--; } GUILayout.Space(5); }
public Texture2D GetTexture(PreviewType previewType) { Texture2D tex = GetModule().GetTexture(textureSize); if (invert) { TextureMaker.InvertColors(ref tex); } switch (previewType) { case PreviewType.GRAYSCALE: tex = TextureMaker.MakeGrayscale(tex); break; case PreviewType.NORMAL_MAP: tex = TextureMaker.MakeNormalMap(tex, strength); break; case PreviewType.SOBEL_OPERATOR: tex = TextureMaker.SobelFilter(tex, strength); break; } return(tex); }
private bool SetPreviews(PreviewType type, object target) { if (type != _previewType || !ReferenceEquals(target, _previewObject)) { // Clear image. using (var g = System.Drawing.Graphics.FromImage(pbPreview.Image)) { g.CompositingMode = CompositingMode.SourceCopy; g.FillRectangle(Brushes.Transparent, 0, 0, pbPreview.Image.Width, pbPreview.Image.Height); } // Clear / set other previews. _ingamePreview.Clear(); _effectPreview.Effect = (string)(type == PreviewType.Effect ? target : null); _projectilePreview.Projectiles = (ProjectileFactory[])(type == PreviewType.Projectile ? target : null); // Adjust preview visibility. pbPreview.Visible = type == PreviewType.Default; _ingamePreview.Visible = type == PreviewType.Ingame; _effectPreview.Visible = type == PreviewType.Effect; _projectilePreview.Visible = type == PreviewType.Projectile; pbPreview.Resize -= PreviewOnResize; // Remember new state. _previewType = type; _previewObject = target; // Something changed. return(true); } // Nothing changed. return(false); }
public void DrawPreviewControls(PreviewType previewType) { if (previewType == PreviewType.NORMAL_MAP || previewType == PreviewType.SOBEL_OPERATOR) { strength = EditorGUILayout.Slider("Strength", strength, 0.0f, 5.0f); } }
/// <summary> /// Display a file /// </summary> /// <param name="path">Full filename</param> /// <param name="previewType">Type of file</param> public void Display(string path, PreviewType previewType) { if (path == null) { return; } if (!File.Exists(path)) { throw new FileNotFoundException(path); } switch (previewType) { case PreviewType.WindowMacro: WindowMacro = new WindowMacro(); WindowMacro.Open(path, EplanProject); SetVariantCombinations(WindowMacro); break; case PreviewType.SymbolMacro: SymbolMacro = new SymbolMacro(); SymbolMacro.Open(path, EplanProject); SetVariantCombinations(SymbolMacro); break; case PreviewType.PageMacro: PageMacro = new PageMacro(); PageMacro.Open(path, EplanProject); SetVariantCombinations(PageMacro); break; default: throw new ArgumentOutOfRangeException(nameof(previewType), previewType, null); } }
private string Flatten(string subDir, string[] files, string mediaType, PreviewType previewType) { StringBuilder sb = new StringBuilder(); if (previewType == PreviewType.Flash) { sb.Append("F,,"); } else { sb.Append("A,,"); } foreach (string file in files) { sb.Append("/ViewMedia.aspx?mediaType="); sb.Append(mediaType); sb.Append("&previewType="); sb.Append(previewType.ToString()); sb.Append("&fileName="); sb.Append(file); sb.Append("&subDir="); sb.Append(subDir); sb.Append("||"); } return(sb.Remove(sb.Length - 2, 2).ToString()); }
public void OnPreviewSettings(UnityEngine.Object[] targets) { if (ShaderUtil.hardwareSupportsRectRenderTexture) { GUI.enabled = true; this.InitPreview(); bool flag = true; bool flag2 = true; bool flag3 = false; int a = 8; foreach (Texture texture in targets) { a = Mathf.Max(a, TextureUtil.GetMipmapCount(texture)); Cubemap cubemap = texture as Cubemap; if (cubemap != null) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && (TextureUtil.GetUsageMode(texture) == TextureUsageMode.Default)) { flag3 = true; } } else { flag3 = true; flag2 = false; } } if (flag2) { this.m_PreviewType = PreviewType.Alpha; flag = false; } else if (!flag3) { this.m_PreviewType = PreviewType.RGB; flag = false; } if (flag) { GUIContent[] contentArray = new GUIContent[] { Styles.RGBIcon, Styles.alphaIcon }; int previewType = (int)this.m_PreviewType; if (GUILayout.Button(contentArray[previewType], Styles.preButton, new GUILayoutOption[0])) { this.m_PreviewType = (PreviewType)(++previewType % contentArray.Length); } } GUI.enabled = a != 1; GUILayout.Box(Styles.smallZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.changed = false; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(64f) }; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0f, Styles.preSlider, Styles.preSliderThumb, options)); GUILayout.Box(Styles.largeZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
void Select(object sender, EventArgs e) { PreviewType preview = sender as PreviewType; previews[previewIndex].deselect(); previewIndex = previews.IndexOf(preview); }
public static void Initialize(PreviewType previewType, bool metadataDetection) { mReadablePreview = previewType == PreviewType.Readable; mPhotoSaveMode = (int)SaveMode.DoNotSave; mMetadataDetection = metadataDetection; listener = new GameObject("NatCamHelper").AddComponent <NatCamHelper>(); Dispatch = NatCamDispatch.Prepare(DispatchMode.Synchronous, listener); RegisterCallbacks(Render, Update, UpdatePhoto, UpdateCode, UpdateFace); InspectDeviceCameras(); isInitialized = true; Ext.LogVerbose("Initialized native interface"); }
private void SetPreview(PreviewType type, Bitmap image) { PictureBox picBox = (type == PreviewType.Result ? resultPictureBox : hairMapPreviewPictureBox); picBox.Image = image; picBox.Width = image.Width; picBox.Height = image.Height; if (type == PreviewType.Result) { resultPictureBox.BackgroundImage = Properties.Resources.checker; resultPictureBox.BackgroundImageLayout = ImageLayout.Tile; } }
private void RefreshThumbnail(Scan scan) { PreviewType previewType = PreviewType.FullFrame; PreviewFeature feature = null; if (boxPreviewFeature.Created) { boxPreviewFeature.Invoke((MethodInvoker) delegate { previewType = _ActivePreviewType; if (boxPreviewFeature.SelectedIndex > 0) { feature = (PreviewFeature)boxPreviewFeature.SelectedItem; } }); } RefreshThumbnailAsync(scan, previewType, feature); }
public PreviewForm(PreviewType type, Stream data) { InitializeComponent(); Type = type; Data = data; switch (type) { case PreviewType.HTML: webBrowserPreview.Visible = true; pictureBoxPreview.Visible = false; richTextBoxPreview.Visible = false; tempFile = Path.Combine(Path.GetTempPath(), "ml_error_report_temp.xml"); byte[] buffer = new byte[data.Length]; data.Seek(0, SeekOrigin.Begin); data.Read(buffer, 0, buffer.Length); File.WriteAllBytes(tempFile, buffer); webBrowserPreview.Url = new Uri(tempFile); break; case PreviewType.Image: webBrowserPreview.Visible = false; pictureBoxPreview.Visible = true; richTextBoxPreview.Visible = false; pictureBoxPreview.Image = Image.FromStream(data); break; case PreviewType.Text: webBrowserPreview.Visible = false; pictureBoxPreview.Visible = false; richTextBoxPreview.Visible = true; data.Seek(0, SeekOrigin.Begin); richTextBoxPreview.Text = (new StreamReader(data)).ReadToEnd(); break; default: throw new NotSupportedException(); } }
public AssetContent(string title, string fileName, string fileNameWithoutExtension, string extension, string imagePath, string imagePathWinFS, string subDir, string imageName, string caption, string creator, DateTime?userGivenDate, string url, float displayDuration, int length, PreviewType previewType) { _name = title; _fileName = fileName; _fileNameWithoutExtension = fileNameWithoutExtension; _extension = extension; _imagePath = imagePath; _imagePathWinFS = imagePathWinFS; _subDir = subDir; _imageName = imageName; _caption = caption; _creator = creator; _userGivenDate = userGivenDate; _url = url; _displayDuration = displayDuration; _length = length; _previewType = previewType; }
private void DrawToolbar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { bool isPreviewingStyles = _activePreview == PreviewType.Styles; bool isPreviewingTextures = _activePreview == PreviewType.Textures; EditorGUI.BeginChangeCheck(); { isPreviewingStyles = GUILayout.Toggle(isPreviewingStyles, _stylesButtonLabel, EditorStyles.toolbarButton); } if (EditorGUI.EndChangeCheck()) { if (isPreviewingStyles) { _activePreview = PreviewType.Styles; } } EditorGUI.BeginChangeCheck(); { isPreviewingTextures = GUILayout.Toggle(isPreviewingTextures, _TexturesButtonLabel, EditorStyles.toolbarButton); } if (EditorGUI.EndChangeCheck()) { if (isPreviewingTextures) { _activePreview = PreviewType.Textures; } } GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); { _previewSize = GUILayout.HorizontalSlider(_previewSize, MIN_PREIVEW_SIZE, MAX_PREVIEW_SIZE, GUILayout.Width(200)); } if (EditorGUI.EndChangeCheck()) { _styleGrid.ElementWidth = _previewSize; _styleGrid.ElementHeight = _previewSize; _styleGrid.FocusElement(_styleGrid.SelectedIndex); } } EditorGUILayout.EndHorizontal(); }
private void previewCombo_SelectedIndexChanged(object sender, EventArgs e) { PreviewType n = (PreviewType)(previewCombo.SelectedIndex + 1); //SwitchPreivewCombo(n); switch (n) { case PreviewType.GridMap: mapPicBox.Visible = true; previewSedimentCompositionPanel.Visible = false; break; case PreviewType.SedimentComposition: mapPicBox.Visible = false; previewSedimentCompositionPanel.Visible = true; break; default: break; } }
private void setOptions() { PreviewListComponent previewList = new PreviewListComponent(); PreviewType preview = new PreviewType("Game/Bricks/Cat-Eye Preview", new Vector2(60, 120), Color.Yellow, "Menus/Brick Highlighter", "Menus/Brick Selector", new Vector2(55, 115)); preview.Selected += SetCatEye; previewList.addPreview(preview); preview = new PreviewType("Game/Bricks/Dragon-Eye Preview", new Vector2(155, 120), Color.Yellow, "Menus/Brick Highlighter", "Menus/Brick Selector", new Vector2(150, 115)); preview.Selected += SetDragonEye; previewList.addPreview(preview); preview = new PreviewType("Game/Bricks/Round Preview", new Vector2(60, 205), Color.Yellow, "Menus/Brick Highlighter", "Menus/Brick Selector", new Vector2(55, 200)); preview.Selected += SetRoundEye; previewList.addPreview(preview); preview = new PreviewType("Game/Bricks/Glass Preview", new Vector2(155, 205), Color.Yellow, "Menus/Brick Highlighter", "Menus/Brick Selector", new Vector2(150, 200)); preview.Selected += SetGlassEye; previewList.addPreview(preview); previewList.setTransitions(new MoveCollection(new Vector2(-200, 0), 15, true), new MoveCollection(new Vector2(200, 0), 15, false)); addComponent(previewList); OptionsComponent options = new OptionsComponent("Fonts/MaturaOptions"); OptionType option = new OptionType(new OptionType("Save", new Vector2(136, 390), Color.Red, OptionAction.previous, true, true, "Menus/Highlighter", new Vector2(137, 390))); option.Selected += SaveTexture; options.addOption(option); option = new OptionType(new OptionType("Cancel", new Vector2(136, 420), Color.Red, OptionAction.previous, true, true, "Menus/Highlighter", new Vector2(137, 420))); option.Selected += DiscardTexture; options.addOption(option); options.setAlignment(TextAlignment.center); options.setTransitions(new MoveCollection(new Vector2(-200, 0), 15, true), new MoveCollection(new Vector2(200, 0), 15, false)); addComponent(options); }
public void OnPreviewSettings(Object[] targets, int mipCount, bool alphaOnly, bool hasAlpha) { if (!ShaderUtil.hardwareSupportsRectRenderTexture) { return; } GUI.enabled = true; InitPreview(); bool showMode = true; if (alphaOnly) { m_PreviewType = PreviewType.Alpha; showMode = false; } else if (!hasAlpha) { m_PreviewType = PreviewType.RGB; showMode = false; } if (showMode) { GUIContent[] kPreviewIcons = { Styles.RGBIcon, Styles.alphaIcon }; int index = (int)m_PreviewType; if (GUILayout.Button(kPreviewIcons[index], Styles.preButton)) { m_PreviewType = (PreviewType)(++index % kPreviewIcons.Length); } } GUI.enabled = (mipCount != 1); GUILayout.Box(Styles.smallZoom, Styles.preLabel); GUI.changed = false; m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, Styles.preSlider, Styles.preSliderThumb, GUILayout.MaxWidth(64))); GUILayout.Box(Styles.largeZoom, Styles.preLabel); GUI.enabled = true; }
/// <summary> /// Constructor. /// </summary> /// <param name="pageUrl">Url of a web page.</param> /// <param name="type">Type of the previewThread.</param> public UIPreview(string pageUrl, PreviewType type) { Contract.Requires(!String.IsNullOrEmpty(pageUrl)); InitializeComponent(); ThreadStart starter = delegate { try { loadPreview(pageUrl, type); } catch (Exception ex) { log.Error(ex.Message, ex); } }; Thread loadPreviewThread = new Thread(starter); loadPreviewThread.Name = "Load Preview"; loadPreviewThread.Start(); }
private void UpdatePreview(PreviewType type) { listViewFile.Visible = pictureBoxImagePreview.Visible = false; listViewFile.Items.Clear(); pictureBoxImagePreview.Image = null; switch (type) { case PreviewType.None: return; case PreviewType.File: iconImageList.Images.Clear(); iconImageList.Images.Add(Win32Util.GetIconForExtension(File.Name)); var fileItem = new ListViewItem(File.Name); listViewFile.Items.Add(fileItem); fileItem.ImageIndex = 0; listViewFile.Visible = true; RecenterIcon(); break; case PreviewType.Image: MemoryStream imgStream = new MemoryStream(File.Data); Image image; try { image = Image.FromStream(imgStream); } catch (Exception) { UpdatePreview(PreviewType.File); return; } pictureBoxImagePreview.Image = image; pictureBoxImagePreview.Size = image.Size; UpdatePictureBoxPosition(); pictureBoxImagePreview.Visible = true; break; } }
public static void DrawPreview(PreviewRenderUtility previewUtil, Material mat, Mesh mesh, PreviewType previewType, Vector2 scroll, ref Quaternion camRot) { const string uPosition = "dr_LightPosition"; const string uColor = "dr_LightColor"; const string uAtten = "dr_LightAtten"; // reset position and rotation previewUtil.m_Camera.transform.position = -Vector3.forward * 4.25f; previewUtil.m_Camera.transform.rotation = Quaternion.identity; Quaternion orientation = Quaternion.identity; if (previewType == PreviewType.kInteractive) { orientation = Quaternion.AngleAxis(scroll.y, Vector3.right) * Quaternion.AngleAxis(scroll.x, Vector3.up); if (Quaternion.Dot(camRot, orientation) < 0f) { orientation = Quaternion.Inverse(orientation); orientation.w *= -1; } camRot = Quaternion.Lerp(camRot, orientation, 0.25f); orientation = Quaternion.Inverse(camRot); } // apply camera orientation and position previewUtil.m_Camera.transform.position = orientation * previewUtil.m_Camera.transform.position; previewUtil.m_Camera.transform.LookAt(Vector3.zero, orientation * Vector3.up); bool staticLit = mat.IsKeywordEnabled("STATIC_LIGHTING"); Vector4 posSave = Vector4.zero; Vector4 colorSave = Vector4.zero; Vector4 attenSave = Vector4.zero; Debug.logger.logEnabled = false; if (!staticLit) { if (mat.HasProperty(uPosition)) { posSave = mat.GetVector(uPosition); colorSave = mat.GetColor(uColor); attenSave = mat.GetVector(uAtten); } Vector4 dir = new Vector4(-0.707f, 0.0f, 0.707f, 0.0f); Vector4 atten = new Vector4(-1f, 1f, 1f, 625f); Vector3 color = new Vector4(1f, 1f, 1f, 1f); mat.SetVector(uPosition, dir); mat.SetVector(uColor, color); mat.SetVector(uAtten, atten); } Debug.logger.logEnabled = true; if (mesh != null) { previewUtil.DrawMesh(mesh, Vector3.zero, Quaternion.identity, mat, 0); } previewUtil.m_Camera.Render(); if (!staticLit) { mat.SetVector(uPosition, posSave); mat.SetVector(uColor, colorSave); mat.SetVector(uAtten, attenSave); } }
// @TODO: Break into separate methods? private async void RefreshThumbnailAsync(Scan scan, PreviewType previewType, PreviewFeature feature) { await Task.Delay(0); try { Geometry minGeo; MagickImage mi; string confidence = string.Empty; Geometry cropGeo = _CropGeometry; if (previewType == PreviewType.FullFrame) { minGeo = Geometry.Min(_VideoGeometry, GetScaledGeometry(_VideoGeometry)); mi = new MagickImage(scan.CurrentFrame.Bitmap); if (!_Selecting) { var roundGeo = cropGeo.Round(); mi.Composite(_ScreenOverlay, (int)roundGeo.X, (int)roundGeo.Y, CompositeOperator.Over); } else { var numRect = NumGeometry.ToRectangle(); using (var overlay = new MagickImage(SCREEN_COLOR, numRect.Width, numRect.Height)) { mi.Composite(overlay, numRect.X, numRect.Y, CompositeOperator.Over); } } } else if (previewType == PreviewType.FrameCrop) { minGeo = Geometry.Min(cropGeo, GetScaledGeometry(cropGeo)); if (!_VideoGeometry.Contains(cropGeo)) { mi = new MagickImage(scan.CurrentFrame.Bitmap); mi.Extent(cropGeo.ToMagick(), STANDARD_GRAVITY, EXTENT_COLOR); } else { mi = new MagickImage(scan.CurrentFrame.Bitmap.Clone(cropGeo.ToRectangle(), PixelFormat.Format24bppRgb)); } if (!_Selecting) { var roundGeo = cropGeo.Round(); var roundTrueGeo = _TrueCropGeometry.Round(); int xOffset = (int)(roundTrueGeo.X - cropGeo.X); int yOffset = (int)(roundTrueGeo.Y - cropGeo.Y); mi.Composite(_WatchZoneOverlay, xOffset, yOffset, CompositeOperator.Over); } } else if (previewType == PreviewType.Features && feature == null) { var trueGeo = _TrueCropGeometry; minGeo = Geometry.Min(trueGeo, GetScaledGeometry(trueGeo)); if (!_VideoGeometry.Contains(trueGeo)) { mi = new MagickImage(scan.CurrentFrame.Bitmap); mi.Extent(trueGeo.ToMagick(), STANDARD_GRAVITY, EXTENT_COLOR); } else { mi = new MagickImage(scan.CurrentFrame.Bitmap.Clone(trueGeo.ToRectangle(), PixelFormat.Format24bppRgb)); } if (!_Selecting) { mi.Composite(_WatchZoneOverlay, CompositeOperator.Over); } } else if (previewType == PreviewType.Features && feature != null) { var wzGeo = feature.WatchZone.Geometry; if (!ckbShowComparison.Checked) { var baseMGeo = new MagickGeometry(64, 64, (int)Math.Round(wzGeo.Width), (int)Math.Round(wzGeo.Height)); wzGeo.Adjust(-64, -64, 128, 128); minGeo = Geometry.Min(wzGeo, GetScaledGeometry(wzGeo)); if (!_VideoGeometry.Contains(wzGeo)) { mi = new MagickImage(scan.CurrentFrame.Bitmap); mi.Extent(wzGeo.ToMagick(), STANDARD_GRAVITY, EXTENT_COLOR); } else { mi = new MagickImage(scan.CurrentFrame.Bitmap.Clone(wzGeo.ToRectangle(), PixelFormat.Format24bppRgb)); } using (var baseM = new MagickImage( MagickColors.Transparent, baseMGeo.Width, baseMGeo.Height)) using (var overlay = new MagickImage( PREVIEW_EXTENT_COLOR, baseMGeo.Width + 128, baseMGeo.Height + 128)) { overlay.Composite(baseM, new PointD(baseMGeo.X, baseMGeo.Y), CompositeOperator.Alpha); mi.Composite(overlay, CompositeOperator.Atop); } } else { minGeo = Geometry.Min(wzGeo, GetScaledGeometry(wzGeo)); if (!_VideoGeometry.Contains(wzGeo)) { mi = new MagickImage(scan.CurrentFrame.Bitmap); mi.Extent(wzGeo.ToMagick(), STANDARD_GRAVITY, EXTENT_COLOR); } else { mi = new MagickImage(scan.CurrentFrame.Bitmap.Clone(wzGeo.ToRectangle(), PixelFormat.Format24bppRgb)); } // @TODO: Add previous frame stuff using (var deltaImage = feature.WatchImage.MagickImage.Clone()) { mi.ColorSpace = feature.Watcher.ColorSpace; deltaImage.ColorSpace = feature.Watcher.ColorSpace; if (feature.WatchImage.HasAlpha) { mi.Composite(feature.WatchImage.AlphaChannel, CompositeOperator.Over); } if (feature.Watcher.Equalize) { mi.Equalize(); } confidence = mi.Compare(deltaImage, feature.Watcher.ErrorMetric).ToString("F4"); mi.Composite(deltaImage, CompositeOperator.Difference); } } } else { throw new InvalidEnumArgumentException("PreviewType out of bounds? This shouldn't happen."); } var drawingSize = minGeo.Size.ToDrawing(); if (mi.Width > drawingSize.Width || mi.Height > drawingSize.Height) { var mGeo = minGeo.ToMagick(); mGeo.IgnoreAspectRatio = false; //mi.ColorSpace = ColorSpace.HCL; mi.FilterType = DEFAULT_SCALE_FILTER; mi.Resize(mGeo); } UpdatepictureBox(drawingSize, mi.ToBitmap(), confidence); } catch (Exception e) { Log.Error(e, "Thumbnail failed to render for the Scan Region."); scan.Dispose(); _RenderingFrame = false; } }
private void LoadVideoFromFile(string FileName) { try { //openFileVideo = FileName; VideoBoxType = PreviewType.DirectShow; videoInfo = new VideoInfo(FileName); nextK.Visible = true; videoPanel.Visible = true; videoPreviewAVS.Checked = previewToolStripMenuItem.Checked = false; openVid(videoInfo.FileName); try { PreviewType tipo = (PreviewType)int.Parse(getFromConfigFile("Video_DefaultPreviewType")); if ((tipo != VideoBoxType) && (tipo == PreviewType.AviSynth)) { SwitchToAVSMode(); } } catch { } GoToVideoPosition(); updateConcatenateConfigFile("LastVID", videoInfo.FileName); putRecentVID(); } catch { nextK.Visible = false; videoPanel.Visible = false; } drawPositions(); updateMenuEnables(); }
public void OnPreviewSettings(Object[] targets) { if (!ShaderUtil.hardwareSupportsRectRenderTexture) { return; } GUI.enabled = true; InitPreview(); bool showMode = true; bool alphaOnly = true; //@TODO: Share some code with texture inspector??? bool hasAlpha = false; int mipCount = 8; foreach (Texture t2 in targets) { mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t2)); Cubemap cubemap = t2 as Cubemap; if (cubemap) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { alphaOnly = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { TextureUsageMode mode = TextureUtil.GetUsageMode(t2); if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha { hasAlpha = true; } } } else { hasAlpha = true; alphaOnly = false; } } if (alphaOnly) { m_PreviewType = PreviewType.Alpha; showMode = false; } else if (!hasAlpha) { m_PreviewType = PreviewType.RGB; showMode = false; } if (showMode) { GUIContent[] kPreviewIcons = { Styles.RGBIcon, Styles.alphaIcon }; int index = (int)m_PreviewType; if (GUILayout.Button(kPreviewIcons[index], Styles.preButton)) { m_PreviewType = (PreviewType)(++index % kPreviewIcons.Length); } } GUI.enabled = (mipCount != 1); GUILayout.Box(Styles.smallZoom, Styles.preLabel); GUI.changed = false; m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, Styles.preSlider, Styles.preSliderThumb, GUILayout.MaxWidth(64))); GUILayout.Box(Styles.largeZoom, Styles.preLabel); GUI.enabled = true; }
/// <summary> /// Creates a VariantCombination with the given PreviewType /// </summary> /// <param name="previewType">Sets how display the object</param> public VariantCombination(PreviewType previewType) { Variants = new ObservableCollection <Variant>(); PreviewType = previewType; }
/// <summary> /// Gets the preview URL. /// </summary> /// <param name="previewType">Type of the preview.</param> /// <param name="url">The URL.</param> /// <returns></returns> public static string GetPreviewUrl(PreviewType previewType, string url) { const string previewUrl = SkyDriveBaseUrl + SkyDriveConstants.GetItemPreview + "?type={0}&url={1}"; return string.Format(previewUrl, previewType.ToString().ToLower(), Uri.EscapeDataString(url)); }
public void SetPreview(PreviewType preview, string profile_key = "") { this.preview_mode = preview; this.preview_mode_profile_key = profile_key; }
public string GetResourcePreviewUrl(string apiKey, ChiliResource.ResourceType resourceType, string id, PreviewType previewType) { return(GetResourceDownloadUrl(apiKey, resourceType, id, previewType.ToString())); }
private void Window_Deactivated(object sender, EventArgs e) { saved_preview = Global.geh.GetPreview(); saved_preview_key = Global.geh.GetPreviewProfileKey(); Global.geh.SetPreview(PreviewType.None); }
public override void OnAppeared() { UINavigationBar.ShowMenus(false); var param = this.controllerParameters; if (param.Keys.Count == 0 || param.ContainsKey("f") == false || param.ContainsKey("v") == false) { return; } ShowDetailInfo(false, ""); NGUITools.SetActive(likeButton.gameObject, true); NGUITools.SetActive(commentButton.gameObject, true); string func = param["f"]; // Get the function parameter string val = param["v"]; string id = param.ContainsKey("id") ? param["id"] : ""; currentId = id; //var email = Konstants.GetSettingsProfile().GetString(Konstants.kdEmail); var data = GameData.Load(); var userid = data.profile._id; if (string.IsNullOrEmpty(func) == false && string.IsNullOrEmpty(val) == false) { Debug.LogWarning("Func: " + func); if (func.ToLower() == "color") { NGUITools.SetActive(likeButton.gameObject, false); NGUITools.SetActive(commentButton.gameObject, false); currentPreview = PreviewType.SkinColor; DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Center); int index = int.Parse(val); DressRoom.ChangePlayerSkin(index); } else if (func.ToLower() == "character") { currentPreview = PreviewType.Character; DressRoom.ChangePlayerCharacter(val); DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Center); NetworkController.DownloadFromUrl(Like.CheckLikeMixApi(userid, id), OnDownloadFinished); NetworkController.DownloadFromUrl(CommentsCount.GetCountCommentsAvatarMixApi(id), OnCommentsDownloadFinished); } else { NetworkController.DownloadFromUrl(Like.CheckLikeAvatarApi(userid, id), OnDownloadFinished); NetworkController.DownloadFromUrl(CommentsCount.GetCountCommentsAvatarItemApi(id), OnCommentsDownloadFinished); currentPreview = PreviewType.Element; DressRoom.ChangePlayerElement(val); Debug.Log("Type: " + func + ", Value: " + val); if (func == "face_part_lip" || func == "face_part_eye_brows" || func == "face_part_eyes" || func == "hair") { DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Head); } if (func == "body") { DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Body); } if (func == "hat") { DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Head); } if (func == "pants") { DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Bottom); } if (func == "shoes") { DressRoom.CameraDolly(CameraShifter.ZoomTargetArea.Foot); } } } DressRoom.ShowCharacter(); }
private static void CreatePreviewInstances() { DestroyPreviewInstances(); if (targets.Length == 0) { return; } if (index >= targets.Length) { index = targets.Length - 1; } GameObject instance = null; if (targets[index] is GameObject) { type = PreviewType.GameObject; instance = GameObject.Instantiate(targets[index]) as GameObject; } else if (targets[index] is Mesh) { type = PreviewType.Mesh; instance = new GameObject("PreviewInstance"); MeshFilter filter = instance.AddComponent <MeshFilter>(); filter.sharedMesh = targets[index] as Mesh; MeshRenderer renderer = instance.AddComponent <MeshRenderer>(); Material material = new Material(Shader.Find("Diffuse")); material.hideFlags = HideFlags.HideAndDontSave; renderer.sharedMaterial = material; } else if (targets[index] is Material) { type = PreviewType.Material; instance = GetPrimitive(); instance.GetComponent <MeshRenderer>().sharedMaterial = targets[index] as Material; } else if (targets[index] is Texture2D) { type = PreviewType.Texture2D; instance = GetPrimitive(); Material material = new Material(Shader.Find("Unlit/Transparent")); material.hideFlags = HideFlags.HideAndDontSave; material.SetTexture("_MainTex", targets[index] as Texture); instance.GetComponent <MeshRenderer>().sharedMaterial = material; } else if (targets[index] is Cubemap) { type = PreviewType.Cubemap; instance = GetPrimitive(); Material material = new Material(Shader.Find("Reflective/Bumped Unlit")); material.hideFlags = HideFlags.HideAndDontSave; material.SetTexture("_Cube", targets[index] as Cubemap); instance.GetComponent <MeshRenderer>().sharedMaterial = material; } instance.hideFlags = HideFlags.HideAndDontSave; if (instance != null) { InitInstantiatedPreviewRecursive(instance); Animator component = instance.GetComponent(typeof(Animator)) as Animator; if (component != null) { component.enabled = false; component.cullingMode = AnimatorCullingMode.AlwaysAnimate; component.logWarnings = false; component.fireEvents = false; } SetEnabledRecursive(instance, false); previewInstance = instance; } }
private static bool DoesPreviewAllowRotation(PreviewType type) { return (type != PreviewType.Plane); }
public string GetResourcePreviewUrl(string apiKey, ChiliResource chiliResource, PreviewType previewType) { return(GetResourcePreviewUrl(apiKey, chiliResource.resourceType, chiliResource.id, previewType)); }
public void OnPreviewSettings(Object[] targets) { if (ShaderUtil.hardwareSupportsRectRenderTexture) { GUI.enabled = true; this.InitPreview(); bool flag = true; bool flag2 = true; bool flag3 = false; int a = 8; foreach (Texture texture in targets) { a = Mathf.Max(a, TextureUtil.GetMipmapCount(texture)); Cubemap cubemap = texture as Cubemap; if (cubemap != null) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && (TextureUtil.GetUsageMode(texture) == TextureUsageMode.Default)) { flag3 = true; } } else { flag3 = true; flag2 = false; } } if (flag2) { this.m_PreviewType = PreviewType.Alpha; flag = false; } else if (!flag3) { this.m_PreviewType = PreviewType.RGB; flag = false; } if (flag) { GUIContent[] contentArray = new GUIContent[] { Styles.RGBIcon, Styles.alphaIcon }; int previewType = (int) this.m_PreviewType; if (GUILayout.Button(contentArray[previewType], Styles.preButton, new GUILayoutOption[0])) { this.m_PreviewType = (PreviewType) (++previewType % contentArray.Length); } } GUI.enabled = a != 1; GUILayout.Box(Styles.smallZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.changed = false; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(64f) }; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float) (a - 1), 0f, Styles.preSlider, Styles.preSliderThumb, options)); GUILayout.Box(Styles.largeZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
private void SwitchPreivewCombo(PreviewType n) { previewCombo.SelectedIndex = (int)(n) - 1; }
public Image CreatePreviewImage() { Type = PreviewType.Image; //ReviewPrevious ReviewPrevious(); if (!string.IsNullOrEmpty(CurrentAcitivity)) { //markcurrent MarkCurrent(); //PreviewNext PreviewNext(); } RemoveApproveDetail(); //saveXoml string filename = Path.GetRandomFileName(); string filepath = Path.GetTempPath() + "\\" + filename; //string filename = string.Format("{0}\\{1}", EEPRegistry.Server, "flowpreview.xoml"); //string filename = "c:\\1.xoml"; Document.Save(filepath); //string filenametest = string.Format("{0}\\{1}", EEPRegistry.Server, "flowpreview.xoml"); //Document.Save(filenametest); string designPath = string.Format("{0}\\{1}", EEPRegistry.Server, DESIGNER_FILE); if (!File.Exists(designPath)) { designPath = string.Format("{0}\\FLDesigner\\{1}", Path.GetDirectoryName(EEPRegistry.Server), DESIGNER_FILE); if (!File.Exists(designPath)) { throw new Exception("Can not find FLDesigner.exe"); } } System.Diagnostics.Process process = System.Diagnostics.Process.Start(designPath, filename); process.WaitForExit(30000); // return (Bitmap)SaveImage(filename); if (File.Exists(filepath + ".bmp")) { Bitmap bmp = (Bitmap)Image.FromFile(filepath + ".bmp"); return bmp; } return null; }
public static Texture2D CreatePreview(AudioClip aud, int width, int height, Color color, PreviewType previewType) { int step = Mathf.CeilToInt((aud.samples * aud.channels) / width); float[] samples = new float[aud.samples * aud.channels]; //workaround to prevent the error in the function getData when Audio Importer loadType is "compressed in memory" string path = AssetDatabase.GetAssetPath(aud); AudioImporter audioImporter = AssetImporter.GetAtPath(path) as AudioImporter; AudioImporterLoadType audioLoadTypeBackup = audioImporter.loadType; audioImporter.loadType = AudioImporterLoadType.StreamFromDisc; AssetDatabase.ImportAsset(path); //getData after the loadType changed aud.GetData(samples, 0); //restore the loadType audioImporter.loadType = audioLoadTypeBackup; AssetDatabase.ImportAsset(path); Texture2D img = new Texture2D(width, height, TextureFormat.RGBA32, false); if (previewType == PreviewType.wave) { Color[] xy = new Color[width * height]; for (int x = 0; x < width * height; x++) { xy[x] = new Color(0, 0, 0, 0); //xy[x] = new Color(0, 1, 0, 0.2f); } img.SetPixels(xy); int i = 0; while (i < width) { int barHeight = Mathf.CeilToInt(Mathf.Clamp(Mathf.Abs(samples[i * step]) * height, 0, height)); int add = samples[i * step] > 0 ? 1 : -1; for (int j = 0; j < barHeight; j++) { img.SetPixel(i, Mathf.FloorToInt(height / 2) - (Mathf.FloorToInt(barHeight / 2) * add) + (j * add), color); } ++i; } img.Apply(); } else if (previewType == PreviewType.bar) { img = new Texture2D(width, 1, TextureFormat.RGBA32, false); int i = 0; while (i < width) { //int barHeight = Mathf.CeilToInt(Mathf.Clamp(Mathf.Abs(samples[i * step]) * height, 0, height)); //int add = samples[i * step] > 0 ? 1 : -1; float colorIntensity = Mathf.Clamp(Mathf.Abs(samples[i * step]) * 10f, 0, 1); Color colorReturn = new Color(color.r / colorIntensity, color.g / colorIntensity, color.b / colorIntensity, colorIntensity / 4f); img.SetPixel(i, 0, colorReturn); ++i; } img.Apply(); } else if (previewType == PreviewType.both) { /* Color[] xy = new Color[width * height]; for (int x = 0; x < width * height; x++) { xy[x] = new Color(1, 0, 0, 1); //xy[x] = new Color(0, 1, 0, 0.2f); } img.SetPixels(xy); */ int i = 0; while (i < width) { int barHeight = Mathf.CeilToInt(Mathf.Clamp(Mathf.Abs(samples[i * step]) * height, 0, height)); int add = samples[i * step] > 0 ? 1 : -1; float colorIntensity = Mathf.Clamp(Mathf.Abs(samples[i * step]) * 10f, 0, 1); Color colorReturn = new Color(color.r / colorIntensity, color.g / colorIntensity, color.b / colorIntensity, colorIntensity / 6f); for (int j = 0; j < height; j++) { img.SetPixel(i, j, colorReturn); } for (int j = 0; j < barHeight; j++) { img.SetPixel(i, Mathf.FloorToInt(height / 2) - (Mathf.FloorToInt(barHeight / 2) * add) + (j * add), color); } ++i; } img.Apply(); } return img; }
public DataTable CreatePreviewTable() { Type = PreviewType.DataTable; PreviewTable = new DataTable(); //PreviewTable.Columns.AddRange(new DataColumn[]{ // new DataColumn("Seq"), // new DataColumn("Activity"), // new DataColumn("Role"), // new DataColumn("User"), // new DataColumn("Status")} // ); string[] listMessage = message.Split(','); for (int i = 0; i < 6; i++) { DataColumn column = new DataColumn(); column.ColumnName = listMessage[i]; PreviewTable.Columns.Add(column); } strApproved = listMessage[6]; strWaiting = listMessage[7]; strPlusApproved = listMessage[8]; //ReviewPrevious ReviewPrevious(); if (!string.IsNullOrEmpty(CurrentAcitivity)) { //markcurrent MarkCurrent(); //PreviewNext PreviewNext(); } for (int i = 0; i < PreviewTable.Rows.Count; i++) { PreviewTable.Rows[i][0] = i + 1; } return PreviewTable; }
private void loadPreview(string pageUrl, PreviewType type) { string htmlCode = new WebClient().DownloadString(pageUrl); string title = FormatString(Regex.Match(htmlCode, @"\<title\>([^>]+)\<\/title\>").Groups[1].Value); string imageUrl = ""; switch (type) { case PreviewType.Youtube: imageUrl = YouTubePreview(pageUrl); break; case PreviewType.Viemo: imageUrl = ViemoPreview(pageUrl); break; case PreviewType.DailyMotion: imageUrl = DailyMotionPreview(pageUrl); break; case PreviewType.Flickr: imageUrl = FlickrPreview(pageUrl); break; //case PreviewType.Picasa: // ImageUrl = PicasaPreview(pageUrl); // break; case PreviewType.JPEG: case PreviewType.PNG: case PreviewType.BMP: case PreviewType.GIF: imageUrl = ImagePreview(pageUrl); break; } Dispatcher.BeginInvoke(new Action(delegate() { Hyperlink hyperlink = new Hyperlink(); hyperlink.NavigateUri = new Uri(pageUrl); hyperlink.Inlines.Add((title == String.Empty) ? pageUrl.Split('/').Last() : title); hyperlink.ToolTip = ("Go to: " + pageUrl); hyperlink.Click += hyperlink_Click; ContextMenu contextMenu = new ContextMenu(); MenuItemWithLink internalBrowser = new MenuItemWithLink(); internalBrowser.hyperlink = hyperlink; internalBrowser.Header = "Internal Browser"; internalBrowser.Click += internalBrowser_Click; MenuItemWithLink externalBrowser = new MenuItemWithLink(); externalBrowser.hyperlink = hyperlink; externalBrowser.Header = "External Browser"; externalBrowser.Click += externalBrowser_Click; contextMenu.Items.Add(internalBrowser); contextMenu.Items.Add(externalBrowser); hyperlink.ContextMenu = contextMenu; PreviewTitle.Inlines.Add(hyperlink); PreviewImage.Source = new BitmapImage(new Uri(imageUrl)); })); }
public static void DrawMain(Material mat, Layout layout) { bool prevLayoutChange = layout.change; layout.Par(54); layout.Label("Texture Arrays:\n(Albedo/Normal)", layout.Inset(1 - layout.fieldSize)); layout.MatField <Texture>(mat, "_MainTexArr", rect: layout.Inset(54f)); layout.MatField <Texture>(mat, "_BumpMapArr", rect: layout.Inset(54f)); layout.Par(20); layout.Inset(1 - layout.fieldSize); if (layout.Button("Save", rect: layout.Inset(54f))) { if (mat.HasProperty("_MainTexArr") && mat.GetTexture("_MainTexArr") != null) { layout.SaveAsset((Texture2DArray)mat.GetTexture("_MainTexArr")); } } if (layout.Button("Save", rect: layout.Inset(54f))) { if (mat.HasProperty("_BumpMapArr") && mat.GetTexture("_BumpMapArr") != null) { layout.SaveAsset((Texture2DArray)mat.GetTexture("_BumpMapArr")); } } layout.Par(5); layout.MatField <int>(mat, "_Culling", "Culling"); layout.MatField <float>(mat, "_Tile", "Tile"); layout.MatField <float>(mat, "_BlendCrisp", "Blend Crispness"); layout.MatField <float>(mat, "_BlendMapFactor", "Blend Map Factor"); layout.MatField <float>(mat, "_Mips", "MipMap Factor"); layout.MatField <float>(mat, "_AmbientOcclusion", "Ambient Occlusion"); //triplanar layout.MatKeyword(mat, "_TRIPLANAR", "Triplanar"); //layout.MatKeyword(mat, "_SPEC", "Metallic/Gloss"); //far layer layout.Par(5); layout.MatKeyword(mat, "_DOUBLELAYER", "Far Layer"); if (mat.IsKeywordEnabled("_DOUBLELAYER")) { layout.MatField <float>(mat, "_FarTile", "Far Tile"); layout.MatField <float>(mat, "_FarStart", "Transition Start"); layout.MatField <float>(mat, "_FarEnd", "Transition End"); layout.disabled = false; } //horizon layout.Par(5); layout.MatKeyword(mat, "_HORIZON", "Horizon"); if (mat.IsKeywordEnabled("_HORIZON")) { layout.MatField <float>(mat, "_HorizonHeightScale", "Horizon Height Scale"); layout.MatField <Texture>(mat, "_HorizonHeightmap", "Horizon Heightmap"); layout.MatField <Texture>(mat, "_HorizonTypemap", "Horizon Typemap"); layout.MatField <Texture>(mat, "_HorizonVisibilityMap", "Horizon Visibility Map"); layout.MatField <float>(mat, "_HorizonBorderLower", "Horizon Border Lower"); } //preview layout.Par(5); if (!mat.HasProperty("_PreviewType")) { layout.disabled = true; layout.Field(PreviewType.disabled, "Preview"); layout.disabled = false; } else { PreviewType previewType = (PreviewType)mat.GetInt("_PreviewType"); if (!mat.IsKeywordEnabled("_PREVIEW")) { previewType = PreviewType.disabled; } layout.Field(ref previewType, "Preview"); if (layout.lastChange) { if (previewType == PreviewType.disabled) { mat.DisableKeyword("_PREVIEW"); mat.SetInt("_PreviewType", 0); } else { mat.EnableKeyword("_PREVIEW"); mat.SetInt("_PreviewType", (int)previewType); } } layout.disabled = false; } layout.lastChange = layout.change; layout.change = prevLayoutChange || layout.lastChange; }
public static void DrawMain(Material mat, Layout layout) { layout.Par(54); layout.Label("Texture Arrays:\n(Albedo/Normal)", layout.Inset(1 - layout.fieldSize)); layout.MatField <Texture>(mat, "_MainTexArr", rect: layout.Inset(54f)); layout.MatField <Texture>(mat, "_BumpMapArr", rect: layout.Inset(54f)); layout.Par(20); layout.Inset(1 - layout.fieldSize); if (layout.Button("Save", rect: layout.Inset(54f))) { if (mat.HasProperty("_MainTexArr") && mat.GetTexture("_MainTexArr") != null) { layout.SaveAsset((Texture2DArray)mat.GetTexture("_MainTexArr")); } } if (layout.Button("Save", rect: layout.Inset(54f))) { if (mat.HasProperty("_BumpMapArr") && mat.GetTexture("_BumpMapArr") != null) { layout.SaveAsset((Texture2DArray)mat.GetTexture("_BumpMapArr")); } } layout.MatField <int>(mat, "_Culling", "Culling"); layout.MatField <float>(mat, "_Cutoff", "Alpha Ref"); layout.MatField <float>(mat, "_Mips", "MipMap Factor"); layout.MatField <float>(mat, "_DistanceFadeZero", "Distance Fade Zero"); layout.MatField <float>(mat, "_DistanceFadeOne", "Distance Fade One"); layout.MatField <Color>(mat, "_ColorTint0", "Color Tint"); layout.Par(5); layout.MatKeyword(mat, "_WIND", "Wind"); if (mat.IsKeywordEnabled("_WIND")) { layout.MatField <Texture>(mat, "_WindTex", "Wind(XY)"); layout.MatField <float>(mat, "_WindSize", "Wind Size"); layout.MatField <float>(mat, "_WindSpeedX", "Wind Speed X"); layout.MatField <float>(mat, "_WindSpeedZ", "Wind Speed Z"); layout.MatField <float>(mat, "_WindStrength", "Wind Strength"); } layout.Par(5); layout.MatKeyword(mat, "_SPEC", "Metallic/Gloss"); //preview layout.Par(5); if (!mat.HasProperty("_PreviewType")) { layout.Field(PreviewType.disabled, "Preview", disabled: true); } else { PreviewType previewType = (PreviewType)mat.GetInt("_PreviewType"); if (!mat.IsKeywordEnabled("_PREVIEW")) { previewType = PreviewType.disabled; } layout.Field(ref previewType, "Preview"); if (layout.lastChange) { if (previewType == PreviewType.disabled) { mat.DisableKeyword("_PREVIEW"); mat.SetInt("_PreviewType", 0); } else { mat.EnableKeyword("_PREVIEW"); mat.SetInt("_PreviewType", (int)previewType); } } } }
private void openRecentVID(object sender, EventArgs e) { ToolStripMenuItem menu = sender as ToolStripMenuItem; VideoBoxType = PreviewType.DirectShow; //openFileVideo = menu.Text; videoInfo = new VideoInfo(menu.Text); nextK.Visible = true; videoPanel.Visible = true; isVideoLoaded = true; videoPreviewAVS.Checked = previewToolStripMenuItem.Checked = false; openVid(videoInfo.FileName); try { PreviewType tipo = (PreviewType)int.Parse(getFromConfigFile("Video_DefaultPreviewType")); if ((tipo != VideoBoxType) && (tipo == PreviewType.AviSynth)) { SwitchToAVSMode(); } } catch { } GoToVideoPosition(); updateConcatenateConfigFile("LastVID", videoInfo.FileName); drawPositions(); updateMenuEnables(); }