コード例 #1
0
 public TerminalServicesProcess(ITerminalServer server, WIN32.Win32API.WTS_PROCESS_INFO processInfo)
 {
     _server = server;
     _sessionId = processInfo.SessionId;
     _processId = processInfo.ProcessId;
     _processName = processInfo.ProcessName;
     // The SID could be null sometimes.
     // TODO: Windows 2008 R2 beta (locally) runs null for all processes except
     // those owned by the current user; is this expected? (works fine from XP client)
     if (processInfo.UserSid != IntPtr.Zero)
     {
         _securityIdentifier = new SecurityIdentifier(processInfo.UserSid);
     }
 }
コード例 #2
0
        private void UpdateUpDown()
        {
            if (bUpDown)
            {
                if (WIN32.IsWindowVisible(scUpDown.Handle))
                {
                    Rectangle rect = new Rectangle();

                    WIN32.GetClientRect(scUpDown.Handle, ref rect);


                    //move the rect is allow close in on (TOP)
                    if ((this.Alignment == TabAlignment.Top) && (_allowCloseButton == true))
                    {
                        WIN32.MoveWindow(scUpDown.Handle, this.Width - 60, rect.Y + 5, rect.Width, rect.Height, true);
                    }
                    else if ((this.Alignment == TabAlignment.Top) && (_allowCloseButton == false))
                    //if ((this.Alignment == TabAlignment.Top))
                    {
                        WIN32.MoveWindow(scUpDown.Handle, this.Width - 41, rect.Y + 5, rect.Width, rect.Height, true);
                    }

                    //move the rect is allow close in on (Bottom)
                    if ((this.Alignment == TabAlignment.Bottom) && (_allowCloseButton == true))
                    {
                        WIN32.MoveWindow(scUpDown.Handle, this.Width - 60, this.Height - 24, rect.Width, rect.Height, true);
                    }
                    else if ((this.Alignment == TabAlignment.Bottom) && (_allowCloseButton == false))
                    //if ((this.Alignment == TabAlignment.Bottom))
                    {
                        WIN32.MoveWindow(scUpDown.Handle, this.Width - 41, this.Height - 24, rect.Width, rect.Height, true);
                    }



                    WIN32.InvalidateRect(scUpDown.Handle, ref rect, true);

                    //Try Disabling Theme
                    try
                    {
                        WIN32.SetWindowTheme(scUpDown.Handle, "", "");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
コード例 #3
0
        protected static ScrollBars GetVisibleScrollbars(Control ctl)
        {
            int  wndStyle  = WIN32.GetWindowLong(ctl.Handle, WIN32.GWL_STYLE);
            bool hsVisible = (wndStyle & WIN32.WS_HSCROLL) != 0;
            bool vsVisible = (wndStyle & WIN32.WS_VSCROLL) != 0;

            if (hsVisible)
            {
                return(vsVisible ? ScrollBars.Both : ScrollBars.Horizontal);
            }
            else
            {
                return(vsVisible ? ScrollBars.Vertical : ScrollBars.None);
            }
        }
コード例 #4
0
        public void DrawBack(ref Message message, int width, int height)
        {
            if (message.Msg == WM_NCPAINT || message.Msg == WM_ERASEBKGND || message.Msg == WM_PAINT)
            {
                IntPtr hdc = WIN32.GetDCEx(message.HWnd, (IntPtr)1, 1 | 0x0020);

                if (hdc != IntPtr.Zero)
                {
                    Graphics  graphics  = Graphics.FromHdc(hdc);
                    Rectangle rectangle = new Rectangle(0, 0, width, height);
                    graphics.FillRectangle(new SolidBrush(Color.Transparent), rectangle);

                    message.Result = (IntPtr)1;
                    WIN32.ReleaseDC(message.HWnd, hdc);
                }
            }
        }
コード例 #5
0
ファイル: Helper.cs プロジェクト: burfab/ScreenRuler
        public static System.Windows.Media.ImageSource ImageSourceFromHBitmap(Bitmap bitmap)
        {
            IntPtr handle = IntPtr.Zero;

            System.Windows.Media.ImageSource ret = null;
            try {
                handle = bitmap.GetHbitmap();
                ret    = Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty,
                                                               BitmapSizeOptions.FromEmptyOptions());
                ret.Freeze();
            } catch (Exception) {
            } finally {
                WIN32.DeleteObject(handle);
            }

            return(ret);
        }
コード例 #6
0
        public void SetDGVScrollBarValue(ref DataGridView dgv, ref HScrollBar HSB)
        {
            int listStyle = WIN32.GetWindowLong(dgv.Handle, WIN32.GWL_STYLE);

            //listStyle |= WIN32.WS_VSCROLL | WIN32.WS_HSCROLL;
            listStyle |= WIN32.WS_HSCROLL;
            listStyle  = WIN32.SetWindowLong(dgv.Handle, WIN32.GWL_STYLE, listStyle);

            HScrollBar1.Value       = HSB.Value;
            HScrollBar1.Visible     = true;
            HScrollBar1.LargeChange = HSB.LargeChange;
            HScrollBar1.Maximum     = HSB.Maximum;
            HScrollBar1.Minimum     = HSB.Minimum;
            HScrollBar1.SmallChange = HSB.SmallChange;
            HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
            //Invalidate();
        }
コード例 #7
0
        static public int Init()
        {
            if ((SystemParametersInfo(SPI_GETWORKAREA, 0, ref rtDesktop, 0) == 1))
            {
                // Successful obtain the system working area(Desktop)
                SetRect(ref rtNewDesktop, 0, 0, 240, 320);
            }

            // Find the Taskbar window handle
            hWndTaskBar = WIN32.FindWindow("HHTaskBar", null);
            //Checking...
            if (hWndTaskBar != 0)
            {
                //Get the original Input panel windowsize
                GetWindowRect(hWndTaskBar, ref rtTaskBar);
            }
            return(1);
        }
        // message - a message from control's WndProc(ref Message m) method
        // width - controls' width
        // height - controls' height
        public void DrawBorder(ref Message message, int width, int height)
        {
            if (message.Msg == WIN32.WM_NCPAINT || message.Msg == WIN32.WM_ERASEBKGND || message.Msg == WIN32.WM_PAINT)
            {
                //get handle to a display device context
                IntPtr hdc = WIN32.GetDCEx(message.HWnd, (IntPtr)1, 1 | 0x0020);

                if (hdc != IntPtr.Zero)
                {
                    //get Graphics object from the display device context
                    Graphics  graphics  = Graphics.FromHdc(hdc);
                    Rectangle rectangle = new Rectangle(0, 0, width, height);
                    ControlPaint.DrawBorder(graphics, rectangle, _borderColor, ButtonBorderStyle.Solid);

                    message.Result = (IntPtr)1;
                    WIN32.ReleaseDC(message.HWnd, hdc);
                }
            }
        }
コード例 #9
0
 private unsafe void DeferredContinue()
 {
     fixed(WIN32.SERVICE_STATUS *service_statusRef = &this.status)
     {
         try
         {
             this.OnContinue();
             this.WriteEventLogEntry(Res.GetString("ContinueSuccessful"));
             this.status.currentState = WIN32.SERVICE_RUNNING;
         }
         catch (Exception exception)
         {
             this.status.currentState = WIN32.SERVICE_PAUSED;
             this.WriteEventLogEntry(Res.GetString("ContinueFailed", new object[] { exception.ToString() }), EventLogEntryType.Error);
             throw;
         }
         finally
         {
             WIN32.SetServiceStatus(this.statusHandle, service_statusRef);
         }
     }
 }
コード例 #10
0
ファイル: BotBugService.cs プロジェクト: harishraj/tools
 protected override void OnStart(string[] args)
 {
     this.Trace("service is starting...");
     //
     try {
         WIN32.OleInitialize(IntPtr.Zero);
         this.oleInitialized = true;
         //
         this.usbMonitor = new USBMonitor(this, this, this.ServiceHandle, true);
         this.usbMonitor.AddDeviceInterfaceOfInterest(AndroidADBDeviceInterface);
         this.usbMonitor.Start();
     }
     catch (Exception e)
     {
         this.ExitCode = WIN32.ERROR_EXCEPTION_IN_SERVICE;
         this.ServiceSpecificExitCode = WIN32.Win32ErrorFromException(e);
         this.Trace($"exception: {e}");
         throw;
     }
     //
     this.Trace("...service has started");
 }
コード例 #11
0
        private unsafe void DeferredStop()
        {
            fixed(WIN32.SERVICE_STATUS *service_statusRef = &this.status)
            {
                int currentState = this.status.currentState;

                this.status.checkPoint   = 0;
                this.status.waitHint     = 0;
                this.status.currentState = WIN32.SERVICE_STOP_PENDING;
                WIN32.SetServiceStatus(this.statusHandle, service_statusRef);
                try
                {
                    this.OnStop();
                    this.WriteEventLogEntry(Res.GetString("StopSuccessful"));
                    this.status.currentState = WIN32.SERVICE_STOPPED;
                    WIN32.SetServiceStatus(this.statusHandle, service_statusRef);
                    if (this.isServiceHosted)
                    {
                        try
                        {
                            AppDomain.Unload(AppDomain.CurrentDomain);
                        }
                        catch (CannotUnloadAppDomainException exception)
                        {
                            this.WriteEventLogEntry(Res.GetString("FailedToUnloadAppDomain", AppDomain.CurrentDomain.FriendlyName, exception.Message), EventLogEntryType.Error);
                        }
                    }
                }
                catch (Exception exception2)
                {
                    this.status.currentState = currentState;
                    WIN32.SetServiceStatus(this.statusHandle, service_statusRef);
                    this.WriteEventLogEntry(Res.GetString("StopFailed", exception2.ToString()), EventLogEntryType.Error);
                    throw;
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Overrided to controll del scrolling of the customControl VScrollBar1
        /// </summary>
        /// <param name="m"></param>
        /// <remarks></remarks>
        protected override void WndProc(ref Message m)
        {
            if (!DesignMode && !(!Parent.CanFocus | (_win == null)))
            {
                //int listStyle = WIN32.GetWindowLong(_win.Handle, WIN32.GWL_STYLE);
                //listStyle |= WIN32.WS_VSCROLL | WIN32.WS_HSCROLL;
                //listStyle |= WIN32.WS_VSCROLL;
                //listStyle |= WIN32.WS_HSCROLL;
                //listStyle = WIN32.SetWindowLong(_win.Handle, WIN32.GWL_STYLE, listStyle);

                int  wndStyle  = WIN32.GetWindowLong(_win.Handle, WIN32.GWL_STYLE);
                bool hsVisible = (wndStyle & WIN32.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & WIN32.WS_VSCROLL) != 0;

                //Vertical
                if (vsVisible)
                {
                    si.fMask  = (int)WIN32.ScrollInfoMask.SIF_ALL;
                    si.cbSize = Marshal.SizeOf(si);
                    WIN32.GetScrollInfo(_win.Handle, (int)WIN32.ScrollBarDirection.SB_VERT, ref si);

                    if ((si.nMax + 0) <= si.nPage)
                    {
                        VScrollBar1.Visible = false;
                    }
                    else
                    {
                        VScrollBar1.Visible = true;
                        if (si.nPage != 0)
                        {
                            VScrollBar1.LargeChange = si.nPage;
                            VScrollBar1.Maximum     = si.nMax;
                            VScrollBar1.Minimum     = si.nMin;
                            VScrollBar1.SmallChange = 1;
                            VScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                        }
                    }
                }

                //horizontal
                if (hsVisible)
                {
                    si.fMask  = (int)WIN32.ScrollInfoMask.SIF_ALL;
                    si.cbSize = Marshal.SizeOf(si);
                    WIN32.GetScrollInfo(_win.Handle, (int)WIN32.ScrollBarDirection.SB_HORZ, ref si);

                    if ((si.nMax + 0) <= si.nPage)
                    {
                        HScrollBar1.Visible = false;
                    }
                    else
                    {
                        HScrollBar1.Visible = true;
                        if (si.nPage != 0)
                        {
                            HScrollBar1.LargeChange = si.nPage;
                            HScrollBar1.Maximum     = si.nMax;
                            HScrollBar1.Minimum     = si.nMin;
                            HScrollBar1.SmallChange = 1;
                            HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                        }
                    }
                }

                if (_win.GetType() == typeof(ListView) || (_win.GetType() == typeof(KryptonListView)))
                {
                    ListView listView1 = (ListView)_win;

                    WIN32.ScrollInfo si = new WIN32.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)WIN32.ScrollInfoMask.SIF_ALL;
                    if (WIN32.GetScrollInfo(listView1.Handle, (int)WIN32.ScrollBarDirection.SB_VERT, ref si))
                    {
                        VScrollBar1.LargeChange = si.nPage;
                        VScrollBar1.Maximum     = si.nMax;
                        VScrollBar1.Minimum     = si.nMin;
                        VScrollBar1.SmallChange = 1;
                        VScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                    }


                    si        = new WIN32.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)WIN32.ScrollInfoMask.SIF_ALL;
                    if (WIN32.GetScrollInfo(listView1.Handle, (int)WIN32.ScrollBarDirection.SB_HORZ, ref si))
                    {
                        HScrollBar1.LargeChange = si.nPage;
                        HScrollBar1.Maximum     = si.nMax;
                        HScrollBar1.Minimum     = si.nMin;
                        HScrollBar1.SmallChange = 1;
                        HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                    }
                }
            }

            base.WndProc(ref m);
        }
コード例 #13
0
        private void HScrollBar1_miScroll(object sender, ScrollEventArgs e)
        {
            if (_win.GetType() == typeof(ListView) || (_win.GetType() == typeof(KryptonListView)))
            {
                ListView listView1 = (ListView)_win;

                int nIsAt       = WIN32.GetScrollPos(listView1.Handle, WIN32.SB_HORZ);
                int nShouldBeAt = (int)e.NewValue;

                int pixelsToScroll = Convert.ToInt32((nShouldBeAt - nIsAt));

                WIN32.SendMessage(listView1.Handle, (int)WIN32.LVM_SCROLL, pixelsToScroll, 0);

                Invalidate();
            }
            else
            {
                if (_win.GetType() == typeof(KryptonGrid) || _win.GetType() == typeof(DataGridView) || (_win.GetType() == typeof(KryptonDataGridView)))
                {
                    DataGridView dgv = (DataGridView)_win;
                    if (GetDGHScrollbar(ref dgv, out HSC))
                    {
                        foreach (Control control in dgv.Controls)
                        {
                            if (control is HScrollBar)
                            {
                                HScrollBar hscroll = (HScrollBar)control;
                                if (hscroll.Visible)
                                {
                                    switch (e.Type)
                                    {
                                    case ScrollEventType.ThumbTrack:
                                        if (e.NewValue >= e.OldValue)
                                        {
                                            WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_LINEDOWN, HSC.Handle);
                                        }
                                        else
                                        {
                                            WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_LINEUP, HSC.Handle);
                                        }

                                        WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_THUMBTRACK, HSC.Handle);
                                        break;

                                    default:
                                        WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)e.Type, HSC.Handle);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        HScrollBar1.Visible = false;
                    }
                }
                else
                {
                    if (_win.GetType() == typeof(TreeView) || (_win.GetType() == typeof(ComponentFactory.Krypton.Toolkit.KryptonTreeView)))
                    {
                        switch (e.Type)
                        {
                        case ScrollEventType.ThumbTrack:
                            if (e.NewValue >= e.OldValue)
                            {
                                WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_LINEDOWN, IntPtr.Zero);
                            }
                            else
                            {
                                WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_LINEUP, IntPtr.Zero);
                            }

                            WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)WIN32.SB_THUMBTRACK, IntPtr.Zero);
                            break;

                        default:
                            WIN32.SendMessage(_win.Handle, WIN32.WM_HSCROLL, (IntPtr)e.Type, IntPtr.Zero);
                            break;
                        }
                    }
                    else
                    {
                        WIN32.PostMessageA(_win.Handle, WIN32.WM_HSCROLL, WIN32.SB_THUMBPOSITION + (0x10000 * HScrollBar1.Value), 0);
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Comming from the customControl
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void VScrollBar1_miScroll(object sender, ScrollEventArgs e)
        {
            if (_win.GetType() == typeof(ListView) || (_win.GetType() == typeof(KryptonListView)))
            {
                ListView listView1 = (ListView)_win;

                IntPtr min = IntPtr.Zero;
                IntPtr max = IntPtr.Zero;
                WIN32.GetScrollRange(listView1.Handle, WIN32.SB_VERT, ref min, ref max);

                int nMax = max.ToInt32();
                nMax += 3;

                int nHeight        = listView1.DisplayRectangle.Height;
                int ItemRectHeight = listView1.GetItemRect(0).Height;

                int nTimes           = (nHeight - 17) / ItemRectHeight;
                int nScrollPositions = (nMax - nTimes) + 1;

                double nThePos = VScrollBar1.Maximum / nScrollPositions;

                double RealPos = 0.0;
                if (nThePos <= 0.0)
                {
                    RealPos = VScrollBar1.Value;
                }
                else
                {
                    RealPos = VScrollBar1.Value / nThePos;
                }

                int nPos = WIN32.GetScrollPos(listView1.Handle, WIN32.SB_VERT);

                double nShouldBeAt = RealPos * ItemRectHeight;
                double nIsAt       = nPos * ItemRectHeight;

                int pixelsToScroll = Convert.ToInt32((nShouldBeAt - nIsAt));

                WIN32.SendMessage(listView1.Handle, WIN32.LVM_SCROLL, IntPtr.Zero, (IntPtr)pixelsToScroll);

                Invalidate();
            }
            else
            {
                if (_win.GetType() == typeof(KryptonGrid) || _win.GetType() == typeof(DataGridView) || (_win.GetType() == typeof(KryptonDataGridView)))
                {
                    DataGridView dgv = (DataGridView)_win;
                    if (GetDGVScrollbar(ref dgv, out VSB))
                    {
                        foreach (Control control in dgv.Controls)
                        {
                            if (control is VScrollBar)
                            {
                                VScrollBar vscroll = (VScrollBar)control;
                                if (vscroll.Visible)
                                {
                                    switch (e.Type)
                                    {
                                    case ScrollEventType.ThumbTrack:
                                        if (e.NewValue >= e.OldValue)
                                        {
                                            WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_LINEDOWN, VSB.Handle);
                                        }
                                        else
                                        {
                                            WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_LINEUP, VSB.Handle);
                                        }

                                        WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_THUMBTRACK, VSB.Handle);
                                        break;

                                    default:
                                        WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)e.Type, VSB.Handle);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        VScrollBar1.Visible = false;
                    }
                }
                else
                {
                    if (_win.GetType() == typeof(TreeView) || (_win.GetType() == typeof(ComponentFactory.Krypton.Toolkit.KryptonTreeView)))
                    {
                        switch (e.Type)
                        {
                        case ScrollEventType.ThumbTrack:
                            if (e.NewValue >= e.OldValue)
                            {
                                WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_LINEDOWN, IntPtr.Zero);
                            }
                            else
                            {
                                WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_LINEUP, IntPtr.Zero);
                            }

                            WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)WIN32.SB_THUMBTRACK, IntPtr.Zero);
                            break;

                        default:
                            WIN32.SendMessage(_win.Handle, WIN32.WM_VSCROLL, (IntPtr)e.Type, IntPtr.Zero);
                            break;
                        }
                    }
                    else
                    {
                        WIN32.PostMessageA(_win.Handle, WIN32.WM_VSCROLL, WIN32.SB_THUMBPOSITION + (0x10000 * VScrollBar1.Value), 0);
                    }
                }
            }
        }
 /// <summary>
 /// Comming from the customControl
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks></remarks>
 private void VScrollBar1_miScroll(object sender, ScrollEventArgs e)
 {
     WIN32.PostMessageA(this._win.Handle, WIN32.WM_HSCROLL, WIN32.SB_THUMBPOSITION + (0x10000 * this.VScrollBar1.Value), 0);
 }
