예제 #1
0
        /// <summary>
        /// Format a group box for the device
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="args">Arguments, if any</param>
        /// <returns></returns>
        GroupBox CreateDeviceBox(AntDevice dev, EventArgs args)
        {
            GroupBox      gb = null;
            List <string> d  = DeviceFormatter.FormatDevice(dev, args);

            gb = new GroupBox();
            // First item in the list is the ID
            gb.Header = d[0];
            ListView lv = new ListView();

            lv.ItemsSource = d;
            lv.Margin      = new Thickness(5);
            lv.Padding     = new Thickness(5);
            gb.Content     = lv;
            return(gb);
        }
예제 #2
0
        /// <summary>
        /// Generic handler for ANT message updates
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_AntMessageEvent(object sender, EventArgs e)
        {
            // Find the listview it corresponds to and refresh
            string targetName = "ID: " + ((AntDevice)sender).ExtendedDeviceNumber.ToString();

            try
            {
                GroupBox gb = MainPanel.Children.OfType <GroupBox>().First <GroupBox>(x => x.Header.ToString() == targetName);
                ListView lv = gb.Content as ListView;

                List <string> newData = DeviceFormatter.FormatDevice((AntDevice)sender, e);
                lv.ItemsSource = null;
                lv.ItemsSource = newData;
                lv.Items.Refresh();
            }
            catch (Exception)
            {
            }
        }
예제 #3
0
        /// <summary>
        /// Format a group box for the device
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="args">Arguments, if any</param>
        /// <returns></returns>
        GroupBox CreateDeviceBox(AntDevice dev, EventArgs args)
        {
            GroupBox      gb = null;
            List <string> d  = DeviceFormatter.FormatDevice(dev, args);

            if (d.Count > 0)
            {
                ListView lv = new ListView();
                lv.ItemsSource = d;
                lv.Margin      = new Thickness(5);
                lv.Padding     = new Thickness(5);
                gb             = new GroupBox()
                {
                    Width = 200,
                    // First item in the list is the ID
                    Header  = d[0],
                    Content = lv
                };
            }
            return(gb);
        }
예제 #4
0
        /// <summary>
        /// Generic handler for ANT message updates
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_AntMessageEvent(object sender, EventArgs e)
        {
            // Find the listview it corresponds to and refresh
            AntDevice dev        = sender as AntDevice;
            string    targetName = string.Format("{0} ID: {1}", dev.DeviceType, dev.ExtendedDeviceNumber);

            try
            {
                GroupBox gb = MainPanel.Children.OfType <GroupBox>().First <GroupBox>(x => x.Header.ToString() == targetName);
                ListView lv = gb.Content as ListView;

                List <string> newData = DeviceFormatter.FormatDevice((AntDevice)sender, e);
                //lv.ItemsSource = null;
                if (newData?.Count > 0)
                {
                    lv.ItemsSource = newData;
                    lv.Items.Refresh();
                }
            }
            catch (Exception)
            {
            }
        }