‪Black Box
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
MiBand_Heartrate.BBMiBandConnect Class Reference
Inheritance diagram for MiBand_Heartrate.BBMiBandConnect:

Public Member Functions

 BBMiBandConnect ()
 

Protected Member Functions

override void Dispose (bool disposing)
 ‪Nettoyage des ressources utilisées. More...
 

Private Member Functions

void ConnectionFrame_Load (object sender, EventArgs e)
 ‪Loads the list of devices More...
 
delegate void OnDeviceAddedHandler (DeviceWatcher w, DeviceInformation d)
 
void OnDeviceAdded (DeviceWatcher w, DeviceInformation d)
 ‪Adds the selected device More...
 
delegate void OnDeviceRemovedHandler (DeviceWatcher w, DeviceInformationUpdate d)
 
void OnDeviceRemoved (DeviceWatcher w, DeviceInformationUpdate d)
 ‪Removed the selected device More...
 
void ConnectionFrame_FormClosing (object sender, FormClosingEventArgs e)
 
void connectButton_Click (object sender, EventArgs e)
 ‪Connects the selected device More...
 
delegate void OnDeviceConnectedHandler (BLEManager con)
 
void OnDeviceConnected (BLEManager con)
 ‪Authenticate on device connection More...
 
void InitializeComponent ()
 ‪Méthode requise pour la prise en charge du concepteur - ne modifiez pas le contenu de cette méthode avec l'éditeur de code. More...
 

Private Attributes

DeviceWatcher BLEWatcher
 
Dictionary< string, string > devices
 
ControlFrame controlFrame
 
System.ComponentModel.IContainer components = null
 ‪Variable nécessaire au concepteur. More...
 
System.Windows.Forms.GroupBox groupBox1
 
System.Windows.Forms.Button connectButton
 
System.Windows.Forms.ComboBox deviceList
 

Detailed Description

Definition at line 17 of file BBMiBandConnect.cs.

Constructor & Destructor Documentation

◆ BBMiBandConnect()

MiBand_Heartrate.BBMiBandConnect.BBMiBandConnect ( )

Definition at line 23 of file BBMiBandConnect.cs.

24  {
26  }
‪void InitializeComponent()
‪Méthode requise pour la prise en charge du concepteur - ne modifiez pas le contenu de cette méthode a...

Member Function Documentation

◆ connectButton_Click()

void MiBand_Heartrate.BBMiBandConnect.connectButton_Click ( object  sender,
EventArgs  e 
)
private

‪Connects the selected device

Parameters
sender
e

Definition at line 112 of file BBMiBandConnect.cs.

113  {
114  ‪connectButton.Enabled = false;
115 
116  ‪BLEWatcher.Stop();
117 
118  string selectedDeviceId = ‪deviceList.SelectedValue.ToString();
119  DeviceControl.Instance.BluetoothManager.Connect(selectedDeviceId, ‪OnDeviceConnected);
120  }
‪void OnDeviceConnected(BLEManager con)
‪Authenticate on device connection
‪System.Windows.Forms.ComboBox deviceList
‪System.Windows.Forms.Button connectButton

Referenced by MiBand_Heartrate.BBMiBandConnect.InitializeComponent().

◆ ConnectionFrame_FormClosing()

void MiBand_Heartrate.BBMiBandConnect.ConnectionFrame_FormClosing ( object  sender,
FormClosingEventArgs  e 
)
private

Definition at line 99 of file BBMiBandConnect.cs.

100  {
101  if (DeviceControl.Instance.BluetoothManager.IsWatchingForDevice())
102  {
103  DeviceControl.Instance.BluetoothManager.StopWatcher();
104  }
105  }

Referenced by MiBand_Heartrate.BBMiBandConnect.InitializeComponent().

◆ ConnectionFrame_Load()

void MiBand_Heartrate.BBMiBandConnect.ConnectionFrame_Load ( object  sender,
EventArgs  e 
)
private

‪Loads the list of devices

Parameters
sender
e

Definition at line 33 of file BBMiBandConnect.cs.

34  {
35  ‪devices = new Dictionary<string, string>();
36 
37  DeviceControl controller = DeviceControl.Instance;
38  ‪BLEWatcher = controller.BluetoothManager.CreateWatcher();
41  ‪BLEWatcher.Start();
42  }
‪void OnDeviceAdded(DeviceWatcher w, DeviceInformation d)
‪Adds the selected device
‪Dictionary< string, string > devices
‪void OnDeviceRemoved(DeviceWatcher w, DeviceInformationUpdate d)
‪Removed the selected device

Referenced by MiBand_Heartrate.BBMiBandConnect.InitializeComponent().