コード例 #16
0
 public ClientDisplay(WIN32.Win32API.WTS_CLIENT_DISPLAY clientDisplay)
 {
     _horizontalResolution = clientDisplay.HorizontalResolution;
     _verticalResolution = clientDisplay.VerticalResolution;
     _bitsPerPixel = GetBitsPerPixel(clientDisplay.ColorDepth);
 }
コード例 #17
0
 public TerminalServicesSession(ITerminalServer server, WIN32.Win32API.WTS_SESSION_INFO sessionInfo)
     : this(server, sessionInfo.SessionID)
 {
     _windowStationName.Value = sessionInfo.pWinStationName;
     _connectionState.Value = (WIN32.Win32API.ConnectionState)sessionInfo.State;
 }
コード例 #18
0
 public void Shutdown(WIN32.Win32API.ShutdownType type)
 {
     WIN32.NativeMethodsHelper.ShutdownSystem(Handle, (int) type);
 }
コード例 #19
0
        internal void DrawControl(Graphics g)
        {
            if (!Visible)
            {
                return;
            }

            Rectangle TabControlArea = this.ClientRectangle;
            Rectangle TabArea        = this.DisplayRectangle;

            //----------------------------
            // fill client area
            Brush br = new SolidBrush(_standardBackColour); //(SystemColors.Control); UPDATED

            g.FillRectangle(br, TabControlArea);
            br.Dispose();
            //----------------------------

            //----------------------------
            // draw border
            int nDelta = SystemInformation.Border3DSize.Width;

            Pen border = new Pen(_borderColour, _borderWidth);

            TabArea.Inflate(nDelta, nDelta);
            g.DrawRectangle(border, TabArea);
            border.Dispose();
            //----------------------------


            //----------------------------
            // clip region for drawing tabs
            Region    rsaved = g.Clip;
            Rectangle rreg;

            int nWidth = TabArea.Width + nMargin;

            // exclude close button control for painting
            if (_allowCloseButton)
            {
                nWidth -= 20;
            }

            if (bUpDown)
            {
                // exclude updown control for painting
                if (WIN32.IsWindowVisible(scUpDown.Handle))
                {
                    Rectangle rupdown = new Rectangle();
                    WIN32.GetWindowRect(scUpDown.Handle, ref rupdown);
                    Rectangle rupdown2 = this.RectangleToClient(rupdown);

                    nWidth = rupdown2.X;
                }
            }

            //if top or bottom leave a blank space for Close button or navigator
            if ((this.Alignment == TabAlignment.Top) || (this.Alignment == TabAlignment.Bottom))
            {
                rreg = new Rectangle(TabArea.Left, TabControlArea.Top, nWidth - nMargin, TabControlArea.Height);
            }
            else
            {
                rreg = ClientRectangle;
            }

            g.SetClip(rreg);

            // draw tabs
            for (int i = 0; i < this.TabCount; i++)
            {
                DrawTab(g, this.TabPages[i], i);
            }

            g.Clip = rsaved;
            //----------------------------


            //----------------------------
            // draw background to cover flat border areas
            if (this.SelectedTab != null)
            {
                TabPage tabPage = this.SelectedTab;
                Color   color   = tabPage.BackColor;
                border = new Pen(color);

                TabArea.Offset(1, 1);
                TabArea.Width  -= 2;
                TabArea.Height -= 2;

                g.DrawRectangle(border, TabArea);
                TabArea.Width  -= 1;
                TabArea.Height -= 1;
                g.DrawRectangle(border, TabArea);

                border.Dispose();
            }
            //----------------------------
        }
