예제 #1
0
        public Controller(Window window, string[] args)
            : base(window)
        {
            if (args.Length >= 2)
            {
                if (args[0] == "server")
                {
                    _netController = new Server(int.Parse(args[1]));
                }
                else if (args[0] == "client")
                {
                    var config = NetworkHelper.GetDefaultConfig();
                    config.Port = int.Parse(args[1]);

                    NetClient client = new NetClient(config);

                    var serverAddress = new IPEndPoint(new IPAddress(new byte[] { 127, 0, 0, 1 }), int.Parse(args[2]));

                    _netController = new Client(serverAddress, this, client);
                }
            }
            else
            {
                //_netController = new Client(111, 112, this);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: AyyTee/Aventyr
 static void Main(string[] args)
 {
     using (Window Window = new Window())
     {
         Window.controller = new Controller(Window);
         Window.Run(Controller.StepsPerSecond, Controller.DrawsPerSecond);
     }
 }
예제 #3
0
 public Controller(Window window)
     : this(window.ClientSize, window.InputExt)
 {
 }
예제 #4
0
파일: Game.cs 프로젝트: Zolniu/DigitalRune
        static void Main()
        {
            Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);

              // Main window
              _window = new Window();

              // Initialization routines
              Initialize();

              // Register game loop
              Application.Idle += GameLoop;

              // Show window, process messages
              Application.Run(_window);
        }
        public static void OnSet_Window_Resizable(Window self, bool newState)
        {
            var oldState = self.Resizable;
            if (newState != oldState)
            {
                if (newState)
                {
                    CurrentSelf = self;
                    CurrentWinMaxButton = new Button(self.Manager);
                    CurrentWinMaxButton.Skin = new SkinControl(self.Manager.Skin.Controls["Window.MaximizeButton"]);
                    CurrentWinMaxButton.Init();
                    CurrentWinMaxButton.Detached = true;
                    CurrentWinMaxButton.CanFocus = false;
                    CurrentWinMaxButton.Text = null;
                    CurrentWinMaxButton.Click += new Game.GUI.Controls.EventHandler((sender, args) =>
                    {
                        Rectangle initalPos;
                        if (!initialWindowPositions.TryGetValue(self.GetType(), out initalPos))
                        {
                            initalPos = initialWindowPositions[self.GetType()] = new Rectangle(self.Left, self.Top, self.Width, self.Height);
                        }

                        var isMax = true;
                        
                        if (((self.ResizeEdge & Anchors.Top) == Anchors.Top) || ((self.ResizeEdge & Anchors.Bottom) == Anchors.Bottom))
                        {
                            //var h = Math.Min(self.MaximumHeight, self.Manager.TargetHeight);
                            //var half_h = (self.Manager.TargetHeight / 2) - (Math.Min(self.MaximumHeight, self.Manager.TargetHeight) / 2);
                            var top = Math.Max(100, (int)(self.Manager.TargetHeight * 0.1f));
                            var bottom = Math.Max(60, (int)(self.Manager.TargetHeight * 0.09f));
                            var height = Math.Min(self.MaximumHeight, self.Manager.TargetHeight - top - bottom);
                            if ((self.Top != top) || (self.Height != height))
                            {
                                isMax = false;
                                self.Top = top;
                                self.Height = height;
                            }
                        }
                        if (((self.ResizeEdge & Anchors.Left) == Anchors.Left) || ((self.ResizeEdge & Anchors.Right) == Anchors.Right))
                        {
                            var w = Math.Min((int)(self.Manager.TargetWidth * 0.8f), self.MaximumWidth);
                            var left = (int)(self.Manager.TargetWidth * 0.1f);
                            if ((self.Left != left) || (self.Width != w))
                            {
                                self.Left = left;
                                self.Width = w;
                                isMax = false;
                            }
                        }

                        if (isMax)
                        {
                            self.Top = initalPos.Top;
                            self.Left = initalPos.Left;
                            self.Width = initalPos.Width;
                            self.Height = initalPos.Height;
                        }
                    });
                    var closeSkin = self.Manager.Skin.Controls["Window.MaximizeButton"];
                    SkinLayer skinLayer = closeSkin.Layers["Control"];
                    CurrentWinMaxButton.Width = skinLayer.Width;
                    CurrentWinMaxButton.Height = skinLayer.Height - closeSkin.OriginMargins.Vertical;
                    CurrentWinMaxButton.Left = self.OriginWidth - self.Skin.OriginMargins.Right - skinLayer.Width - closeSkin.OriginMargins.Horizontal + skinLayer.OffsetX - CurrentWinMaxButton.Width;
                    CurrentWinMaxButton.Top = self.Skin.OriginMargins.Top + skinLayer.OffsetY;
                    CurrentWinMaxButton.Anchor = (Anchors.Top | Anchors.Right);
                    self.Add(CurrentWinMaxButton, false);
                }
                else
                {
                    if (self == CurrentSelf)
                    {
                        self.Remove(CurrentWinMaxButton);
                        CurrentWinMaxButton = null;
                        CurrentSelf = null;
                    }
                }
            }
        }