◆ Dispose()

override void MiBand_Heartrate.BBMiBandConnect.Dispose ( bool  disposing)
protected

‪Nettoyage des ressources utilisées.

Parameters
disposing‪true si les ressources managées doivent être supprimées ; sinon, false.

Definition at line 14 of file BBMiBandConnect.Designer.cs.

15  {
16  if (disposing && (‪components != null))
17  {
18  ‪components.Dispose();
19  }
20  base.Dispose(disposing);
21  }
‪System.ComponentModel.IContainer components
‪Variable nécessaire au concepteur.

◆ InitializeComponent()

void MiBand_Heartrate.BBMiBandConnect.InitializeComponent ( )
private

‪Méthode requise pour la prise en charge du concepteur - ne modifiez pas le contenu de cette méthode avec l'éditeur de code.

Definition at line 29 of file BBMiBandConnect.Designer.cs.

30  {
31  System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(‪BBMiBandConnect));
32  this.‪groupBox1 = new System.Windows.Forms.GroupBox();
33  this.‪connectButton = new System.Windows.Forms.Button();
34  this.‪deviceList = new System.Windows.Forms.ComboBox();
35  this.‪groupBox1.SuspendLayout();
36  this.SuspendLayout();
37  //
38  // groupBox1
39  //
40  this.‪groupBox1.Controls.Add(this.‪connectButton);
41  this.‪groupBox1.Controls.Add(this.‪deviceList);
42  this.‪groupBox1.Location = new System.Drawing.Point(12, 12);
43  this.‪groupBox1.Name = "groupBox1";
44  this.‪groupBox1.Size = new System.Drawing.Size(143, 87);
45  this.‪groupBox1.TabIndex = 0;
46  this.‪groupBox1.TabStop = false;
47  this.‪groupBox1.Text = "Select Mi Band device";
48  //
49  // connectButton
50  //
51  this.‪connectButton.Location = new System.Drawing.Point(6, 44);
52  this.‪connectButton.Name = "connectButton";
53  this.‪connectButton.Size = new System.Drawing.Size(130, 37);
54  this.‪connectButton.TabIndex = 1;
55  this.‪connectButton.Text = "Connect";
56  this.‪connectButton.UseVisualStyleBackColor = true;
57  this.‪connectButton.Click += new System.EventHandler(this.‪connectButton_Click);
58  //
59  // deviceList
60  //
61  this.‪deviceList.FormattingEnabled = true;
62  this.‪deviceList.Location = new System.Drawing.Point(6, 19);
63  this.‪deviceList.Name = "deviceList";
64  this.‪deviceList.Size = new System.Drawing.Size(130, 21);
65  this.‪deviceList.TabIndex = 0;
66  //
67  // BBMiBandConnect
68  //
69  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
70  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
71  this.BackColor = System.Drawing.SystemColors.Highlight;
72  this.ClientSize = new System.Drawing.Size(165, 111);
73  this.Controls.Add(this.‪groupBox1);
74  this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
75  this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
76  this.MaximizeBox = false;
77  this.MinimizeBox = false;
78  this.Name = "BBMiBandConnect";
79  this.ShowIcon = false;
80  this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
81  this.Text = "Mi Band - Connection";
82  this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.‪ConnectionFrame_FormClosing);
83  this.Load += new System.EventHandler(this.‪ConnectionFrame_Load);
84  this.‪groupBox1.ResumeLayout(false);
85  this.ResumeLayout(false);
86 
87  }
‪System.Windows.Forms.ComboBox deviceList
‪void ConnectionFrame_FormClosing(object sender, FormClosingEventArgs e)
‪void ConnectionFrame_Load(object sender, EventArgs e)
‪Loads the list of devices
‪System.Windows.Forms.Button connectButton
‪System.Windows.Forms.GroupBox groupBox1
‪void connectButton_Click(object sender, EventArgs e)
‪Connects the selected device

Referenced by MiBand_Heartrate.BBMiBandConnect.BBMiBandConnect().

◆ OnDeviceAdded()

void MiBand_Heartrate.BBMiBandConnect.OnDeviceAdded ( DeviceWatcher  w,
DeviceInformation  d 
)
private

‪Adds the selected device

Parameters
w
d

Definition at line 51 of file BBMiBandConnect.cs.