コード例 #20
0
 public ProtocolStatistics(WIN32.Win32API.PROTOCOLCOUNTERS counters)
 {
     _bytes = counters.Bytes;
     _frames = counters.Frames;
     _compressedBytes = counters.CompressedBytes;
 }
コード例 #21
0
        public unsafe void ServiceMainCallback(int argCount, IntPtr argPointer)
        {
            fixed(WIN32.SERVICE_STATUS *service_statusRef = &this.status)
            {
                string[] state = null;
                if (argCount > 0)
                {
                    char **chPtr = (char **)argPointer.ToPointer();
                    state = new string[argCount - 1];
                    for (int i = 0; i < state.Length; i++)
                    {
                        chPtr++;
                        state[i] = Marshal.PtrToStringUni(*((IntPtr *)chPtr));
                    }
                }
                if (!this.initialized)
                {
                    this.isServiceHosted = true;
                    this.Initialize(true);
                }
                if (Environment.OSVersion.Version.Major >= 5)
                {
                    this.statusHandle = WIN32.RegisterServiceCtrlHandlerEx(this.ServiceName, this.commandCallbackEx, IntPtr.Zero);
                }
                else
                {
                    this.statusHandle = WIN32.RegisterServiceCtrlHandler(this.ServiceName, this.commandCallback);
                }
                this.nameFrozen = true;
                if (this.statusHandle == IntPtr.Zero)
                {
                    string message = new Win32Exception().Message;
                    this.WriteEventLogEntry(Res.GetString("StartFailed", new object[] { message }), EventLogEntryType.Error);
                }
                this.status.controlsAccepted = this.acceptedCommands;
                this.commandPropsFrozen      = true;
                if ((this.status.controlsAccepted & 1) != 0)
                {
                    this.status.controlsAccepted |= 4;
                }
                if (Environment.OSVersion.Version.Major < 5)
                {
                    this.status.controlsAccepted &= -65;
                }
                this.status.currentState = 2;
                if (WIN32.SetServiceStatus(this.statusHandle, service_statusRef))
                {
                    // Execute the startup work in a separate thread. Not exactly sure why, as
                    // we wait until it's fully complete before going on.
                    this.startCompletedSignal = new ManualResetEvent(false);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(this.ServiceQueuedMainCallback), state);
                    this.startCompletedSignal.WaitOne();

                    // Report our status
                    if (!WIN32.SetServiceStatus(this.statusHandle, service_statusRef))
                    {
                        this.WriteEventLogEntry(Res.GetString("StartFailed", new Win32Exception().Message), EventLogEntryType.Error);
                        this.status.currentState = 1;
                        WIN32.SetServiceStatus(this.statusHandle, service_statusRef);
                    }
                }
            }
        }
