Esempio n. 1
0
        void infoButton_Click(object sender, EventArgs e)
        {
            Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
            Thread thread = new Thread(new ThreadStart(LaunchWebSiteRun));

            thread.Start();
        }
Esempio n. 2
0
 void buttonOk_Click(object sender, EventArgs e)
 {
     SaveSettings();
     owner.Player.FlightModel.Paused = false;
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
     parent.HideDialog();
 }
Esempio n. 3
0
        /// <summary>Creates a new edit box control</summary>
        public EditBox(Dialog parent)
            : base(parent)
        {
            controlType  = ControlType.EditBox;
            parentDialog = parent;

            border    = 5; // Default border
            spacing   = 4; // default spacing
            isCaretOn = true;

            textData = new System.Windows.Forms.RichTextBox();
            // Create the control
            textData.Visible    = true;
            textData.Font       = new System.Drawing.Font("Arial", 8.0f);
            textData.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
            textData.Multiline  = false;
            textData.Text       = string.Empty;
            textData.MaxLength  = ushort.MaxValue; // 65k characters should be plenty
            textData.WordWrap   = false;
            // Now create the control
            textData.CreateControl();

            isHidingCaret     = false;
            firstVisible      = 0;
            blinkTime         = NativeMethods.GetCaretBlinkTime() * 0.001f;
            lastBlink         = FrameworkTimer.GetAbsoluteTime();
            textColor         = new ColorValue(0.06f, 0.06f, 0.06f, 1.0f);
            selectedTextColor = new ColorValue(1.0f, 1.0f, 1.0f, 1.0f);
            selectedBackColor = new ColorValue(0.15f, 0.196f, 0.36f, 1.0f);
            caretColor        = new ColorValue(0, 0, 0, 1.0f);
            caretPosition     = textData.SelectionStart = 0;
            isInsertMode      = true;
            isMouseDragging   = false;
        }
Esempio n. 4
0
        void buttonOk_Click(object sender, EventArgs e)
        {
            owner.Player.FlightModel.Paused = false;

            Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());

            if (changed)
            {
                // The device needs to be updated
                if (globalSettings.presentParams.Windowed)
                {
                    globalSettings.presentParams.FullScreenRefreshRateInHz = 0;
                    globalSettings.presentParams.BackBufferWidth           = (int)windowWidth;
                    globalSettings.presentParams.BackBufferHeight          = (int)windowHeight;
                }

                if (globalSettings.presentParams.MultiSample != MultiSampleType.None)
                {
                    globalSettings.presentParams.PresentFlag &= ~PresentFlag.LockableBackBuffer;
                }

                // Save settings
                Bonsai.Utils.Settings.SetValue("FullScreen", fullscreen.ToString());
                if (fullscreen)
                {
                    Bonsai.Utils.Settings.SetValue("ResolutionWidth", resX.ToString());
                    Bonsai.Utils.Settings.SetValue("ResolutionHeight", resY.ToString());
                }

                // Create a device
                parent.CreateDeviceFromSettings(globalSettings);
            }
            parent.HideDialog();
        }
Esempio n. 5
0
 void buttonOk_Click(object sender, EventArgs e)
 {
     if (changed)
     {
         AircraftInfo ai = aircraftCombo.GetSelectedData() as AircraftInfo;
         if (ai != null)
         {
             if (checkboxStartOnWater.IsChecked && checkboxStartOnWater.IsVisible)
             {
                 owner.Player.TakeOffFromWater = true;
             }
             else
             {
                 owner.Player.TakeOffFromWater = false;
             }
             owner.Player.LoadModel(ai.ParFile);
             if (owner.Player.AircraftParameters.AllowsTowing)
             {
                 owner.CenterHud.ShowGameText("Press 'T' to start towing", 30f);
             }
             else
             {
                 owner.CenterHud.ShowGameText("", 0f);
             }
         }
         Program.Instance.SetWaterCamera(owner.Player.TakeOffFromWater);
     }
     owner.Player.FlightModel.Paused = false;
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
     owner.CenterHud.SetCrashPicture(owner.Player.AircraftParameters.AdLocation, url, owner.Player.AircraftParameters.FolderName);
     parent.HideDialog();
 }
Esempio n. 6
0
 /// <summary>
 /// Handles the click event of the demo button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void demoButton_Click(object sender, EventArgs e)
 {
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
     if (DemoClicked != null)
     {
         DemoClicked(this, EventArgs.Empty);
     }
 }
Esempio n. 7
0
 public virtual void OnShowDialog()
 {
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
     if (centered)
     {
         Center();
     }
 }
