Exemple #1
0
 /// <summary>
 /// Destroys the chart instance. Calling this method should generally dispose of any chart resources.
 /// </summary>
 /// <returns>A task that represents the asynchronous operation.</returns>
 public async Task Destroy()
 {
     if (initialized)
     {
         await JSModule.Destroy(ElementRef, ElementId);
     }
 }
Exemple #2
0
        /// <inheritdoc/>
        protected override async ValueTask DisposeAsync(bool disposing)
        {
            if (disposing)
            {
                // remove button from parents
                ParentDropdown?.NotifyButtonRemoved(this);
                ParentAddons?.NotifyButtonRemoved(this);

                if (Rendered)
                {
                    await JSModule.SafeDestroy(ElementRef, ElementId);
                }

                if (command != null)
                {
                    command.CanExecuteChanged -= OnCanExecuteChanged;
                }

                if (Theme != null)
                {
                    Theme.Changed -= OnThemeChanged;
                }
            }

            await base.DisposeAsync(disposing);
        }
Exemple #3
0
        /// <inheritdoc/>
        protected override void OnInitialized()
        {
            // notify dropdown that the button is inside of it
            ParentDropdown?.NotifyButtonInitialized(this);

            // notify addons that the button is inside of it
            ParentAddons?.NotifyButtonInitialized(this);

            ExecuteAfterRender(async() =>
            {
                await JSModule.Initialize(ElementRef, ElementId, new
                {
                    PreventDefaultOnSubmit
                });
            });

            LoadingTemplate ??= ProvideDefaultLoadingTemplate();

            if (Theme != null)
            {
                Theme.Changed += OnThemeChanged;
            }

            base.OnInitialized();
        }
    public void Dispose_Error()
    {
        var js     = new MockErrorJSObjectReference();
        var module = new JSModule(js);

        Assert.ThrowsAsync <InvalidOperationException>(async() => await module.DisposeAsync());
    }
Exemple #5
0
        /// <inheritdoc/>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await JSModule.Initialize(DotNetObjectRef, ElementRef, ElementId, new
                {
                    Controls,
                    AutomaticallyHideControls,
                    AutoPlay,
                    AutoPause,
                    Muted,
                    Source,
                    Poster,
                    StreamingLibrary = StreamingLibrary.ToStreamingLibrary(),
                    SeekTime,
                    CurrentTime,
                    Volume,
                    ClickToPlay,
                    DisableContextMenu,
                    ResetOnEnd,
                    Ratio,
                    InvertTime,
                    Protection = ProtectionType != VideoProtectionType.None ? new
                    {
                        Data               = ProtectionData,
                        Type               = ProtectionType.ToVideoProtectionType(),
                        ServerUrl          = ProtectionServerUrl,
                        HttpRequestHeaders = ProtectionHttpRequestHeaders
                    } : null
                });
            }

            await base.OnAfterRenderAsync(firstRender);
        }