コード例 #22
0
 public void StartRemoteControl(ConsoleKey hotkey, WIN32.Win32API.RemoteControlHotkeyModifiers hotkeyModifiers)
 {
     if (IsVistaSp1OrHigher)
     {
         WIN32.NativeMethodsHelper.StartRemoteControl(_server.Handle, _sessionId, hotkey, hotkeyModifiers);
     }
     else
     {
         WIN32.NativeMethodsHelper.LegacyStartRemoteControl(_server.Handle, _sessionId, hotkey, hotkeyModifiers);
     }
 }
コード例 #23
0
        /// <summary>
        /// Overrided to controll del scrolling of the customControl VScrollBar1
        /// </summary>
        /// <param name="m"></param>
        /// <remarks></remarks>
        protected override void WndProc(ref Message m)
        {
            if (!this.DesignMode && !(!this.Parent.CanFocus | (_win == null)))
            {
                int  wndStyle  = WIN32.GetWindowLong(this._win.Handle, WIN32.GWL_STYLE);
                bool hsVisible = (wndStyle & WIN32.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & WIN32.WS_VSCROLL) != 0;

                //debug
                //Console.WriteLine("Visible ScrollBars: " + GetVisibleScrollbars(_win));
                //ShowScrollBar(this._win.Handle, (int)ScrollBarDirection.SB_HORZ, false /*false*/);


                //vertical
                if (true)// (vsVisible || hsVisible)
                {
                    int  iWParam = (int)m.WParam;
                    int  iLParam = (int)m.LParam;
                    uint sbCode  = WIN32.LoWord(m.WParam);

                    if (sbCode == WIN32.SB_THUMBTRACK || sbCode == WIN32.SB_THUMBPOSITION)
                    {
                        WIN32.ScrollInfo siv = new WIN32.ScrollInfo();
                        siv.cbSize = Marshal.SizeOf(siv);
                        siv.fMask  = (int)WIN32.ScrollInfoMask.SIF_ALL;
                        WIN32.ScrollInfo sih = siv;

                        uint nPos = WIN32.HiWord(m.WParam);


                        WIN32.GetScrollInfo(this._win.Handle, (int)WIN32.ScrollBarDirection.SB_VERT, ref siv);
                        WIN32.GetScrollInfo(this._win.Handle, (int)WIN32.ScrollBarDirection.SB_HORZ, ref sih);

                        if ((sih.nMax + 0) <= sih.nPage)
                        {
                            this.HScrollBar1.Visible = false;
                        }
                        else
                        {
                            this.HScrollBar1.Visible = true;
                            if (sih.nPage != 0)
                            {
                                this.HScrollBar1.Maximum     = (sih.nMax - sih.nPage) + 1;
                                this.HScrollBar1.Minimum     = sih.nMin;
                                this.HScrollBar1.Value       = sih.nPos;
                                this.HScrollBar1.LargeChange = (int)Math.Round((double)(((double)sih.nMax) / ((double)sih.nPage)));
                                this.HScrollBar1.SyncThumbPositionWithLogicalValue();
                            }
                        }

                        if (vsVisible)
                        {
                            if ((siv.nMax + 0) < siv.nPage)
                            {
                                this.VScrollBar1.Visible = false;
                            }
                            else
                            {
                                this.VScrollBar1.Visible = true;
                                if (siv.nPage != 0)
                                {
                                    this.VScrollBar1.Maximum     = (siv.nMax - siv.nPage) + 1;
                                    this.VScrollBar1.Minimum     = siv.nMin;
                                    this.VScrollBar1.Value       = siv.nPos;
                                    this.VScrollBar1.LargeChange = (int)Math.Round((double)(((double)siv.nMax) / ((double)siv.nPage)));
                                    this.VScrollBar1.SyncThumbPositionWithLogicalValue();
                                }
                            }
                        }
                    }
                }
            }
            base.WndProc(ref m);
        }