Esempio n. 8
0
 void crashPicture_Click(object sender, EventArgs e)
 {
     if (crashUrl != null)
     {
         Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
         Thread thread = new Thread(new ThreadStart(LaunchWebSiteRun));
         thread.Start();
     }
 }
Esempio n. 9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            deltaTime = FrameworkTimer.GetElapsedTime();


            FrameworkTimer.Start();

            this.Invalidate();
        }
Esempio n. 10
0
        private void ModelRun()
        {
            double currentTime  = FrameworkTimer.GetTime();
            double previousTime = currentTime;

            while (running)
            {
                float elapsedTime = (float)(currentTime - previousTime);
                MoveScene(elapsedTime);
                previousTime = currentTime;
                Thread.Sleep(2);
                currentTime = FrameworkTimer.GetTime();
            }
        }
Esempio n. 11
0
 void buttonOk_Click(object sender, EventArgs e)
 {
     if (changed)
     {
         SceneryInfo sceneryInfo = comboSceneries.GetSelectedData() as SceneryInfo;
         if (sceneryInfo != null)
         {
             Program.Instance.Scenery.LoadDefinition(sceneryInfo.ParFile);
         }
         Program.Instance.Player.Reset();
     }
     owner.Player.FlightModel.Paused = false;
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
     parent.HideDialog();
 }
Esempio n. 12
0
 void Device_DeviceReset(object sender, EventArgs e)
 {
     base.OnResetDevice();
     Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
 }
Esempio n. 13
0
        /// <summary>Render the control</summary>
        public override void Render(Device device, float elapsedTime)
        {
            if (!IsVisible)
            {
                return; // Nothing to render
            }
            // Render the control graphics
            for (int i = 0; i <= LowerRightBorder; ++i)
            {
                Element e = elementList[i] as Element;
                e.TextureColor.Blend(ControlState.Normal, elapsedTime);
                parentDialog.DrawSprite(e, elementRects[i]);
            }
            //
            // Compute the X coordinates of the first visible character.
            //
            int xFirst = textData.GetPositionFromCharIndex(firstVisible).X;
            int xCaret = textData.GetPositionFromCharIndex(caretPosition).X;
            int xSel;

            if (caretPosition != textData.SelectionStart)
            {
                xSel = textData.GetPositionFromCharIndex(textData.SelectionStart).X;
            }
            else
            {
                xSel = xCaret;
            }

            // Render the selection rectangle
            System.Drawing.Rectangle selRect = System.Drawing.Rectangle.Empty;
            if (caretPosition != textData.SelectionStart)
            {
                int selLeft = xCaret, selRight = xSel;
                // Swap if left is beigger than right
                if (selLeft > selRight)
                {
                    int temp = selLeft;
                    selLeft  = selRight;
                    selRight = temp;
                }
                selRect = System.Drawing.Rectangle.FromLTRB(
                    selLeft, textRect.Top, selRight, textRect.Bottom);
                selRect.Offset(textRect.Left - xFirst, 0);
                selRect.Intersect(textRect);
                Parent.DrawRectangle(selRect, selectedBackColor);
            }

            // Render the text
            Element textElement = elementList[TextLayer] as Element;

            textElement.FontColor.Current = textColor;
            parentDialog.DrawText(textData.Text.Substring(firstVisible), textElement, textRect);

            // Render the selected text
            if (caretPosition != textData.SelectionStart)
            {
                int firstToRender = Math.Max(firstVisible, Math.Min(textData.SelectionStart, caretPosition));
                int numToRender   = Math.Max(textData.SelectionStart, caretPosition) - firstToRender;
                textElement.FontColor.Current = selectedTextColor;
                parentDialog.DrawText(textData.Text.Substring(firstToRender, numToRender), textElement, selRect);
            }

            //
            // Blink the caret
            //
            if (FrameworkTimer.GetAbsoluteTime() - lastBlink >= blinkTime)
            {
                isCaretOn = !isCaretOn;
                lastBlink = FrameworkTimer.GetAbsoluteTime();
            }

            //
            // Render the caret if this control has the focus
            //
            if (hasFocus && isCaretOn && !isHidingCaret)
            {
                // Start the rectangle with insert mode caret
                System.Drawing.Rectangle caretRect = textRect;
                caretRect.Width    = 2;
                caretRect.Location = new System.Drawing.Point(
                    caretRect.Left - xFirst + xCaret - 1,
                    caretRect.Top);

                // If we are in overwrite mode, adjust the caret rectangle
                // to fill the entire character.
                if (!isInsertMode)
                {
                    // Obtain the X coord of the current character
                    caretRect.Width = 4;
                }

                parentDialog.DrawRectangle(caretRect, caretColor);
            }
        }
