void SaturationYSelectionChanged(object sender, EventArgs e)
        {
            TextBox cx   = (TextBox)sender;
            int     indx = Convert.ToInt32(cx.Name.Replace("txrlsaty", ""));
            Bind    cr   = MainStructure.GetBindForRelation(CURRENTDISPLAYEDRELATION[indx].NAME);

            if (cr == null)
            {
                if (cx.Text.Length > 0)
                {
                    MessageBox.Show("Please set first the button or the axis.");
                }
                else
                {
                    MainStructure.ResyncRelations();
                }
                return;
            }
            if (cx.Text.Length < 1 || cx.Text.Replace(" ", "") == ".")
            {
                return;
            }
            string cleaned = cx.Text.Replace(',', '.');

            try
            {
                cr.SaturationY = Convert.ToDouble(cleaned, System.Globalization.CultureInfo.InvariantCulture);
            }
            catch
            {
                MessageBox.Show("Given SaturationY not a valid double");
            }
        }
        void CurvitureSelectionChanged(object sender, EventArgs e)
        {
            TextBox cx   = (TextBox)sender;
            int     indx = Convert.ToInt32(cx.Name.Replace("txrlsacv", ""));
            Bind    cr   = MainStructure.GetBindForRelation(CURRENTDISPLAYEDRELATION[indx].NAME);

            if (cr == null)
            {
                if (cx.Text.Length > 0)
                {
                    MessageBox.Show("Please set first the button or the axis.");
                }
                else
                {
                    MainStructure.ResyncRelations();
                }
                return;
            }
            if (cx.Text.Length < 1 || cx.Text.Replace(" ", "") == ".")
            {
                return;
            }
            double curv    = double.NaN;
            string cleaned = cx.Text.Replace(',', '.');
            bool   succ    = false;

            try
            {
                curv = Convert.ToDouble(cleaned, System.Globalization.CultureInfo.InvariantCulture);
                succ = true;
            }
            catch
            {
                MessageBox.Show("Given Curviture not a valid double");
            }
            if (succ == true)
            {
                if (cr.Curviture.Count > 0)
                {
                    cr.Curviture[0] = curv;
                }
                else
                {
                    cr.Curviture.Add(curv);
                }
            }
        }
        void modSet(object sender, EventArgs e)
        {
            ActivateInputs();
            int indx = buttonSetting;

            buttonSetting = -1;
            Bind cr = MainStructure.GetBindForRelation(CURRENTDISPLAYEDRELATION[indx].NAME);

            if (joyReader == null || cr == null)
            {
                MessageBox.Show("Something went wrong when setting a modifier. Either listener was not started correctly or the main button was not assigend beforehand.");
                return;
            }
            if (modToEdit != "None" && modToEdit.Length > 0)
            {
                cr.deleteReformer(modToEdit);
                modToEdit = "";
            }
            if (joyReader.result == null)
            {
                MainStructure.ResyncRelations();
                return;
            }
            string device;

            if (joyReader.result.Device == "Keyboard")
            {
                device = "Keyboard";
            }
            else
            {
                device = "m" + joyReader.result.Device.Split('{')[1].Split('}')[0].GetHashCode().ToString().Substring(0, 5);
            }
            string nameToShow   = device + joyReader.result.AxisButton;
            string moddedDevice = cr.JoystickGuidToModifierGuid(joyReader.result.Device);
            string toAdd        = nameToShow + "§" + moddedDevice + "§" + joyReader.result.AxisButton;

            if (!cr.AllReformers.Contains(toAdd))
            {
                cr.AllReformers.Add(toAdd);
            }
            MainStructure.ResyncRelations();
        }
Esempio n. 4
0
        void FinishRelation(object sender, EventArgs e)
        {
            if (Current.NAME == null || Current.NAME.Length < 1)
            {
                MessageBox.Show("No Relation name set.");
                return;
            }
            if (Current.IsEmpty())
            {
                MessageBox.Show("Relation has no nodes.");
                return;
            }
            if (MainStructure.DoesRelationAlreadyExist(Current.NAME) && !MainStructure.RelationIsTheSame(Current.NAME, Current))
            {
                MessageBox.Show("Relation with same Name already exists.");
                return;
            }
            foreach (KeyValuePair <string, int> kvp in Current.GetPlaneSetState())
            {
                if (kvp.Value > 1)
                {
                    MessageBox.Show("The Plane " + kvp.Key + " has multiple Bindings in this Relation. Either get completly get rid of binding by unchecking all checkboxes of it or reduce it so that the Aircraft has only one appearance");
                    return;
                }
            }

            if (!editMode)
            {
                MainStructure.AddRelation(Current);
                Console.WriteLine("Adds new relation " + Current.NAME);
            }
            else
            {
                MainStructure.ResyncRelations();
                Console.WriteLine("Finished Editing Relation " + Current.NAME);
            }

            Close();
        }
        void AxisSet(object sender, EventArgs e)
        {
            ActivateInputs();
            int indx = buttonSetting;

            buttonSetting            = -1;
            setBtns[indx].Background = Brushes.White;
            if (e == null)
            {
                setBtns[indx].Content     = "None";
                stickLabels[indx].Content = "None";
                return;
            }
            Bind cr = MainStructure.GetBindForRelation(CURRENTDISPLAYEDRELATION[indx].NAME);

            if (cr == null)
            {
                cr = new Bind(CURRENTDISPLAYEDRELATION[indx]);
                MainStructure.AddBind(cr.Rl.NAME, cr);
            }
            if (joyReader == null)
            {
                MessageBox.Show("Something went wrong. Joyreader is null try again.");
                return;
            }
            if (joyReader.result == null)
            {
                //Delete Bind
                MainStructure.DeleteBind(cr.Rl.NAME);
                MainStructure.ResyncRelations();
                return;
            }
            cr.Joystick               = joyReader.result.Device;
            cr.JAxis                  = joyReader.result.AxisButton;
            setBtns[indx].Content     = joyReader.result.AxisButton;
            stickLabels[indx].Content = joyReader.result.Device;
            joyReader                 = null;
            Console.WriteLine(setBtns[indx].Content);
        }