Exemplo n.º 1
0
        static void Main()
        {
            bool isRunning = true;

            var windowParams = new WindowParameters
            {
                Title        = "Whatep!",
                Width        = 800,
                Height       = 600,
                IsBordered   = true,
                IsResizable  = true,
                IsFullscreen = false
            };

            using (var window = Window.Create(windowParams))
            {
                window.CloseRequested += (object sender, WindowCloseRequestedEventArgs e) => isRunning = false;
                Keyboard.OnKeyPressed += (Keys key) => { if (key == Keys.Escape)
                                                         {
                                                             isRunning = false;
                                                         }
                };

                var graphics = window.Graphics;
                graphics.IsVsyncEnabled = true;

                while (isRunning)
                {
                    window.PollEvents();
                    graphics.Clear(0, 0, 0, 0);
                    graphics.DrawFilledRectangle(100f, 200f, 100f, 100f, 1, 0, 0, 1);
                    graphics.SwapFramebuffer();
                }
            }
        }
        /// <summary>
        ///     Событие загрузки страницы
        /// </summary>
        /// <param name="sender">Объект страницы</param>
        /// <param name="e">Аргументы</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "no-cache";

            IsRememberWindowProperties = true;
            WindowParameters           = new WindowParameters("UserExtWndLeft", "UserExtWndTop", "UserExtWidth", "UserExtHeight");

            if (Entity != null)
            {
                BindFields();
            }

            // ToDo: Связь с 1С пока не реализована
            //if (Request.QueryString["buh1s"] != null)
            //{
            //    row1s.Visible = true;

            //    if (Request.QueryString["1s"] != null)
            //    {
            //        Kesco.Lib.Web.DataObjectModel.Env._1s.Sync_Справочник_Пользователи(int.Parse(Request.QueryString["buh1s"]), int.Parse(Request.QueryString["1s"]));
            //        Response.Redirect("http://ok.htm?id=" + Request.QueryString["1s"], true);
            //    }
            //}
            //Title = Kesco.Web.jScripts.ReadQueryParameter(Request, "title");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Going through all the elements and looking for those that need to be re-size
        /// and re-render
        /// </summary>
        private void CheckMeasureOrVisualInvalidate(WindowParameters wndParams)
        {
            if (wndParams?.Window == null || wndParams.Window.WasClosed)
            {
                return;
            }
            // 1-Check whether there is anything to re-size or re-render (run to the first
            // !IsMeasureValid or all trying to find at least one !IsVisualValid)
            var shouldRender  = false;
            var shouldMeasure = DetectMeasureInvalidate(wndParams.Window, ref shouldRender);

            // 2- If it needed re-size, call Measure and Arrange
            var previousWndSize = wndParams.Window.Bounds;

            if (shouldMeasure)
            {
                PrepareWindow(wndParams);
            }

            // 3- if it needed re-render, or re-size was called, call ReleaseDrawingContext
            if (shouldMeasure || shouldRender)
            {
                pseudographicsProvider.CursorVisible = false;
                var bufferForRender = new ScreenDrawingContext(wndParams.Window.Bounds);
                bufferForRender.Release(Color.NotSet, Color.NotSet);

                // Run on all controls and for those who have !IsVisualValid calling BeforeRender
                DetectVisualInvalidate(wndParams.Window, Point.Empty, bufferForRender);
                TransferToScreen(wndParams, bufferForRender, wndParams.Window.Bounds != previousWndSize);
                SetFocusableBehavior(wndParams);
            }
        }
        /// <summary>
        ///     Событие загрузки страницы
        /// </summary>
        /// <param name="sender">Объект страницы</param>
        /// <param name="e">Аргументы</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            btnSocketAdd.OnClick = "cmd('cmd','SocketAdd');";
            btnSocketAdd.Text    = Resx.GetString("Inv_lblAddSocket") + "&nbsp;(Ins)";

            IsRememberWindowProperties = true;
            WindowParameters           = new WindowParameters("InvLocSrchWndLeft", "InvLocSrchWndTop", "InvLocSrchWidth", "InvLocSrchHeight");
        }