Esempio n. 14
0
 /// <summary>Reset's the caret blink time</summary>
 protected void ResetCaretBlink()
 {
     isCaretOn = true;
     lastBlink = FrameworkTimer.GetAbsoluteTime();
 }
Esempio n. 15
0
        /// <summary>Changes the UI defaults to the current device settings</summary>
        public void Refresh()
        {
            // Get some information
            globalSettings = parent.DeviceSettings.Clone();
            System.Drawing.Rectangle client = parent.WindowClientRectangle;
            windowWidth  = (uint)client.Width;
            windowHeight = (uint)client.Height;

            // Fill the UI with the current settings
            if (!deviceCombo.ContainsItem(globalSettings.DeviceType.ToString()))
            {
                deviceCombo.AddItem(globalSettings.DeviceType.ToString(), globalSettings.DeviceType.ToString());
            }

            SetWindowed(globalSettings.presentParams.Windowed);
            clipBox.IsChecked = ((globalSettings.presentParams.PresentFlag & PresentFlag.DeviceClip) != 0);

            if (!adapterFormatCombo.ContainsItem(globalSettings.AdapterFormat.ToString()))
            {
                adapterFormatCombo.AddItem(globalSettings.AdapterFormat.ToString(), globalSettings.AdapterFormat);
            }

            AddResolution((short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight);
            AddRefreshRate(globalSettings.presentParams.FullScreenRefreshRateInHz);

            if (!backBufferCombo.ContainsItem(globalSettings.presentParams.BackBufferFormat.ToString()))
            {
                backBufferCombo.AddItem(globalSettings.presentParams.BackBufferFormat.ToString(), globalSettings.presentParams.BackBufferFormat);
            }

            if (!depthStencilCombo.ContainsItem(globalSettings.presentParams.AutoDepthStencilFormat.ToString()))
            {
                depthStencilCombo.AddItem(globalSettings.presentParams.AutoDepthStencilFormat.ToString(), globalSettings.presentParams.AutoDepthStencilFormat);
            }

            if (!multiSampleTypeCombo.ContainsItem(globalSettings.presentParams.MultiSample.ToString()))
            {
                multiSampleTypeCombo.AddItem(globalSettings.presentParams.MultiSample.ToString(), globalSettings.presentParams.MultiSample);
            }

            if (!multiSampleQualityCombo.ContainsItem(globalSettings.presentParams.MultiSampleQuality.ToString()))
            {
                multiSampleQualityCombo.AddItem(globalSettings.presentParams.MultiSampleQuality.ToString(), globalSettings.presentParams.MultiSampleQuality);
            }

            if (!presentCombo.ContainsItem(globalSettings.presentParams.PresentationInterval.ToString()))
            {
                presentCombo.AddItem(globalSettings.presentParams.PresentationInterval.ToString(), globalSettings.presentParams.PresentationInterval);
            }

            if (!textureFilterCombo.ContainsItem(globalSettings.TextureFilter.ToString()))
            {
                textureFilterCombo.AddItem(globalSettings.TextureFilter.ToString(), globalSettings.TextureFilter);
            }

            BehaviorFlags flags = new BehaviorFlags(globalSettings.BehaviorFlags);

            if (flags.PureDevice)
            {
                AddVertexProcessing(CreateFlags.PureDevice);
            }
            else if (flags.HardwareVertexProcessing)
            {
                AddVertexProcessing(CreateFlags.HardwareVertexProcessing);
            }
            else if (flags.SoftwareVertexProcessing)
            {
                AddVertexProcessing(CreateFlags.SoftwareVertexProcessing);
            }
            else if (flags.MixedVertexProcessing)
            {
                AddVertexProcessing(CreateFlags.MixedVertexProcessing);
            }

            // Get the adapters list from Enumeration object
            ArrayList adapterInfoList = Enumeration.AdapterInformationList;

            if (adapterInfoList.Count == 0)
            {
                throw new NoCompatibleDevicesException();
            }

            adapterCombo.Clear();

            // Add all of the adapters
            for (int iAdapter = 0; iAdapter < adapterInfoList.Count; iAdapter++)
            {
                EnumAdapterInformation adapterInfo = adapterInfoList[iAdapter] as EnumAdapterInformation;
                if (!adapterCombo.ContainsItem(adapterInfo.UniqueDescription))
                {
                    adapterCombo.AddItem(adapterInfo.UniqueDescription, iAdapter);
                }
            }
            adapterCombo.SetSelectedByData(globalSettings.AdapterOrdinal);

            // The adapter changed, call the handler
            OnAdapterChanged(adapterCombo, System.EventArgs.Empty);

            Dialog.SetRefreshTime((float)FrameworkTimer.GetTime());
        }