Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MemoryMonitorModule" /> class.
        /// </summary>
        /// <param name="container"> The container. </param>
        /// <param name="factory"> The metric provider factory. </param>
        internal DiskMonitorModule([NotNull] IObjectContainer container,
                                 [NotNull] IMetricProviderFactory factory)
            : base(container, factory)
        {
            _diskReadCounter = MetricProvider.Build(DiskCategoryName, DiskReadCounterName, TotalInstanceName);
            _diskWriteCounter = MetricProvider.Build(DiskCategoryName, DiskWriteCounterName, TotalInstanceName);

            _diskReadWidget = CreatePercentWidget(BuildWidgetParameters(@"progDiskTotalRead"));
            _diskReadWidget.Text = Resources.DiskReadLabel;

            _diskWriteWidget = CreatePercentWidget(BuildWidgetParameters(@"progDiskTotalWrite"));
            _diskWriteWidget.Text = Resources.DiskWriteLabel;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MemoryMonitorModule" /> class.
        /// </summary>
        /// <param name="container"> The container. </param>
        /// <param name="factory"> The metric provider factory. </param>
        internal MemoryMonitorModule([NotNull] IObjectContainer container,
                                   [NotNull] IMetricProviderFactory factory)
            : base(container, factory)
        {
            _usedBytesCounter = MetricProvider.Build(MemoryCategoryName,
                                                        MemoryUtilizationBytesCounterName);

            _widget = new AlfredProgressBarWidget(BuildWidgetParameters(@"progMemoryUsed"))
            {
                Minimum = 0,
                Maximum = 100,
                Text = Resources.MemoryMonitorModule_LabelName,
                ValueFormatString = "{0:F2} %"
            };
        }
Ejemplo n.º 3
0
        private static AlfredProgressBarWidget CreatePercentWidget(
            [NotNull] WidgetCreationParameters parameters)
        {
            var widget = new AlfredProgressBarWidget(parameters)
            {
                Minimum = 0,
                Maximum = 100,
                ValueFormatString = "{0:F2} %"
            };

            return widget;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Handles module initialization events
        /// </summary>
        /// <param name="alfred"></param>
        protected override void InitializeProtected(IAlfred alfred)
        {
            BuildCounters();

            _cpuWidgets.Clear();

            var core = 1;

            foreach (var counter in _processorCounters.OrderBy(c => c.Name))
            {
                // Don't add a core indicator for the total
                Debug.Assert(counter != null);
                if (counter.Name == TotalInstanceName) { continue; }

                // Create a widget for the counter
                // Store the counter as the widget's data context for easier updating later on
                var id = string.Format(Locale, @"progProcessor{0}", counter.Name);
                var widget = new AlfredProgressBarWidget(BuildWidgetParameters(id))
                {
                    DataContext = counter,
                    Minimum = 0,
                    Maximum = 100
                };

                // Get the first value of the widget and have the label applied to the widget
                var label = string.Format(CultureInfo.CurrentCulture, _cpuMonitorLabel, core);
                UpdateCpuWidget(widget, counter, label);

                _cpuWidgets.Add(widget);

                Register(widget);

                core++;
            }
        }