Ejemplo n.º 1
0
        public static CounterInfo FromPerfmonCounter(CounterItem item)
        {
            CounterInfo info = new CounterInfo();

            SaveCounterItemInfo(item, info);
            return(info);
        }
Ejemplo n.º 2
0
        private void PopulateTreeView()
        {
            var mainWindow = (MainWindow)Application.Current.MainWindow;

            CategoryList categories = TryList();

            categories.Sort((a, b) => a.Name.CompareTo(b.Name));
            foreach (Category category in categories)
            {
                category.Counters.Sort((a, b) => a.Name.CompareTo(b.Name));
            }

            foreach (Category category in categories)
            {
                CategoryItem categoryItem = new CategoryItem(category.Name, MachineItem);

                foreach (Counter counter in category.Counters)
                {
                    CounterItem counterItem = new CounterItem(counter.Name, categoryItem);
                    counterItem.PropertyChanged += OnPropertyChanged;
                    categoryItem.CounterItems.Add(counterItem);
                }

                MachineItem.CategoryItems.Add(categoryItem);
            }

            mainWindow.MachineItems.Add(MachineItem);
        }
Ejemplo n.º 3
0
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "IsChecked" && !ignoreCheckedEvent)
            {
                CounterItem counterItem = (CounterItem)sender;

                if (counterItem.IsChecked == true)
                {
                    if (!TrySubscribe(counterItem.Parent.Name, counterItem.Name))
                    {
                        MessageBox.Show(string.Format("The following counter no longer exists:\n\\{0}\\{1}",
                                                      counterItem.Parent.Name, counterItem.Name), "Performance Monitor for WCF",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    counterItem.IsExpanded = true;
                }
                else
                {
                    TryUnsubscribe(counterItem.Parent.Name, counterItem.Name);

                    counterItem.IsExpanded = false;
                    counterItem.InstanceItems.Clear();
                }
            }
        }
Ejemplo n.º 4
0
        private void AddCounters(CounterGroup group)
        {
            group.ListViewGroup = this.listView1.Groups.Add(group.Name, group.Name);

            List <CounterItem> items = new List <CounterItem>(group.Counters.Length);

            foreach (Counter counter in group.Counters)
            {
                CounterItem item = new CounterItem();
                item.Text                    = counter.Name;
                item.ToolTipText             = counter.Description;
                item.Group                   = group.ListViewGroup;
                item.Font                    = _nameFont;
                item.Counter                 = counter;
                item.UseItemStyleForSubItems = false;

                ListViewItem.ListViewSubItem valueItem = new ListViewItem.ListViewSubItem(item, "-");
                valueItem.Font = _valueFont;
                item.SubItems.Add(valueItem);
                ListViewItem.ListViewSubItem deltaItem = new ListViewItem.ListViewSubItem(item, "-");
                deltaItem.Font = _valueFont;
                item.SubItems.Add(deltaItem);

                this.listView1.Items.Add(item);
                items.Add(item);
            }
            group.Items = items.ToArray();

            this.timer1.Enabled = true;
        }
Ejemplo n.º 5
0
 private void SaveCounterVisualProperties(CounterInfo counterInfo, CounterItem item)
 {
     if (counterInfo.OriginalPath != item.Path)
     {
         return;
     }
     CounterInfoHelper.SaveCounterItemInfo(item, counterInfo);
 }
Ejemplo n.º 6
0
        public void SetCounterItem(CounterItem counterItem)
        {
            CounterItem = counterItem;

            NameTextView.Text  = counterItem.Name;
            ValueTextView.Text = $"{counterItem.Count}";
            DateTextView.Text  = counterItem.CreatedDate.ToLongDateString();
        }
Ejemplo n.º 7
0
        private void ApplyLayout()
        {
            Width  = _rectSize * _columns + 1;
            Height = _rectSize * _rows + 1;

            _background.Width  = Width;
            _background.Height = Height;

            CounterItem[] items = GetControls <CounterItem>();

            int[] indices = new int[items.Length];

            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _columns; col++)
                {
                    int index = /*_isVertical ? col * _rows + row :*/ row * _columns + col;

                    if (index < items.Length)
                    {
                        CounterItem c = items[index];

                        c.X      = col * _rectSize + 2;
                        c.Y      = row * _rectSize + 2;
                        c.Width  = _rectSize - 4;
                        c.Height = _rectSize - 4;

                        TextureControl textControl = c.Children.OfType <TextureControl>().FirstOrDefault();

                        if (textControl != null)
                        {
                            textControl.Width  = c.Width;
                            textControl.Height = c.Height;
                        }

                        indices[index] = -1;
                    }
                    else
                    {
                        Add(new CounterItem(col * _rectSize + 2, row * _rectSize + 2, _rectSize - 4, _rectSize - 4));
                    }
                }
            }

            for (int i = 0; i < indices.Length; i++)
            {
                int index = indices[i];

                if (index >= 0 && index < items.Length)
                {
                    items[i].Parent = null;
                    items[i].Dispose();
                }
            }

            SetInScreen();
        }
