Exemplo n.º 1
0
        private void InitializeComponent()
        {
            // TODO: iOS does not support dynamically loading assemblies
            // so we must refer to this resource DLL statically. For
            // now I am doing that here. But we need a better solution!!
            var theme = new Avalonia.Themes.Default.DefaultTheme();

            theme.TryGetResource("Button", out _);
            AvaloniaXamlLoader.Load(this);
            this.FindControl <Control>("TitleBar").PointerPressed += delegate
            {
                PlatformImpl?.BeginMoveDrag();
            };
            SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
            SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
            SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
            SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
            SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);
            this.FindControl <Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; };
            this.FindControl <Button>("MaximizeButton").Click += delegate
            {
                WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
            };
            this.FindControl <Button>("CloseButton").Click += delegate
            {
                Close();
            };
        }
Exemplo n.º 2
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            SetupWindowEdge(e, "PART_RightGrip", StandardCursorType.RightSide, WindowEdge.East);
            SetupWindowEdge(e, "PART_LeftGrip", StandardCursorType.LeftSide, WindowEdge.West);
            SetupWindowEdge(e, "PART_TopGrip", StandardCursorType.TopSide, WindowEdge.North);
            SetupWindowEdge(e, "PART_BottomGrip", StandardCursorType.BottomSize, WindowEdge.South);
            SetupWindowEdge(e, "PART_TopLeftGrip", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupWindowEdge(e, "PART_TopRightGrip", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupWindowEdge(e, "PART_BottomLeftGrip", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupWindowEdge(e, "PART_BottomRightGrip", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);

            GetControl <Border>(e, "PART_TitleBar").PointerPressed += delegate { PlatformImpl?.BeginMoveDrag(); };

            _closeButton        = GetControl <Button>(e, "PART_Close");
            _closeButton.Click += delegate { Close(); };

            var isNotModal = !IsModal;

            _minimizeButton           = GetControl <Button>(e, "PART_Minimize");
            _minimizeButton.IsVisible = isNotModal;
            _minimizeButton.Click    += delegate { WindowState = WindowState.Minimized; };

            _maximizeButton           = GetControl <Button>(e, "PART_Maximize");
            _maximizeButton.IsVisible = isNotModal;
            _maximizeButton.Click    += delegate { WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };

            _icon        = GetControl <Image>(e, "PART_Icon");
            _icon.Source = GetIcon(Icon);

            _isTemplateApplied = true;
        }
Exemplo n.º 3
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     this.FindControl <Control>("TitleBar").PointerPressed += delegate
     {
         PlatformImpl?.BeginMoveDrag();
     };
     SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
     SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
     SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
     SetupSide("Bottom", StandardCursorType.BottomSize, WindowEdge.South);
     SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
     SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
     SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
     SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);
     this.FindControl <Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; };
     this.FindControl <Button>("MaximizeButton").Click += delegate
     {
         WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
     };
     this.FindControl <Button>("CloseButton").Click += delegate
     {
         Close();
     };
 }
Exemplo n.º 4
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     this.FindControl <Control>("TitleBar").PointerPressed += (i, e) =>
     {
         PlatformImpl?.BeginMoveDrag(e);
     };
 }
Exemplo n.º 5
0
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
            TitleBarGrid   = this.FindControl <Grid>("TitleBarGrid");
            CloseGrid      = this.FindControl <Grid>("CloseGrid");
            CloseButton    = this.FindControl <Button>("CloseButton");
            ResizeGrid     = this.FindControl <Grid>("ResizeGrid");
            ResizeButton   = this.FindControl <Button>("ResizeButton");
            MinimizeGrid   = this.FindControl <Grid>("MinimizeGrid");
            MinimizeButton = this.FindControl <Button>("MinimizeButton");

            SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
            SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
            SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
            SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
            SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);

            TitleBarGrid.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e);

            CloseGrid.PointerEnter += CloseGrid_PointerEnter;
            CloseGrid.PointerLeave += CloseGrid_PointerLeave;

            ResizeGrid.PointerEnter += ResizeGrid_PointerEnter;
            ResizeGrid.PointerLeave += ResizeGrid_PointerLeave;

            MinimizeButton.PointerLeave += MinimizeButton_PointerLeave;
            MinimizeButton.PointerEnter += MinimizeButton_PointerEnter;

            CloseButton.Click    += CloseButton_Click;
            ResizeButton.Click   += ResizeButton_Click;
            MinimizeButton.Click += MinimizeButton_Click;

            PlatformImpl.WindowStateChanged = WindowStateChanged;

            var openBtn = this.FindControl <Button>("OpenSaveButton");

            openBtn.Click += OpenFileButton_Click;

            this.FindControl <Button>("SaveButton").Click += SaveButton_Click;

            playerPocketsGrid = new ItemGrid(40, 10, 4, 16);
            playerStorageGrid = new ItemGrid(5000, 50, 100, 16);

            var playersGrid = this.FindControl <StackPanel>("PocketsPanel");

            playersGrid.Children.Add(playerPocketsGrid);

            this.FindControl <ScrollViewer>("StorageScroller").Content = playerStorageGrid;

            openBtn.IsVisible = true;
            this.FindControl <TabControl>("EditorTabControl").IsVisible = false;
            this.FindControl <Grid>("BottomBar").IsVisible = false;
        }