52  {
53  if (InvokeRequired)
54  {
56  Invoke(c, new object[] { w, d });
57  }
58  else
59  {
60  try
61  {
62  ‪devices.Add(d.Id, d.Name);
63  ‪deviceList.DataSource = new BindingSource(‪devices, null);
64  ‪deviceList.DisplayMember = "Value";
65  ‪deviceList.ValueMember = "Key";
66  }
67  catch (Exception) { }
68  }
69  }
‪void OnDeviceAdded(DeviceWatcher w, DeviceInformation d)
‪Adds the selected device
‪System.Windows.Forms.ComboBox deviceList
‪Dictionary< string, string > devices
‪delegate void OnDeviceAddedHandler(DeviceWatcher w, DeviceInformation d)

Referenced by MiBand_Heartrate.BBMiBandConnect.ConnectionFrame_Load().

◆ OnDeviceAddedHandler()

delegate void MiBand_Heartrate.BBMiBandConnect.OnDeviceAddedHandler ( DeviceWatcher  w,
DeviceInformation  d 
)
private

◆ OnDeviceConnected()

void MiBand_Heartrate.BBMiBandConnect.OnDeviceConnected ( BLEManager  con)
private

‪Authenticate on device connection

Parameters
con

Definition at line 128 of file BBMiBandConnect.cs.

129  {
130  if (InvokeRequired)
131  {
133  Invoke(c, new object[] { con });
134  }
135  else
136  {
137  if (DeviceControl.Instance.BluetoothManager.HasDeviceConnected())
138  {
139  Hide();
140  ‪controlFrame = new ControlFrame();
141  ‪controlFrame.Closed += (s, args) => Close();
142  ‪controlFrame.Show();
143  }
144  else
145  {
146  MessageBox.Show("Connection to the device failed !", "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
147  ‪connectButton.Enabled = true;
148  ‪devices.Clear();
149  ‪BLEWatcher.Start();
150  }
151  }
152  }
‪void OnDeviceConnected(BLEManager con)
‪Authenticate on device connection
‪Dictionary< string, string > devices
‪delegate void OnDeviceConnectedHandler(BLEManager con)
‪System.Windows.Forms.Button connectButton

Referenced by MiBand_Heartrate.BBMiBandConnect.connectButton_Click().

◆ OnDeviceConnectedHandler()

delegate void MiBand_Heartrate.BBMiBandConnect.OnDeviceConnectedHandler ( BLEManager  con)
private

◆ OnDeviceRemoved()

void MiBand_Heartrate.BBMiBandConnect.OnDeviceRemoved ( DeviceWatcher  w,
DeviceInformationUpdate  d 
)
private

‪Removed the selected device

Parameters
w
d

Definition at line 78 of file BBMiBandConnect.cs.

79  {
80  if (InvokeRequired)
81  {
83  Invoke(c, new object[] { w, d });
84  }
85  else
86  {
87  ‪devices.Remove(d.Id);
88 
89  try
90  {
91  ‪deviceList.DataSource = new BindingSource(‪devices, null);
92  ‪deviceList.DisplayMember = "Value";
93  ‪deviceList.ValueMember = "Key";
94  }
95  catch (Exception) { }
96  }
97  }
‪System.Windows.Forms.ComboBox deviceList
‪delegate void OnDeviceRemovedHandler(DeviceWatcher w, DeviceInformationUpdate d)
‪Dictionary< string, string > devices
‪void OnDeviceRemoved(DeviceWatcher w, DeviceInformationUpdate d)
‪Removed the selected device

Referenced by MiBand_Heartrate.BBMiBandConnect.ConnectionFrame_Load().

◆ OnDeviceRemovedHandler()

delegate void MiBand_Heartrate.BBMiBandConnect.OnDeviceRemovedHandler ( DeviceWatcher  w,
DeviceInformationUpdate  d 
)
private

Field Documentation

◆ BLEWatcher

DeviceWatcher MiBand_Heartrate.BBMiBandConnect.BLEWatcher
private

◆ components

System.ComponentModel.IContainer MiBand_Heartrate.BBMiBandConnect.components = null
private

‪Variable nécessaire au concepteur.

Definition at line 8 of file BBMiBandConnect.Designer.cs.

Referenced by MiBand_Heartrate.BBMiBandConnect.Dispose().

◆ connectButton

System.Windows.Forms.Button MiBand_Heartrate.BBMiBandConnect.connectButton
private

◆ controlFrame

ControlFrame MiBand_Heartrate.BBMiBandConnect.controlFrame
private

◆ deviceList

System.Windows.Forms.ComboBox MiBand_Heartrate.BBMiBandConnect.deviceList
private

◆ devices

Dictionary<string, string> MiBand_Heartrate.BBMiBandConnect.devices
private

◆ groupBox1

System.Windows.Forms.GroupBox MiBand_Heartrate.BBMiBandConnect.groupBox1
private

The documentation for this class was generated from the following files: