Beispiel #1
0
        private void OnLearnComplete(byte[] packet)
        {
            if (_selectedItem == null)
            {
                return;
            }

            timerLearn.Enabled = false;

            buttonStart.Text    = "&Learn";
            buttonStart.Enabled = true;
            buttonTest.Enabled  = true;

            BlasterCommand command = _selectedItem.Tag as BlasterCommand;

            command.RawData = packet;
            command.Status  = packet == null ? Status.Failed : Status.Success;

            _selectedItem.SubItems[0].Text = command.Name;

            if (packet != null)
            {
                // quick and dirty way to make sure that the property grid is updated
                listButtons.Items[Math.Min(_selectedItem.Index + 1, listButtons.Items.Count - 1)].Selected = false;
                listButtons.Items[Math.Min(_selectedItem.Index + 1, listButtons.Items.Count - 1)].Selected = true;
            }

            Save2();
        }
Beispiel #2
0
        //////////////
        ///
        private void Test()
        {
            if (Blaster.Connected == false)
            {
                return;
            }
            if (buttonTest.Enabled == false)
            {
                return;
            }
            if (_selectedItem == null || _selectedItem.Tag == null)
            {
                return;
            }
            if (_selectedItem.Tag.GetType() != typeof(BlasterCommand))
            {
                return;
            }

            BlasterCommand command = _selectedItem.Tag as BlasterCommand;

            if (command.RawData == null)
            {
                return;
            }

            switch (command.Speed)
            {
            case Speed.Fast:
                Blaster.Speed = 0;
                break;

            case Speed.Medium:
                Blaster.Speed = 1;
                break;

            case Speed.Slow:
                Blaster.Speed = 2;
                break;
            }

            switch (command.Port)
            {
            case Port.Both:
                Blaster.Send(0, command.RawData);
                break;

            case Port.One:
                Blaster.Send(1, command.RawData);
                break;

            case Port.Two:
                Blaster.Send(2, command.RawData);
                break;
            }
        }
Beispiel #3
0
        private void LoadConfig()
        {
            try
            {
                using (FileStream fs = new FileStream("serverblaster.dat", FileMode.Open, FileAccess.Read))
                {
                    BinaryFormatter bf         = new BinaryFormatter();
                    object          objectRoot = bf.Deserialize(fs);

                    if (objectRoot is Hashtable)
                    {
                        Hashtable hashTable = objectRoot as Hashtable;

                        foreach (object objectKey in hashTable.Keys)
                        {
                            if (objectKey is string)
                            {
                                object objectValue = hashTable[objectKey];

                                if (objectValue is byte[])
                                {
                                    hashTable[objectKey] = new BlasterCommand(objectKey as string, objectValue as byte[]);
                                }
                                else if (objectValue is Hashtable)
                                {
                                    bool b = true;
                                }
                                else
                                {
                                    Log.Write("Form1.LoadConfig: Unexpected value type '{0}'", objectValue.GetType());
                                }
                            }
                            else
                            {
                                Log.Write("Form1.LoadConfig: Unexpected key type '{0}'", objectKey.GetType());
                            }
                        }
                    }
                    else
                    {
                        Log.Write("Form1.LoadConfig: Unexpected root object");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write("Form1.LoadConfig: {0}", ex.Message);
            }
        }
Beispiel #4
0
        private void propertyGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            if (_selectedItem == null)
            {
                return;
            }

            BlasterCommand command = _selectedItem.Tag as BlasterCommand;

            _selectedItem.SubItems[0].Text = command.Name;

            propertyGrid.Validate();

//			e.ChangedItem.PropertyDescriptor = PropertyDescriptor

            Console.WriteLine("Desc: {0}", command.Description);

            Save2();
        }
Beispiel #5
0
    private void LoadConfig()
    {
      try
      {
        using (FileStream fs = new FileStream("serverblaster.dat", FileMode.Open, FileAccess.Read))
        {
          BinaryFormatter bf = new BinaryFormatter();
          object objectRoot = bf.Deserialize(fs);

          if (objectRoot is Hashtable)
          {
            Hashtable hashTable = objectRoot as Hashtable;

            foreach (object objectKey in hashTable.Keys)
            {
              if (objectKey is string)
              {
                object objectValue = hashTable[objectKey];

                if (objectValue is byte[])
                {
                  hashTable[objectKey] = new BlasterCommand(objectKey as string, objectValue as byte[]);
                }
                else if (objectValue is Hashtable)
                {
                  bool b = true;
                }
                else
                {
                  Log.Write("Form1.LoadConfig: Unexpected value type '{0}'", objectValue.GetType());
                }
              }
              else
              {
                Log.Write("Form1.LoadConfig: Unexpected key type '{0}'", objectKey.GetType());
              }
            }
          }
          else
          {
            Log.Write("Form1.LoadConfig: Unexpected root object");
          }
        }
      }
      catch (Exception ex)
      {
        Log.Write("Form1.LoadConfig: {0}", ex.Message);
      }
    }