Ejemplo n.º 8
0
        private void ApplyLayout()
        {
            Width  = _rectSize * _columns + 1;
            Height = _rectSize * _rows + 1;

            _background.Width  = Width;
            _background.Height = Height;


            CounterItem[] items = GetControls <CounterItem>();

            int[] indices = new int[items.Length];

            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _columns; col++)
                {
                    int index = /*_isVertical ? col * _rows + row :*/ row * _columns + col;

                    if (index < items.Length)
                    {
                        CounterItem c = items[index];

                        c.X      = col * _rectSize + 2;
                        c.Y      = row * _rectSize + 2;
                        c.Width  = _rectSize - 4;
                        c.Height = _rectSize - 4;

                        c.SetGraphic(c.Graphic, c.Hue);

                        indices[index] = -1;
                    }
                    else
                    {
                        Add(new CounterItem(col * _rectSize + 2, row * _rectSize + 2, _rectSize - 4, _rectSize - 4));
                    }
                }
            }

            for (int i = 0; i < indices.Length; i++)
            {
                int index = indices[i];

                if (index >= 0 && index < items.Length)
                {
                    items[i]
                    .Parent = null;

                    items[i]
                    .Dispose();
                }
            }

            SetInScreen();
        }
Ejemplo n.º 9
0
        public static void CounterStart(string name)
        {
            var item = new CounterItem();

            item.Name  = name;
            item.Level = currentLevel;
            item.Start = DateTime.Now;
            counters.Add(item);

            currentLevel++;
        }
Ejemplo n.º 10
0
        private void AddNewSysCounterFromUI(CounterItem currentUICounter, CounterFolder folder)
        {
            CounterInfo newCOunterInfo = CounterInfoHelper.FromPerfmonCounter(currentUICounter);

            if (folder.ContainsCounter(newCOunterInfo))
            {
                return;
            }
            folder.Counterinfos.Add(newCOunterInfo);
            AddCounterToTree(TreeSelectedFolderNode, newCOunterInfo);
        }
Ejemplo n.º 11
0
        public static void AddCounterItem(CounterInfo info, SysMonitorControlEx monitor)
        {
            CounterItem item =
                monitor.Counters.Add(info.FinalPath);

            item.Color     = (uint)info.Colornum;
            item.LineStyle = info.LineStyle;
//			item.ScaleFactor= info.Scale;
            item.Width = info.Width;
            info.Tag   = item;
        }
        internal override IFFFile Get()
        {
            var item = new CounterItem();

            item.Header.Active = Reader().ReadUInt32();
            item.Header.ID     = Reader().ReadUInt32();
            item.Header.Name   = GetString(240);
            if (item.Header.ID == 1816133689)
            {
            }
            return(item);
        }
Ejemplo n.º 13
0
        // Add the counter to the database when the add counter dialog button is clicked
        private async void AddCounterDialogClick(object sender, EventArgs dialogEventClickArgs)
        {
            var dialog = sender as AlertDialog;

            var nameTextView = dialog.FindViewById <EditText>(Resource.Id.AddCounterName);
            var item         = new CounterItem {
                Name = nameTextView.Text, Count = 0, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
            };

            await CounterItemDB.InsertCounterItemAsync(item);

            Adapter.AddCounter(item);
        }
Ejemplo n.º 14
0
        public void AddExistingCountersToTree(AxSystemMonitor.AxSystemMonitor ActiveMonitor)
        {
            isLoading = true;
            CounterFolder folder = TreeSelectedFolder;
            int           count  = ActiveMonitor.Counters.Count;

            for (int i = 1; i <= count; i++)
            {
                CounterItem currentUICounter = ActiveMonitor.Counters[i];
                AddNewSysCounterFromUI(currentUICounter, folder);
            }
            isLoading = false;
        }
Ejemplo n.º 15
0
        public void OnNext(EventData e)
        {
            var mainWindow = (MainWindow)Application.Current.MainWindow;

            Category category  = e.Category;
            DateTime timestamp = e.Timestamp;

            CategoryItem categoryItem = MachineItem.CategoryItems.FirstOrDefault(item => item.Name == category.Name);

            if (categoryItem == null)
            {
                return;
            }

            foreach (Counter counter in category.Counters)
            {
                CounterItem counterItem = categoryItem.CounterItems.FirstOrDefault(item => item.Name == counter.Name);
                if (counterItem == null)
                {
                    continue;
                }

                if (!counter.Instances.Any())
                {
                    if (!counterItem.InstanceItems.Contains(MainWindow.NoneItem))
                    {
                        counterItem.InstanceItems.Clear();
                        counterItem.InstanceItems.Add(MainWindow.NoneItem);
                    }
                }
                else
                {
                    counterItem.InstanceItems.Remove(MainWindow.NoneItem);
                }

                counter.Instances.Sort((a, b) => a.Name.CompareTo(b.Name));

                foreach (Instance instance in counter.Instances)
                {
                    InstanceItem instanceItem = counterItem.InstanceItems.FirstOrDefault(item => item.Name == instance.Name);

                    if (instanceItem == null)
                    {
                        instanceItem = new InstanceItem(instance.Name, counterItem);
                        counterItem.InstanceItems.Add(instanceItem);
                    }

                    mainWindow.UpdateSeries(instanceItem.Path, timestamp, instance.Value);
                }
            }
        }
Ejemplo n.º 16
0
        private CounterItem OnCreateCounter(string processname)
        {
            CounterItem item = mCounters.Find(e => e.ProcessName == processname);

            if (item == null)
            {
                item                      = new CounterItem();
                item.ProcessName          = processname;
                item.Counter              = new PerformanceCounter("Process", "% Processor Time");
                item.Counter.InstanceName = processname;
                mCounters.Add(item);
            }
            item.Enabled = true;
            return(item);
        }
Ejemplo n.º 17
0
 private void SaveVisualProperties(AxSystemMonitor.AxSystemMonitor ActiveMonitor, CounterItem SelectedCounter)
 {
     if (TreeSelectedCounter == null)
     {
         int           sysCountersCount = ActiveMonitor.Counters.Count;
         CounterFolder folder           = TreeSelectedFolder;
         for (int i = 1; i <= sysCountersCount; i++)
         {
             CounterInfo info = (CounterInfo)folder.Counterinfos[i - 1];
             CounterItem item = ActiveMonitor.Counters[i];
             SaveCounterVisualProperties(info, item);
         }
     }
     else
     {
         SaveCounterVisualProperties(TreeSelectedCounter, SelectedCounter);
     }
     MessageBox.Show("Saved!");
 }
        public static void SaveCounterItemInfo(CounterItem item,CounterInfo info)
        {
            //find bug of short name
            //			info.Colornum=(int) item.Color;
            //			info.LineStyle= item.LineStyle;
            //			info.OriginalPath= item.Path;
            //			info.Scale=item.ScaleFactor;
            //			info.Width=item.Width;
            //			info.Tag= item;
            //
            info.Colornum= int.Parse(item.Color.ToString());
            info.LineStyle= int.Parse(item.LineStyle.ToString());
            string newpath = string.Copy(item.Path);
            info.OriginalPath= newpath;

            info.Scale=int.Parse(item.ScaleFactor.ToString());
            info.Width=int.Parse(item.Width.ToString());
            info.Tag= item;
        }