Exemplo n.º 6
0
        public MainWindow(IWindowImpl impl) : base(impl)
        {
            AvaloniaXamlLoader.Load(this);
            this.AttachDevTools();

            Pager = this.FindControl <PageContainer>("Container");

            Pager.RegisterPages(HomePage, new AmbientSoundPage(), new FindMyGearPage(), new FactoryResetPage(),
                                new CreditsPage(), new TouchpadPage(), new EqualizerPage(), new AdvancedPage(), new NoiseProPage(),
                                new SystemPage(), new SelfTestPage(), new SettingsPage(), new PopupSettingsPage(),
                                ConnectionLostPage, CustomTouchActionPage, DeviceSelectionPage, new SystemInfoPage(),
                                new WelcomePage(), UnsupportedFeaturePage, UpdatePage, UpdateProgressPage, new SystemCoredumpPage(),
                                new HotkeyPage());

            _titleBar = this.FindControl <CustomTitleBar>("TitleBar");
            _titleBar.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e);
            _titleBar.OptionsPressed += (i, e) => _titleBar.OptionsButton.ContextMenu.Open(_titleBar.OptionsButton);

            _popup = new BudsPopup();

            BluetoothImpl.Instance.BluetoothError += OnBluetoothError;
            BluetoothImpl.Instance.Disconnected   += OnDisconnected;
            BluetoothImpl.Instance.Connected      += OnConnected;

            SPPMessageHandler.Instance.ExtendedStatusUpdate += OnExtendedStatusUpdate;
            SPPMessageHandler.Instance.StatusUpdate         += OnStatusUpdate;
            SPPMessageHandler.Instance.OtherOption          += HandleOtherTouchOption;

            EventDispatcher.Instance.EventReceived += OnEventReceived;
            NotifyIconImpl.Instance.LeftClicked    += TrayIcon_OnLeftClicked;
            TrayManager.Instance.Rebuild();

            Pager.PageSwitched  += (sender, pages) => BuildOptionsMenu();
            Loc.LanguageUpdated += BuildOptionsMenu;
            BuildOptionsMenu();

            if (BluetoothImpl.Instance.RegisteredDeviceValid)
            {
                Task.Factory.StartNew(() => BluetoothImpl.Instance.ConnectAsync());
                Pager.SwitchPage(AbstractPage.Pages.Home);
            }
            else
            {
                Pager.SwitchPage(AbstractPage.Pages.Welcome);
            }

            if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                if (desktop.Args.Contains("/StartMinimized") && PlatformUtils.SupportsTrayIcon)
                {
                    WindowState = WindowState.Minimized;
                }
            }
        }
Exemplo n.º 7
0
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

            this.FindControl <Button>("WidgetClose").Click += WidgetClose_OnClick;
            var titleBar = this.FindControl <DockPanel>("TitleBar");

            titleBar.PointerPressed += delegate
            {
                PlatformImpl?.BeginMoveDrag();
            };
        }
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     this.FindControl <Control>("TitleBar").PointerPressed += (i, e) => { PlatformImpl?.BeginMoveDrag(e); };
     SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
     SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
     SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
     SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
     SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
     SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
     SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
     SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);
 }
