private async Task InitializeVM(BoardViewModel viewModel) { if (viewModel == null) { return; } ViewModel.NodeChanged += (sender, node) => _currentGameTreeNode = node; _currentGameTreeNode = ViewModel.GameTreeNode; _boardControlState = ViewModel.BoardControlState; _renderService = new RenderService(_boardControlState); _inputService = new InputService(_boardControlState); await RenderService.AwaitResources(); canvas.Draw += canvas_Draw; canvas.Update += canvas_Update; canvas.PointerMoved += canvas_PointerMoved; canvas.PointerPressed += canvas_PointerPressed; canvas.PointerReleased += canvas_PointerReleased; canvas.PointerExited += Canvas_PointerExited; _inputService.PointerTapped += (sender, ev) => ViewModel.BoardTap(ev); }
protected override async ValueTask Init() { this.AddService(new InputService()); var collisionService = new CollisionService(this, new Size(64, 64)); this.AddService(collisionService); var sceneGraph = new SceneGraph(this); this.AddService(sceneGraph); var player = BuildPlayer(); sceneGraph.Root.AddChild(player); for (var i = 0; i != 6; ++i) { AddAsteroid(sceneGraph); } var context = await _canvas.CreateCanvas2DAsync(); var renderService = new RenderService(this, context); this.AddService(renderService); }
public IActionResult Back(CardType?type) { if (type == default) { return(BadRequest("Unknown card type")); } CallCardBack ??= RenderService.RenderCardBack(Color.Black, Color.White); ResponseCardBack ??= RenderService.RenderCardBack(Color.White, Color.Black); var cardBitmap = type switch { CardType.Call => CallCardBack, CardType.Response => ResponseCardBack, _ => throw new InvalidOperationException(), }; var cardStream = new MemoryStream(); lock ( cardBitmap ) { cardBitmap.Save(cardStream, ImageFormat.Png); cardStream.Seek(0, SeekOrigin.Begin); } return(File(cardStream, "image/png")); }
/// <summary> /// Clears the current mesh and recalculates it from scratch. /// Does all required culling based on the chunks passed into it. /// Does not create the actual mesh yet; this only calculates it. /// </summary> private void CreateFaces() { List <BlockLight> lightList = RenderService.GetAllLightsWithinMaxRange( associatedChunkMeshCluster.chunk.WorldPosition()); // Resist the urge to remove the lists and convert this all to a two-step system of counting the faces and // then initializing the arrays to the proper size. Adjacent chunks can change while this calculation is // happening, which can result in mis-counts. verticesList.Clear(); uvList.Clear(); trianglesList.Clear(); normalsList.Clear(); colorList.Clear(); meshArraysIndex = 0; for (byte xIttr = 0; xIttr < Chunk.SIZE; xIttr++) { for (byte zIttr = 0; zIttr < Chunk.SIZE; zIttr++) { for (int yIttr = Chunk.SIZE - 1; yIttr >= 0; yIttr--) { CreateFacesAtPosition(xIttr, yIttr, zIttr, lightList); } } } }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << globals >> { //Always include var globalScript = $"var SiteLang=\"{ErpSettings.Lang}\";"; globalScript += $"moment.locale(\"{ErpSettings.Lang}\");"; scriptTagsToInclude.Add(new ScriptTagInclude() { InlineContent = globalScript }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
private async void canvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) { await RenderService.AwaitResources(); RenderService.Draw( sender, sender.Size.Width, sender.Size.Height, args.DrawingSession, _currentGameTreeNode); }
void rssc_HasNameCompleted(object sender, RenderService.HasNameCompletedEventArgs e) { if (!e.Result) { UploadFile(nameText.Text, stream); } else { MessageBox.Show("Name already used."); enable(); } }
void Start() { if (player == null) { throw new MissingComponentException("Missing Player component"); } if (blockParticle == null) { throw new MissingComponentException("Missing Block Particle component"); } if (chunkMeshPrefab == null) { throw new MissingComponentException("Missing Chunk Mesh component"); } if (solidBlockMaterial == null) { throw new MissingComponentException("Missing Solid Block Material component"); } if (transparentBlockMaterial == null) { throw new MissingComponentException("Missing Transparent Block Material component"); } if (waterBlockMaterial == null) { throw new MissingComponentException("Missing Water Block Material component"); } Vector3 playerStartPosition; playerStartPosition.x = 64.5f; playerStartPosition.y = 148; playerStartPosition.z = 64.5f; Instantiate(player, playerStartPosition, Quaternion.identity); instance = this; BlockDefinition.InitializeAllTypes(); AsyncService.Initialize(); ChunkRepository.Initialize(); CollisionService.Initialize(); GeneratorService.Initialize(); RenderService.Initialize(); SetSeed(UnityEngine.Random.Range(Int32.MinValue + 1, Int32.MaxValue - 1)); fogDistance = 0.0f; AsyncService.Load(); // Remove the next line if you want your game to stop processing when it loses focus Application.runInBackground = true; }
public void Draw() { // it is example with using a second FBO // gen FBO GenTexturedFBO(); // set scene viewport according to items size GL.Viewport(0, 0, GetWidth(), GetHeight()); // crear color and depth bits GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /////////////// // draw cube with light GL.UseProgram(_shaderCommon); UniformSender.SendColorAsUniformVariable(_shaderCommon, Color.White, "lightColor"); UniformSender.SendVec3AsUniformVariable(_shaderCommon, new float[] { 1.2f, 1.0f, 2.0f }, "lightPos"); UniformSender.SendMVPAsUniformVariable(_shaderCommon, _model, _view, _projection); BindCubeBuffer(); UniformSender.SendColorAsUniformVariable(_shaderCommon, _color, "objectColor"); GL.DrawArrays(GL_TRIANGLES, 0, _VBOlenght); // optionally: draw edges UniformSender.SendColorAsUniformVariable(_shaderCommon, Color.Black, "objectColor"); GL.DrawArrays(GL_LINE_STRIP, 0, _VBOlenght); // using light of lamp GL.UseProgram(_shaderLamp); BindLampBuffer(); GL.DrawArrays(GL_TRIANGLES, 0, _VBOlenght); ///////////////// // unbind second FBO and restore viewport to current window UnbindFBO(); RenderService.SetGLLayerViewport(GetHandler(), this); // draw FBO texture GL.UseProgram(_shaderTexture); GenTextureBuffers(); BindTexture(); UniformSender.SendUniformSample2D(_shaderTexture, "tex"); GL.DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, IntPtr.Zero); // delete resources GL.DeleteFramebuffersEXT(1, _FBO); GL.DeleteRenderbuffersEXT(1, _depthrenderbuffer); GL.DeleteTextures(1, _texture); GL.DeleteBuffers(2, _buffers); GL.DisableVertexAttribArray(0); GL.DisableVertexAttribArray(1); }
private Notification BuildNotificationFromTemplate(string templateName, NotificationType type, Person recipient, Announcement announcement = null , Guid?applicationId = null, MarkingPeriod markingPeriod = null, PrivateMessage privateMessage = null, Person asker = null, object other = null, string baseUrl = null) { var parameters = new List <string> { GetBaseUrlByRole(recipient, baseUrl) }; var notification = new NotificationDetails { PersonRef = recipient.Id, Person = recipient, RoleRef = recipient.RoleRef, Shown = false, Type = type, Created = serviceLocator.Context.NowSchoolTime }; if (announcement != null) { notification.AnnouncementRef = announcement.Id; notification.Announcement = announcement; } if (applicationId.HasValue) { //notification.Application = application; notification.ApplicationRef = applicationId; } if (markingPeriod != null) { notification.MarkingPeriod = markingPeriod; notification.MarkingPeriodRef = markingPeriod.Id; } if (privateMessage != null) { notification.PrivateMessage = privateMessage; notification.PrivateMessageRef = privateMessage.Id; } if (asker != null) { notification.QuestionPerson = asker; notification.QuestionPersonRef = asker.Id; parameters.Add(GetRelativeUrlByRole(asker)); } var model = new { Notification = notification, Other = other }; string message = RenderService.Render(templateName, model, parameters); notification.Message = message; return(notification); }
public void WhenPrivateValidResults_CanRenderToExpectedFormat() { //Arrange var testViewData = FakeModels.CatsViewForRender; var stubILogger = StubHelper.StubILogger <RenderService>(); var testedService = new RenderService(stubILogger.Object); //Act var actual = testedService.RenderRegistrations(testViewData); //Assert Assert.Contains("Female", actual); }
private async void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args) { if (GameBoard != null) { await RenderService.AwaitResources(); RenderService.SharedBoardControlState = new BoardControlState(Rectangle.GetBoundingRectangle(GameBoard)); RenderService.ShowCoordinates = false; RenderService.SimpleRenderService = true; RenderService.Draw(sender, sender.Size.Width, sender.Size.Height, args.DrawingSession, new GameTreeNode() { BoardState = GameBoard }); } }
public async Task <IActionResult> Display(int id) { JsonResultObject result = new JsonResultObject(); try { var model = VaultService.Instance.GetById(id); result.PartialViewHtml = await RenderService.RenderToStringAsync(PARTIAL_DISPLAY, model); } catch (PermissionException) { return(NotFound()); } return(Ok(result)); }
public void UpdateTexture(BlockSpacePosition blockPosition, Block block) { Vector2 textureCoordinates = block.GetTextureCoordinates(CubeSide.Top, true, true, (byte)254); Vector2 overallTextureSize = block.GetOverallTextureSize(); Vector2 individualTextureSize = block.GetIndividualTextureSize(); Vector2 lowerUVs, upperUVs; lowerUVs.x = textureCoordinates.x / overallTextureSize.x; lowerUVs.y = 1.0f - textureCoordinates.y / overallTextureSize.y; upperUVs.x = (textureCoordinates.x + individualTextureSize.x) / overallTextureSize.x; upperUVs.y = 1.0f - (textureCoordinates.y + individualTextureSize.y) / overallTextureSize.y; Vector2[] uvs = CubeMesh.uv; for (int j = 0; j < 6; j++) { Vector2 uv; uv.x = lowerUVs.x; uv.y = upperUVs.y; uvs[j * 4 + 0] = uv; uv.x = lowerUVs.x; uv.y = lowerUVs.y; uvs[j * 4 + 1] = uv; uv.x = upperUVs.x; uv.y = upperUVs.y; uvs[j * 4 + 2] = uv; uv.x = upperUVs.x; uv.y = lowerUVs.y; uvs[j * 4 + 3] = uv; } CubeMesh.uv = uvs; Color lightColor = RenderService.SampleLight(blockPosition, CubeSide.Top); Color[] colors = CubeMesh.colors; for (int j = 0; j < 4 * 6; j++) { colors[j] = lightColor; } CubeMesh.colors = colors; }
private static async Task <List <byte[]> > CreateResponseCards(string deckCode) { var deck = await DeckCache.GetItemAsync(deckCode); var cardSheets = RenderService.RenderCardSheets(deck.Cards.Responses, deckCode, Color.White, Color.Black); var sheetBuffers = new List <byte[]>(); Debug.WriteLine($"Creating response cards for deck {deckCode}"); foreach (var sheet in cardSheets) { await using var sheetStream = new MemoryStream(); sheet.Save(sheetStream, ImageFormat.Png); sheetBuffers.Add(sheetStream.ToArray()); } return(sheetBuffers); }
private void SetBlock(ChunkSubspacePosition position, BlockDefinition definition, bool triggerLightingUpdate) { lock (padlock) { if (position.x < 0 || position.x >= SIZE || position.y < 0 || position.y >= SIZE || position.z < 0 || position.z >= SIZE) { return; } if (triggerLightingUpdate) { BlockSpacePosition blockPosition = position.GetBlockSpacePosition(this); RenderService.MarkChunksWithinMaxLightRadiusForMeshUpdate(blockPosition); } else { PutInChunkProcessingList(); } dirty = true; if (MeshGenerationIsInProgress()) { BlockModification modification; modification.position = position; modification.definition = definition; modificationList.Enqueue(modification); } else { BlockDefinition prevDefinition; prevDefinition = blocks[position.x, position.y, position.z].GetDefinition(); blocks[position.x, position.y, position.z].Set(definition); if (definition.IsActive() == false) { FlushBlockRemoval(position, definition, prevDefinition); } else { FlushBlockSet(position, definition, prevDefinition); } } } }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
private CoreComponent(IGraphUiContainer uiContainer, bool enableGeometricPreview) { // Either create or reuse a session name. EstablishSessionName(uiContainer); this.uiContainer = uiContainer; if (false != enableGeometricPreview) this.renderService = new RenderService(this); if (this.HostApplication != null) { object filteredClasses = null; Dictionary<string, object> configs = this.HostApplication.Configurations; if (configs.TryGetValue(ConfigurationKeys.FilteredClasses, out filteredClasses)) { this.filteredClasses = ((string)filteredClasses).ToLower(); if (!this.filteredClasses.EndsWith(";")) this.filteredClasses += ';'; } } this.heartbeat = Heartbeat.GetInstance(); this.studioSettings = StudioSettings; }
/// <summary> /// Returns the icon as a Bitmap /// </summary> /// <returns>Icon as a Bitmap</returns> public Bitmap GetImage() { return(RenderService.GetImage(icon)); }
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { if (!isVisible) { output.SuppressOutput(); return(Task.CompletedTask); } #region << Init >> var initSuccess = InitField(context, output); if (!initSuccess) { return(Task.CompletedTask); } if (Value == "") { Value = null; } if (Value != null && !(Value is List <EntityRecord>)) { output.Content.AppendHtml("<div class='go-red'>'value' property should be 'List<EntityRecord>'"); return(Task.CompletedTask); } if (Value != null && Value is List <EntityRecord> ) { var valueRecords = (List <EntityRecord>)Value; foreach (var file in valueRecords) { if (!file.Properties.ContainsKey(PathFieldName)) { output.Content.AppendHtml($"<div class='go-red'>{PathFieldName} property is missing in value (List<EntityRecord>)"); return(Task.CompletedTask); } var fileId = (Guid)file["id"]; RelatedFileIds.Add(fileId); var fileRecord = new EntityRecord(); fileRecord["id"] = fileId; var fileUrl = (string)file[PathFieldName]; if (fileUrl.StartsWith("/fs")) { fileUrl = fileUrl.Substring(3); } fileRecord["path"] = fileUrl; fileRecord["icon_class"] = new RenderService().GetPathTypeIcon(fileUrl); fileRecord["name"] = Path.GetFileName(fileUrl); fileRecord["size"] = (decimal)0; if (!string.IsNullOrWhiteSpace(SizeFieldName) && file.Properties.ContainsKey(SizeFieldName)) { fileRecord["size"] = (decimal)file[SizeFieldName]; } FileRecords.Add(fileRecord); } } #endregion #region << Render >> if (Mode == FieldRenderMode.Form) { if (Access == FieldAccess.Full || Access == FieldAccess.FullAndCreate) { #region << Hidden input for posting >> output.Content.AppendHtml($"<input type='hidden' id='input-{FieldId}' name='{Name}' value='{String.Join(',', RelatedFileIds)}' data-entity-name='{FileEntityName}' data-path-field-name='{PathFieldName}'/>"); #endregion #region << fake upload >> var inputGroupEl = new TagBuilder("div"); inputGroupEl.AddCssClass("input-group erp-file-multiple-input"); var fakeInputEl = new TagBuilder("div"); var inputElCssClassList = new List <string>(); inputElCssClassList.Add("form-control erp-file with-progress"); fakeInputEl.Attributes.Add("id", $"fake-{FieldId}"); if (ValidationErrors.Count > 0) { inputElCssClassList.Add("is-invalid"); } fakeInputEl.Attributes.Add("class", String.Join(' ', inputElCssClassList)); var fakeInputProgress = new TagBuilder("div"); fakeInputProgress.AddCssClass("form-control-progress"); fakeInputEl.InnerHtml.AppendHtml(fakeInputProgress); inputGroupEl.InnerHtml.AppendHtml(fakeInputEl); var appendEl = new TagBuilder("span"); appendEl.AddCssClass("input-group-append action erp-file"); var selectFileLink = new TagBuilder("button"); selectFileLink.Attributes.Add("type", $"button"); selectFileLink.AddCssClass("btn btn-white"); selectFileLink.Attributes.Add("onclick", $"document.getElementById('file-{FieldId}').click();"); selectFileLink.InnerHtml.AppendHtml("browse"); appendEl.InnerHtml.AppendHtml(selectFileLink); inputGroupEl.InnerHtml.AppendHtml(appendEl); output.Content.AppendHtml(inputGroupEl); var realHiddenFileInput = new TagBuilder("input"); realHiddenFileInput.Attributes.Add("id", $"file-{FieldId}"); realHiddenFileInput.Attributes.Add("type", $"file"); realHiddenFileInput.Attributes.Add("multiple", $"true"); realHiddenFileInput.AddCssClass("d-none"); realHiddenFileInput.Attributes.Add("value", $""); if (!String.IsNullOrWhiteSpace(Accept)) { realHiddenFileInput.Attributes.Add("accept", $"{Accept}"); } output.Content.AppendHtml(realHiddenFileInput); #endregion #region << Files list element >> var filesListEl = new TagBuilder("div"); filesListEl.AddCssClass("form-control erp-file-multiple-list form"); filesListEl.Attributes.Add("id", $"fake-list-{FieldId}"); if (FileRecords.Count == 0) { filesListEl.AddCssClass("d-none"); } //Generate the files list foreach (var file in FileRecords) { var fileRow = new TagBuilder("div"); fileRow.AddCssClass("filerow"); fileRow.Attributes.Add("data-file-id", ((Guid)file["id"]).ToString()); //Append icon fileRow.InnerHtml.AppendHtml($"<div class='icon'><i class='fa {(string)file["icon_class"]}'></i></div>"); //Append meta var rowMeta = new TagBuilder("div"); rowMeta.AddCssClass("meta"); //Append file rowMeta.InnerHtml.AppendHtml($"<a class='link' href='/fs{(string)file["path"]}' target='_blank' title='/fs{(string)file["path"]}'>{(string)file["name"]}<em></em></a>"); //Append size var sizeString = ""; var sizeKBInt = (int)((decimal)file["size"]); //size is in KB if (sizeKBInt < 1024) { sizeString = sizeKBInt + " KB"; } else if (sizeKBInt >= 1024 && sizeKBInt < Math.Pow(1024, 2)) { sizeString = Math.Round((decimal)(sizeKBInt / 1024), 1) + " MB"; } else { sizeString = Math.Round((decimal)(sizeKBInt / Math.Pow(1024, 2)), 1) + " GB"; } rowMeta.InnerHtml.AppendHtml($"<div class='size'>{sizeString}</div>"); fileRow.InnerHtml.AppendHtml(rowMeta); //Action var rowAction = new TagBuilder("div"); rowAction.AddCssClass("action remove"); rowAction.InnerHtml.AppendHtml($"<a class='link' href='#'><i class='fa fa-times-circle'></i></a>"); //rowAction.InnerHtml.AppendHtml($"<span class='progress d-none'>0%</span>"); //rowAction.InnerHtml.AppendHtml($"<span class='error go-red d-none'><i class='fas fa-exclamation-circle'></i></span>"); fileRow.InnerHtml.AppendHtml(rowAction); filesListEl.InnerHtml.AppendHtml(fileRow); } output.Content.AppendHtml(filesListEl); #endregion var jsCompressor = new JavaScriptCompressor(); #region << Init Scripts >> var tagHelperInitialized = false; var fileName = "form"; if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldUserFileMultiple) + fileName)) { var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldUserFileMultiple) + fileName]; tagHelperInitialized = tagHelperContext.Initialized; } if (!tagHelperInitialized) { var scriptContent = FileService.GetEmbeddedTextResource("form.js", "WebVella.Erp.Web.TagHelpers.WvFieldUserFileMultiple"); var scriptEl = new TagBuilder("script"); scriptEl.Attributes.Add("type", "text/javascript"); //scriptEl.InnerHtml.AppendHtml(scriptContent); scriptEl.InnerHtml.AppendHtml(jsCompressor.Compress(scriptContent)); output.PostContent.AppendHtml(scriptEl); ViewContext.HttpContext.Items[typeof(WvFieldUserFileMultiple) + fileName] = new WvTagHelperContext() { Initialized = true }; } #endregion #region << Add Inline Init Script for this instance >> var initScript = new TagBuilder("script"); initScript.Attributes.Add("type", "text/javascript"); var scriptTemplate = @" $(function(){ FieldUserMultiFileFormInit(""{{FieldId}}"",{{ConfigJson}}); });" ; scriptTemplate = scriptTemplate.Replace("{{FieldId}}", (FieldId ?? null).ToString()); var fieldConfig = new WvFieldFileConfig() { ApiUrl = ApiUrl, CanAddValues = Access == FieldAccess.FullAndCreate ? true : false, Accept = Accept }; scriptTemplate = scriptTemplate.Replace("{{ConfigJson}}", JsonConvert.SerializeObject(fieldConfig)); initScript.InnerHtml.AppendHtml(jsCompressor.Compress(scriptTemplate)); output.PostContent.AppendHtml(initScript); #endregion } else if (Access == FieldAccess.ReadOnly) { //if (!String.IsNullOrWhiteSpace(Value)) //{ // var inputGroupEl = new TagBuilder("div"); // inputGroupEl.AddCssClass("input-group"); // var prependEl = new TagBuilder("span"); // prependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); // prependEl.Attributes.Add("title", $"/fs{Value}"); // var prependText = new TagBuilder("span"); // prependText.AddCssClass("input-group-text"); // var prependIcon = new TagBuilder("span"); // prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); // prependText.InnerHtml.AppendHtml(prependIcon); // prependEl.InnerHtml.AppendHtml(prependText); // inputGroupEl.InnerHtml.AppendHtml(prependEl); // var inputEl = new TagBuilder("div"); // inputEl.AddCssClass("form-control erp-file disabled"); // var inputElLink = new TagBuilder("a"); // inputElLink.Attributes.Add("href", $"/fs{Value}"); // inputElLink.Attributes.Add("target", "_blank"); // inputElLink.Attributes.Add("title", $"/fs{Value}"); // inputElLink.InnerHtml.Append(FileName); // inputEl.InnerHtml.AppendHtml(inputElLink); // inputGroupEl.InnerHtml.AppendHtml(inputEl); // output.Content.AppendHtml(inputGroupEl); // //Hidden input with the value // var hiddenInput = new TagBuilder("input"); // hiddenInput.Attributes.Add("type", "hidden"); // hiddenInput.Attributes.Add("id", $"input-{FieldId}"); // hiddenInput.Attributes.Add("name", Name); // hiddenInput.Attributes.Add("value", (Value ?? "").ToString()); // output.Content.AppendHtml(hiddenInput); //} //else { // var inputEl = new TagBuilder("input"); // inputEl.Attributes.Add("readonly", null); // inputEl.AddCssClass("form-control erp-file"); // inputEl.Attributes.Add("value",""); // inputEl.Attributes.Add("name", Name); // output.Content.AppendHtml(inputEl); //} } } else if (Mode == FieldRenderMode.Display) { output.Content.AppendHtml("Not implemented yet"); //if (!String.IsNullOrWhiteSpace(Value)) //{ // var divEl = new TagBuilder("div"); // divEl.Attributes.Add("id", $"input-{FieldId}"); // divEl.AddCssClass("form-control-plaintext erp-file"); // var iconEl = new TagBuilder("span"); // iconEl.AddCssClass($"fa fa-fw {PathTypeIcon}"); // divEl.InnerHtml.AppendHtml(iconEl); // var linkEl = new TagBuilder("a"); // linkEl.Attributes.Add("href", $"/fs{Value}"); // linkEl.Attributes.Add("target", $"_blank"); // linkEl.InnerHtml.Append(FileName); // divEl.InnerHtml.AppendHtml(linkEl); // output.Content.AppendHtml(divEl); //} //else //{ // output.Content.AppendHtml(EmptyValEl); //} } else if (Mode == FieldRenderMode.Simple) { output.Content.AppendHtml("Not implemented yet"); //output.SuppressOutput(); //var linkEl = new TagBuilder("a"); //linkEl.Attributes.Add("href", $"/fs{Value}"); //linkEl.Attributes.Add("target", $"_blank"); //linkEl.InnerHtml.Append(FileName); //output.Content.AppendHtml(linkEl); //return Task.CompletedTask; } else if (Mode == FieldRenderMode.InlineEdit) { output.Content.AppendHtml("Not implemented yet"); //if (Access == FieldAccess.Full || Access == FieldAccess.FullAndCreate) //{ // #region << View Wrapper >> // { // var viewWrapperEl = new TagBuilder("div"); // viewWrapperEl.AddCssClass("input-group view-wrapper"); // viewWrapperEl.Attributes.Add("title", "double click to edit"); // viewWrapperEl.Attributes.Add("id", $"view-{FieldId}"); // var viewInputPrepend = new TagBuilder("span"); // viewInputPrepend.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")}"); // viewInputPrepend.Attributes.Add("title", $"/fs{Value}"); // var viewInputPrependText = new TagBuilder("span"); // viewInputPrependText.AddCssClass("input-group-text"); // var prependIcon = new TagBuilder("span"); // prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); // viewInputPrependText.InnerHtml.AppendHtml(prependIcon); // viewInputPrepend.InnerHtml.AppendHtml(viewInputPrependText); // viewWrapperEl.InnerHtml.AppendHtml(viewInputPrepend); // var viewFormControlEl = new TagBuilder("div"); // viewFormControlEl.AddCssClass("form-control erp-file"); // var viewFormControlLinkEl = new TagBuilder("a"); // viewFormControlLinkEl.Attributes.Add("href", $"/fs{Value}"); // viewFormControlLinkEl.Attributes.Add("target", "_blank"); // viewFormControlLinkEl.Attributes.Add("title", $"/fs{Value}"); // viewFormControlLinkEl.InnerHtml.Append(FileName); // viewFormControlEl.InnerHtml.AppendHtml(viewFormControlLinkEl); // viewWrapperEl.InnerHtml.AppendHtml(viewFormControlEl); // var viewInputActionEl = new TagBuilder("span"); // viewInputActionEl.AddCssClass("input-group-append action"); // viewInputActionEl.Attributes.Add("title", "edit"); // var viewInputActionLinkEl = new TagBuilder("button"); // viewInputActionLinkEl.Attributes.Add("type", "button"); // viewInputActionLinkEl.AddCssClass("btn btn-white"); // var viewInputActionIconEl = new TagBuilder("span"); // viewInputActionIconEl.AddCssClass("fa fa-fw fa-pencil-alt"); // viewInputActionLinkEl.InnerHtml.AppendHtml(viewInputActionIconEl); // viewInputActionEl.InnerHtml.AppendHtml(viewInputActionLinkEl); // viewWrapperEl.InnerHtml.AppendHtml(viewInputActionEl); // output.Content.AppendHtml(viewWrapperEl); // } // #endregion // #region << Edit Wrapper>> // { // var editWrapperEl = new TagBuilder("div"); // editWrapperEl.Attributes.Add("id", $"edit-{FieldId}"); // editWrapperEl.Attributes.Add("style", $"display:none;"); // editWrapperEl.AddCssClass("edit-wrapper"); // var editInputGroupEl = new TagBuilder("div"); // editInputGroupEl.AddCssClass("input-group"); // var editWrapperPrependEl = new TagBuilder("span"); // editWrapperPrependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); // editWrapperPrependEl.Attributes.Add("title", $"/fs{Value}"); // var editWrapperPrependText = new TagBuilder("span"); // editWrapperPrependText.AddCssClass("input-group-text"); // var editWrapperPrependIcon = new TagBuilder("span"); // editWrapperPrependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); // editWrapperPrependText.InnerHtml.AppendHtml(editWrapperPrependIcon); // editWrapperPrependEl.InnerHtml.AppendHtml(editWrapperPrependText); // editInputGroupEl.InnerHtml.AppendHtml(editWrapperPrependEl); // var fakeInputEl = new TagBuilder("div"); // var inputElCssClassList = new List<string>(); // inputElCssClassList.Add("form-control erp-file with-progress "); // fakeInputEl.Attributes.Add("id", $"fake-{FieldId}"); // if (ValidationErrors.Count > 0) // { // inputElCssClassList.Add("is-invalid"); // } // fakeInputEl.Attributes.Add("class", String.Join(' ', inputElCssClassList)); // var fakeInputFileLinkEl = new TagBuilder("a"); // fakeInputFileLinkEl.Attributes.Add("href", $"/fs{Value}"); // fakeInputFileLinkEl.Attributes.Add("target", "_blank"); // fakeInputFileLinkEl.Attributes.Add("title", $"/fs{Value}"); // fakeInputFileLinkEl.InnerHtml.Append(FileName); // fakeInputEl.InnerHtml.AppendHtml(fakeInputFileLinkEl); // var fakeInputProgress = new TagBuilder("div"); // fakeInputProgress.AddCssClass("form-control-progress"); // fakeInputEl.InnerHtml.AppendHtml(fakeInputProgress); // editInputGroupEl.InnerHtml.AppendHtml(fakeInputEl); // var editInputGroupAppendEl = new TagBuilder("span"); // editInputGroupAppendEl.AddCssClass("input-group-append"); // if (!Required) // { // var appendDeleteLink = new TagBuilder("button"); // appendDeleteLink.Attributes.Add("type", $"button"); // appendDeleteLink.Attributes.Add("id", $"remove-{FieldId}"); // appendDeleteLink.AddCssClass($"btn btn-white remove {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")}"); // appendDeleteLink.Attributes.Add("title", "select as undefined"); // var appendDeleteLinkIcon = new TagBuilder("span"); // appendDeleteLinkIcon.AddCssClass("fa fa-fw fa-trash go-red"); // appendDeleteLink.InnerHtml.AppendHtml(appendDeleteLinkIcon); // editInputGroupAppendEl.InnerHtml.AppendHtml(appendDeleteLink); // } // var selectFileLink = new TagBuilder("button"); // selectFileLink.Attributes.Add("type", $"button"); // selectFileLink.AddCssClass("btn btn-white"); // selectFileLink.Attributes.Add("onclick", $"document.getElementById('file-{FieldId}').click();"); // selectFileLink.InnerHtml.AppendHtml("select"); // editInputGroupAppendEl.InnerHtml.AppendHtml(selectFileLink); // var editSaveBtnEl = new TagBuilder("button"); // editSaveBtnEl.Attributes.Add("type", "submit"); // editSaveBtnEl.AddCssClass("btn btn-white save"); // editSaveBtnEl.Attributes.Add("title", "save"); // var editSaveIconEl = new TagBuilder("span"); // editSaveIconEl.AddCssClass("fa fa-fw fa-check go-green"); // editSaveBtnEl.InnerHtml.AppendHtml(editSaveIconEl); // editInputGroupAppendEl.InnerHtml.AppendHtml(editSaveBtnEl); // var editCancelBtnEl = new TagBuilder("button"); // editCancelBtnEl.Attributes.Add("type", "submit"); // editCancelBtnEl.AddCssClass("btn btn-white cancel"); // editCancelBtnEl.Attributes.Add("title", "cancel"); // var editCancelIconEl = new TagBuilder("span"); // editCancelIconEl.AddCssClass("fa fa-fw fa-times go-gray"); // editCancelBtnEl.InnerHtml.AppendHtml(editCancelIconEl); // editInputGroupAppendEl.InnerHtml.AppendHtml(editCancelBtnEl); // editInputGroupEl.InnerHtml.AppendHtml(editInputGroupAppendEl); // editWrapperEl.InnerHtml.AppendHtml(editInputGroupEl); // output.Content.AppendHtml(editWrapperEl); // var realHiddenFileInput = new TagBuilder("input"); // realHiddenFileInput.Attributes.Add("id", $"file-{FieldId}"); // realHiddenFileInput.Attributes.Add("type", $"file"); // realHiddenFileInput.AddCssClass("d-none"); // realHiddenFileInput.Attributes.Add("value", $""); // if (!String.IsNullOrWhiteSpace(Accept)) // { // realHiddenFileInput.Attributes.Add("accept", $"{Accept}"); // } // output.Content.AppendHtml(realHiddenFileInput); // var realSubmitInput = new TagBuilder("input"); // realSubmitInput.Attributes.Add("id", $"input-{FieldId}"); // realSubmitInput.Attributes.Add("type", $"hidden"); // realSubmitInput.Attributes.Add("value", $"{Value}"); // realSubmitInput.Attributes.Add("data-newfilepath", $"{Value}"); // realSubmitInput.Attributes.Add("data-filename", $"{FileName}"); // realSubmitInput.Attributes.Add("data-newfilename", $"{FileName}"); // output.Content.AppendHtml(realSubmitInput); // } // #endregion // var jsCompressor = new JavaScriptCompressor(); // #region << Init Scripts >> // var tagHelperInitialized = false; // if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldFile) + "-inline-edit")) // { // var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-inline-edit"]; // tagHelperInitialized = tagHelperContext.Initialized; // } // if (!tagHelperInitialized) // { // var scriptContent = FileService.GetEmbeddedTextResource("inline-edit.js", "WebVella.Erp.Web.TagHelpers.WvFieldFile"); // var scriptEl = new TagBuilder("script"); // scriptEl.Attributes.Add("type", "text/javascript"); // scriptEl.InnerHtml.AppendHtml(jsCompressor.Compress(scriptContent)); // output.PostContent.AppendHtml(scriptEl); // ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-inline-edit"] = new WvTagHelperContext() // { // Initialized = true // }; // } // #endregion // #region << Add Inline Init Script for this instance >> // var initScript = new TagBuilder("script"); // initScript.Attributes.Add("type", "text/javascript"); // var scriptTemplate = @" // $(function(){ // FileInlineEditInit(""{{FieldId}}"",""{{Name}}"",""{{EntityName}}"",""{{RecordId}}"",{{ConfigJson}}); // });"; // scriptTemplate = scriptTemplate.Replace("{{FieldId}}", (FieldId ?? null).ToString()); // scriptTemplate = scriptTemplate.Replace("{{Name}}", Name); // scriptTemplate = scriptTemplate.Replace("{{EntityName}}", EntityName); // scriptTemplate = scriptTemplate.Replace("{{RecordId}}", (RecordId ?? null).ToString()); // var fieldConfig = new WvFieldFileConfig() // { // ApiUrl = ApiUrl, // CanAddValues = Access == FieldAccess.FullAndCreate ? true : false, // Accept = Accept // }; // scriptTemplate = scriptTemplate.Replace("{{ConfigJson}}", JsonConvert.SerializeObject(fieldConfig)); // initScript.InnerHtml.AppendHtml(jsCompressor.Compress(scriptTemplate)); // output.PostContent.AppendHtml(initScript); // #endregion //} //else if (Access == FieldAccess.ReadOnly) //{ // var divEl = new TagBuilder("div"); // divEl.AddCssClass("input-group"); // var prependEl = new TagBuilder("span"); // prependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); // prependEl.Attributes.Add("title", $"/fs{Value}"); // var prependText = new TagBuilder("span"); // prependText.AddCssClass("input-group-text"); // var prependIcon = new TagBuilder("span"); // prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); // prependText.InnerHtml.AppendHtml(prependIcon); // prependEl.InnerHtml.AppendHtml(prependText); // divEl.InnerHtml.AppendHtml(prependEl); // var inputEl = new TagBuilder("div"); // inputEl.AddCssClass("form-control erp-file disabled"); // var inputElLink = new TagBuilder("a"); // inputElLink.Attributes.Add("href", $"/fs{Value}"); // inputElLink.Attributes.Add("target", "_blank"); // inputElLink.Attributes.Add("title", $"/fs{Value}"); // inputElLink.InnerHtml.Append(FileName); // inputEl.InnerHtml.AppendHtml(inputElLink); // divEl.InnerHtml.AppendHtml(inputEl); // var appendActionSpan = new TagBuilder("span"); // appendActionSpan.AddCssClass("input-group-append"); // appendActionSpan.AddCssClass("action"); // var appendTextSpan = new TagBuilder("span"); // appendTextSpan.AddCssClass("input-group-text"); // var appendIconSpan = new TagBuilder("span"); // appendIconSpan.AddCssClass("fa fa-fw fa-lock"); // appendTextSpan.InnerHtml.AppendHtml(appendIconSpan); // appendActionSpan.InnerHtml.AppendHtml(appendTextSpan); // divEl.InnerHtml.AppendHtml(appendActionSpan); // output.Content.AppendHtml(divEl); //} } #endregion //Finally if (SubInputEl != null) { output.PostContent.AppendHtml(SubInputEl); } return(Task.CompletedTask); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.MetaTags = new List <MetaTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); ViewBag.ScriptTags = new List <ScriptTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region == <title> == var includedTitle = pageModel.HttpContext.Items.ContainsKey("<title>") ? (string)pageModel.HttpContext.Items["<title>"] : ""; ViewBag.Title = ""; if (string.IsNullOrWhiteSpace(includedTitle)) { var titleTag = "<title>" + pageModel.PageContext.ViewData["Title"] + "</title>"; ViewBag.Title = titleTag; pageModel.HttpContext.Items["<title>"] = titleTag; } #endregion #region === <meta> === { var includedMetaTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <MetaTagInclude>)) ? (List <MetaTagInclude>)pageModel.HttpContext.Items[typeof(List <MetaTagInclude>)] : new List <MetaTagInclude>(); var metaTagsToInclude = new List <MetaTagInclude>(); //Your includes below >>>> #region << viewport >> { var tagName = "viewpost"; if (!includedMetaTags.Any(x => x.Name == tagName)) { metaTagsToInclude.Add(new MetaTagInclude() { Name = tagName, Content = "width=device-width, initial-scale=1, shrink-to-fit=no" }); } } #endregion #region << charset >> { var tagName = "charset"; if (!includedMetaTags.Any(x => x.Name == tagName)) { metaTagsToInclude.Add(new MetaTagInclude() { Charset = "utf-8" }); } } #endregion //<<<< Your includes up includedMetaTags.AddRange(metaTagsToInclude); pageModel.HttpContext.Items[typeof(List <MetaTagInclude>)] = includedMetaTags; ViewBag.MetaTags = metaTagsToInclude; } #endregion #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << favicon >> { if (!includedLinkTags.Any(x => x.Href.Contains("favicon"))) { linkTagsToInclude.Add(new LinkTagInclude() { Href = $"/webvella-erp-web/assets/favicon.png", Rel = RelType.Icon, Type = "image/png" }); } } #endregion //#region << framework >> //{ // //Always include // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/api/v3.0/p/core/framework.css", // CacheBreaker = pageModel.ErpAppContext.StyleFrameworkHash, // CrossOrigin = CrossOriginType.Anonymous, // Integrity = $"sha256-{pageModel.ErpAppContext.StyleFrameworkHash}" // }); //} //#endregion //#region << bootstrap.css >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/bootstrap.css"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/twitter-bootstrap/css/bootstrap.css?cb=" + cacheKey // }); // } //} //#endregion //#region << flatpickr >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/flatpickr"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/flatpickr/flatpickr.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << select2 >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/select2"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/select2/css/select2.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << font-awesome >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/font-awesome"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/css/font-awesome-5.10.2/css/all.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << toastr >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/toastr"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/toastr.js/toastr.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << colorpicker >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/colorpicker"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/spectrum/spectrum.min.css?cb=" + cacheKey // }); // } //} //#endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { if (!isVisible) { output.SuppressOutput(); return(Task.CompletedTask); } #region << Init >> var initSuccess = InitField(context, output); if (!initSuccess) { return(Task.CompletedTask); } if (Value != null && !String.IsNullOrWhiteSpace((Value ?? "").ToString())) { if (Value.StartsWith("/fs")) { Value = Value.Substring(3); } PathTypeIcon = new RenderService().GetPathTypeIcon(Value); FileName = Path.GetFileName(Value); } #endregion #region << Render >> if (Mode == FieldRenderMode.Form) { if (Access == FieldAccess.Full || Access == FieldAccess.FullAndCreate) { var inputGroupEl = new TagBuilder("div"); inputGroupEl.AddCssClass("input-group"); var prependEl = new TagBuilder("span"); prependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); prependEl.Attributes.Add("title", $"/fs{Value}"); var prependText = new TagBuilder("span"); prependText.AddCssClass("input-group-text"); var prependIcon = new TagBuilder("span"); prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); prependText.InnerHtml.AppendHtml(prependIcon); prependEl.InnerHtml.AppendHtml(prependText); inputGroupEl.InnerHtml.AppendHtml(prependEl); var fakeInputEl = new TagBuilder("div"); var inputElCssClassList = new List <string>(); inputElCssClassList.Add("form-control erp-file with-progress "); fakeInputEl.Attributes.Add("id", $"fake-{FieldId}"); if (ValidationErrors.Count > 0) { inputElCssClassList.Add("is-invalid"); } fakeInputEl.Attributes.Add("class", String.Join(' ', inputElCssClassList)); var fakeInputFileLinkEl = new TagBuilder("a"); fakeInputFileLinkEl.Attributes.Add("href", $"/fs{Value}"); fakeInputFileLinkEl.Attributes.Add("target", "_blank"); fakeInputFileLinkEl.Attributes.Add("title", $"/fs{Value}"); fakeInputFileLinkEl.InnerHtml.Append(FileName); fakeInputEl.InnerHtml.AppendHtml(fakeInputFileLinkEl); var fakeInputProgress = new TagBuilder("div"); fakeInputProgress.AddCssClass("form-control-progress"); fakeInputEl.InnerHtml.AppendHtml(fakeInputProgress); inputGroupEl.InnerHtml.AppendHtml(fakeInputEl); var appendEl = new TagBuilder("span"); appendEl.AddCssClass("input-group-append action erp-file"); if (!Required) { var appendDeleteLink = new TagBuilder("button"); appendDeleteLink.Attributes.Add("type", $"button"); appendDeleteLink.Attributes.Add("id", $"remove-{FieldId}"); appendDeleteLink.AddCssClass($"btn btn-white remove {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")}"); appendDeleteLink.Attributes.Add("title", "select as undefined"); var appendDeleteLinkIcon = new TagBuilder("span"); appendDeleteLinkIcon.AddCssClass("fa fa-fw fa-trash go-red"); appendDeleteLink.InnerHtml.AppendHtml(appendDeleteLinkIcon); appendEl.InnerHtml.AppendHtml(appendDeleteLink); } var selectFileLink = new TagBuilder("button"); selectFileLink.Attributes.Add("type", $"button"); selectFileLink.AddCssClass("btn btn-white"); selectFileLink.Attributes.Add("onclick", $"document.getElementById('file-{FieldId}').click();"); selectFileLink.InnerHtml.AppendHtml("browse"); appendEl.InnerHtml.AppendHtml(selectFileLink); inputGroupEl.InnerHtml.AppendHtml(appendEl); output.Content.AppendHtml(inputGroupEl); var realHiddenFileInput = new TagBuilder("input"); realHiddenFileInput.Attributes.Add("id", $"file-{FieldId}"); realHiddenFileInput.Attributes.Add("type", $"file"); realHiddenFileInput.AddCssClass("d-none"); realHiddenFileInput.Attributes.Add("value", $""); if (!String.IsNullOrWhiteSpace(Accept)) { realHiddenFileInput.Attributes.Add("accept", $"{Accept}"); } output.Content.AppendHtml(realHiddenFileInput); var realSubmitInput = new TagBuilder("input"); realSubmitInput.Attributes.Add("id", $"input-{FieldId}"); realSubmitInput.Attributes.Add("type", $"hidden"); realSubmitInput.Attributes.Add("name", $"{Name}"); realSubmitInput.Attributes.Add("value", $"{Value}"); output.Content.AppendHtml(realSubmitInput); var jsCompressor = new JavaScriptCompressor(); #region << Init Scripts >> var tagHelperInitialized = false; if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldFile) + "-form")) { var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-form"]; tagHelperInitialized = tagHelperContext.Initialized; } if (!tagHelperInitialized) { var scriptContent = FileService.GetEmbeddedTextResource("form.js", "WebVella.Erp.Web.TagHelpers.WvFieldFile"); var scriptEl = new TagBuilder("script"); scriptEl.Attributes.Add("type", "text/javascript"); scriptEl.InnerHtml.AppendHtml(jsCompressor.Compress(scriptContent)); output.PostContent.AppendHtml(scriptEl); ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-form"] = new WvTagHelperContext() { Initialized = true }; } #endregion #region << Add Inline Init Script for this instance >> var initScript = new TagBuilder("script"); initScript.Attributes.Add("type", "text/javascript"); var scriptTemplate = @" $(function(){ FileFormInit(""{{FieldId}}"",""{{Name}}"",{{ConfigJson}}); });" ; scriptTemplate = scriptTemplate.Replace("{{FieldId}}", (FieldId ?? null).ToString()); scriptTemplate = scriptTemplate.Replace("{{Name}}", Name); var fieldConfig = new WvFieldFileConfig() { ApiUrl = ApiUrl, CanAddValues = Access == FieldAccess.FullAndCreate ? true : false, Accept = Accept }; scriptTemplate = scriptTemplate.Replace("{{ConfigJson}}", JsonConvert.SerializeObject(fieldConfig)); initScript.InnerHtml.AppendHtml(jsCompressor.Compress(scriptTemplate)); output.PostContent.AppendHtml(initScript); #endregion } else if (Access == FieldAccess.ReadOnly) { if (!String.IsNullOrWhiteSpace(Value)) { var inputGroupEl = new TagBuilder("div"); inputGroupEl.AddCssClass("input-group"); var prependEl = new TagBuilder("span"); prependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); prependEl.Attributes.Add("title", $"/fs{Value}"); var prependText = new TagBuilder("span"); prependText.AddCssClass("input-group-text"); var prependIcon = new TagBuilder("span"); prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); prependText.InnerHtml.AppendHtml(prependIcon); prependEl.InnerHtml.AppendHtml(prependText); inputGroupEl.InnerHtml.AppendHtml(prependEl); var inputEl = new TagBuilder("div"); inputEl.AddCssClass("form-control erp-file disabled"); var inputElLink = new TagBuilder("a"); inputElLink.Attributes.Add("href", $"/fs{Value}"); inputElLink.Attributes.Add("target", "_blank"); inputElLink.Attributes.Add("title", $"/fs{Value}"); inputElLink.InnerHtml.Append(FileName); inputEl.InnerHtml.AppendHtml(inputElLink); inputGroupEl.InnerHtml.AppendHtml(inputEl); output.Content.AppendHtml(inputGroupEl); //Hidden input with the value var hiddenInput = new TagBuilder("input"); hiddenInput.Attributes.Add("type", "hidden"); hiddenInput.Attributes.Add("id", $"input-{FieldId}"); hiddenInput.Attributes.Add("name", Name); hiddenInput.Attributes.Add("value", (Value ?? "").ToString()); output.Content.AppendHtml(hiddenInput); } else { var inputEl = new TagBuilder("input"); inputEl.Attributes.Add("readonly", null); inputEl.AddCssClass("form-control erp-file"); inputEl.Attributes.Add("value", ""); inputEl.Attributes.Add("name", Name); output.Content.AppendHtml(inputEl); } } } else if (Mode == FieldRenderMode.Display) { if (!String.IsNullOrWhiteSpace(Value)) { var divEl = new TagBuilder("div"); divEl.Attributes.Add("id", $"input-{FieldId}"); divEl.AddCssClass("form-control-plaintext erp-file"); var iconEl = new TagBuilder("span"); iconEl.AddCssClass($"fa fa-fw {PathTypeIcon}"); divEl.InnerHtml.AppendHtml(iconEl); var linkEl = new TagBuilder("a"); linkEl.Attributes.Add("href", $"/fs{Value}"); linkEl.Attributes.Add("target", $"_blank"); linkEl.InnerHtml.Append(FileName); divEl.InnerHtml.AppendHtml(linkEl); output.Content.AppendHtml(divEl); } else { output.Content.AppendHtml(EmptyValEl); } } else if (Mode == FieldRenderMode.Simple) { output.SuppressOutput(); var linkEl = new TagBuilder("a"); linkEl.Attributes.Add("href", $"/fs{Value}"); linkEl.Attributes.Add("target", $"_blank"); linkEl.InnerHtml.Append(FileName); output.Content.AppendHtml(linkEl); return(Task.CompletedTask); } else if (Mode == FieldRenderMode.InlineEdit) { if (Access == FieldAccess.Full || Access == FieldAccess.FullAndCreate) { #region << View Wrapper >> { var viewWrapperEl = new TagBuilder("div"); viewWrapperEl.AddCssClass("input-group view-wrapper"); viewWrapperEl.Attributes.Add("title", "double click to edit"); viewWrapperEl.Attributes.Add("id", $"view-{FieldId}"); var viewInputPrepend = new TagBuilder("span"); viewInputPrepend.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")}"); viewInputPrepend.Attributes.Add("title", $"/fs{Value}"); var viewInputPrependText = new TagBuilder("span"); viewInputPrependText.AddCssClass("input-group-text"); var prependIcon = new TagBuilder("span"); prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); viewInputPrependText.InnerHtml.AppendHtml(prependIcon); viewInputPrepend.InnerHtml.AppendHtml(viewInputPrependText); viewWrapperEl.InnerHtml.AppendHtml(viewInputPrepend); var viewFormControlEl = new TagBuilder("div"); viewFormControlEl.AddCssClass("form-control erp-file"); var viewFormControlLinkEl = new TagBuilder("a"); viewFormControlLinkEl.Attributes.Add("href", $"/fs{Value}"); viewFormControlLinkEl.Attributes.Add("target", "_blank"); viewFormControlLinkEl.Attributes.Add("title", $"/fs{Value}"); viewFormControlLinkEl.InnerHtml.Append(FileName); viewFormControlEl.InnerHtml.AppendHtml(viewFormControlLinkEl); viewWrapperEl.InnerHtml.AppendHtml(viewFormControlEl); var viewInputActionEl = new TagBuilder("span"); viewInputActionEl.AddCssClass("input-group-append action"); viewInputActionEl.Attributes.Add("title", "edit"); var viewInputActionLinkEl = new TagBuilder("button"); viewInputActionLinkEl.Attributes.Add("type", "button"); viewInputActionLinkEl.AddCssClass("btn btn-white"); var viewInputActionIconEl = new TagBuilder("span"); viewInputActionIconEl.AddCssClass("fa fa-fw fa-pencil-alt"); viewInputActionLinkEl.InnerHtml.AppendHtml(viewInputActionIconEl); viewInputActionEl.InnerHtml.AppendHtml(viewInputActionLinkEl); viewWrapperEl.InnerHtml.AppendHtml(viewInputActionEl); output.Content.AppendHtml(viewWrapperEl); } #endregion #region << Edit Wrapper>> { var editWrapperEl = new TagBuilder("div"); editWrapperEl.Attributes.Add("id", $"edit-{FieldId}"); editWrapperEl.Attributes.Add("style", $"display:none;"); editWrapperEl.AddCssClass("edit-wrapper"); var editInputGroupEl = new TagBuilder("div"); editInputGroupEl.AddCssClass("input-group"); var editWrapperPrependEl = new TagBuilder("span"); editWrapperPrependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); editWrapperPrependEl.Attributes.Add("title", $"/fs{Value}"); var editWrapperPrependText = new TagBuilder("span"); editWrapperPrependText.AddCssClass("input-group-text"); var editWrapperPrependIcon = new TagBuilder("span"); editWrapperPrependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); editWrapperPrependText.InnerHtml.AppendHtml(editWrapperPrependIcon); editWrapperPrependEl.InnerHtml.AppendHtml(editWrapperPrependText); editInputGroupEl.InnerHtml.AppendHtml(editWrapperPrependEl); var fakeInputEl = new TagBuilder("div"); var inputElCssClassList = new List <string>(); inputElCssClassList.Add("form-control erp-file with-progress "); fakeInputEl.Attributes.Add("id", $"fake-{FieldId}"); if (ValidationErrors.Count > 0) { inputElCssClassList.Add("is-invalid"); } fakeInputEl.Attributes.Add("class", String.Join(' ', inputElCssClassList)); var fakeInputFileLinkEl = new TagBuilder("a"); fakeInputFileLinkEl.Attributes.Add("href", $"/fs{Value}"); fakeInputFileLinkEl.Attributes.Add("target", "_blank"); fakeInputFileLinkEl.Attributes.Add("title", $"/fs{Value}"); fakeInputFileLinkEl.InnerHtml.Append(FileName); fakeInputEl.InnerHtml.AppendHtml(fakeInputFileLinkEl); var fakeInputProgress = new TagBuilder("div"); fakeInputProgress.AddCssClass("form-control-progress"); fakeInputEl.InnerHtml.AppendHtml(fakeInputProgress); editInputGroupEl.InnerHtml.AppendHtml(fakeInputEl); var editInputGroupAppendEl = new TagBuilder("span"); editInputGroupAppendEl.AddCssClass("input-group-append"); if (!Required) { var appendDeleteLink = new TagBuilder("button"); appendDeleteLink.Attributes.Add("type", $"button"); appendDeleteLink.Attributes.Add("id", $"remove-{FieldId}"); appendDeleteLink.AddCssClass($"btn btn-white remove {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")}"); appendDeleteLink.Attributes.Add("title", "select as undefined"); var appendDeleteLinkIcon = new TagBuilder("span"); appendDeleteLinkIcon.AddCssClass("fa fa-fw fa-trash go-red"); appendDeleteLink.InnerHtml.AppendHtml(appendDeleteLinkIcon); editInputGroupAppendEl.InnerHtml.AppendHtml(appendDeleteLink); } var selectFileLink = new TagBuilder("button"); selectFileLink.Attributes.Add("type", $"button"); selectFileLink.AddCssClass("btn btn-white"); selectFileLink.Attributes.Add("onclick", $"document.getElementById('file-{FieldId}').click();"); selectFileLink.InnerHtml.AppendHtml("select"); editInputGroupAppendEl.InnerHtml.AppendHtml(selectFileLink); var editSaveBtnEl = new TagBuilder("button"); editSaveBtnEl.Attributes.Add("type", "submit"); editSaveBtnEl.AddCssClass("btn btn-white save"); editSaveBtnEl.Attributes.Add("title", "save"); var editSaveIconEl = new TagBuilder("span"); editSaveIconEl.AddCssClass("fa fa-fw fa-check go-green"); editSaveBtnEl.InnerHtml.AppendHtml(editSaveIconEl); editInputGroupAppendEl.InnerHtml.AppendHtml(editSaveBtnEl); var editCancelBtnEl = new TagBuilder("button"); editCancelBtnEl.Attributes.Add("type", "submit"); editCancelBtnEl.AddCssClass("btn btn-white cancel"); editCancelBtnEl.Attributes.Add("title", "cancel"); var editCancelIconEl = new TagBuilder("span"); editCancelIconEl.AddCssClass("fa fa-fw fa-times go-gray"); editCancelBtnEl.InnerHtml.AppendHtml(editCancelIconEl); editInputGroupAppendEl.InnerHtml.AppendHtml(editCancelBtnEl); editInputGroupEl.InnerHtml.AppendHtml(editInputGroupAppendEl); editWrapperEl.InnerHtml.AppendHtml(editInputGroupEl); output.Content.AppendHtml(editWrapperEl); var realHiddenFileInput = new TagBuilder("input"); realHiddenFileInput.Attributes.Add("id", $"file-{FieldId}"); realHiddenFileInput.Attributes.Add("type", $"file"); realHiddenFileInput.AddCssClass("d-none"); realHiddenFileInput.Attributes.Add("value", $""); if (!String.IsNullOrWhiteSpace(Accept)) { realHiddenFileInput.Attributes.Add("accept", $"{Accept}"); } output.Content.AppendHtml(realHiddenFileInput); var realSubmitInput = new TagBuilder("input"); realSubmitInput.Attributes.Add("id", $"input-{FieldId}"); realSubmitInput.Attributes.Add("type", $"hidden"); realSubmitInput.Attributes.Add("value", $"{Value}"); realSubmitInput.Attributes.Add("data-newfilepath", $"{Value}"); realSubmitInput.Attributes.Add("data-filename", $"{FileName}"); realSubmitInput.Attributes.Add("data-newfilename", $"{FileName}"); output.Content.AppendHtml(realSubmitInput); } #endregion var jsCompressor = new JavaScriptCompressor(); #region << Init Scripts >> var tagHelperInitialized = false; if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldFile) + "-inline-edit")) { var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-inline-edit"]; tagHelperInitialized = tagHelperContext.Initialized; } if (!tagHelperInitialized) { var scriptContent = FileService.GetEmbeddedTextResource("inline-edit.js", "WebVella.Erp.Web.TagHelpers.WvFieldFile"); var scriptEl = new TagBuilder("script"); scriptEl.Attributes.Add("type", "text/javascript"); scriptEl.InnerHtml.AppendHtml(jsCompressor.Compress(scriptContent)); output.PostContent.AppendHtml(scriptEl); ViewContext.HttpContext.Items[typeof(WvFieldFile) + "-inline-edit"] = new WvTagHelperContext() { Initialized = true }; } #endregion #region << Add Inline Init Script for this instance >> var initScript = new TagBuilder("script"); initScript.Attributes.Add("type", "text/javascript"); var scriptTemplate = @" $(function(){ FileInlineEditInit(""{{FieldId}}"",""{{Name}}"",""{{EntityName}}"",""{{RecordId}}"",{{ConfigJson}}); });" ; scriptTemplate = scriptTemplate.Replace("{{FieldId}}", (FieldId ?? null).ToString()); scriptTemplate = scriptTemplate.Replace("{{Name}}", Name); scriptTemplate = scriptTemplate.Replace("{{EntityName}}", EntityName); scriptTemplate = scriptTemplate.Replace("{{RecordId}}", (RecordId ?? null).ToString()); var fieldConfig = new WvFieldFileConfig() { ApiUrl = ApiUrl, CanAddValues = Access == FieldAccess.FullAndCreate ? true : false, Accept = Accept }; scriptTemplate = scriptTemplate.Replace("{{ConfigJson}}", JsonConvert.SerializeObject(fieldConfig)); initScript.InnerHtml.AppendHtml(jsCompressor.Compress(scriptTemplate)); output.PostContent.AppendHtml(initScript); #endregion } else if (Access == FieldAccess.ReadOnly) { var divEl = new TagBuilder("div"); divEl.AddCssClass("input-group"); var prependEl = new TagBuilder("span"); prependEl.AddCssClass($"input-group-prepend icon-addon {(String.IsNullOrWhiteSpace(Value) ? "d-none" : "")} {(ValidationErrors.Count > 0 ? "is-invalid" : "")}"); prependEl.Attributes.Add("title", $"/fs{Value}"); var prependText = new TagBuilder("span"); prependText.AddCssClass("input-group-text"); var prependIcon = new TagBuilder("span"); prependIcon.AddCssClass($"fa fa-fw type-icon {PathTypeIcon}"); prependText.InnerHtml.AppendHtml(prependIcon); prependEl.InnerHtml.AppendHtml(prependText); divEl.InnerHtml.AppendHtml(prependEl); var inputEl = new TagBuilder("div"); inputEl.AddCssClass("form-control erp-file disabled"); var inputElLink = new TagBuilder("a"); inputElLink.Attributes.Add("href", $"/fs{Value}"); inputElLink.Attributes.Add("target", "_blank"); inputElLink.Attributes.Add("title", $"/fs{Value}"); inputElLink.InnerHtml.Append(FileName); inputEl.InnerHtml.AppendHtml(inputElLink); divEl.InnerHtml.AppendHtml(inputEl); var appendActionSpan = new TagBuilder("span"); appendActionSpan.AddCssClass("input-group-append"); appendActionSpan.AddCssClass("action"); var appendTextSpan = new TagBuilder("span"); appendTextSpan.AddCssClass("input-group-text"); var appendIconSpan = new TagBuilder("span"); appendIconSpan.AddCssClass("fa fa-fw fa-lock"); appendTextSpan.InnerHtml.AppendHtml(appendIconSpan); appendActionSpan.InnerHtml.AppendHtml(appendTextSpan); divEl.InnerHtml.AppendHtml(appendActionSpan); output.Content.AppendHtml(divEl); } } #endregion //Finally if (SubInputEl != null) { output.PostContent.AppendHtml(SubInputEl); } return(Task.CompletedTask); }
public void Shutdown() { if (null != studioSettings) { string settingsFilePath = GetSettingsFilePath(); PersistentSettings.Serialize(settingsFilePath, studioSettings); studioSettings = null; } if (null != this.renderService) { this.renderService.Shutdown(); this.renderService = null; } }
private void canvas_CreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args) { args.TrackAsyncAction(RenderService.AwaitResources().AsAsyncAction()); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include if (pageModel != null && pageModel.ErpAppContext != null && !String.IsNullOrEmpty(pageModel.ErpAppContext.StylesHash)) { linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } else { linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey }); } } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/_content/WebVella.Erp.Web/js/site.js?cb=" + cacheKey }); } #endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/_content/WebVella.Erp.Web/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion //var stencilComponents = new List<string>(){"wv-lazyload", "wv-timelog-list", "wv-pb-manager", // "wv-sitemap-manager", "wv-datasource-manage","wv-post-list", "wv-feed-list", "wv-recurrence-template"}; var stencilComponents = new List <string>() { "wv-lazyload" }; foreach (var componentName in stencilComponents) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/_content/WebVella.Erp.Web/js/{componentName}/{componentName}.esm.js", Type = "module" }); scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/_content/WebVella.Erp.Web/js/{componentName}/{componentName}.js", IsNomodule = true }); } //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
private static async Task Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: CardCastToImage.exe <deck codes>"); return; } var deckCodes = args[0].Split(','); // Render the card backs (calls then responses) using (var callCardBack = RenderService.RenderCardBack(Color.Black, Color.White)) callCardBack.Save("CallCardBack.png", ImageFormat.Png); using (var responseCardBack = RenderService.RenderCardBack(Color.White, Color.Black)) responseCardBack.Save("ResponseCardBack.png", ImageFormat.Png); // Fetch and render all the individual decks foreach (var deckCode in deckCodes) { try { Console.Write($"Attempting to fetch card deck \"{deckCode}\"..."); var deck = await CardCastService.GetDeckAsync(deckCode); Console.WriteLine("Done!"); Console.Write("Rendering..."); // Render the card fronts (calls then responses) var callCardSheets = RenderService.RenderCardSheets(deck.Cards.Calls, deckCode, Color.Black, Color.White); var responseCardSheets = RenderService.RenderCardSheets(deck.Cards.Responses, deckCode, Color.White, Color.Black); foreach (var(sheetIndex, sheetBitmap) in callCardSheets.Pairs()) { using (sheetBitmap) sheetBitmap.Save($"DeckCalls-{deckCode}-{sheetIndex}.png", ImageFormat.Png); } foreach (var(sheetIndex, sheetBitmap) in responseCardSheets.Pairs()) { using (sheetBitmap) sheetBitmap.Save($"DeckResponses-{deckCode}-{sheetIndex}.png", ImageFormat.Png); } Console.WriteLine("Done!"); // Don't want to piss off the server timeouts Thread.Sleep(1000); } catch (Exception ex) { Console.WriteLine("Error!"); Console.WriteLine(ex.ToString()); } } Console.WriteLine("Done with all decks! Press any key to exit."); while (Console.KeyAvailable) { Console.ReadKey(true); } Console.ReadKey(true); }
protected override bool RendersAddChild(ViewNode currentNode, ViewNode parentNode, RenderService rendererService) { return(true); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << jquery >> { if (!includedScriptTags.Any(x => x.Src.Contains("/jquery"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/jquery/jquery.min.js?cb=" + cacheKey }); } } #endregion #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/site.js?cb=" + cacheKey }); } #endregion #region << bootstrap >> { if (!includedScriptTags.Any(x => x.Src.Contains("/bootstrap"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/twitter-bootstrap/js/bootstrap.bundle.min.js?cb=" + cacheKey }); } } #endregion #region << uri.js >> { if (!includedScriptTags.Any(x => x.Src.Contains("/uri"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/URI.js/URI.min.js?cb=" + cacheKey }); } } #endregion #region << moment >> { if (!includedScriptTags.Any(x => x.Src.Contains("/moment"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/moment.js/moment.min.js?cb=" + cacheKey }); } } #endregion #region << ckeditor >> { if (!includedScriptTags.Any(x => x.Src.Contains("/ckeditor"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/ckeditor/ckeditor.js?cb=" + cacheKey }); } } #endregion #region << lodash >> { if (!includedScriptTags.Any(x => x.Src.Contains("/lodash"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/lodash.js/lodash.min.js?cb=" + cacheKey }); } } #endregion #region << flatpickr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/flatpickr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/flatpickr/flatpickr.min.js?cb=" + cacheKey }); } } #endregion #region << select2 >> { if (!includedScriptTags.Any(x => x.Src.Contains("/select2"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/select2/js/select2.min.js?cb=" + cacheKey }); } } #endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion #region << decimal >> { if (!includedScriptTags.Any(x => x.Src.Contains("/decimal"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/decimal.js/decimal.min.js?cb=" + cacheKey }); } } #endregion #region << toastr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/toastr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/toastr.js/toastr.min.js?cb=" + cacheKey }); } } #endregion #region << colorpicker >> { if (!includedScriptTags.Any(x => x.Src.Contains("/colorpicker"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/spectrum/spectrum.min.js?cb=" + cacheKey }); } } #endregion #region << wv-lazyload >> { //Always add scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/wv-lazyload/wv-lazyload.js?cb=" + cacheKey }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
protected override bool RendersSize(ViewNode currentNode, ViewNode parentNode, RenderService rendererService) { //if (currentNode.FigmaNode.IsDialogParentContainer()) // return false; //if (currentNode.FigmaNode.IsNodeWindowContent()) // return false; return(true); }
protected override bool RendersConstraints(ViewNode currentNode, ViewNode parentNode, RenderService rendererService) { if (currentNode.Node.IsDialogParentContainer()) { return(false); } if (currentNode.Node.IsNodeWindowContent()) { return(false); } return(base.RendersConstraints(currentNode, parentNode, rendererService)); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //#region << jquery >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/jquery"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/jquery/jquery.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/webvella-erp-web/js/site.js?cb=" + cacheKey }); } #endregion //#region << bootstrap >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/bootstrap"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/twitter-bootstrap/js/bootstrap.bundle.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << uri.js >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/uri"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/URI.js/URI.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << moment >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/moment"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/moment.js/moment.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << ckeditor >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/ckeditor"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/ckeditor/ckeditor.js?cb=" + cacheKey // }); // } //} //#endregion //#region << lodash >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/lodash"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/lodash.js/lodash.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << flatpickr >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/flatpickr"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/flatpickr/flatpickr.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << select2 >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/select2"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/select2/js/select2.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/webvella-erp-web/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion //#region << decimal >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/decimal"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/decimal.js/decimal.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << toastr >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/toastr"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/toastr.js/toastr.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << colorpicker >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/colorpicker"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/spectrum/spectrum.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << wv-lazyload >> { ////Always add //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.esm.js", // Type = "module" //}); //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.js", // IsNomodule = true //}); //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.js" //}); } #endregion var stencilComponents = new List <string>() { "wv-lazyload", "wv-timelog-list", "wv-pb-manager", "wv-sitemap-manager", "wv-datasource-manage", "wv-post-list", "wv-feed-list", "wv-recurrence-template" }; foreach (var componentName in stencilComponents) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/webvella-erp-web/js/{componentName}/{componentName}.esm.js", Type = "module" }); scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/webvella-erp-web/js/{componentName}/{componentName}.js", IsNomodule = true }); } //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
/// <summary> /// Creates shared resources for Win2D rendering /// </summary> private void PersistentHolderCanvas_CreateResources(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.CanvasCreateResourcesEventArgs args) { args.TrackAsyncAction(RenderService.CreateResourcesAsync(sender).AsAsyncAction()); }
private void canvas_Update(ICanvasAnimatedControl sender, CanvasAnimatedUpdateEventArgs args) { RenderService.Update(args.Timing.ElapsedTime); }