Ejemplo n.º 19
0
        public static void SaveCounterItemInfo(CounterItem item, CounterInfo info)
        {
            //find bug of short name
//			info.Colornum=(int) item.Color;
//			info.LineStyle= item.LineStyle;
//			info.OriginalPath= item.Path;
//			info.Scale=item.ScaleFactor;
//			info.Width=item.Width;
//			info.Tag= item;
//
            info.Colornum  = int.Parse(item.Color.ToString());
            info.LineStyle = int.Parse(item.LineStyle.ToString());
            string newpath = string.Copy(item.Path);

            info.OriginalPath = newpath;

            info.Scale = int.Parse(item.ScaleFactor.ToString());
            info.Width = int.Parse(item.Width.ToString());
            info.Tag   = item;
        }
Ejemplo n.º 20
0
        public void Refresh()
        {
            var activeCounters = new HashSet <Tuple <string, string> >();

            foreach (CategoryItem categoryItem in MachineItem.CategoryItems)
            {
                foreach (CounterItem counterItem in categoryItem.CounterItems)
                {
                    if (counterItem.IsChecked == true)
                    {
                        activeCounters.Add(Tuple.Create(categoryItem.Name, counterItem.Name));
                    }
                }
            }

            ClearTreeView();
            TryRefresh();
            PopulateTreeView();

            foreach (Tuple <string, string> tuple in activeCounters)
            {
                CategoryItem categoryItem = MachineItem.CategoryItems.FirstOrDefault(item => item.Name == tuple.Item1);
                if (categoryItem == null)
                {
                    continue;
                }
                CounterItem counterItem = categoryItem.CounterItems.FirstOrDefault(item => item.Name == tuple.Item2);
                if (counterItem == null)
                {
                    continue;
                }

                ignoreCheckedEvent    = true;
                counterItem.IsChecked = true;
                ignoreCheckedEvent    = false;
            }
        }
Ejemplo n.º 21
0
 private void SaveCounterVisualProperties(CounterInfo counterInfo, CounterItem item)
 {
     if(counterInfo.OriginalPath!=item.Path)
     {
         return;
     }
     CounterInfoHelper.SaveCounterItemInfo(item,counterInfo);
 }
 public async Task <bool> InsertCounterItemAsync(CounterItem item)
 {
     return(await Db.InsertAsync(item) > 0);
 }
 public async Task <bool> DeleteCounterItemAsync(CounterItem item)
 {
     return(await Db.DeleteAsync(item) > 0);
 }
Ejemplo n.º 24
0
 // Handle delete events from the adapter
 private async void CounterDeleteAsync(CounterItem item, int postion)
 {
     await CounterItemDB.DeleteCounterItemAsync(item);
 }
Ejemplo n.º 25
0
        public async void InitCounter()
        {
            var idLogin = await BlobCache.LocalMachine.GetObject <string>("loginCookie");

            string      counterId   = null;
            string      imgName     = null;
            CounterItem counterList = null;
            Image       img         = null;

            //Set the cookiee manually (propertie 'UseCookies = false')
            //Or use cookieContainer
            using (var client = new HttpClient(new HttpClientHandler {
                UseCookies = false
            }))
            {
                client.DefaultRequestHeaders.Add("Cookie", idLogin);
                var dashboardUrl = new Uri("http://app.casterstats.com/dashboard");
                var resp         = await client.GetAsync(dashboardUrl);

                string content = await resp.Content.ReadAsStringAsync();


                List <Dashboard> dashboards = JsonConvert.DeserializeObject <List <Dashboard> >(content);
                foreach (var dashboard in dashboards)
                {
                    counterId = dashboard.DashboardComponents.FirstOrDefault(x => x.Name.Equals("Stream Counter")).Id;
                }

                if (counterId != null)
                {
                    dashboardUrl = new Uri("http://app.casterstats.com/dashboard/component/counter/" + counterId + "");
                    resp         = await client.GetAsync(dashboardUrl);

                    content = await resp.Content.ReadAsStringAsync();



                    counterList = JsonConvert.DeserializeObject <CounterItem>(content);
                }
                if (counterList != null)
                {
                    foreach (var c in counterList.CounterDatas)
                    {
                        var counterUrl = new Uri("http://app.casterstats.com" + c[1] + "");
                        resp = await client.GetAsync(counterUrl);

                        var byteContent = await resp.Content.ReadAsStreamAsync();

                        var image = ImageSource.FromStream(() => byteContent);
                        img = new Image {
                            Source = image
                        };
                        imgName = c[0];
                    }
                }
            }
            //Display content
            StackLayout s = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center
            };

            s.Children.Add(img);
            s.Children.Add(new Label
            {
                Text = imgName,
                HorizontalOptions = LayoutOptions.Center
            });
            Content = s;
        }
 private void OnCounterChange(CounterItem item, int postion)
 {
     CounterChange?.Invoke(item, postion);
 }