Exemple #6
0
        /// <inheritdoc/>
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            if (Rendered)
            {
                var sourceChanged = parameters.TryGetValue <VideoSource>(nameof(Source), out var paramSource) && !Source.Equals(paramSource);

                var protectionTypeChanged               = parameters.TryGetValue <VideoProtectionType>(nameof(ProtectionType), out var paramProtectionType) && !ProtectionType.IsEqual(paramProtectionType);
                var protectionDataChanged               = parameters.TryGetValue <object>(nameof(ProtectionData), out var paramProtectionData) && !ProtectionData.IsEqual(paramProtectionData);
                var protectionServerUrlChanged          = parameters.TryGetValue <string>(nameof(ProtectionServerUrl), out var paramProtectionServerUrl) && !ProtectionServerUrl.IsEqual(paramProtectionServerUrl);
                var protectionHttpRequestHeadersChanged = parameters.TryGetValue <string>(nameof(ProtectionHttpRequestHeaders), out var paramProtectionHttpRequestHeaders) && !ProtectionHttpRequestHeaders.IsEqual(paramProtectionHttpRequestHeaders);

                var currentTimeChanged = parameters.TryGetValue <double>(nameof(CurrentTime), out var paramCurrentTime) && !CurrentTime.IsEqual(paramCurrentTime);
                var volumeChanged      = parameters.TryGetValue <double>(nameof(Volume), out var paramVolume) && !Volume.IsEqual(paramVolume);

                if (sourceChanged || currentTimeChanged || volumeChanged)
                {
                    ExecuteAfterRender(async() => await JSModule.UpdateOptions(ElementRef, ElementId, new
                    {
                        Source                       = new { Changed = sourceChanged, Value = paramSource },
                        ProtectionType               = new { Changed = protectionTypeChanged, Value = paramProtectionType },
                        ProtectionData               = new { Changed = protectionDataChanged, Value = paramProtectionData },
                        ProtectionServerUrl          = new { Changed = protectionServerUrlChanged, Value = paramProtectionServerUrl },
                        ProtectionHttpRequestHeaders = new { Changed = protectionHttpRequestHeadersChanged, Value = paramProtectionHttpRequestHeaders },
                        CurrentTime                  = new { Changed = currentTimeChanged, Value = paramCurrentTime },
                        Volume                       = new { Changed = volumeChanged, Value = paramVolume },
                    }));
                }
            }

            await base.SetParametersAsync(parameters);
        }
        /// <inheritdoc/>
        protected override async Task OnFirstAfterRenderAsync()
        {
            dotNetObjectRef ??= CreateDotNetObjectRef(new NumericPickerAdapter(this));

            // find the min and max possible value based on the supplied value type
            var(minFromType, maxFromType) = Converters.GetMinMaxValueOfType <TValue>();

            await JSModule.Initialize(dotNetObjectRef, ElementRef, ElementId, new
            {
                Value,
                Immediate        = IsImmediate,
                Debounce         = IsDebounce,
                DebounceInterval = DebounceIntervalValue,
                Decimals,
                DecimalSeparator,
                AlternativeDecimalSeparator,
                GroupSeparator,
                GroupSpacing,
                CurrencySymbol,
                CurrencySymbolPlacement = CurrencySymbolPlacement.ToCurrencySymbolPlacement(),
                RoundingMethod          = RoundingMethod.ToNumericRoundingMethod(),
                AllowDecimalPadding     = AllowDecimalPadding.ToNumericDecimalPadding(),
                AlwaysAllowDecimalSeparator,
                Min = MinDefined ? (object)Min : null,
                Max = MaxDefined ? (object)Max : null,
                MinMaxLimitsOverride = MinMaxLimitsOverride.ToNumericMinMaxLimitsOverride(),
                TypeMin = minFromType,
                TypeMax = maxFromType,
                Step,
                SelectAllOnFocus,
            });

            await base.OnFirstAfterRenderAsync();
        }
Exemple #8
0
        /// <inheritdoc/>
        protected override async Task OnFirstAfterRenderAsync()
        {
            object defaultDate = null;

            // for multiple mode default dates must be set as array
            if (SelectionMode != DateInputSelectionMode.Single)
            {
                defaultDate = Dates?.Select(x => FormatValueAsString(new TValue[] { x }))?.ToArray();
            }
            else
            {
                defaultDate = FormatValueAsString(new TValue[] { Date });
            }

            await JSModule.Initialize(ElementRef, ElementId, new
            {
                InputMode,
                SelectionMode  = SelectionMode.ToDateInputSelectionMode(),
                FirstDayOfWeek = (int)FirstDayOfWeek,
                DisplayFormat  = DateTimeFormatConverter.Convert(DisplayFormat),
                TimeAs24hr,
                DefaultDate = defaultDate,
                Min         = Min?.ToString(DateFormat),
                Max         = Max?.ToString(DateFormat),
                Disabled,
                ReadOnly,
                DisabledDates = DisabledDates?.Select(x => FormatValueAsString(new TValue[] { x })),
                Localization  = GetLocalizationObject()
            });

            await base.OnFirstAfterRenderAsync();
        }
Exemple #9
0
        /// <inheritdoc/>
        protected override async Task OnFirstAfterRenderAsync()
        {
            dotNetObjectRef ??= CreateDotNetObjectRef(this);

            await JSModule.Initialize(dotNetObjectRef, ElementRef, ElementId, new
            {
                Mask,
                Regex,
                Alias,
                InputFormat,
                OutputFormat,
                Placeholder,
                ShowMaskOnFocus,
                ShowMaskOnHover,
                NumericInput,
                RightAlign,
                DecimalSeparator,
                GroupSeparator,
                Nullable,
                AutoUnmask,
                PositionCaretOnClick = PositionCaretOnClick.ToInputMaskCaretPosition(),
                ClearMaskOnLostFocus,
                ClearIncomplete,
                Disabled,
                ReadOnly,
            });

            await base.OnFirstAfterRenderAsync();
        }
