Beispiel #1
0
 public SeriesView()
 {
     InitializeComponent();
     Observers     = new List <SeriesViewObserver>();
     Profiles      = new GroupProfiles();
     NonEditGroups = new SeriesGroupNodes();
     toolTip.SetToolTip(comboBoxProfiles, "Change PDP Profile");
     toolTip.SetToolTip(buttonEditGroups, "Edit PDP Profiles");
 }
Beispiel #2
0
        public object Clone()
        {
            GroupProfiles profiles = new GroupProfiles();

            foreach (var profile in this)
            {
                profiles.Add((GroupProfile)profile.Clone());
            }
            return(profiles);
        }
Beispiel #3
0
        private void buttonEditGroups_Click(object sender, EventArgs e)
        {
            GroupEditorDialog groupEditor = new GroupEditorDialog((GroupProfiles)Profiles.Clone());

            groupEditor.ShowInTaskbar = false;
            groupEditor.ShowDialog();
            if (groupEditor.OK)
            {
                Profiles = groupEditor.Profiles;
                comboBoxProfiles.Items.Clear();
                comboBoxProfiles.Items.AddRange(Profiles.Select(p => p.Name).ToArray());
                comboBoxProfiles.SelectedIndex = 0;
                SetChartSeries();
            }
        }
 public GroupEditorDialog(GroupProfiles profiles)
 {
     InitializeComponent();
     Profiles = profiles;
     OK       = false;
 }
Beispiel #5
0
        public void LoadSeries()
        {
            SeriesGroupNode robotMode = new SeriesGroupNode("robotMode", "Robot Mode", SystemColors.ControlLightLight);

            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSDisabled, "DS Disabled", Color.DarkGray));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSAuto, "DS Auto", Color.Lime));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSTele, "DS Tele", Color.Cyan));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotDisabled, "Robot Disabled", Color.DarkGray));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotAuto, "Robot Auto", Color.Lime));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotTele, "Robot Tele", Color.Cyan));

            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.Brownout, "Brownout", Color.OrangeRed));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.Watchdog, "Watchdog", Color.FromArgb(249, 0, 255)));


            SeriesGroupNode basic = new SeriesGroupNode("basic", "Basic", SystemColors.ControlLightLight);

            basic.Childern.Add(new SeriesChildNode(DSAttConstants.CANUtil, "CAN", Color.Silver));
            basic.Childern.Add(new SeriesChildNode(DSAttConstants.Voltage, "Voltage", Color.Yellow));
            basic.Childern.Add(new SeriesChildNode(DSAttConstants.RoboRIOCPU, "roboRIO CPU", Color.Red));



            SeriesGroupNode comms = new SeriesGroupNode("comms", "Comms", SystemColors.ControlLightLight);

            comms.Childern.Add(new SeriesChildNode(DSAttConstants.TripTime, "Trip Time", Color.Lime));
            comms.Childern.Add(new SeriesChildNode(DSAttConstants.LostPackets, "Lost Packets", Color.Chocolate));


            SeriesGroupNode  groupNode = null;
            SeriesGroupNodes defG      = new SeriesGroupNodes();

            for (int i = 0; i < 24; i++)
            {
                if (groupNode == null)
                {
                    groupNode = new SeriesGroupNode($"grouppdp{i}{i + 4}", $"PDP ({i}-{i + 4})", SystemColors.ControlLightLight);
                }


                groupNode.Childern.Add(new SeriesChildNode($"{DSAttConstants.PDPPrefix}{i}", $"PDP {i}", Util.PdpColors[i]));
                if (groupNode.Childern.Count == 4)
                {
                    defG.Add(groupNode);
                    groupNode = null;
                }
            }


            SeriesGroupNode other = new SeriesGroupNode("other", "Other", SystemColors.ControlLightLight);

            other.Childern.Add(new SeriesChildNode(DSAttConstants.Messages, "Messages", Color.Gainsboro));


            other.Childern.Add(new SeriesChildNode(DSAttConstants.TotalPDP, "Total PDP", Color.FromArgb(249, 0, 255)));


            NonEditGroups.Add(comms);
            NonEditGroups.Add(basic);
            NonEditGroups.Add(robotMode);
            NonEditGroups.Add(other);

            treeView.Nodes.Add(comms.ToTreeNode());
            treeView.Nodes.Add(basic.ToTreeNode());
            treeView.Nodes.Add(robotMode.ToTreeNode());
            foreach (var node in defG)
            {
                treeView.Nodes.Add(node.ToTreeNode());
            }
            treeView.Nodes.Add(other.ToTreeNode());

            treeView.ItemHeight = 20;
            treeView.ExpandAll();
            if (File.Exists(Util.ProfilesFile))
            {
                FileStream fileStream = null;
                try
                {
                    XmlSerializer profilesSerializer = new XmlSerializer(typeof(GroupProfiles));
                    fileStream = new FileStream(Util.ProfilesFile, FileMode.Open);
                    Profiles   = (GroupProfiles)profilesSerializer.Deserialize(fileStream);
                } catch (Exception ex)
                {
                    MessageBox.Show($"Profile file is corrupted! {ex.Message}");
                    Profiles.Clear();
                    Profiles.Add(new GroupProfile("Default", defG));
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Close();
                    }
                }
            }
            else
            {
                Profiles.Clear();
                Profiles.Add(new GroupProfile("Default", defG));
            }
            comboBoxProfiles.Items.Clear();
            comboBoxProfiles.Items.AddRange(Profiles.Select(e => e.Name).ToArray());
            comboBoxProfiles.SelectedIndex = 0;

            SetChartSeriesEnabled();
            SetChartSeries();
        }