Ejemplo n.º 27
0
 // Handle update events from the adapter
 private async void CounterChangeAsync(CounterItem item, int postion)
 {
     await CounterItemDB.UpdateCounterItemAsync(item);
 }
 // Handle add counter call from the main activity
 public void AddCounter(CounterItem counterItem)
 {
     CounterItems.Insert(0, counterItem);
     NotifyItemInserted(0);
 }
Ejemplo n.º 29
0
        private void AddCounters( CounterGroup group )
        {
            group.ListViewGroup = this.listView1.Groups.Add( group.Name, group.Name );

            List<CounterItem> items = new List<CounterItem>( group.Counters.Length );
            foreach( Counter counter in group.Counters )
            {
                CounterItem item = new CounterItem();
                item.Text = counter.Name;
                item.ToolTipText = counter.Description;
                item.Group = group.ListViewGroup;
                item.Font = _nameFont;
                item.Counter = counter;
                item.UseItemStyleForSubItems = false;

                ListViewItem.ListViewSubItem valueItem = new ListViewItem.ListViewSubItem( item, "-" );
                valueItem.Font = _valueFont;
                item.SubItems.Add( valueItem );
                ListViewItem.ListViewSubItem deltaItem = new ListViewItem.ListViewSubItem( item, "-" );
                deltaItem.Font = _valueFont;
                item.SubItems.Add( deltaItem );

                this.listView1.Items.Add( item );
                items.Add( item );
            }
            group.Items = items.ToArray();

            this.timer1.Enabled = true;
        }
 public static CounterInfo FromPerfmonCounter(CounterItem item)
 {
     CounterInfo info = new CounterInfo();
     SaveCounterItemInfo(item, info);
     return info;
 }
Ejemplo n.º 31
0
 private void AddNewSysCounterFromUI(CounterItem currentUICounter, CounterFolder folder)
 {
     CounterInfo newCOunterInfo = CounterInfoHelper.FromPerfmonCounter(currentUICounter);
     if(folder.ContainsCounter(newCOunterInfo))
     {
         return;
     }
     folder.Counterinfos.Add(newCOunterInfo);
     AddCounterToTree(TreeSelectedFolderNode, newCOunterInfo);
 }
Ejemplo n.º 32
0
 private CounterItem OnCreateCounter(string processname)
 {
     CounterItem item = mCounters.Find(e => e.ProcessName == processname);
     if (item == null)
     {
         item = new CounterItem();
         item.ProcessName = processname;
         item.Counter = new PerformanceCounter("Process", "% Processor Time");
         item.Counter.InstanceName = processname;
         mCounters.Add(item);
     }
     item.Enabled = true;
     return item;
 }
Ejemplo n.º 33
0
 private void SaveVisualProperties(AxSystemMonitor.AxSystemMonitor ActiveMonitor,CounterItem SelectedCounter)
 {
     if(TreeSelectedCounter==null)
     {
         int sysCountersCount=ActiveMonitor.Counters.Count;
         CounterFolder folder = TreeSelectedFolder;
         for(int i=1;i<=sysCountersCount;i++)
         {
             CounterInfo info= (CounterInfo) folder.Counterinfos[i-1];
             CounterItem item= ActiveMonitor.Counters[i];
             SaveCounterVisualProperties(info,item);
         }
     }
     else
     {
         SaveCounterVisualProperties(TreeSelectedCounter,SelectedCounter);
     }
     MessageBox.Show("Saved!");
 }
Ejemplo n.º 34
0
 static string GetText(CounterItem item)
 {
     return(new string( ' ', item.Level * 2 ) + item.Name + ": ");
 }