Example #1
0
        internal Manager(ref RulerRender form, ref RenderTarget drawer, ref SwapChain swapChain)
        {
            Form           = form;
            this.drawer    = drawer;
            this.swapChain = swapChain;
            EventsAndGlobalsController.RenderTargetSize = new RawVector2(drawer.Size.Width, drawer.Size.Height);
            EventsAndGlobalsController.Parameters       = Parameter.GetParameters($"{Form.Bounds.Width}x{Form.Bounds.Height}");

            InitializeComponent();
        }
Example #2
0
        private void InitializeForm()
        {
            ModeDescription modeDescription = new ModeDescription()
            {
                Width       = ClientSize.Width,
                Height      = ClientSize.Height,
                RefreshRate = new Rational(60, 1),
                Format      = Format.R8G8B8A8_UNorm
            };
            SwapChainDescription desc = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = modeDescription,
                IsWindowed        = true,
                OutputHandle      = Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };

            // Create Device and SwapChain
            SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport,
                                                          new[] { SharpDX.Direct3D.FeatureLevel.Level_11_1 }, desc, out SharpDX.Direct3D11.Device device, out SwapChain swapChain);

            SharpDX.Direct2D1.Factory d2dFactory = new SharpDX.Direct2D1.Factory();

            // Ignore all windows events
            SharpDX.DXGI.Factory factory = swapChain.GetParent <SharpDX.DXGI.Factory>();
            factory.MakeWindowAssociation(Handle, WindowAssociationFlags.IgnoreAll);

            Texture2D        backBuffer = SharpDX.Direct3D11.Resource.FromSwapChain <Texture2D>(swapChain, 0);
            RenderTargetView renderView = new RenderTargetView(device, backBuffer);

            Surface surface = backBuffer.QueryInterface <Surface>();

            RenderTarget d2dRenderTarget = new RenderTarget(d2dFactory, surface,
                                                            new RenderTargetProperties(new PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Premultiplied)));

            // Release all resources
            renderView.Dispose();
            backBuffer.Dispose();
            device.ImmediateContext.ClearState();
            device.ImmediateContext.Flush();
            device.Dispose();
            factory.Dispose();

            RulerRender thisForm = this;

            Manager = new Manager(ref thisForm, ref d2dRenderTarget, ref swapChain);
        }
Example #3
0
        private void InitializeComponent()
        {
            SuspendLayout();
            ClientSize = new Size(resolution.Width, resolution.Height);

            Int32 valueBoxWidthPosition  = (Int32)(0.75 * monitor.Resolution.Width);
            Int32 valueBoxHeightPosition = (Int32)(0.85 * EventsAndGlobalsController.CurrentMonitor.Resolution.Height);

            #region Power Angle Wind valueBox defines

            angleValueBox = new ValueBox("Angle")
            {
                BackColor    = Color.FromArgb(0, 75, 0),
                Location     = new Point(valueBoxWidthPosition, valueBoxHeightPosition),
                Size         = new Size(ValueBoxWidth, ValueBoxHeight),
                EndString    = @"°",
                DefaultValue = EventsAndGlobalsController.Angle,
                MaxValue     = 359,
            };
            angleValueBox.Text = angleValueBox.DefaultValue.ToString();
            //angleValueBox.TextChanged += (sender, e) => ValueBoxOnTextChanged(ref angleValueBox);

            windValueBox = new ValueBox("Wind")
            {
                BackColor    = Color.FromArgb(0, 0, 75),
                Location     = new Point(ValueBoxWidth + valueBoxWidthPosition + DistanceBetweenValueBox, valueBoxHeightPosition),
                Size         = new Size(ValueBoxWidth, ValueBoxHeight),
                EndString    = $@"{_localization.Meters}",
                DefaultValue = EventsAndGlobalsController.Wind,
                MaxValue     = 100,
                MinValue     = -100
            };
            windValueBox.Text = windValueBox.DefaultValue.ToString();
            //windValueBox.TextChanged += (sender, e) => ValueBoxOnTextChanged(ref windValueBox);

            powerValueBox = new ValueBox("Power")
            {
                BackColor    = Color.FromArgb(75, 0, 0),
                Location     = new Point(valueBoxWidthPosition, ValueBoxHeight + valueBoxHeightPosition),
                Size         = new Size(2 * ValueBoxWidth + DistanceBetweenValueBox, ValueBoxHeight),
                EndString    = @"%",
                DefaultValue = EventsAndGlobalsController.Power,
                MaxValue     = 100,
            };
            powerValueBox.Text = powerValueBox.DefaultValue.ToString();
            //powerValueBox.TextChanged += (sender, e) => ValueBoxOnTextChanged(ref powerValueBox);

            #endregion

            weaponsPanel = new WeaponsPanel();

            MainForm    thisForm = this;
            RulerRender ruler    = new RulerRender(ref thisForm);

            TopMost         = true;
            ControlBox      = false;
            AutoScaleMode   = AutoScaleMode.Font;
            Text            = !isDisguise ? _localization.RulerVersion : _localization.MaskName;
            BackColor       = Color.Black;
            TransparencyKey = Color.Black;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            Icon            = !isDisguise ? Resources.icon : Resources.notepad;
            ShowInTaskbar   = !isDisguise;
            Location        = new Point(resolution.X, resolution.Y);
            Size            = new Size(resolution.Width, resolution.Height);
            Controls.Add(powerValueBox);
            Controls.Add(angleValueBox);
            Controls.Add(windValueBox);
            Controls.Add(weaponsPanel);
            ResumeLayout(false);
            PerformLayout();
            ruler.Start();
        }