//@Construct /// <summary> /// Initializes the device-layout. /// </summary> public void ConstructDeviceLayout() { // Width DeviceLayout layout = this.Setting.DeviceLayout; { double width = Window.Current.Bounds.Width; DeviceLayoutType type = layout.GetActualType(width); this.DeviceLayoutType = type; } }
private void Window_SizeChanged(object sender, WindowSizeChangedEventArgs e) { this.WindowWidth = e.Size.Width; this.WindowHeight = e.Size.Height; DeviceLayout layout = this.Setting.DeviceLayout; { double width = e.Size.Width; DeviceLayoutType type = layout.GetActualType(width); this.DeviceLayoutType = type; } }
private async Task SetDeviceLayoutType(DeviceLayoutType type2, bool isAdaptive) { // Setting DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout; { layout.IsAdaptive = isAdaptive; layout.FallBackType = type2; DeviceLayoutType type = layout.GetActualType(this.ActualWidth); this.SettingViewModel.DeviceLayoutType = type; } await this.Save(); }
// DeviceLayout private void ConstructDeviceLayout() { DeviceLayout deviceLayout = this.SettingViewModel.Setting.DeviceLayout; // Type { DeviceLayoutType type = deviceLayout.FallBackType; bool isAdaptive = deviceLayout.IsAdaptive; this.PhoneButton.IsChecked = (isAdaptive == false && type == DeviceLayoutType.Phone); this.PadButton.IsChecked = (isAdaptive == false && type == DeviceLayoutType.Pad); this.PCButton.IsChecked = (isAdaptive == false && type == DeviceLayoutType.PC); this.AdaptiveButton.IsChecked = (isAdaptive); this.PhoneButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.Phone, false); this.PadButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.Pad, false); this.PCButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.PC, false); this.AdaptiveButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.PC, true); } // Adaptive { int phone = deviceLayout.PhoneMaxWidth; int pad = deviceLayout.PadMaxWidth; this.AdaptiveWidthGrid.PhoneWidth = phone; this.AdaptiveWidthGrid.PadWidth = pad; this.AdaptiveWidthGrid.SetWidth(); this.AdaptiveWidthGrid.ScrollModeChanged += (s, mode) => { this.ScrollViewer.HorizontalScrollMode = mode; this.ScrollViewer.VerticalScrollMode = mode; }; this.AdaptiveWidthGrid.PhoneWidthChanged += async(s, value) => { // Setting DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout; { layout.PhoneMaxWidth = value; DeviceLayoutType type = layout.GetActualType(this.ActualWidth); this.SettingViewModel.DeviceLayoutType = type; } await this.Save(); }; this.AdaptiveWidthGrid.PadWidthChanged += async(s, value) => { // Setting DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout; { layout.PadMaxWidth = value; DeviceLayoutType type = layout.GetActualType(this.ActualWidth); this.SettingViewModel.DeviceLayoutType = type; } await this.Save(); }; } this.ResetAdaptiveWidthButton.Click += async(s, e) => { DeviceLayout default2 = DeviceLayout.Default; int phone2 = default2.PhoneMaxWidth; int pad2 = default2.PadMaxWidth; this.AdaptiveWidthGrid.PhoneWidth = phone2; this.AdaptiveWidthGrid.PadWidth = pad2; this.AdaptiveWidthGrid.SetWidth(); // Setting DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout; { layout.PhoneMaxWidth = phone2; layout.PadMaxWidth = pad2; DeviceLayoutType type = layout.GetActualType(this.ActualWidth); this.SettingViewModel.DeviceLayoutType = type; } await this.Save(); }; }