public override void Dispose() { JSRunner.DestroyNumericEdit(ElementId, ElementRef); JSRunner.DisposeDotNetObjectRef(dotNetObjectRef); base.Dispose(); }
protected override async Task OnFirstAfterRenderAsync() { dotNetObjectRef = dotNetObjectRef ?? JSRunner.CreateDotNetObjectRef(new NumericEditAdapter(this)); await JSRunner.InitializeNumericEdit(dotNetObjectRef, ElementId, ElementRef, Decimals, DecimalsSeparator, Step); await base.OnFirstAfterRenderAsync(); }
protected async void HandleOnChanged(UIChangeEventArgs e) { if (IsMultiple) { // when multiple selection is enabled we need to use javascript to get the list of selected items multiValue = await JSRunner.GetSelectedOptions <TValue>(ElementId); // changed event must be called before validation SelectedValuesChanged?.Invoke(multiValue); ParentValidation?.UpdateInputValue(multiValue); } else { if (Converters.TryChangeType <TValue>(e.Value, out var value)) { singleValue = value; } else { singleValue = default; } // changed event must be called before validation SelectedValueChanged?.Invoke(singleValue); ParentValidation?.UpdateInputValue(singleValue); } }
protected async Task OnClickHandler(MouseEventArgs e) { if (Disabled || ReadOnly) { return; } await JSRunner.ActivateDatePicker(ElementId, Parsers.InternalDateFormat); }
void Start() { //get references _DesktopPanel = transform.GetChild(1); _LavaPanel = transform.GetChild(2); _LavaClientPanel = _LavaPanel.GetChild(12); _LavaServerPanel = _LavaPanel.GetChild(13); _LavaExamplesPanel = _LavaPanel.GetChild(14); _BrowserPanel = transform.GetChild(3); _BrowserController = _BrowserPanel.GetComponent <BrowserController>(); _IDEPanel = transform.GetChild(4); _IDEController = _IDEPanel.GetComponent <IDEController>(); _IDEController.MainController = this; _NavigationController = transform.GetChild(0).GetComponent <NavigationController>(); _NavigationController.SetMainController(this); _TerminalPanel = transform.GetChild(5); _TerminalController = _TerminalPanel.GetComponent <TerminalController>(); _TerminalController.SetMainController(this); _MissionPanelPlaceholder = transform.GetChild(7); _MissionPanelController = transform.GetChild(6).GetComponent <MissionPanelController>(); _MissionPanelController.Init(_MissionPanelPlaceholder, this); _FinishedMissions = new List <int>(); _RewardPopup = transform.GetChild(10); _RewardPopupController = _RewardPopup.GetComponent <RwardPopupController>(); _RewardPopupPlaceholderIn = transform.GetChild(9); _RewardPopupPlaceholderOut = transform.GetChild(8); _RewardPopupController.Init(_RewardPopupPlaceholderOut, _RewardPopupPlaceholderIn); _JSRunner = gameObject.GetComponent <JSRunner>(); _IntroPanel = transform.GetChild(11); _UsernameTextField = transform.GetChild(11).GetChild(0).GetChild(0).GetComponent <Text>(); _OutroPanel = transform.GetChild(12); _OutroUsernameText = _OutroPanel.GetChild(1).GetComponent <Text>(); _OutroXPText = _OutroPanel.GetChild(9).GetComponent <Text>(); _InstrumentJSFile = transform.GetChild(2).GetChild(14).GetChild(5); _LogoutButton = transform.GetChild(0).GetChild(2).GetChild(6).GetChild(1); _IntroUsernameLabel = _IntroPanel.GetChild(1).GetComponent <Text>(); _BrowserButton = transform.GetChild(0).GetChild(2).GetChild(5); _Nav1 = transform.GetChild(0).GetChild(2).GetChild(0); _Nav2 = transform.GetChild(0).GetChild(2).GetChild(1); _Nav3 = transform.GetChild(0).GetChild(2).GetChild(2); }
public void Dispose() { // make sure to unregister listener if (isRegistered) { isRegistered = false; JSRunner.UnregisterClosableComponent(this); } }
private async Task Expand() { // An element location must be known every time we need to show the dropdown. The reason is mainly // because sometimes input can have diferent offset based on the changes on the page. For example // when validation is trigered the input can be pushed down by the error messages. elementInfo = await JSRunner.GetElementInfo(ElementRef, ElementId); await JSRunner.RegisterClosableComponent(dotNetObjectRef, ElementId); Expanded = true; }
protected override void Dispose(bool disposing) { if (disposing && Rendered) { // TODO: switch to IAsyncDisposable _ = JSRunner.UnregisterClosableComponent(this); JSRunner.DisposeDotNetObjectRef(dotNetObjectRef); } base.Dispose(disposing); }
protected async void PathChangedHandler(UIChangeEventArgs e) { if (IsMultiple) { InternalValue = await JSRunner.GetFilePaths(ElementRef); } else { InternalValue = new string[] { e?.Value?.ToString() } }; PathChanged?.Invoke(InternalValue); }
protected async void PathChangedHandler(UIChangeEventArgs e) { if (IsMultiple) { var files = await JSRunner.GetFilePaths(ElementRef); PathChanged?.Invoke(files); } else { PathChanged?.Invoke(new string[] { e?.Value?.ToString() }); } }
protected override async Task OnAfterRenderAsync(bool firstRender) { var listRect = await JSRunner.GetElementInfo(slickListElementRef, null); if (slickWidth != (int)listRect.BoundingClientRect.Width) { slickWidth = (int)listRect.BoundingClientRect.Width; totalWidth = slickWidth * (carouselSlides.Count * 2 + 1); await InvokeAsync(StateHasChanged); } await base.OnAfterRenderAsync(firstRender); }
private async Task Expand() { // An element location must be known every time we need to show the dropdown. The reason is mainly // because sometimes input can have different offset based on the changes on the page. For example // when validation is triggered the input can be pushed down by the error messages. elementInfo = await JSRunner.GetElementInfo(ElementRef, ElementId); await JSRunner.RegisterClosableComponent(dotNetObjectRef, ElementRef); Expanded = true; // automatically set focus to the dropdown so that we can make it auto-close on blur event ExecuteAfterRender(async() => await DropdownElementRef.FocusAsync()); }
protected override void Dispose(bool disposing) { if (disposing) { // make sure to unregister listener if (isRegistered) { isRegistered = false; JSRunner.UnregisterClosableComponent(this); } } base.Dispose(disposing); }
protected override void OnVisibleChanged(object sender, bool e) { ExecuteAfterRender(async() => { if (ParentDropdown != null && ParentDropdown is AntDesign.Dropdown dropdown) { var dropdownMenuElementInfo = await JSRunner.GetElementInfo(ElementRef, ElementId); MenuStyleNames = GetMenuStyleNames(dropdown.ElementInfo, dropdownMenuElementInfo, dropdown.Direction); await InvokeAsync(StateHasChanged); } }); base.OnVisibleChanged(sender, e); }
public async Task WriteToStreamAsync(Stream stream, CancellationToken cancellationToken) { await FileEdit.UpdateFileStartedAsync(FileEntry); long position = 0; try { while (position < FileEntry.Size) { cancellationToken.ThrowIfCancellationRequested(); var length = Math.Min(maxMessageSize, FileEntry.Size - position); var base64 = await JSRunner.ReadDataAsync(ElementRef, FileEntry.Id, position, length, cancellationToken); var buffer = Convert.FromBase64String(base64); if (length != buffer.Length) { throw new InvalidOperationException($"Requested a maximum of {length}, but received {buffer.Length}"); } cancellationToken.ThrowIfCancellationRequested(); await stream.WriteAsync(buffer, cancellationToken); position += buffer.Length; // notify of all the changes await Task.WhenAll( FileEdit.UpdateFileWrittenAsync(FileEntry, position, buffer), FileEdit.UpdateFileProgressAsync(FileEntry, buffer.Length)); } } catch { throw; } finally { await FileEdit.UpdateFileEndedAsync(FileEntry, position == FileEntry.Size); } }
private void HandleOpenState(bool isOpen) { if (modalBackdrop != null) { modalBackdrop.IsOpen = isOpen; } // TODO: find a way to remove javascript if (isOpen) { JSRunner.AddClassToBody("modal-open"); } else { JSRunner.RemoveClassFromBody("modal-open"); } ClassMapper.Dirty(); StyleMapper.Dirty(); }
protected async Task OnSliderMouseDown(MouseEventArgs e) { // only the left button can trigger the change if (e.Button != 0) { return; } mouseDown = true; sliderElementInfo = await JSRunner.GetElementInfo(ElementRef, ElementId); sliderStart = sliderElementInfo.BoundingClientRect.Left; sliderWidth = sliderElementInfo.BoundingClientRect.Width; startedAt = e.ClientX; Percentage = CalculatePercentage(e.ClientX); await CurrentValueHandler(CalculateValue( Percentage )); }
protected void ClickHandler(UIMouseEventArgs e) { JSRunner.ActivateDatePicker(ElementId); }
public void RunTests(IEnumerable <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { var olock = new Object(); var cache = new Dictionary <string, string>(); Parallel.ForEach(tests, test => { var result = new TestResult(test); // full path to temporary file string filePath = Path.ChangeExtension(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N") + DateTime.Now.ToString("HH-mm-ss-fff")), ".js"); try { lock (olock) { if (!cache.ContainsKey(test.CodeFilePath)) { TypeScriptCompiler.Compile(test.CodeFilePath, new TypeScriptCompiler.Options(outPath: filePath)); cache.Add(test.CodeFilePath, filePath); } else { filePath = cache[test.CodeFilePath]; } } var testResult = new JSRunner.TestResult(); var scriptFilePath = filePath + Guid.NewGuid().ToString("N") + "exec.js"; using (var fs = new FileStream(scriptFilePath, FileMode.Create)) { using (var sw = new StreamWriter(fs)) { sw.WriteLine("try{"); sw.Write(File.ReadAllText(filePath)); var className = test.FullyQualifiedName.Substring(0, test.FullyQualifiedName.LastIndexOf(".")); var methodName = test.FullyQualifiedName.Substring(test.FullyQualifiedName.LastIndexOf(".") + 1); sw.WriteLine("var ____TSTestExecutor____ = new " + className + "();____TSTestExecutor____." + methodName + "();"); sw.WriteLine("phantom.exit(0)}catch(ex){console.log(ex);phantom.exit(-1)}"); sw.Flush(); } } testResult = JSRunner.Run(scriptFilePath); result.Outcome = testResult.Outcome; if (result.Outcome != TestOutcome.Passed) { result.ErrorMessage = testResult.Output; } try { File.Delete(scriptFilePath); } catch { } } catch (InvalidTypeScriptFileException ex) { result.Outcome = TestOutcome.Failed; result.ErrorMessage = ex.Message; } catch (Exception ex) { result.Outcome = TestOutcome.Failed; result.ErrorMessage = ex.Message + ex.StackTrace; } frameworkHandle.RecordResult(result); }); foreach (KeyValuePair <string, string> item in cache) { try { File.Delete(item.Value); } catch { } } }
public override void Dispose() { JSRunner.DestroyTextEdit(ElementId, ElementRef); base.Dispose(); }
protected async override Task OnFirstAfterRenderAsync() { await JSRunner.InitializeTextEdit(ElementId, ElementRef, MaskType.ToMaskTypeString(), EditMask); await base.OnFirstAfterRenderAsync(); }
protected void ClickHandler(UIMouseEventArgs e) { JSRunner.ActivateDatePicker(ElementId, Utils.Parsers.InternalDateFormat); }
protected async void SelectionChangedHandler(UIChangeEventArgs e) { selectedValues = await JSRunner.GetSelectedOptions(ElementId); SelectedValueChanged?.Invoke(string.Join(";", selectedValues)); }
private const string MultipleValuesSeparator = ";"; // Let's hope ";" will be enough to distinguish the values! #endregion #region Methods protected override async Task OnFirstAfterRenderAsync() { dotNetObjectRef ??= JSRunner.CreateDotNetObjectRef(new CloseActivatorAdapter(this)); await base.OnFirstAfterRenderAsync(); }
private async Task Collapse() { await JSRunner.UnregisterClosableComponent(this); Expanded = false; }
protected override async Task OnAfterRenderAsync(bool firstRender) { elementInfo = await JSRunner.GetElementInfo(ElementRef, ElementId); await base.OnAfterRenderAsync(firstRender); }