コード例 #24
0
        // Check in UpDown Is visible


        protected override void OnPaint(PaintEventArgs e)

        {
            base.OnPaint(e);
            DrawControl(e.Graphics);

            //firt load?
            if (bFirtsLoad == true)
            {
                FindUpDown();
                UpdateUpDown();
                bFirtsLoad = false;
            }

            //bool bIsVisibleUpDown = false;

            // Check in UpDown Is visible
            if (bUpDown)
            {
                if (WIN32.IsWindowVisible(scUpDown.Handle))
                {
                    //bIsVisibleUpDown = true;
                }
            }


            if (_allowCloseButton == true)
            {
                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FlatTabControl));
                Bitmap closeImage = ((System.Drawing.Bitmap)(resources.GetObject("CloseIcon.bmp")));

                closeImage.MakeTransparent(Color.White);

                if (Alignment == TabAlignment.Top)
                {
                    //if (bIsVisibleUpDown)
                    //{
                    //    m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 56, ClientRectangle.Y + 8, 14, 14);
                    //}
                    //else
                    //{
                    m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 18, ClientRectangle.Y + 8, 14, 14);
                    //}
                }
                else if (Alignment == TabAlignment.Right)
                {
                    m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 21, ClientRectangle.Y + ClientRectangle.Height - 18, 14, 14);
                }
                else if (Alignment == TabAlignment.Left)
                {
                    m_closeRect = new Rectangle(ClientRectangle.X + 8, ClientRectangle.Y + ClientRectangle.Height - 18, 14, 14);
                }
                else if (Alignment == TabAlignment.Bottom)
                {
                    //if (bIsVisibleUpDown)
                    //{
                    //    m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 56, ClientRectangle.Y + ClientRectangle.Height - 21, 14, 14);
                    //}
                    //else
                    //{
                    m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 18, ClientRectangle.Y + ClientRectangle.Height - 21, 14, 14);
                    //}
                }

                //paint border and backcolor of the button
                Rectangle closeBorder = m_closeRect;
                closeBorder.Inflate(3, 3);
                closeBorder.Width  -= 1;
                closeBorder.Height -= 1;
                e.Graphics.FillRectangle(new SolidBrush(_buttonsBackColour), closeBorder);
                e.Graphics.DrawRectangle(new Pen(_buttonsBorderColour), closeBorder);

                //paint the image
                e.Graphics.DrawImage(closeImage, m_closeRect);

                // e.Graphics.DrawRectangle(new Pen(Color.Red), m_closeRect);
            }
        }
