Exemplo n.º 1
0
 /// <summary>
 /// Returns true if a preset pre-exists with a given frequency
 /// </summary>
 /// <param name="freq">frequency to check for</param>
 /// <returns>true if found, false if not</returns>
 private bool HasPresetWithFrequency(UInt64 freq)
 {
     foreach (UserPresetItem i in frequencyPresets)
     {
         MicrowaveTuningPreset p = i as MicrowaveTuningPreset;
         if (p != null)
         {
             if (p.Tuning.Frequency == freq)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        void scanner_ScanCompleted(object sender, ScanCompleteEvent e)
        {
            AppLogger.Message("MicrowaveControlService scanner_ScanCompleted");
            ChannelScanCompleteEventArgs argsToClient = new ChannelScanCompleteEventArgs();

            argsToClient.Cancelled = !scanInProgress;

            argsToClient.ChannelsFound = e.PeakDictionary.Count;

            scanInProgress = false;

            FireChannelScanCompleted(argsToClient);

            lock (_userLock)
            {
                AppLogger.Message("    removing old scan presets");
                List <Guid> autoGeneratedIDs = new List <Guid>();
                foreach (UserPresetItem i in frequencyPresets)
                {
                    if (i is MicrowaveTuningPreset)
                    {
                        if (((MicrowaveTuningPreset)i).AutoGenerated)
                        {
                            autoGeneratedIDs.Add(i.ID);
                        }
                    }
                }
                foreach (Guid id in autoGeneratedIDs)
                {
                    frequencyPresets.Remove(id);
                }

                AppLogger.Message("    adding new presets");
                foreach (MicrowaveTuning freq in e.PeakDictionary.Keys)
                {
                    if (!HasPresetWithFrequency(freq.Frequency))
                    {
                        MicrowaveTuningPreset p = new MicrowaveTuningPreset(freq);
                        p.AutoGenerated = true;
                        frequencyPresets.Add(p);
                    }
                }
            }

            FirePresetsChanged();
        }
Exemplo n.º 3
0
 public UserPresetItem SavePreset()
 {
     lock (_userLock)
     {
         AppLogger.Message("MicrowaveControlService2.SavePreset");
         try
         {
             MicrowaveTuningPreset item = new MicrowaveTuningPreset(microwaveReceiver.GetTuning());
             frequencyPresets.Add(item);
             return(item);
         }
         catch (Exception exc)
         {
             AppLogger.Dump(exc);
             return(null);
         }
     }
 }
Exemplo n.º 4
0
 private void presets_AddPreset(object sender, EventArgs e)
 {
     try
     {
         MicrowaveTuningPreset item = client.SavePreset() as MicrowaveTuningPreset;
         if (item != null)
         {
             UserPresetItemView view = new UserPresetItemView();
             view.Preset = item;
             view.Image  = StreamViewerControl.GetSnapshot();
             presets.Add(view);
         }
     }
     catch (Exception ex)
     {
         FCMessageBox.Show(@"Can't add preset!", "There was an error fetching the preset from the server.", this);
         ErrorLogger.DumpToDebug(ex);
     }
 }
Exemplo n.º 5
0
        public void RestorePreset(Guid id)
        {
            MicrowaveTuningPreset item = null;

            lock (_userLock)
            {
                AppLogger.Message("MicrowaveControlService2.RestorePreset " + id);

                try
                {
                    item = frequencyPresets[id] as MicrowaveTuningPreset;
                }
                catch (Exception exc)
                {
                    AppLogger.Dump(exc);
                }
            }

            if (item != null)
            {
                AppLogger.Message("Preset found, restoring...");
                this.SetTuning(item.Tuning);
            }
        }