Exemple #10
0
 /// <summary>
 /// Extends the alias options with the custom settings.
 /// </summary>
 /// <param name="aliasOptions">Options for the alias initialization.</param>
 /// <returns>A task that represents the asynchronous operation.</returns>
 public virtual async Task ExtendAliases(object aliasOptions)
 {
     if (Rendered)
     {
         await JSModule.ExtendAliases(ElementRef, ElementId, aliasOptions);
     }
 }
Exemple #11
0
        /// <inheritdoc/>
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            var replaceTabChanged = parameters.TryGetValue(nameof(ReplaceTab), out bool paramReplaceTab) && ReplaceTab != paramReplaceTab;
            var tabSizeChanged    = parameters.TryGetValue(nameof(TabSize), out int paramTabSize) && TabSize != paramTabSize;
            var softTabsChanged   = parameters.TryGetValue(nameof(SoftTabs), out bool paramSoftTabs) && SoftTabs != paramSoftTabs;
            var autoSizeChanged   = parameters.TryGetValue(nameof(AutoSize), out bool paramAutoSize) && AutoSize != paramAutoSize;

            if (Rendered && (replaceTabChanged ||
                             tabSizeChanged ||
                             softTabsChanged ||
                             autoSizeChanged))
            {
                ExecuteAfterRender(async() => await JSModule.UpdateOptions(ElementRef, ElementId, new
                {
                    ReplaceTab = new { Changed = replaceTabChanged, Value = paramReplaceTab },
                    TabSize    = new { Changed = tabSizeChanged, Value = paramTabSize },
                    SoftTabs   = new { Changed = softTabsChanged, Value = paramSoftTabs },
                    AutoSize   = new { Changed = autoSizeChanged, Value = paramAutoSize },
                }));
            }

            await base.SetParametersAsync(parameters);

            if (ParentValidation != null)
            {
                if (parameters.TryGetValue <Expression <Func <string> > >(nameof(TextExpression), out var expression))
                {
                    await ParentValidation.InitializeInputExpression(expression);
                }

                await InitializeValidation();
            }
        }
Exemple #12
0
 /// <summary>
 ///  Manually resize the canvas element. This is run each time the canvas container is resized,
 ///  but you can call this method manually if you change the size of the canvas nodes container element.
 ///  Should also be called when updating the aspect ratio.
 /// </summary>
 /// <returns>A task that represents the asynchronous operation.</returns>
 public async Task Resize()
 {
     if (initialized)
     {
         await JSModule.Resize(ElementId);
     }
 }
Exemple #13
0
 /// <summary>
 /// Destroy the current chart instance and recreates it by using the same data and options.
 /// </summary>
 /// <param name="type">New chart type.</param>
 /// <returns>A task that represents the asynchronous operation.</returns>
 public async Task ChangeType(ChartType type)
 {
     if (initialized)
     {
         await JSModule.ChangeType(ElementRef, ElementId, type);
     }
 }
    public async ValueTask JSModuleGeneric_Error()
    {
        var js     = new MockErrorJSObjectReference();
        var module = new JSModule <object>(js, new Foo());
        await module.InvokeVoidAsync("$.text");

        await module.DisposeAsync();
    }
Exemple #15
0
 /// <summary>
 /// Clears the editor content asynchronous.
 /// </summary>
 public async ValueTask ClearAsync()
 {
     await InvokeAsync(() => ExecuteAfterRender( async() =>
     {
         await JSModule.ClearAsync(EditorRef);
         await OnContentChanged();
     } ));
 }
Exemple #16
0
        private List <JSModule> SetUserMenu()
        {
            List <JSModule> lst = new List <JSModule>();

            if (Login.Login_Var.lstMenu == null || Login.Login_Var.lstMenu.Count <= 0)
            {
                return(lst);
            }

            bool            haveOpen = false;
            JSModule        j;
            List <MenuInfo> _lstMenu;

            dicParent = new Dictionary <int, string>();
            dicParent.Add(0, "0");

            _lstMenu = Login.Login_Var.lstMenu.FindAll(delegate(MenuInfo temp) { return(temp.MenuStatus == 1 && temp.MenuType == 1); });
            if (_lstMenu == null || _lstMenu.Count <= 0)
            {
                return(lst);
            }

            //_lstMenu = _lstMenu.OrderBy(temp => temp.NodeLevel).ToList();
            foreach (MenuInfo menu in _lstMenu)
            {
                if (!menu.BIsChecked)
                {
                    continue;
                }
                if (!dicParent.ContainsKey(menu.ParentID))
                {
                    continue;
                }

                j                 = new JSModule();
                j.ID              = menu.ProjectName;
                j.Level           = menu.NodeLevel.ToString();
                j.ParentID        = dicParent[menu.ParentID];
                j.Name            = menu.MenuName;
                j.moduleClassName = GetMenuForm(menu);
                if (string.IsNullOrEmpty(j.moduleClassName))
                {
                    continue;
                }
                if (!haveOpen)
                {
                    haveOpen = j.OpenFlag = menu.BIsDefault;
                }
                lst.Add(j);

                if (!dicParent.ContainsKey(menu.ID))
                {
                    dicParent.Add(menu.ID, menu.ProjectName);
                }
            }

            return(lst);
        }
