Click or drag to resize

CountWidget Class

The class CountWidget provides base counter dashboard widget
Inheritance Hierarchy

Namespace:  Dynamicweb.Dashboards.Widgets
Assembly:  Dynamicweb.Dashboards (in Dynamicweb.Dashboards.dll) Version: 2.9.4
Syntax
public abstract class CountWidget : DashboardElementWidget

The CountWidget type exposes the following members.

Constructors
  NameDescription
Public methodCountWidget
The counter widget default constructor
Top
Properties
  NameDescription
Protected propertyBackgroundColor
Gets or sets counter background color
Public propertyColumns
Gets or sets widget size
(Inherited from DashboardWidget.)
Public propertyCreatedDate
Gets the created date and time.
(Inherited from DashboardWidget.)
Public propertyDefaultAction
Gets or sets action for click on counter number.
Public propertyDefaultBackgroundColor
Gets or sets counter default background color
Public propertyElement
The to be shown
(Inherited from DashboardElementWidget.)
Public propertyId
Gets widget Id
(Inherited from DashboardWidget.)
Public propertyModifiedDate
Gets the last modified date and time.
(Inherited from DashboardWidget.)
Public propertyOrder
Gets or sets widget order
(Inherited from DashboardWidget.)
Public propertyShowTitle
Gets or sets value indicating whether to show widget title.
(Inherited from DashboardWidget.)
Public propertySubtitle
Gets or sets counter sub title
Public propertyTitle
Gets or sets widget title
(Inherited from DashboardWidget.)
Public propertyTitleAction
Gets or sets widget title action
(Inherited from DashboardWidget.)
Top
Methods
  NameDescription
Public methodFetch
Fetches widget with data
(Overrides DashboardWidgetFetch(IDashboard, String).)
Protected methodGetCounterNumber
Gets or sets counter number
Public methodGetIdSuitableString (Inherited from ConfigurableAddIn.)
Public methodGetOptions
Return dropdown options
(Inherited from DashboardWidget.)
Public methodGetParametersToXml (Inherited from ConfigurableAddIn.)
Public methodGetParametersToXml(Boolean) (Inherited from ConfigurableAddIn.)
Public methodLoadParametersFromXml (Inherited from ConfigurableAddIn.)
Public methodRender
The method render widget and return html
(Inherited from DashboardElementWidget.)
Public methodRenderAdditionalContent (Inherited from ConfigurableAddIn.)
Public methodScriptDependencies
Specifies relative paths to all script files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodSetValue (Inherited from ConfigurableAddIn.)
Public methodStylesheetDependencies
Specifies relative paths to all style files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodUpdateFromPost (Inherited from ConfigurableAddIn.)
Top
Examples
How to inherit CountWidget
using Dynamicweb.Dashboards.Widgets;
using Dynamicweb.Extensibility.AddIns;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dynamicweb.Dashboards.Examples
{
    [AddInName("Application memory usage")]
    [AddInDescription("Show current process memory usage information")]
    [AddInIcon(Core.UI.Icons.KnownIcon.Dehaze)]
    public sealed class MemoryUsageCounter: CountWidget
    {
        public MemoryUsageCounter()
        {
            Title = "Memory usage";
        }

        [AddInParameterEditor("", "")]
        public override int Columns
        {
            get { return 2; }
            set
            {}
        }

        protected override string GetCounterNumber(IDashboard dashboard, string path)
        {
            double count;
            string subtitle;
            var currentProcess = Process.GetCurrentProcess();
            long totalBytesOfMemoryUsed = currentProcess.WorkingSet64;
            Helper.HumanizeByteSize(totalBytesOfMemoryUsed, out count, out subtitle);
            Subtitle = subtitle;
            return string.Format("{0:0.##}", count);
        }
    }
}
See Also