示例#1
0
 private void MenuContextEditBipTextBoxClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var textBox = GetTextBoxInFocus();
         if (textBox == null)
         {
             throw new Exception("Failed to locate which textbox is focused.");
         }
         BIPLinkWindow bipLinkWindow;
         if (((TagDataClassTPM)textBox.Tag).ContainsBIPLink())
         {
             var bipLink = ((TagDataClassTPM)textBox.Tag).BIPLink;
             bipLinkWindow = new BIPLinkWindow(bipLink);
         }
         else
         {
             var bipLink = new BIPLinkTPM();
             bipLinkWindow = new BIPLinkWindow(bipLink);
         }
         bipLinkWindow.ShowDialog();
         if (bipLinkWindow.DialogResult.HasValue && bipLinkWindow.DialogResult == true && bipLinkWindow.IsDirty && bipLinkWindow.BIPLink != null)
         {
             ((TagDataClassTPM)textBox.Tag).BIPLink = (BIPLinkTPM)bipLinkWindow.BIPLink;
             UpdateBIPLinkBindings(textBox);
         }
         TextBoxLogTPM.Focus();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(442044, ex);
     }
 }
示例#2
0
 private void MenuContextEditTextBoxClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var textBox = GetTextBoxInFocus();
         if (textBox == null)
         {
             throw new Exception("Failed to locate which textbox is focused.");
         }
         SequenceWindow sequenceWindow;
         if (((TagDataClassTPM)textBox.Tag).ContainsKeySequence())
         {
             sequenceWindow = new SequenceWindow(textBox.Text, ((TagDataClassTPM)textBox.Tag).GetKeySequence());
         }
         else
         {
             sequenceWindow = new SequenceWindow();
         }
         sequenceWindow.ShowDialog();
         if (sequenceWindow.DialogResult.HasValue && sequenceWindow.DialogResult.Value)
         {
             //Clicked OK
             //If the user added only a single key stroke combo then let's not treat this as a sequence
             if (!sequenceWindow.IsDirty)
             {
                 //User made no changes
                 return;
             }
             var sequenceList = sequenceWindow.GetSequence;
             if (sequenceList.Count > 1)
             {
                 var osKeyPress = new OSKeyPress("Key press sequence", sequenceList);
                 ((TagDataClassTPM)textBox.Tag).KeyPress             = osKeyPress;
                 ((TagDataClassTPM)textBox.Tag).KeyPress.Information = sequenceWindow.GetInformation;
                 if (!string.IsNullOrEmpty(sequenceWindow.GetInformation))
                 {
                     textBox.Text = sequenceWindow.GetInformation;
                 }
                 UpdateKeyBindingProfileSequencedKeyStrokesTPM(textBox);
             }
             else
             {
                 //If only one press was created treat it as a simple keypress
                 ((TagDataClassTPM)textBox.Tag).ClearAll();
                 var osKeyPress = new OSKeyPress(sequenceList[0].VirtualKeyCodesAsString, sequenceList[0].LengthOfKeyPress);
                 ((TagDataClassTPM)textBox.Tag).KeyPress             = osKeyPress;
                 ((TagDataClassTPM)textBox.Tag).KeyPress.Information = sequenceWindow.GetInformation;
                 textBox.Text = sequenceList[0].VirtualKeyCodesAsString;
                 UpdateKeyBindingProfileSimpleKeyStrokes(textBox);
             }
         }
         TextBoxLogTPM.Focus();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2044, ex);
     }
 }