Exemple #17
0
        /// <summary>
        /// Handles the element onclick event.
        /// </summary>
        /// <returns>A task that represents the asynchronous operation.</returns>
        protected async Task OnClickHandler(MouseEventArgs e)
        {
            if (Disabled || ReadOnly)
            {
                return;
            }

            await JSModule.Activate(ElementRef, ElementId, Parsers.InternalTimeFormat);
        }
Exemple #18
0
        /// <inheritdoc/>
        protected override async ValueTask DisposeAsync(bool disposing)
        {
            if (disposing && Rendered)
            {
                await JSModule.SafeDestroy(ElementRef, ElementId);
            }

            await base.DisposeAsync(disposing);
        }
Exemple #19
0
        /// <summary>
        /// Sets the markdown value.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public async Task SetValueAsync(string value)
        {
            if (!Initialized)
            {
                return;
            }

            await JSModule.SetValue(ElementId, value);
        }
Exemple #20
0
        /// <summary>
        /// Gets the markdown value.
        /// </summary>
        /// <returns>Markdown value.</returns>
        public async Task <string> GetValueAsync()
        {
            if (!Initialized)
            {
                return(null);
            }

            return(await JSModule.GetValue(ElementId));
        }
        /// <inheritdoc/>
        public override Task SetParametersAsync(ParameterView parameters)
        {
            if (parameters.TryGetValue <string>(nameof(Text), out var text) && Text != text)
            {
                ExecuteAfterRender(async() => await JSModule.UpdateContent(ElementRef, ElementId, text));
            }

            return(base.SetParametersAsync(parameters));
        }
        protected override async ValueTask DisposeAsync(bool disposing)
        {
            if (disposing && Rendered)
            {
                await JSModule.SafeDisposeAsync();
            }

            await base.DisposeAsync(disposing);
        }
Exemple #23
0
        /// <inheritdoc/>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender == true)
            {
                await JSModule.Initialize(ElementRef, ElementId);
            }

            await base.OnAfterRenderAsync(firstRender);
        }
    public void JSModule_Error()
    {
        var js     = new MockJSObjectReference();
        var module = new JSModule(js);

        Assert.NotNull(module);

        Assert.Throws <ArgumentNullException>(() => new JSModule(null));
    }
        public async Task AddTrendLineOptions(List <ChartTrendlineData> trendlineData)
        {
            if (!Rendered)
            {
                return;
            }

            await JSModule.AddTrendlineOptions(ParentChart.ElementId, trendlineData);
        }
    public void InvokeVoidAsync_Ok()
    {
        var js     = new MockJSObjectReference();
        var module = new JSModule(js);

        module.InvokeVoidAsync("$.test");
        module.InvokeVoidAsync("$.test", CancellationToken.None);
        module.InvokeAsync <object>("$.test");
    }
Exemple #27
0
        /// <summary>
        /// Removes the newest label.
        /// </summary>
        public async Task PopLabel()
        {
            dirty = true;

            if (initialized)
            {
                await JSModule.PopLabel(ElementId);
            }
        }
Exemple #28
0
        /// <summary>
        /// Update and redraw the chart.
        /// </summary>
        /// <returns></returns>
        public async Task Update()
        {
            if (dirty)
            {
                dirty = false;

                await JSModule.Update(ElementId);
            }
        }
Exemple #29
0
        /// <summary>
        /// Removes the newest data point from the specified dataset.
        /// </summary>
        /// <param name="dataSetIndex">Dataset index from which the newest data point is to be removed from.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public async Task PopData(int dataSetIndex)
        {
            dirty = true;

            if (initialized)
            {
                await JSModule.PopData(ElementId, dataSetIndex);
            }
        }
Exemple #30
0
        /// <summary>
        /// Called when [first after render asynchronous].
        /// </summary>
        protected override async Task OnFirstAfterRenderAsync()
        {
            cleanup = await JSModule.Initialize(this);

            if (Editor != null)
            {
                await OnContentChanged();
            }
        }