Exemplo n.º 9
0
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
            TitleBarGrid   = this.FindControl <Grid>("TitleBarGrid");
            CloseGrid      = this.FindControl <Grid>("CloseGrid");
            CloseButton    = this.FindControl <Button>("CloseButton");
            ResizeGrid     = this.FindControl <Grid>("ResizeGrid");
            ResizeButton   = this.FindControl <Button>("ResizeButton");
            MinimizeGrid   = this.FindControl <Grid>("MinimizeGrid");
            MinimizeButton = this.FindControl <Button>("MinimizeButton");

            SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
            SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
            SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
            SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
            SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);

            TitleBarGrid.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e);

            CloseGrid.PointerEnter += CloseGrid_PointerEnter;
            CloseGrid.PointerLeave += CloseGrid_PointerLeave;

            ResizeGrid.PointerEnter += ResizeGrid_PointerEnter;
            ResizeGrid.PointerLeave += ResizeGrid_PointerLeave;

            MinimizeButton.PointerLeave += MinimizeButton_PointerLeave;
            MinimizeButton.PointerEnter += MinimizeButton_PointerEnter;

            CloseButton.Click    += CloseButton_Click;
            ResizeButton.Click   += ResizeButton_Click;
            MinimizeButton.Click += MinimizeButton_Click;

            PlatformImpl.WindowStateChanged = WindowStateChanged;

            // Set up connections
            SetupPlayerTabConnections();

            var openBtn = this.FindControl <Button>("OpenSaveButton");

            openBtn.Click += OpenFileButton_Click;

            this.FindControl <Button>("SaveButton").Click += SaveButton_Click;

            openBtn.IsVisible = true;
            this.FindControl <TabControl>("EditorTabControl").IsVisible = false;
        }
Exemplo n.º 10
0
        public MainWindow()
        {
            AvaloniaXamlLoader.Load(this);
            this.AttachDevTools();

            // Weird OSX hack to hide decorations properly
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                SystemDecorations    = SystemDecorations.Full;
                HasSystemDecorations = false;
            }

            _titleBar = this.FindControl <CustomTitleBar>("TitleBar");
            _titleBar.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e);
            _titleBar.OptionsPressed += (i, e) =>
            {
                _titleBar.OptionsButton.ContextMenu?.Open(_titleBar.OptionsButton);
            };
            _titleBar.ClosePressed += (sender, args) => Close();

            BuildOptionsMenu();
        }
Exemplo n.º 11
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest, ref e);
            SetupSide("TopCenter", StandardCursorType.TopSide, WindowEdge.North, ref e);
            SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast, ref e);
            SetupSide("MiddleRight", StandardCursorType.RightSide, WindowEdge.East, ref e);
            SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast, ref e);
            SetupSide("BottomCenter", StandardCursorType.BottomSide, WindowEdge.South, ref e);
            SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest, ref e);
            SetupSide("MiddleLeft", StandardCursorType.LeftSide, WindowEdge.West, ref e);

            Border titlebar = GetControl <Border>(e, "PART_TitleBar");

            titlebar.PointerPressed += (sender, args) => PlatformImpl?.BeginMoveDrag(args);
            titlebar.DoubleTapped   += (sneder, args) =>
            {
                if (CanResize && (!IsModal))
                {
                    WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
                }
            };

            _closeButton        = GetControl <Button>(e, "PART_Close");
            _closeButton.Click += (object sender, RoutedEventArgs arg) => Close();

            var isNotModal = !IsModal;

            _minimizeButton           = GetControl <Button>(e, "PART_Minimize");
            _minimizeButton.IsVisible = isNotModal;
            _minimizeButton.Click    += (sneder, args) => WindowState = WindowState.Minimized;

            _maximizeButton           = GetControl <Button>(e, "PART_Maximize");
            _maximizeButton.IsVisible = isNotModal;
            _maximizeButton.Click    += (sneder, args) => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            _isTemplateApplied = true;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Starts moving a window with left button being held. Should be called from left mouse button press event handler
 /// </summary>
 public void BeginMoveDrag(PointerPressedEventArgs e) => PlatformImpl?.BeginMoveDrag(e);
Exemplo n.º 13
0
 /// <summary>
 /// Starts moving a window with left button being held. Should be called from left mouse button press event handler
 /// </summary>
 public void BeginMoveDrag() => PlatformImpl.BeginMoveDrag();