Exemplo n.º 5
0
        private void TransferToScreen(WindowParameters windowParameters, ScreenDrawingContext bufferForRender, bool shouldBackgroundRender)
        {
            var targetBuffer = shouldBackgroundRender
                ? windowParameters.ParentContext.Merge(windowParameters.Window.Location, bufferForRender)
                : bufferForRender;
            var targetLocation = shouldBackgroundRender
                ? Point.Empty
                : windowParameters.Window.Location;

            var strBuilder = new StringBuilder(targetBuffer.ContextBounds.Width);
            var colorPoint = targetBuffer.GetColorPoint(0, 0);

            for (var row = 0; row < targetBuffer.ContextBounds.Height; row++)
            {
                strBuilder.Clear();

                pseudographicsProvider.SetCursorPosition(targetLocation.X, row + targetLocation.Y);
                for (var col = 0; col < targetBuffer.ContextBounds.Width; col++)
                {
                    var currentPoint = targetBuffer.GetColorPoint(col, row);
                    if (currentPoint == colorPoint)
                    {
                        strBuilder.Append(targetBuffer.Chars[col, row]);
                    }
                    else
                    {
                        if (strBuilder.Length > 0)
                        {
                            if (colorPoint.Background != Color.NotSet && colorPoint.Foreground != Color.NotSet)
                            {
                                pseudographicsProvider.BackgroundColor = colorPoint.Background;
                                pseudographicsProvider.ForegroundColor = colorPoint.Foreground;
                                pseudographicsProvider.Write(strBuilder.ToString());
                            }
                            else
                            {
                                pseudographicsProvider.SetCursorPosition(col + targetLocation.X, row + targetLocation.Y);
                            }
                            strBuilder.Clear();
                        }
                        colorPoint = currentPoint;
                        strBuilder.Append(targetBuffer.Chars[col, row]);
                    }
                }

                if (strBuilder.Length > 0)
                {
                    if (colorPoint.Background != Color.NotSet && colorPoint.Foreground != Color.NotSet)
                    {
                        pseudographicsProvider.BackgroundColor = colorPoint.Background;
                        pseudographicsProvider.ForegroundColor = colorPoint.Foreground;
                        pseudographicsProvider.Write(strBuilder.ToString());
                    }
                }
            }
            pseudographicsProvider.SetCursorPosition(0, 0);
            windowParameters.CurrentBuffer = bufferForRender;
        }
 /// <summary>
 /// Resizes buffers and target to a new parameters
 /// </summary>
 /// <param name="windowParameters">Window parameters</param>
 // FIX: ResizeTarget doesn't cleanup memory on switch sizes
 public void ResizeTarget(WindowParameters windowParameters)
 {
     GameWindow.Current.WindowParameters = windowParameters;
     IsRendererSuppressed = true;
     ReleaseDevices();
     InitializeDevices();
     Clock.Restart();
     IsRendererSuppressed = false;
 }
Exemplo n.º 7
0
        internal GLFWWindow(WindowParameters parameters)
        {
            GLFW.Init();
            GLFW.WindowHint(GLFW.CONTEXT_VERSION_MAJOR, 4);
            GLFW.WindowHint(GLFW.CONTEXT_VERSION_MINOR, 5);
            GLFW.WindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE);
            GLFW.WindowHint(GLFW.FOCUSED, GLFW.TRUE);
            GLFW.WindowHint(GLFW.FOCUS_ON_SHOW, GLFW.TRUE);
            GLFW.WindowHint(GLFW.DECORATED, parameters.IsBordered ? GLFW.TRUE : GLFW.FALSE);
            GLFW.WindowHint(GLFW.RESIZABLE, parameters.IsResizable ? GLFW.TRUE : GLFW.FALSE);

            IntPtr monitorPtr = parameters.IsFullscreen ? GLFW.GetPrimaryMonitor() : IntPtr.Zero;

            Handle = GLFW.CreateWindow(parameters.Width, parameters.Height, parameters.Title, monitorPtr, IntPtr.Zero);

            if (Handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Could not create Glfw window!");
            }

            _frameBufferWidth  = parameters.Width;
            _frameBufferHeight = parameters.Height;
            Width  = parameters.Width;
            Height = parameters.Height;

            // Must be called before creating our graphics object.
            GLFW.MakeContextCurrent(Handle);
            Graphics = new Graphics(this);

            _closeRequested = (IntPtr window) =>
            {
                PublishCloseRequestedEvent(new WindowCloseRequestedEventArgs());
            };

            _sizeChanged = (IntPtr window, int w, int h) =>
            {
                Width  = w;
                Height = h;
                PublishResizedEvent(new WindowResizedEventArgs(w, h));
            };

            _framebufferSizeChanged = (IntPtr window, int w, int h) =>
            {
                _frameBufferWidth  = w;
                _frameBufferHeight = h;
                PublishFramebufferSizeChangedEvent(new FramebufferSizeChangedEventArgs(w, h));
            };

            GLFW.SetWindowCloseCallback(Handle, Marshal.GetFunctionPointerForDelegate(_closeRequested));
            GLFW.SetWindowSizeCallback(Handle, Marshal.GetFunctionPointerForDelegate(_sizeChanged));
            GLFW.SetFramebufferSizeCallback(Handle, Marshal.GetFunctionPointerForDelegate(_framebufferSizeChanged));

            // TODO: Remove this. Eventually, Milk will have an InputDeviceManager.
            Keyboard.Init(Handle);
        }
        public void SaveState()
        {
            WindowParameters windowParameters = new WindowParameters()
            {
                Height = (int)ChildWindow.ChildWindow.Height,
                Width = (int)ChildWindow.ChildWindow.Width,
                X = (int)((TranslateTransform)ChildWindow.ChildWindow.RenderTransform).X,
                Y = (int)((TranslateTransform)ChildWindow.ChildWindow.RenderTransform).Y,
                IsVisible = ChildWindow.ChildWindow.IsVisible
            };

            windowParameters.Save(Path);
        }