コード例 #25
0
 public void MessageBox(string text, string caption, WIN32.Win32API.RemoteMessageBoxIcon icon)
 {
     MessageBox(text, caption, default(WIN32.Win32API.RemoteMessageBoxButtons), icon,
         default(WIN32.Win32API.RemoteMessageBoxDefaultButton),
                default(WIN32.Win32API.RemoteMessageBoxOptions), TimeSpan.Zero, false);
 }
コード例 #26
0
        internal void DrawIcons(Graphics g)
        {
            if ((leftRightImages == null) || (leftRightImages.Images.Count != 4))
            {
                return;
            }

            //----------------------------
            // calc positions
            Rectangle TabControlArea = this.ClientRectangle;

            Rectangle r0 = new Rectangle();

            WIN32.GetClientRect(scUpDown.Handle, ref r0);

            //paint backcolor
            Brush br = new SolidBrush(_buttonsBackColour);

            r0.Width = r0.Width - 1;
            g.FillRectangle(br, r0);
            br.Dispose();

            //paint border
            Pen       border  = new Pen(_buttonsBorderColour);
            Rectangle rborder = r0;

            rborder.Height = rborder.Height - 1;
            rborder.Width  = rborder.Width - 0;
            g.DrawRectangle(border, rborder);
            border.Dispose();



            int nMiddle = (r0.Width / 2);
            int nTop    = (r0.Height - 16) / 2;
            int nLeft   = (nMiddle - 16) / 2;

            Rectangle r1 = new Rectangle(nLeft, nTop, 16, 16);
            Rectangle r2 = new Rectangle(nMiddle + nLeft, nTop, 16, 16);
            //----------------------------

            //----------------------------
            // draw buttons
            Image img = leftRightImages.Images[1];

            if (img != null)
            {
                if (this.TabCount > 0)
                {
                    Rectangle r3 = this.GetTabRect(0);
                    if (r3.Left < TabControlArea.Left)
                    {
                        g.DrawImage(img, r1);
                    }
                    else
                    {
                        img = leftRightImages.Images[3];
                        if (img != null)
                        {
                            g.DrawImage(img, r1);
                        }
                    }
                }
            }

            img = leftRightImages.Images[0];
            if (img != null)
            {
                if (this.TabCount > 0)
                {
                    Rectangle r3 = this.GetTabRect(this.TabCount - 1);
                    if (r3.Right > (TabControlArea.Width - r0.Width))
                    {
                        g.DrawImage(img, r2);
                    }
                    else
                    {
                        img = leftRightImages.Images[2];
                        if (img != null)
                        {
                            g.DrawImage(img, r2);
                        }
                    }
                }
            }
            Invalidate();
            //----------------------------
        }
コード例 #27
0
 public WIN32.Win32API.RemoteMessageBoxResult MessageBox(string text, string caption, 
     WIN32.Win32API.RemoteMessageBoxButtons buttons,
     WIN32.Win32API.RemoteMessageBoxIcon icon, WIN32.Win32API.RemoteMessageBoxDefaultButton defaultButton,
     WIN32.Win32API.RemoteMessageBoxOptions options, TimeSpan timeout, bool synchronous)
 {
     var timeoutSeconds = (int) timeout.TotalSeconds;
     var style = (int) buttons | (int) icon | (int) defaultButton | (int) options;
     // TODO: Win 2003 Server doesn't start timeout counter until user moves mouse in session.
     var result = WIN32.NativeMethodsHelper.SendMessage(_server.Handle, _sessionId, caption, text, style,
                                                  timeoutSeconds, synchronous);
     // TODO: Windows Server 2008 R2 beta returns 0 if the timeout expires.
     // find out why this happens or file a bug report.
     return result == 0 ? WIN32.Win32API.RemoteMessageBoxResult.Timeout : result;
 }