示例#3
0
        private void TextBoxMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var textBox = (TextBox)sender;

                if (e.ChangedButton == MouseButton.Left)
                {
                    //Check if this textbox contains DCS-BIOS information. If so then prompt the user for deletion
                    if (((TagDataClassTPM)textBox.Tag).ContainsDCSBIOS())
                    {
                        if (MessageBox.Show("Do you want to delete the DCS-BIOS configuration?", "Delete DCS-BIOS configuration?", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                        {
                            return;
                        }
                        textBox.Text = "";
                        _tpmPanel.RemoveTPMPanelSwitchFromList(ControlListTPM.DCSBIOS, GetTPMSwitch(textBox).TPMSwitch, GetTPMSwitch(textBox).ButtonState);
                        ((TagDataClassTPM)textBox.Tag).DCSBIOSBinding = null;
                    }
                    else if (((TagDataClassTPM)textBox.Tag).ContainsKeySequence())
                    {
                        //Check if this textbox contains sequence information. If so then prompt the user for deletion
                        if (MessageBox.Show("Do you want to delete the key sequence?", "Delete key sequence?", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                        {
                            return;
                        }
                        ((TagDataClassTPM)textBox.Tag).KeyPress.KeySequence.Clear();
                        textBox.Text = "";
                        UpdateKeyBindingProfileSimpleKeyStrokes(textBox);
                    }
                    else if (((TagDataClassTPM)textBox.Tag).ContainsSingleKey())
                    {
                        ((TagDataClassTPM)textBox.Tag).KeyPress.KeySequence.Clear();
                        textBox.Text = "";
                        UpdateKeyBindingProfileSimpleKeyStrokes(textBox);
                    }
                    if (((TagDataClassTPM)textBox.Tag).ContainsBIPLink())
                    {
                        //Check if this textbox contains sequence information. If so then prompt the user for deletion
                        if (MessageBox.Show("Do you want to delete BIP Links?", "Delete BIP Link?", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                        {
                            return;
                        }
                        ((TagDataClassTPM)textBox.Tag).BIPLink.BIPLights.Clear();
                        textBox.Background = Brushes.White;
                        UpdateBIPLinkBindings(textBox);
                    }
                    TextBoxLogTPM.Focus();
                }
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(3001, ex);
            }
        }
示例#4
0
 private void MouseDownFocusLogTextBox(object sender, MouseButtonEventArgs e)
 {
     try
     {
         TextBoxLogTPM.Focus();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(ex);
     }
 }
示例#5
0
        private void NotifySwitchChanges(HashSet <object> switches)
        {
            try
            {
                //Set focus to this so that virtual keypresses won't affect settings
                Dispatcher?.BeginInvoke((Action)(() => TextBoxLogTPM.Focus()));
                foreach (var tpmPanelSwitch in switches)
                {
                    var key = (TPMPanelSwitch)tpmPanelSwitch;

                    if (_tpmPanel.ForwardPanelEvent)
                    {
                        if (!string.IsNullOrEmpty(_tpmPanel.GetKeyPressForLoggingPurposes(key)))
                        {
                            Dispatcher?.BeginInvoke(
                                (Action)
                                (() =>
                                 TextBoxLogTPM.Text =
                                     TextBoxLogTPM.Text.Insert(0, _tpmPanel.GetKeyPressForLoggingPurposes(key) + "\n")));
                        }
                    }
                    else
                    {
                        Dispatcher?.BeginInvoke(
                            (Action)
                            (() =>
                             TextBoxLogTPM.Text =
                                 TextBoxLogTPM.Text = TextBoxLogTPM.Text.Insert(0, "No action taken, panel events Disabled.\n")));
                    }
                }

                SetGraphicsState(switches);
            }
            catch (Exception ex)
            {
                Dispatcher?.BeginInvoke(
                    (Action)
                    (() =>
                     TextBoxLogTPM.Text = TextBoxLogTPM.Text.Insert(0, "0x16" + ex.Message + ".\n")));
                Common.ShowErrorMessageBox(ex);
            }
        }
示例#6
0
 private void MenuContextEditDCSBIOSControlTextBoxClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var textBox = GetTextBoxInFocus();
         if (textBox == null)
         {
             throw new Exception("Failed to locate which textbox is focused.");
         }
         DCSBIOSControlsConfigsWindow dcsBIOSControlsConfigsWindow;
         if (((TagDataClassTPM)textBox.Tag).ContainsDCSBIOS())
         {
             dcsBIOSControlsConfigsWindow = new DCSBIOSControlsConfigsWindow(_globalHandler.GetAirframe(), textBox.Name.Replace("TextBox", ""), ((TagDataClassTPM)textBox.Tag).DCSBIOSBinding.DCSBIOSInputs, textBox.Text);
         }
         else
         {
             dcsBIOSControlsConfigsWindow = new DCSBIOSControlsConfigsWindow(_globalHandler.GetAirframe(), textBox.Name.Replace("TextBox", ""), null);
         }
         dcsBIOSControlsConfigsWindow.ShowDialog();
         if (dcsBIOSControlsConfigsWindow.DialogResult.HasValue && dcsBIOSControlsConfigsWindow.DialogResult == true)
         {
             var dcsBiosInputs = dcsBIOSControlsConfigsWindow.DCSBIOSInputs;
             var text          = string.IsNullOrWhiteSpace(dcsBIOSControlsConfigsWindow.Description) ? "DCS-BIOS" : dcsBIOSControlsConfigsWindow.Description;
             //1 appropriate text to textbox
             //2 update bindings
             textBox.Text = text;
             ((TagDataClassTPM)textBox.Tag).Consume(dcsBiosInputs);
             UpdateDCSBIOSBinding(textBox);
         }
         TextBoxLogTPM.Focus();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(442044, ex);
     }
 }