Exemplo n.º 9
0
        private void SetFocusableBehavior(WindowParameters wndParams)
        {
            pseudographicsProvider.SetCursorPosition(0, 0);
            pseudographicsProvider.BackgroundColor = systemColors.WindowBackground;
            pseudographicsProvider.ForegroundColor = systemColors.WindowForeground;

            // Now we are looking for a control that the cursor will work for and put it there
            if (wndParams.Window?.FocusableControl is ICursorAdmit cursorControl &&
                wndParams.Window?.FocusableControl is Control control)
            {
                var cursorPosition = control.GetScreenLocation() + cursorControl.CursorPosition;
                pseudographicsProvider.SetCursorPosition(cursorPosition.X, cursorPosition.Y);
                pseudographicsProvider.CursorVisible = true;
            }
        }
        /// <summary>
        ///     Обработчик события загрузки страницы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Параметр события</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            IsRememberWindowProperties = true;
            WindowParameters           = new WindowParameters("InvTerWndLeft", "InvTerWndTop", "InvTerWndWidth", "InvTerWndHeight");
            IsSilverLight = false;

            tvTerritory.SetJsonData("TerritoryData.ashx");
            tvTerritory.SetDataSource("Инвентаризация.dbo.Территории", "vwТерритории", Config.DS_user, "КодТерритории", "Территория", "");

            tvTerritory.IsLoadData = true;
            tvTerritory.LoadData   = LoadTreeViewData;

            tvTerritory.IsOrderMenu = true;
            tvTerritory.RootVisible = true;
            tvTerritory.Resizable   = true;
            //tvTerritory.Dock = Lib.Web.Controls.V4.TreeView.TreeView.DockStyle.None;
            tvTerritory.IsSaveState = true;
            tvTerritory.ParamName   = "InvTerTreeState";
            tvTerritory.ClId        = ClId;

            tvTerritory.IsContextMenu     = true;
            tvTerritory.ContextMenuAdd    = true;
            tvTerritory.ContextMenuRename = true;
            tvTerritory.ContextMenuDelete = true;

            var loadById = 0;

            if (!Request.QueryString["id"].IsNullEmptyOrZero())
            {
                int.TryParse(Request.QueryString["id"], out loadById);
            }
            else if (!Request.QueryString["idloc"].IsNullEmptyOrZero())
            {
                int.TryParse(Request.QueryString["idloc"], out loadById);
            }
            if (loadById != 0)
            {
                tvTerritory.LoadById = loadById;
            }

            InitGridTerritory();
            LoadDataGridTerritory();
        }
Exemplo n.º 11
0
 /// <summary>
 /// Creates a new <see cref="WindowParameters"/> structure with exact properties values as passed into copy and sets new specified width and height
 /// </summary>
 /// <param name="windowParameters">Exists window parameters</param>
 /// <param name="newWidth">New window width in pixels</param>
 /// <param name="newHeight">New window height in pixels</param>
 public WindowParameters(WindowParameters windowParameters, int newWidth, int newHeight) : this(newWidth, newHeight, windowParameters.IsFullscreen, windowParameters.VSyncMode, windowParameters.Title)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates a new <see cref="WindowParameters"/> structure with exact properties values as passed into copy
 /// </summary>
 /// <param name="windowParameters">Exists window parameters</param>
 public WindowParameters(WindowParameters windowParameters) : this(windowParameters.Width, windowParameters.Height, windowParameters.IsFullscreen, windowParameters.VSyncMode, windowParameters.Title)
 {
 }