Windows() static private method

static private Windows ( ) : bool
return bool
Example #1
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            if (e.Item.DisplayStyle == ToolStripItemDisplayStyle.Image)
            {
                // Do not paint a background for icon only buttons
                return;
            }

            if (this.inactiveTabBkg == null)
            {
                this.inactiveTabBkg = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.Control, SystemColors.ControlDark);
                this.hoverTabBkg    = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.ControlLight, SystemColors.Control);
                this.pressedTabBkg  = new SolidBrush(SystemColors.ControlLight);
            }

            using (LinearGradientBrush activeTabBkg = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.ControlLight, this.GetActiveTabBtmCol(e.ToolStrip, e.Item)))
            {
                ToolStripButton button = (ToolStripButton)e.Item;
                Brush           colour = this.inactiveTabBkg;

                if (button.Checked)
                {
                    colour = activeTabBkg;

                    if (OsUtils.Windows())
                    {
                        // Invalidate between the buttons and the bottom of the toolstrip so that it gets repainted
                        e.ToolStrip.Invalidate(new Rectangle(0, e.Item.Bounds.Bottom, e.ToolStrip.Bounds.Width, e.ToolStrip.Bounds.Height - e.Item.Bounds.Bottom));
                    }
                }
                else if (e.Item.Selected)
                {
                    if (e.Item.Pressed)
                    {
                        colour = this.pressedTabBkg;
                    }
                    else
                    {
                        colour = this.hoverTabBkg;
                    }
                }

                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                int width  = e.Item.Width - TabSeparation;
                int height = e.Item.Height;

                using (GraphicsPath tab = new GraphicsPath())
                {
                    tab.AddLine(0, height, 0, CurveSize);
                    tab.AddArc(0, 0, CurveSize, CurveSize, 180, 90);
                    tab.AddLine(CurveSize, 0, width - CurveSize, 0);
                    tab.AddArc(width - CurveSize, 0, CurveSize, CurveSize, 270, 90);
                    tab.AddLine(width, CurveSize, width, height);

                    e.Graphics.FillPath(colour, tab);
                    e.Graphics.DrawPath(this.tabBorder, tab);
                }
            }
        }
Example #2
0
        public void SetWholeDropDown(ToolBarButton button)
        {
            if (button == null)
            {
                throw new ArgumentNullException("button");
            }

            if (!this.wholeDropDownButtons.Contains(button))
            {
                this.wholeDropDownButtons.Add(button);

                if (!OsUtils.Windows())
                {
                    // Append a down arrow as BTNS_WHOLEDROPDOWN is only supported under Windows
                    button.Text += " ▾";
                }
            }

            NativeMethods.TBBUTTONINFO buttonInfo = default(NativeMethods.TBBUTTONINFO);

            buttonInfo.cbSize  = Marshal.SizeOf(buttonInfo);
            buttonInfo.dwMask  = NativeMethods.TBIF_STYLE | NativeMethods.TBIF_BYINDEX;
            buttonInfo.fsStyle = NativeMethods.BTNS_WHOLEDROPDOWN | NativeMethods.BTNS_AUTOSIZE;

            NativeMethods.SendMessage(this.Handle, NativeMethods.TB_SETBUTTONINFO, (IntPtr)this.Buttons.IndexOf(button), ref buttonInfo);
        }
Example #3
0
 private void Status_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Prevent closing under Windows via right-click taskbar menu
     // Mono sets e.CloseReason to UserClosing from a call to Hide()
     if (e.CloseReason == CloseReason.UserClosing && OsUtils.Windows())
     {
         e.Cancel = true;
     }
 }
Example #4
0
        protected override void OnCreateMainForm()
        {
            // If /exit was passed on the command line, then just exit immediately
            foreach (string commandLineArg in Environment.GetCommandLineArgs())
            {
                if (commandLineArg.ToUpperInvariant() == "/EXIT")
                {
                    Environment.Exit(1);
                }
            }

            if (!OsUtils.Windows())
            {
                // Mono has a bug which causes the useDefaultCredentials attribute to be
                // treated as invalid, so clear the default proxy to prevent an exception
                WebRequest.DefaultWebProxy = null;
            }

            try
            {
                // Add TLS 1.1 and 1.2 to allowed protocols for HTTPS requests
                // Constants are not defined until .NET 4.5, so use the values
                ServicePointManager.SecurityProtocol |=
                    (SecurityProtocolType)0x00000300 | // SecurityProtocolType.Tls11
                    (SecurityProtocolType)0x00000C00;  // SecurityProtocolType.Tls12
            }
            catch (NotSupportedException)
            {
                if (OsUtils.Windows())
                {
                    MessageBox.Show(
                        "The .NET framework needs an update (to enable TLS 1.1 and 1.2) before Radio Downloader can run." + Environment.NewLine + Environment.NewLine +
                        "Please check for available updates and install all of those which relate to the .NET framework.",
                        Application.ProductName,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Stop);

                    Environment.Exit(1);
                }

                throw;
            }

            // Set up the application database and perform any required updates or cleanup
            if (!DatabaseInit.Startup())
            {
                Environment.Exit(1);
            }

            this.MainForm             = new Main();
            this.StartupNextInstance += ((Main)this.MainForm).App_StartupNextInstance;
        }
Example #5
0
        public TaskbarNotify()
        {
            if (!OsUtils.Windows())
            {
                // OS doesn't support ITaskbarList3 interface
                return;
            }

            this.taskBarListInst = (NativeMethods.ITaskbarList3) new TaskbarList();

            try
            {
                this.taskBarListInst.HrInit();
            }
            catch (NotImplementedException)
            {
                // Some third party Windows shells don't support ITaskbarList3
                return;
            }

            this.Supported = true;
        }
Example #6
0
        /// <summary>
        /// Handle the WM_SETCURSOR message and set the correct system link cursor.
        /// </summary>
        /// <param name="m">The Windows <see cref="Message" /> to process.</param>
        protected override void WndProc(ref Message m)
        {
            if (OsUtils.Windows() && m.Msg == NativeMethods.WM_SETCURSOR)
            {
                // Fetch a handle to the system 'hand' cursor.
                IntPtr cursor = NativeMethods.LoadCursor(IntPtr.Zero, (IntPtr)NativeMethods.IDC_HAND);

                // NULL cursor
                if (cursor == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }

                // Set this control's cursor to the 'hand'
                NativeMethods.SetCursor(cursor);

                // Show that the message has been handled successfully
                m.Result = IntPtr.Zero;
                return;
            }

            base.WndProc(ref m);
        }