Exemplo n.º 14
0
        public MainWindow()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            TitleBarGrid   = this.FindControl <Grid>("TitleBarGrid");
            CloseGrid      = this.FindControl <Grid>("CloseGrid");
            CloseButton    = this.FindControl <Button>("CloseButton");
            ResizeGrid     = this.FindControl <Grid>("ResizeGrid");
            ResizeButton   = this.FindControl <Button>("ResizeButton");
            MinimizeGrid   = this.FindControl <Grid>("MinimizeGrid");
            MinimizeButton = this.FindControl <Button>("MinimizeButton");

            SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
            SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
            SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
            SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
            SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);

            TitleBarGrid.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e);

            CloseGrid.PointerEnter += CloseGrid_PointerEnter;
            CloseGrid.PointerLeave += CloseGrid_PointerLeave;

            ResizeGrid.PointerEnter += ResizeGrid_PointerEnter;
            ResizeGrid.PointerLeave += ResizeGrid_PointerLeave;

            MinimizeButton.PointerLeave += MinimizeButton_PointerLeave;
            MinimizeButton.PointerEnter += MinimizeButton_PointerEnter;

            CloseButton.Click    += CloseButton_Click;
            ResizeButton.Click   += ResizeButton_Click;
            MinimizeButton.Click += MinimizeButton_Click;

            PlatformImpl.WindowStateChanged = WindowStateChanged;

            var openBtn = this.FindControl <Button>("OpenSaveButton");
            openBtn.Click += OpenFileButton_Click;

            this.FindControl <Button>("SaveButton").Click += SaveButton_Click;

            playerPocketsGrid     = new ItemGrid(40, 10, 4, 16);
            playerStorageGrid     = new ItemGrid(5000, 50, 100, 16);
            villagerFurnitureGrid = new ItemGrid(16, 8, 2, 16)
            {
                HorizontalAlignment = HorizontalAlignment.Left
            };

            var playersGrid = this.FindControl <StackPanel>("PocketsPanel");
            playersGrid.Children.Add(playerPocketsGrid);

            this.FindControl <ScrollViewer>("StorageScroller").Content = playerStorageGrid;

            this.FindControl <StackPanel>("VillagerFurniturePanel").Children.Add(villagerFurnitureGrid);

            SetSelectedItemIndex();

            openBtn.IsVisible = true;
            this.FindControl <TabControl>("EditorTabControl").IsVisible = false;
            this.FindControl <Grid>("BottomBar").IsVisible = false;

            _singleton = this;
        }
Exemplo n.º 15
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            SetupWindowEdge(e, "PART_RightGrip", StandardCursorType.RightSide, WindowEdge.East);
            SetupWindowEdge(e, "PART_LeftGrip", StandardCursorType.LeftSide, WindowEdge.West);
            SetupWindowEdge(e, "PART_TopGrip", StandardCursorType.TopSide, WindowEdge.North);
            SetupWindowEdge(e, "PART_BottomGrip", StandardCursorType.BottomSide, WindowEdge.South);
            SetupWindowEdge(e, "PART_TopLeftGrip", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
            SetupWindowEdge(e, "PART_TopRightGrip", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
            SetupWindowEdge(e, "PART_BottomLeftGrip", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
            SetupWindowEdge(e, "PART_BottomRightGrip", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);

            GetControl <Border>(e, "PART_TitleBar").PointerPressed += (sender, args) => PlatformImpl?.BeginMoveDrag(args);

            _closeButton        = GetControl <Button>(e, "PART_Close");
            _closeButton.Click += (object sender, RoutedEventArgs arg) => Close();

            var isNotModal = !IsModal;

            _minimizeButton           = GetControl <Button>(e, "PART_Minimize");
            _minimizeButton.IsVisible = isNotModal;
            _minimizeButton.Click    += delegate { WindowState = WindowState.Minimized; };

            _maximizeButton           = GetControl <Button>(e, "PART_Maximize");
            _maximizeButton.IsVisible = isNotModal;
            _maximizeButton.Click    += delegate { WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };

            _icon = GetControl <Image>(e, "PART_Icon");
            if (Icon == null)
            {
                var uri    = new Uri(DEFAULT_ICON, UriKind.Absolute);
                var assets = AvaloniaLocator.Current.GetService <IAssetLoader>();
                using (var stream = assets.Open(uri))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    _icon.Source = new Bitmap(stream);
                }

                Icon = new WindowIcon(_icon.Source);
            }
            else
            {
                _icon.Source = GetIcon(Icon);
            }

            _isTemplateApplied = true;
        }