Ejemplo n.º 1
0
 public void add_button(RemoteButton btn, bool reset_scanner)
 {
     buttons.Add(btn);
     if (reset_scanner)
     {
         resetScanner();
     }
     else if(abbreviations.Count < MAX_BUTTONS_SHOWN)
     {
         abbreviations.Insert(0, btn.getName());
     }
 }
Ejemplo n.º 2
0
 public void update_channel(int index, RemoteButton btn)
 {
     buttonScanner.update_button(index, btn);
     saveDevice();
 }
Ejemplo n.º 3
0
 public void add_channel(RemoteButton new_chan)
 {
     num_channels++;
     buttonScanner.add_button(new_chan, true);
     saveDevice();
 }
Ejemplo n.º 4
0
 public void createButtons()
 {
     // Create Volume buttons
     string down_name;
     string down_abbv;
     string up_name;
     string up_abbv;
     for (int x = 1; x < 3; x++)
     {
         int reps = x * volume_increments;
         down_name = "Down " + reps.ToString();
         down_abbv = "-" + reps.ToString();
         Uri down_icon_path = new Uri("ms-appx:///img/vol-" + reps.ToString() + ".png");
         RemoteButton down_btn = new RemoteButton(down_name, down_abbv, volume_down_ir_code, reps, down_icon_path);
         up_name = "Up " + reps.ToString();
         up_abbv = "+" + reps.ToString();
         Uri up_icon_path = new Uri("ms-appx:///img/vol+" + reps.ToString() + ".png");
         RemoteButton up_btn = new RemoteButton(up_name, up_abbv, volume_up_ir_code, reps, up_icon_path);
         buttonScanner.add_button(down_btn, false);
         buttonScanner.add_button(up_btn, false);
     }
     string mute_name = "Mute";
     string mute_abbv = "Mute";
     Uri mute_uri = new Uri("ms-appx:///img/volMute.png");
     RemoteButton mute_button = new RemoteButton(mute_name, mute_abbv, mute_ir_code, 1, mute_uri);
     buttonScanner.add_button(mute_button, false);
     is_initialized = true;
     remote_timer.Interval = TimeSpan.FromSeconds(1);
     remote_timer.Tick += setAllowIRTransmission;
 }
Ejemplo n.º 5
0
 public void update_button(int index, RemoteButton btn)
 {
     RemoteButton old_button = buttons.ElementAt(index);
     buttons[index] = btn;
     resetScanner();
 }
Ejemplo n.º 6
0
    private void saveClicked(object sender, object e)
    {
        if(is_edit)
        {
            if (validateChannel())
            {
                RemoteButton btn = createButton();
                ((App)(CPRemoteApp.App.Current)).deviceController.channelController.update_channel(chan_ind, btn);
            }
            closePopup(null, null);
            return;
        }
      //
      // CHECK FOR CHANNEL NAME DUPLICATES.
      //
      ChannelDevice c = ((App)(CPRemoteApp.App.Current)).deviceController.channelController;
      foreach(RemoteButton b in c.buttonScanner.getButtons())
      {
        if(b.getName().ToLower() == _ch_name.Text.ToLower())
        {
          MessageDialog msgDialog = new MessageDialog("There is already a channel saved with that name! Please enter a unique name for the channel!", "Whoops!");
          UICommand okBtn = new UICommand("OK");
          okBtn.Invoked += delegate { };
          msgDialog.Commands.Add(okBtn);
          msgDialog.ShowAsync();
          return;
        }
      }

      //
      // CHECK THAT NUMBER IS A NUMBER
      //
      foreach(char a in _ch_num.Text)
      {
        string s = "1234567890";
        if(!s.Contains(a))
        {
          MessageDialog msgDialog = new MessageDialog("The number for the channel can only contain numbers! Please enter a positive integer for the channel number!", "Whoops!");
          UICommand okBtn = new UICommand("OK");
          okBtn.Invoked += delegate { };
          msgDialog.Commands.Add(okBtn);
          msgDialog.ShowAsync();
          return;
        }
      }


      if (_ch_name.Text != "" && _ch_num.Text != "")
      {
        this._save_button.Focus(Windows.UI.Xaml.FocusState.Programmatic);
        if (savePressed != null) savePressed.Invoke(this, EventArgs.Empty);

        BitmapImage bi = _img.Source as BitmapImage;
        if (bi == null)
        {
            uri = new Uri("ms-appx:///img/unset.png"); 
        }
        else
        {
            uri = bi.UriSource;

        }
       

        RemoteButton b = new RemoteButton(_ch_name.Text, _ch_name.Text, _ch_num.Text, 1, uri);
        ((App)CPRemoteApp.App.Current).deviceController.channelController.add_channel(b);
        closePopup(null, null);
      }
      else
      {
        MessageDialog msgDialog = new MessageDialog("The channel name and channel number fields are required!", "Whoops!");
        UICommand okBtn = new UICommand("OK");
        okBtn.Invoked += delegate { };
        msgDialog.Commands.Add(okBtn);
        msgDialog.ShowAsync();
        return;
      }
    }
Ejemplo n.º 7
0
 public RemoteButton createButton()
 {
     RemoteButton btn = new RemoteButton(_ch_name.Text, _ch_name.Text, _ch_num.Text, 1, uri);
     return btn;
 }