示例#1
0
		public ContentDecorator(ScrollViewer owner)
		{
			this.owner = owner;

			HorizontalAlignment = HorizontalAlignment.Center;
			VerticalAlignment = VerticalAlignment.Center;
		}
示例#2
0
        public void Offset_Should_Be_Coerced_To_Viewport()
        {
            var target = new ScrollViewer();
            target.SetValue(ScrollViewer.ExtentProperty, new Size(20, 20));
            target.SetValue(ScrollViewer.ViewportProperty, new Size(10, 10));
            target.Offset = new Vector(12, 12);

            Assert.Equal(new Vector(10, 10), target.Offset);
        }
示例#3
0
        public void Content_Is_Created()
        {
            var target = new ScrollViewer
            {
                Template = new FuncControlTemplate<ScrollViewer>(CreateTemplate),
                Content = "Foo",
            };

            target.ApplyTemplate();
            ((ContentPresenter)target.Presenter).UpdateChild();

            Assert.IsType<TextBlock>(target.Presenter.Child);
        }
示例#4
0
 private Control CreateTemplate(ScrollViewer control)
 {
     return new Grid
     {
         ColumnDefinitions = new ColumnDefinitions
         {
             new ColumnDefinition(1, GridUnitType.Star),
             new ColumnDefinition(GridLength.Auto),
         },
         RowDefinitions = new RowDefinitions
         {
             new RowDefinition(1, GridUnitType.Star),
             new RowDefinition(GridLength.Auto),
         },
         Children = new Controls
         {
             new ScrollContentPresenter
             {
                 Name = "PART_ContentPresenter",
                 [~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
                 [~~ScrollContentPresenter.ExtentProperty] = control[~~ScrollViewer.ExtentProperty],
                 [~~ScrollContentPresenter.OffsetProperty] = control[~~ScrollViewer.OffsetProperty],
                 [~~ScrollContentPresenter.ViewportProperty] = control[~~ScrollViewer.ViewportProperty],
                 [~ScrollContentPresenter.CanScrollHorizontallyProperty] = control[~ScrollViewer.CanScrollHorizontallyProperty],
             },
             new ScrollBar
             {
                 Name = "horizontalScrollBar",
                 Orientation = Orientation.Horizontal,
                 [~RangeBase.MaximumProperty] = control[~ScrollViewer.HorizontalScrollBarMaximumProperty],
                 [~~RangeBase.ValueProperty] = control[~~ScrollViewer.HorizontalScrollBarValueProperty],
                 [~ScrollBar.ViewportSizeProperty] = control[~ScrollViewer.HorizontalScrollBarViewportSizeProperty],
                 [~ScrollBar.VisibilityProperty] = control[~ScrollViewer.HorizontalScrollBarVisibilityProperty],
                 [Grid.RowProperty] = 1,
             },
             new ScrollBar
             {
                 Name = "verticalScrollBar",
                 Orientation = Orientation.Vertical,
                 [~RangeBase.MaximumProperty] = control[~ScrollViewer.VerticalScrollBarMaximumProperty],
                 [~~RangeBase.ValueProperty] = control[~~ScrollViewer.VerticalScrollBarValueProperty],
                 [~ScrollBar.ViewportSizeProperty] = control[~ScrollViewer.VerticalScrollBarViewportSizeProperty],
                 [~ScrollBar.VisibilityProperty] = control[~ScrollViewer.VerticalScrollBarVisibilityProperty],
                 [Grid.ColumnProperty] = 1,
             },
         },
     };
 }
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var sprites = Content.Load<SpriteSheet>("UIImages");

            var img1 = new ImageElement { Name = "UV 1 stack panel", Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };
            var img2 = new ImageElement { Name = "UV 2 stack panel", Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };
            img3 = new ImageElement { Name = "UV 3 stack panel", Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };

            stackPanel = new StackPanel { Orientation = Orientation.Vertical };
            stackPanel.Children.Add(img1);
            stackPanel.Children.Add(img2);
            stackPanel.Children.Add(img3);

            var img4 = new ImageElement { Name = "UV grid", Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };
            var img5 = new ImageElement { Name = "UV grid 2", Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };
            var img6 = new ImageElement { Name = "Game screen grid", Source = SpriteFromSheet.Create(sprites, "GameScreen") };

            img4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            img4.DependencyProperties.Set(GridBase.RowPropertyKey, 0);
            img5.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            img5.DependencyProperties.Set(GridBase.RowPropertyKey, 0);
            img6.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            img6.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            img6.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);

            grid = new UniformGrid { Columns = 2, Rows = 2 };
            grid.Children.Add(img4);
            grid.Children.Add(img5);
            grid.Children.Add(img6);

            scrollViewer = new ScrollViewer { Content = grid, ScrollMode = ScrollingMode.HorizontalVertical};

            contentDecorator = new ContentDecorator { Content = scrollViewer };

            UIComponent.Page = new Engine.UIPage { RootElement = contentDecorator };
        }
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var random = new Random(0);

            var sprites = Content.Load<SpriteSheet>("UIImages");
            var img1 = new ImageElement { Source = (SpriteFromTexture)new Sprite(Content.Load<Texture>("uv")) };
            var img2 = new ImageElement { Source = SpriteFromSheet.Create(sprites, "GameScreenLeft") };
            var img3 = new ImageElement { Source = SpriteFromSheet.Create(sprites, "GameScreenRight") };

            stackPanel1 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            stackPanel1.Children.Add(img1);
            stackPanel1.Children.Add(img2);
            stackPanel1.Children.Add(img3);

            stackPanel2 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (var i = 0; i < 1000; i++)
                stackPanel2.Children.Add(CreateButton("" + i, 75, "button number " + i));

            stackPanel3 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true, VerticalAlignment = VerticalAlignment.Center };
            for (var i = 0; i < 103; i++)
                stackPanel3.Children.Add(CreateButton("" + i, 50 + 500 * random.NextFloat(), "random button number " + i));

            stackPanel4 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (var i = 0; i < 5; i++)
                stackPanel4.Children.Add(CreateButton("" + i, i * 30, "random button number "));

            currentStackPanel = stackPanel1;

            scrollViewer = new ScrollViewer { Name = "sv", Content = currentStackPanel, ScrollMode = ScrollingMode.Vertical };

            UIComponent.Page = new Engine.UIPage { RootElement = scrollViewer };
        }
        private ItemsRepeater SetupRepeater(object dataSource, VirtualizingLayout layout, string itemContent, out ScrollViewer scrollViewer)
        {
            ItemsRepeater repeater = null;
            ScrollViewer  sv       = null;

            RunOnUIThread.Execute(() =>
            {
                var elementFactory               = new RecyclingElementFactory();
                elementFactory.RecyclePool       = new RecyclePool();
                elementFactory.Templates["Item"] = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> " + itemContent + @"</DataTemplate>");

                repeater = new ItemsRepeater()
                {
                    ItemsSource = dataSource,
#if BUILD_WINDOWS
                    ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                    ItemTemplate = elementFactory,
#endif
                    Layout = layout,
                    HorizontalCacheLength = 0.0,
                    VerticalCacheLength   = 0.0
                };

                sv = new ScrollViewer
                {
                    Content = repeater
                };

                Content = new ItemsRepeaterScrollHost()
                {
                    Width        = 200,
                    Height       = 200,
                    ScrollViewer = sv
                };
            });

            IdleSynchronizer.Wait();
            scrollViewer = sv;
            return(repeater);
        }
 private void InitializeComponent()
 {
     // e_0 element
     this.e_0 = new Grid();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     this.e_0.Height = 640F;
     this.e_0.Width = 800F;
     this.e_0.HorizontalAlignment = HorizontalAlignment.Center;
     RowDefinition row_e_0_0 = new RowDefinition();
     row_e_0_0.Height = new GridLength(1F, GridUnitType.Auto);
     this.e_0.RowDefinitions.Add(row_e_0_0);
     RowDefinition row_e_0_1 = new RowDefinition();
     row_e_0_1.Height = new GridLength(1F, GridUnitType.Star);
     this.e_0.RowDefinitions.Add(row_e_0_1);
     // e_1 element
     this.e_1 = new TextBlock();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Width = float.NaN;
     this.e_1.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_1.VerticalAlignment = VerticalAlignment.Center;
     this.e_1.Text = "Controls";
     this.e_1.TextAlignment = TextAlignment.Center;
     this.e_1.FontSize = 40F;
     this.e_1.FontStyle = FontStyle.Bold;
     // e_2 element
     this.e_2 = new Button();
     this.e_0.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.Height = 80F;
     this.e_2.Width = 165F;
     this.e_2.HorizontalAlignment = HorizontalAlignment.Left;
     this.e_2.VerticalAlignment = VerticalAlignment.Center;
     this.e_2.TabIndex = 0;
     this.e_2.FontSize = 20F;
     this.e_2.FontStyle = FontStyle.Bold;
     this.e_2.Content = "Back";
     this.e_2.CommandParameter = "Options";
     Binding binding_e_2_Command = new Binding("ButtonCommand");
     this.e_2.SetBinding(Button.CommandProperty, binding_e_2_Command);
     // e_3 element
     this.e_3 = new ScrollViewer();
     this.e_0.Children.Add(this.e_3);
     this.e_3.Name = "e_3";
     Grid.SetRow(this.e_3, 1);
     // e_4 element
     this.e_4 = new TextBlock();
     this.e_3.Content = this.e_4;
     this.e_4.Name = "e_4";
     this.e_4.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_4.Padding = new Thickness(20F, 20F, 20F, 20F);
     this.e_4.TextAlignment = TextAlignment.Center;
     this.e_4.FontSize = 40F;
     this.e_4.FontStyle = FontStyle.Bold;
     Binding binding_e_4_Text = new Binding("ControlsText");
     this.e_4.SetBinding(TextBlock.TextProperty, binding_e_4_Text);
     FontManager.Instance.AddFont("Segoe UI", 40F, FontStyle.Bold, "Segoe_UI_30_Bold");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
 }
示例#9
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.m_totalUploadProgressGrid            = GetTemplateChild(TotalUploadProgressGridName) as Grid;
            this.m_totalUploadProgressGrid.Visibility = this.IsShowTotalUploadProgress ? Visibility.Visible : Visibility.Collapsed;
            this.m_totalCountTextBlock = GetTemplateChild(TotalCountBlockName) as TextBlock;
            string a = Resource.ResUploader.ResourceManager.GetString("Uploader_TotalCount");

            this.m_totalCountTextBlock.Text           = string.Format(ResUploader.Uploader_TotalCount, 0);
            this.m_totalSizeTextBlock                 = GetTemplateChild(TotalSizeTextBlockName) as TextBlock;
            this.m_totalSizeTextBlock.Text            = ResUploader.Uploader_TotalSize;
            this.m_timeLeftTextBlock                  = GetTemplateChild(TimeLeftTextBlockName) as TextBlock;
            this.m_fileListItemsControl               = GetTemplateChild(FileListItemsControlName) as ItemsControl;
            this.m_uploadProgressBar                  = GetTemplateChild(UploadProgressBarName) as ProgressBar;
            this.m_addFilesButton                     = GetTemplateChild(AddFilesButtonName) as Button;
            this.m_addFilesButton.Content             = ResUploader.Uploader_Browse;
            this.m_clearFilesButton                   = GetTemplateChild(ClearFilesButtonName) as Button;
            this.m_clearFilesButton.Content           = ResUploader.Uploader_ClearFiles;
            this.m_uploadFilesButton                  = GetTemplateChild(UploadFilesButtonName) as Button;
            this.m_uploadFilesButton.Content          = ResUploader.Uploader_UploadFiles;
            this.m_displayThumbailCheckBox            = GetTemplateChild(DisplayThumbailCheckBoxName) as CheckBox;
            this.m_displayThumbailCheckBox.Visibility = this.AllowThumbnail ? Visibility.Visible : Visibility.Collapsed;
            this.m_displayThumbailCheckBox.IsChecked  = this.DisplayThumbnails;
            this.m_displayThumbailCheckBox.Content    = ResUploader.Uploader_DisplayThumbnails;
            this.m_borderBackground                   = GetTemplateChild(BorderBackgroundName) as Border;

            this.m_filesScrollViewer = GetTemplateChild(FilesScrollViewerName) as ScrollViewer;

            string tip = string.Empty;

            if (MultiUpload)
            {
                tip = string.Format(ResUploader.Uploader_TipsInfo, this.MaximumUploadSize, this.MaximumTotalUploadSize);
            }
            else
            {
                tip = string.Format(ResUploader.Uploader_SingleFileTipsInfo, this.MaximumUploadSize);
            }
            ToolTipService.SetToolTip(this.m_addFilesButton, tip);

            if (this.m_addFilesButton != null)
            {
                this.m_addFilesButton.Click += new RoutedEventHandler(m_addFilesButton_Click);
            }
            if (this.m_clearFilesButton != null)
            {
                this.m_clearFilesButton.Click += new RoutedEventHandler(m_clearFilesButton_Click);
            }
            if (this.m_uploadFilesButton != null)
            {
                this.m_uploadFilesButton.Click += new RoutedEventHandler(m_uploadFilesButton_Click);
            }
            if (this.m_displayThumbailCheckBox != null)
            {
                this.m_displayThumbailCheckBox.Checked   += new RoutedEventHandler(m_displayThumbailCheckBox_Checked);
                this.m_displayThumbailCheckBox.Unchecked += new RoutedEventHandler(m_displayThumbailCheckBox_Checked);
            }
            if (!MultiUpload)
            {
                this.m_clearFilesButton.Visibility        = Visibility.Collapsed;
                this.m_displayThumbailCheckBox.IsChecked  = false;
                this.m_displayThumbailCheckBox.Visibility = Visibility.Collapsed;
                this.m_clearFilesButton.Visibility        = Visibility.Collapsed;
                //this.m_filesScrollViewer.VerticalAlignment = VerticalAlignment.Top;
                this.m_filesScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                this.m_borderBackground.VerticalAlignment = VerticalAlignment.Top;
                this.m_borderBackground.Height            = 23d;
                this.m_borderBackground.Margin            = new Thickness(0, 1, 0, 0);

                Grid.SetRow(this.m_uploadFilesButton, 0);
                Grid.SetColumn(this.m_uploadFilesButton, 2);
                this.m_addFilesButton.Margin    = new Thickness(10, 1, 0, 0);
                this.m_uploadFilesButton.Margin = new Thickness(10, 1, 0, 0);
                this.MinHeight = 32;
                this.m_filesScrollViewer.MinHeight = 34;
                this.Height = Double.NaN;
            }
            Loaded += new RoutedEventHandler(FileUploadControl_Loaded);
        }
        public void ValidateElementClearingOrderFromFlowLayout()
        {
            ItemsSourceView dataSource = null;

            RunOnUIThread.Execute(() => dataSource = new ItemsSourceView(Enumerable.Range(0, 15).ToList()));
            ScrollViewer scrollViewer     = null;
            var          repeater         = SetupRepeater(dataSource, null /*layout*/, out scrollViewer);
            List <int>   clearedIndices   = new List <int>();
            var          viewChangedEvent = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                scrollViewer.ViewChanged += (sender, args) =>
                {
                    if (!args.IsIntermediate)
                    {
                        viewChangedEvent.Set();
                    }
                };

                repeater.Layout           = new StackLayout();
                repeater.ElementPrepared += (sender, args) =>
                {
                    ((FrameworkElement)args.Element).Height = 20;
                };
                repeater.UpdateLayout();

                repeater.ElementClearing += (sender, args) =>
                {
                    int index = repeater.GetElementIndex(args.Element);
                    Log.Comment("Clearing.." + index);
                    clearedIndices.Add(index);
                };

                scrollViewer.ChangeView(null, 100.0, null, disableAnimation: true);
            });

            Verify.IsTrue(viewChangedEvent.WaitOne(DefaultWaitTime), "Waiting for ViewChanged.");
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                // Validate order is 0, 1, 2, 3
                for (int i = 0; i < 4; i++)
                {
                    Verify.AreEqual(i, clearedIndices[i]);
                }

                clearedIndices.Clear();
                viewChangedEvent.Reset();
                scrollViewer.ChangeView(null, 0.0, null, disableAnimation: true);
            });

            Verify.IsTrue(viewChangedEvent.WaitOne(DefaultWaitTime), "Waiting for ViewChanged.");
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                // Validate order is backwards 14, 13, 12, 11
                for (int i = 0; i < 4; i++)
                {
                    Verify.AreEqual(14 - i, clearedIndices[i]);
                }
            });
        }
示例#11
0
 /// <summary>
 /// Scrolls to the specified offset using an animation instead of
 /// immediately jumping to that offset as with ScrollToVerticalOffset().
 /// </summary>
 /// <remarks>
 /// Note that calling ScrollToVerticalOffset() does not update VerticalOffset immediately,
 /// so it is important to wait for it to change before calling this method.
 /// </remarks>
 /// <param name="scrollViewer"></param>
 /// <param name="offset"></param>
 /// <returns></returns>
 public static void ScrollToVerticalOffsetAnimation(
     this ScrollViewer scrollViewer,
     double offset)
 {
     scrollViewer.ScrollToVerticalOffsetAnimation(offset, DefaultAnimatedScrollDuration);
 }
示例#12
0
 private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_151_Items() {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // tabAllConst element
     TabItem tabAllConst = new TabItem();
     tabAllConst.Name = "tabAllConst";
     tabAllConst.Header = "All Constructions";
     // e_152 element
     ScrollViewer e_152 = new ScrollViewer();
     tabAllConst.Content = e_152;
     e_152.Name = "e_152";
     Binding binding_e_152_IsEnabled = new Binding("IsUIEnabled");
     e_152.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_152_IsEnabled);
     // e_153 element
     Grid e_153 = new Grid();
     e_152.Content = e_153;
     e_153.Name = "e_153";
     ColumnDefinition col_e_153_0 = new ColumnDefinition();
     e_153.ColumnDefinitions.Add(col_e_153_0);
     ColumnDefinition col_e_153_1 = new ColumnDefinition();
     e_153.ColumnDefinitions.Add(col_e_153_1);
     Binding binding_e_153_DataContext = new Binding("PlanetBuildingsData");
     e_153.SetBinding(Grid.DataContextProperty, binding_e_153_DataContext);
     items.Add(tabAllConst);
     // tabUnusedRes element
     TabItem tabUnusedRes = new TabItem();
     tabUnusedRes.Name = "tabUnusedRes";
     tabUnusedRes.Header = "Unused Resources";
     // e_154 element
     ScrollViewer e_154 = new ScrollViewer();
     tabUnusedRes.Content = e_154;
     e_154.Name = "e_154";
     Binding binding_e_154_IsEnabled = new Binding("IsUIEnabled");
     e_154.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_154_IsEnabled);
     // e_155 element
     Grid e_155 = new Grid();
     e_154.Content = e_155;
     e_155.Name = "e_155";
     ColumnDefinition col_e_155_0 = new ColumnDefinition();
     e_155.ColumnDefinitions.Add(col_e_155_0);
     ColumnDefinition col_e_155_1 = new ColumnDefinition();
     e_155.ColumnDefinitions.Add(col_e_155_1);
     Binding binding_e_155_DataContext = new Binding("PlanetBuildingsData");
     e_155.SetBinding(Grid.DataContextProperty, binding_e_155_DataContext);
     // e_156 element
     ListBox e_156 = new ListBox();
     e_155.Children.Add(e_156);
     e_156.Name = "e_156";
     ToolTipService.SetInitialShowDelay(e_156, 0);
     Grid.SetColumn(e_156, 0);
     ScrollViewer.SetCanContentScroll(e_156, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_156, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_156, ScrollBarVisibility.Hidden);
     Binding binding_e_156_IsEnabled = new Binding("IsUIEnabled");
     e_156.SetBinding(ListBox.IsEnabledProperty, binding_e_156_IsEnabled);
     Binding binding_e_156_ItemsSource = new Binding("UnusedResourceIcons");
     e_156.SetBinding(ListBox.ItemsSourceProperty, binding_e_156_ItemsSource);
     Binding binding_e_156_SelectedIndex = new Binding("SelectedUnusedResource");
     e_156.SetBinding(ListBox.SelectedIndexProperty, binding_e_156_SelectedIndex);
     // e_157 element
     ListBox e_157 = new ListBox();
     e_155.Children.Add(e_157);
     e_157.Name = "e_157";
     ToolTipService.SetInitialShowDelay(e_157, 0);
     Grid.SetColumn(e_157, 1);
     ScrollViewer.SetCanContentScroll(e_157, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_157, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_157, ScrollBarVisibility.Hidden);
     Binding binding_e_157_IsEnabled = new Binding("IsUIEnabled");
     e_157.SetBinding(ListBox.IsEnabledProperty, binding_e_157_IsEnabled);
     Binding binding_e_157_ItemsSource = new Binding("UnusedResourceNames");
     e_157.SetBinding(ListBox.ItemsSourceProperty, binding_e_157_ItemsSource);
     Binding binding_e_157_SelectedIndex = new Binding("SelectedUnusedResource");
     e_157.SetBinding(ListBox.SelectedIndexProperty, binding_e_157_SelectedIndex);
     items.Add(tabUnusedRes);
     return items;
 }
示例#13
0
        private void BuildUI()
        {
            _menuFileNew              = new MenuItem();
            _menuFileNew.Text         = "&New";
            _menuFileNew.ShortcutText = "Ctrl+N";
            _menuFileNew.Id           = "_menuFileNew";

            _menuFileOpen              = new MenuItem();
            _menuFileOpen.Text         = "&Open";
            _menuFileOpen.ShortcutText = "Ctrl+O";
            _menuFileOpen.Id           = "_menuFileOpen";

            _menuFileReload              = new MenuItem();
            _menuFileReload.Text         = "&Reload";
            _menuFileReload.ShortcutText = "Ctrl+R";
            _menuFileReload.Id           = "_menuFileReload";

            _menuFileSave              = new MenuItem();
            _menuFileSave.Text         = "&Save";
            _menuFileSave.ShortcutText = "Ctrl+S";
            _menuFileSave.Id           = "_menuFileSave";

            _menuFileSaveAs      = new MenuItem();
            _menuFileSaveAs.Text = "Save &As...";
            _menuFileSaveAs.Id   = "_menuFileSaveAs";

            _menuFileExportToCS              = new MenuItem();
            _menuFileExportToCS.Text         = "&Export To C#...";
            _menuFileExportToCS.ShortcutText = "Ctrl+E";
            _menuFileExportToCS.Id           = "_menuFileExportToCS";

            var menuSeparator1 = new MenuSeparator();

            _menuFileLoadStylesheet      = new MenuItem();
            _menuFileLoadStylesheet.Text = "&Load Stylesheet";
            _menuFileLoadStylesheet.Id   = "_menuFileLoadStylesheet";

            _menuFileResetStylesheet      = new MenuItem();
            _menuFileResetStylesheet.Text = "Rese&t Stylesheet";
            _menuFileResetStylesheet.Id   = "_menuFileResetStylesheet";

            var menuSeparator2 = new MenuSeparator();

            _menuFileDebugOptions      = new MenuItem();
            _menuFileDebugOptions.Text = "&UI Debug Options";
            _menuFileDebugOptions.Id   = "_menuFileDebugOptions";

            var menuSeparator3 = new MenuSeparator();

            _menuFileQuit              = new MenuItem();
            _menuFileQuit.Text         = "&Quit";
            _menuFileQuit.ShortcutText = "Ctrl+Q";
            _menuFileQuit.Id           = "_menuFileQuit";

            _menuFile      = new MenuItem();
            _menuFile.Text = "&File";
            _menuFile.Id   = "_menuFile";
            _menuFile.Items.Add(_menuFileNew);
            _menuFile.Items.Add(_menuFileOpen);
            _menuFile.Items.Add(_menuFileReload);
            _menuFile.Items.Add(_menuFileSave);
            _menuFile.Items.Add(_menuFileSaveAs);
            _menuFile.Items.Add(_menuFileExportToCS);
            _menuFile.Items.Add(menuSeparator1);
            _menuFile.Items.Add(_menuFileLoadStylesheet);
            _menuFile.Items.Add(_menuFileResetStylesheet);
            _menuFile.Items.Add(menuSeparator2);
            _menuFile.Items.Add(_menuFileDebugOptions);
            _menuFile.Items.Add(menuSeparator3);
            _menuFile.Items.Add(_menuFileQuit);

            _menuItemSelectAll              = new MenuItem();
            _menuItemSelectAll.Text         = "Select &All";
            _menuItemSelectAll.ShortcutText = "Ctrl+A";
            _menuItemSelectAll.Id           = "_menuItemSelectAll";

            _menuItemCopy              = new MenuItem();
            _menuItemCopy.Text         = "&Copy";
            _menuItemCopy.ShortcutText = "Ctrl+Insert, Ctrl+C";
            _menuItemCopy.Id           = "_menuItemCopy";

            _menuItemPaste              = new MenuItem();
            _menuItemPaste.Text         = "&Paste";
            _menuItemPaste.ShortcutText = "Shift+Insert, Ctrl+V";
            _menuItemPaste.Id           = "_menuItemPaste";

            _menuItemCut              = new MenuItem();
            _menuItemCut.Text         = "Cu&t";
            _menuItemCut.ShortcutText = "Ctrl+X";
            _menuItemCut.Id           = "_menuItemCut";

            _menuItemDuplicate              = new MenuItem();
            _menuItemDuplicate.Text         = "Duplicate";
            _menuItemDuplicate.ShortcutText = "Ctrl+D";
            _menuItemDuplicate.Id           = "_menuItemDuplicate";

            var menuSeparator4 = new MenuSeparator();

            _menuEditFormatSource              = new MenuItem();
            _menuEditFormatSource.Text         = "&Format Source";
            _menuEditFormatSource.ShortcutText = "Ctrl+F";
            _menuEditFormatSource.Id           = "_menuEditFormatSource";

            var menuItem1 = new MenuItem();

            menuItem1.Text = "&Edit";
            menuItem1.Items.Add(_menuItemSelectAll);
            menuItem1.Items.Add(_menuItemCopy);
            menuItem1.Items.Add(_menuItemPaste);
            menuItem1.Items.Add(_menuItemCut);
            menuItem1.Items.Add(_menuItemDuplicate);
            menuItem1.Items.Add(menuSeparator4);
            menuItem1.Items.Add(_menuEditFormatSource);

            _menuHelpAbout      = new MenuItem();
            _menuHelpAbout.Text = "&About";
            _menuHelpAbout.Id   = "_menuHelpAbout";

            var menuItem2 = new MenuItem();

            menuItem2.Text = "&Help";
            menuItem2.Items.Add(_menuHelpAbout);

            _mainMenu    = new HorizontalMenu();
            _mainMenu.Id = "_mainMenu";
            _mainMenu.Items.Add(_menuFile);
            _mainMenu.Items.Add(menuItem1);
            _mainMenu.Items.Add(menuItem2);

            _projectHolder    = new Panel();
            _projectHolder.Id = "_projectHolder";

            _textSource                   = new TextBox();
            _textSource.Multiline         = true;
            _textSource.Wrap              = true;
            _textSource.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _textSource.GridRow           = 2;
            _textSource.Id                = "_textSource";

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _textSource;

            _leftSplitPane    = new VerticalSplitPane();
            _leftSplitPane.Id = "_leftSplitPane";
            _leftSplitPane.Widgets.Add(_projectHolder);
            _leftSplitPane.Widgets.Add(scrollViewer1);

            var horizontalSeparator1 = new HorizontalSeparator();

            _textStatus      = new Label();
            _textStatus.Text = "Reloading...";
            _textStatus.Id   = "_textStatus";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_leftSplitPane);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(_textStatus);

            _propertyGridPane         = new ScrollViewer();
            _propertyGridPane.Content = null;
            _propertyGridPane.Id      = "_propertyGridPane";

            var horizontalSeparator2 = new HorizontalSeparator();

            _textLocation      = new Label();
            _textLocation.Text = "Line: 1, Column: 2, Indent: 3";
            _textLocation.Id   = "_textLocation";

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Background = new SolidBrush("#000000FF");
            verticalStackPanel2.Widgets.Add(_propertyGridPane);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(_textLocation);

            _topSplitPane    = new HorizontalSplitPane();
            _topSplitPane.Id = "_topSplitPane";
            _topSplitPane.Widgets.Add(verticalStackPanel1);
            _topSplitPane.Widgets.Add(verticalStackPanel2);


            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            Widgets.Add(_mainMenu);
            Widgets.Add(_topSplitPane);
        }
示例#14
0
        //public static void Seek(this ScalarKeyFrameAnimation animation, float from, float to, double duration)
        //{
        //    CompositionScopedBatch batch = null;
        //    batch.
        //    batch = animation.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
        //    batch.Completed += (s, e) => completed();

        //    visual.StartAnimation($"Offset.{orientation.ToString()}", compositor.CreateScalarKeyFrameAnimation(to, duration, easing));

        //    batch.End();
        //}

        public static CompositionPropertySet ScrollProperties(this ScrollViewer scrollViewer)
        {
            return(ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer));
        }
示例#15
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //this._background = this.GetTemplateChild(BackgroundTemplateContainerName) as ContentControl;

            //if (this._background == null)
            //{
            //    throw new InvalidOperationException("Missing Viewbox with name PART_Background in template.");
            //}

            _container = this.GetTemplateChild(ContainerName) as Panel;

            this._scrollViewer = this.GetTemplateChild(ScrollViewerName) as ScrollViewer;

            if (this._scrollViewer == null)
            {
                throw new InvalidOperationException("Missing ScrollViewer with name PART_ScrollViewer in template.");
            }

            this.ConfigureBackground();
            this.ConfigureScrollViewer();
        }
示例#16
0
 private ScrollViewer GetScrollViewer()
 {
     return(_scrollViewer ?? (_scrollViewer = this.FindDescendant <ScrollViewer>()));
 }
        private static void removeFromHorizontalScrollGroup(string horizontalGroupName, ScrollViewer scrollViewer)
        {
            if (horizontalScrollGroups.ContainsKey(horizontalGroupName))
            {
                horizontalScrollGroups[horizontalGroupName].ScrollViewers.Remove(scrollViewer);
                if (horizontalScrollGroups[horizontalGroupName].ScrollViewers.Count == 0)
                {
                    horizontalScrollGroups.Remove(horizontalGroupName);
                }
            }

            scrollViewer.ScrollChanged -= ScrollViewer_HorizontalScrollChanged;
        }
示例#18
0
 private void STRBDpopout_Completed(object sender, object e)
 {
     this.Visibility = Visibility.Collapsed;
     ScrollViewer a = new ScrollViewer();
 }
示例#19
0
 /// <summary>
 /// Zooms to the specified factor using an animation instead of
 /// immediately jumping to that value as with ZoomToFactor().
 /// </summary>
 /// <remarks>
 /// Note that calling ZoomToFactor() does not update ZoomFactor immediately,
 /// so it is important to wait for it to change before calling this method.
 /// </remarks>
 /// <param name="scrollViewer"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public static async Task ZoomToFactorWithAnimation(
     this ScrollViewer scrollViewer,
     double factor)
 {
     await scrollViewer.ZoomToFactorWithAnimation(factor, DefaultAnimatedScrollDuration);
 }
示例#20
0
        private void CreateShipSelectionPopup()
        {
            // Create "Please select your SpaceShip" text
            var pleaseSelectText = new TextBlock
            {
                Font = westernFont,
                TextSize = 48,
                TextColor = Color.White,
                Text = "Please select your ship",
                TextAlignment = TextAlignment.Center,
                WrapText = true
            };

            // Layout elements in vertical StackPanel
            var contentStackpanel = new StackPanel { Orientation = Orientation.Vertical };

            // Create and Add SpaceShip to the stack layout
            foreach (var ship in shipList)
                contentStackpanel.Children.Add(CreateShipButtonElement(ship));

            // Uncomment those lines to have an example of stack panel item virtualization
            //var shipInitialCount = shipList.Count;
            //contentStackpanel.ItemVirtualizationEnabled = true;
            //for (int i = 0; i < 200; i++)
            //{
            //    shipList.Add(new SpaceShip { Name = shipList[i % shipInitialCount].Name });
            //    contentStackpanel.Children.Add(CreateShipButtonElement(shipList[shipList.Count - 1]));
            //}

            UpdateShipStatus();

            var contentScrollView = new ScrollViewer
            {
                MaximumHeight = 425,
                Content = contentStackpanel,
                ScrollMode = ScrollingMode.Vertical,
                Margin = new Thickness(12, 10, 7, 10),
                Padding = new Thickness(0, 0, 6, 0),
                ScrollBarColor = Color.Orange
            };

            var scrollViewerBackgroundImage = mainScreneImages["scroll_background"];
            var scrollViewerDecorator = new ContentDecorator { BackgroundImage = scrollViewerBackgroundImage, Content = contentScrollView, };
            scrollViewerDecorator.SetGridRow(2);

            var layoutGrid = new Grid();
            layoutGrid.ColumnDefinitions.Add(new StripDefinition());
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // white space
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Star));
            layoutGrid.LayerDefinitions.Add(new StripDefinition());
            layoutGrid.Children.Add(pleaseSelectText);
            layoutGrid.Children.Add(scrollViewerDecorator);

            var shipSelectPopupContent = new ContentDecorator
            {
                BackgroundImage = popupWindowImage,
                Content = layoutGrid,
                Padding = new Thickness(110, 120, 100, 140)
            };

            // Create SpaceShip selection popup
            shipSelectPopup = new ModalElement
            {
                Visibility = Visibility.Collapsed,
                Content = shipSelectPopupContent
            };

            shipSelectPopup.SetPanelZIndex(1);
        }
示例#21
0
        public void VerifyCurrentAnchor()
        {
            if (PlatformConfiguration.IsDebugBuildConfiguration())
            {
                // Test is failing in chk configuration due to:
                // Bug #1726 Test Failure: RepeaterTests.VerifyCurrentAnchor
                Log.Warning("Skipping test for Debug builds.");
                return;
            }

            ItemsRepeater           rootRepeater = null;
            ScrollViewer            scrollViewer = null;
            ItemsRepeaterScrollHost scrollhost   = null;
            ManualResetEvent        viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                scrollhost = (ItemsRepeaterScrollHost)XamlReader.Parse(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                     xmlns:controls='http://schemas.modernwpf.com/2019'>
                    <controls:ItemsRepeaterScrollHost.Resources>
                        <DataTemplate x:Key='ItemTemplate' >
                            <TextBlock Text='{Binding}' Height='50'/>
                        </DataTemplate>
                    </controls:ItemsRepeaterScrollHost.Resources>
                    <ScrollViewer x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource ItemTemplate}' VerticalCacheLength='0' />
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater = (ItemsRepeater)scrollhost.FindName("rootRepeater");
                scrollViewer = (ScrollViewer)scrollhost.FindName("scrollviewer");
                scrollViewer.ScrollChanged += (sender, args) =>
                {
                    if (args.HorizontalChange != 0 || args.VerticalChange != 0)
                    {
                        viewChanged.Set();
                    }
                };

                rootRepeater.ItemsSource = Enumerable.Range(0, 500);
                Content = scrollhost;
            });

            // scroll down several times and validate current anchor
            for (int i = 1; i < 10; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    scrollViewer.ChangeView(null, i * 200, null);
                });

                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
                IdleSynchronizer.Wait();

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(i * 200, scrollViewer.VerticalOffset);
                    var anchor      = scrollhost.CurrentAnchor;
                    var anchorIndex = rootRepeater.GetElementIndex(anchor);
                    Log.Comment("CurrentAnchor: " + anchorIndex);
                    Verify.AreEqual(i * 4, anchorIndex);
                });
            }
        }
示例#22
0
        public void SmallChange_Should_Be_16()
        {
            var target = new ScrollViewer();

            Assert.Equal(new Size(16, 16), target.SmallChange);
        }
示例#23
0
        private void NestedRepeaterWithDataTemplateScenario(bool disableAnimation)
        {
            /*if (!disableAnimation && PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
             * {
             *  Log.Warning("This test is showing consistent issues with not scrolling enough on RS5 and 19H1 when animations are enabled, tracked by microsoft-ui-xaml#779");
             *  return;
             * }*/

            // Example of how to include debug tracing in an ApiTests.ItemsRepeater test's output.
            // using (PrivateLoggingHelper privateLoggingHelper = new PrivateLoggingHelper("Repeater"))
            // {
            ItemsRepeater    rootRepeater = null;
            ScrollViewer     scrollViewer = null;
            ManualResetEvent viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                var anchorProvider = (ItemsRepeaterScrollHost)XamlReader.Parse(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                        xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                        xmlns:controls='http://schemas.modernwpf.com/2019'>
                    <controls:ItemsRepeaterScrollHost.Resources>
                        <DataTemplate x:Key='ItemTemplate' >
                            <TextBlock Text='{Binding}' />
                        </DataTemplate>
                        <DataTemplate x:Key='GroupTemplate'>
                            <StackPanel>
                                <TextBlock Text='{Binding}' />
                                <controls:ItemsRepeater ItemTemplate='{StaticResource ItemTemplate}' ItemsSource='{Binding}' VerticalCacheLength='0'/>
                            </StackPanel>
                        </DataTemplate>
                    </controls:ItemsRepeaterScrollHost.Resources>
                    <ScrollViewer x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource GroupTemplate}' VerticalCacheLength='0' />
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater              = (ItemsRepeater)anchorProvider.FindName("rootRepeater");
                rootRepeater.SizeChanged += (sender, args) =>
                {
                    Log.Comment($"SizeChanged: Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})");
                };

                scrollViewer = (ScrollViewer)anchorProvider.FindName("scrollviewer");

                /*scrollViewer.ViewChanging += (sender, args) =>
                 * {
                 *  Log.Comment($"ViewChanging: Next VerticalOffset={args.NextView.VerticalOffset}, Final VerticalOffset={args.FinalView.VerticalOffset}");
                 * };*/
                scrollViewer.ScrollChanged += (sender, args) =>
                {
                    if (args.HorizontalChange != 0 || args.VerticalChange != 0)
                    {
                        Log.Comment($"ViewChanged: VerticalOffset={scrollViewer.VerticalOffset}");

                        viewChanged.Set();
                    }
                };

                var itemsSource = new ObservableCollection <ObservableCollection <int> >();
                for (int i = 0; i < 100; i++)
                {
                    itemsSource.Add(new ObservableCollection <int>(Enumerable.Range(0, 5)));
                }
                ;

                rootRepeater.ItemsSource = itemsSource;
                Content = anchorProvider;
            });

            // scroll down several times to cause recycling of elements
            for (int i = 1; i < 10; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    Log.Comment($"Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})");
                    Log.Comment($"ChangeView(VerticalOffset={i * 200})");
                    scrollViewer.ChangeView(null, i * 200, null, disableAnimation);
                });

                Log.Comment("Waiting for view change completion...");
                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
                Log.Comment("View change completed");

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(i * 200, scrollViewer.VerticalOffset);
                });
            }
            // }
        }
        /// <summary>
        /// Determine whether an element is currently in the view of the
        /// ScrollViewer.
        /// </summary>
        /// <param name="viewer">The ScrollViewer.</param>
        /// <param name="element">The element.</param>
        /// <returns>
        /// A value indicating whether the element is currently in the view of
        /// the ScrollViewer.
        /// </returns>
        private static bool IsInView(ScrollViewer viewer, FrameworkElement element)
        {
            Assert.IsNotNull(viewer, "viewer should not be null!");
            Assert.IsNotNull(element, "element should not be null!");

            Rect? itemBounds = element.GetBoundsRelativeTo(viewer);
            if (itemBounds == null)
            {
                return false;
            }

            double viewBottom = viewer.ViewportHeight;
            double viewRight = viewer.ViewportWidth;

            return
                itemBounds.Value.Top >= 0 && itemBounds.Value.Top <= viewBottom &&
                itemBounds.Value.Bottom >= 0 && itemBounds.Value.Bottom <= viewBottom &&
                itemBounds.Value.Left >= 0 && itemBounds.Value.Left <= viewRight &&
                itemBounds.Value.Right >= 0 && itemBounds.Value.Right <= viewRight;
        }
示例#25
0
        public void VerifyCorrectionsInNonScrollableDirection()
        {
            ItemsRepeater           rootRepeater = null;
            ScrollViewer            scrollViewer = null;
            ItemsRepeaterScrollHost scrollhost   = null;
            ManualResetEvent        viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                scrollhost = (ItemsRepeaterScrollHost)XamlReader.Parse(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                     xmlns:controls='http://schemas.modernwpf.com/2019'>
                    <ScrollViewer Width='400' Height='400' x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='repeater'>
                            <DataTemplate>
                                <StackPanel>
                                    <controls:ItemsRepeater ItemsSource='{Binding}'>
                                        <controls:ItemsRepeater.Layout>
                                            <controls:StackLayout Orientation='Horizontal' />
                                        </controls:ItemsRepeater.Layout>
                                    </controls:ItemsRepeater>
                                </StackPanel>
                            </DataTemplate>
                        </controls:ItemsRepeater>
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater = (ItemsRepeater)scrollhost.FindName("repeater");
                scrollViewer = (ScrollViewer)scrollhost.FindName("scrollviewer");
                scrollViewer.ScrollChanged += (sender, args) =>
                {
                    if (args.HorizontalChange != 0 || args.VerticalChange != 0)
                    {
                        viewChanged.Set();
                    }
                };

                List <List <int> > items = new List <List <int> >();
                for (int i = 0; i < 100; i++)
                {
                    items.Add(Enumerable.Range(0, 4).ToList());
                }
                rootRepeater.ItemsSource = items;
                Content = scrollhost;
            });

            // scroll down several times and validate no crash
            for (int i = 1; i < 5; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    scrollViewer.ChangeView(null, i * 200, null);
                });

                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
            }
        }
示例#26
0
        public override void Initialize()
        {
            selectedMealPlan     = new List <MealPlan>(new MealPlan[rooms.Count]);
            selectedWebsitePrice = new List <Tuple <Website, int> >(new Tuple <Website, int> [rooms.Count]);
            int    boxSpacing = 50;
            double cardWidth  = canvas.Width - 0.2 * canvas.Width;
            double cardHeight = 0.7 * canvas.Height;

            canvas.Background = new SolidColorBrush(Color.FromRgb(239, 239, 239));

            ScrollViewer roomScrollViewer = new ScrollViewer
            {
                Height = canvas.Height
            };

            canvas.Children.Add(roomScrollViewer);

            StackPanel roomCardStackPanel = new StackPanel();

            roomScrollViewer.Content = roomCardStackPanel;

            for (int i = 0; i < rooms.Count; i++)
            {
                Room room = rooms[i];

                //creates room card
                Border cardBorder = new Border
                {
                    BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                    BorderThickness = new Thickness(3),
                    Width           = cardWidth,
                    Margin          = new Thickness(0.1 * canvas.Width, boxSpacing, 0.1 * canvas.Width, 0)
                };
                Grid roomGrid = new Grid
                {
                    Width = cardWidth,

                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(0.4 * cardWidth)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(0.6 * cardWidth)
                        }
                    },
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    }
                };
                cardBorder.Child = roomGrid;
                roomCardStackPanel.Children.Add(cardBorder);

                //set card image
                Image roomImage = room.image.GetImage();
                roomImage.MaxWidth  = 0.35 * cardWidth;
                roomImage.MaxHeight = 0.85 * cardHeight;
                Grid.SetColumn(roomImage, 0);
                Grid.SetRow(roomImage, 0);
                roomGrid.Children.Add(roomImage);

                //set roomdatastackpanel
                StackPanel roomDataStackPanel = new StackPanel
                {
                    Width  = 0.6 * cardWidth,
                    Height = 0.85 * cardHeight,
                };
                Grid.SetColumn(roomDataStackPanel, 1);
                Grid.SetRow(roomDataStackPanel, 0);
                roomGrid.Children.Add(roomDataStackPanel);

                //set room type
                Label roomTypeLabel = new Label
                {
                    Content  = "Room Type: " + room.type.name,
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.2 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomTypeLabel);

                //set hotel name
                Label roomHotelLabel = new Label
                {
                    Content  = "Hotel: " + room.hotel.name,
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomHotelLabel);

                //set room price
                Label roomPriceLabel = new Label
                {
                    Content  = "Price: ",
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomPriceLabel);

                //set Reserve button and location
                Grid grid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(0.5 * roomDataStackPanel.Width)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(0.5 * roomDataStackPanel.Width)
                        }
                    },
                    Margin = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(grid);

                Label locationLabel = new Label
                {
                    Content  = "Loaction: " + room.hotel.location.city + ", " + room.hotel.location.country,
                    FontSize = 22,
                };
                Grid.SetColumn(locationLabel, 0);
                grid.Children.Add(locationLabel);

                Button reserveButton = FrontEndHelper.CreateButton(cardWidth * 0.1, cardHeight * 0.1, "Reserve");
                reserveButton.Tag    = i;
                reserveButton.Click += FrontEndHelper.GetMainWindow().ReserveButton_Click;
                Grid.SetColumn(reserveButton, 1);
                grid.Children.Add(reserveButton);

                //creates view more expander
                Expander viewMoreExpander = new Expander
                {
                    Width  = canvas.Width,
                    Margin = new Thickness(0, 0, 0, 0.05 * cardHeight),
                    Header = "More Data"
                };
                Grid.SetColumnSpan(viewMoreExpander, 2);
                Grid.SetRow(viewMoreExpander, 1);
                roomGrid.Children.Add(viewMoreExpander);

                //creates tabs
                TabControl MoreDetailsTabs = new TabControl();
                viewMoreExpander.Content   = MoreDetailsTabs;
                MoreDetailsTabs.Background = new SolidColorBrush(Color.FromRgb(239, 239, 239));

                //creates meals tab
                TabItem MealsTab = new TabItem {
                    Header = "Meals"
                };
                StackPanel MealsPanel = new StackPanel();
                MealsTab.Content = MealsPanel;
                MoreDetailsTabs.Items.Add(MealsTab);

                for (int j = 0; j < room.hotel.mealPlans.Count; j++)
                {
                    MealPlan    mealPlan            = room.hotel.mealPlans[j];
                    RadioButton mealPlanRadioButton = new RadioButton
                    {
                        GroupName = "MealPlanRadioGroup " + i.ToString(),
                        Content   = mealPlan,
                        FontSize  = 22,
                        Margin    = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    mealPlanRadioButton.Checked += mealRadioButtonChecked;
                    if (j == 0)
                    {
                        mealPlanRadioButton.IsChecked = true;
                    }
                    MealsPanel.Children.Add(mealPlanRadioButton);
                }

                //creates website and prices tab
                TabItem websitesTab = new TabItem {
                    Header = "Websites"
                };
                StackPanel websitesPanel = new StackPanel();
                websitesTab.Content = websitesPanel;
                MoreDetailsTabs.Items.Add(websitesTab);

                List <Tuple <Website, int> > websitePrice = DataModels.GetInstance().GetWebsitePricesForRoom(room);
                for (int j = 0; j < websitePrice.Count; j++)
                {
                    RadioButton websitePriceRadioButton = new RadioButton
                    {
                        GroupName = "WebsitePriceRadioGroup " + i.ToString(),
                        Tag       = websitePrice[j],
                        Content   = websitePrice[j].Item1.name + " , " + websitePrice[j].Item2.ToString(),
                        FontSize  = 22,
                        Margin    = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    websitePriceRadioButton.Checked += webstiePriceRadioButtonChecked;
                    if (j == 0)
                    {
                        websitePriceRadioButton.IsChecked = true;
                    }
                    websitesPanel.Children.Add(websitePriceRadioButton);
                }

                //creates room view tab
                TabItem roomViewsTab = new TabItem {
                    Header = "Views"
                };
                StackPanel roomViewsPanel = new StackPanel();
                roomViewsTab.Content = roomViewsPanel;
                MoreDetailsTabs.Items.Add(roomViewsTab);

                foreach (RoomView view in room.views)
                {
                    Label viewLabel = new Label
                    {
                        Content  = view.view,
                        FontSize = 22,
                        Margin   = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    roomViewsPanel.Children.Add(viewLabel);
                }

                //create room photos
                TabItem hotelPhotosTab = new TabItem {
                    Header = "Photos"
                };
                Canvas hotelPhotosCanvas = new Canvas
                {
                    Width  = cardWidth,
                    Height = 300
                };
                hotelPhotosTab.Content = hotelPhotosCanvas;
                MoreDetailsTabs.Items.Add(hotelPhotosTab);

                List <CustomImage> images = new List <CustomImage>();
                images.Add(room.hotel.image);
                foreach (HotelFacility facility in room.hotel.facilities)
                {
                    images.Add(facility.image);
                }
                foreach (PlaceOfIntrest placeOfIntrest in room.hotel.location.placesOfIntrest)
                {
                    images.Add(placeOfIntrest.image);
                }
                ImageAlbum hotelAlbum = new ImageAlbum(hotelPhotosCanvas, 25, 25, 250, 250, images);

                //creates room reviews
                TabItem roomReviewsTab = new TabItem {
                    Header = "Room Reviews"
                };
                StackPanel roomReviewsStackPanel = new StackPanel();
                roomReviewsTab.Content = roomReviewsStackPanel;
                MoreDetailsTabs.Items.Add(roomReviewsTab);

                List <Booking> roomBookings = DataModels.GetInstance().GetRoomBookings(room);
                for (int j = 0; j < roomBookings.Count; j++)
                {
                    Booking booking = roomBookings[j];
                    Border  roomBookingCardBorder = new Border
                    {
                        Width               = 0.8 * cardWidth,
                        BorderBrush         = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                        BorderThickness     = new Thickness(3),
                        HorizontalAlignment = HorizontalAlignment.Left
                    };
                    if (j == roomBookings.Count - 1)
                    {
                        roomBookingCardBorder.Margin = new Thickness(0.1 * cardWidth, 25, 0.1 * cardWidth, 25);
                    }
                    else
                    {
                        roomBookingCardBorder.Margin = new Thickness(0.1 * cardWidth, 25, 0.1 * cardWidth, 0);
                    }
                    StackPanel roomBookingCardPanel = new StackPanel();
                    roomBookingCardBorder.Child = roomBookingCardPanel;
                    roomReviewsStackPanel.Children.Add(roomBookingCardBorder);

                    Label userNameLabel = new Label
                    {
                        Content  = "User Name : " + booking.bookingUser.username,
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(userNameLabel);

                    Label ratingLabel = new Label
                    {
                        Content  = "Rating : " + booking.bookingReview.rating,
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(ratingLabel);

                    Label startDateLabel = new Label
                    {
                        Content  = "From " + booking.startDate.ToShortDateString() + " To " + booking.endDate.ToShortDateString(),
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(startDateLabel);

                    TextBlock description = new TextBlock
                    {
                        Width        = 0.8 * cardWidth - 5,
                        Text         = "Description : " + booking.bookingReview.description,
                        FontSize     = 22,
                        Margin       = new Thickness(0, 0, 0, 10),
                        TextWrapping = TextWrapping.WrapWithOverflow,
                        Padding      = new Thickness(5, 0, 0, 0)
                    };
                    roomBookingCardPanel.Children.Add(description);
                }
            }
        }
        /// <summary>
        /// Creation of an expression to manage modulo (positive and negative value)
        /// </summary>
        /// <param name="scrollViewer">The ScrollViewer to synchronized. A null value is valid</param>
        /// <param name="imageWidth">Width of the image</param>
        /// <param name="imageHeight">Height of the image</param>
        /// <param name="scrollOrientation">The ScrollOrientation</param>
        private void CreateModuloExpression(ScrollViewer scrollViewer, double imageWidth, double imageHeight, ScrollOrientation scrollOrientation)
        {
            const string offsetXParam     = "offsetX";
            const string offsetYParam     = "offsetY";
            const string imageWidthParam  = "imageWidth";
            const string imageHeightParam = "imageHeight";
            const string speedParam       = "speed";

            if (_containerVisual == null)
            {
                return;
            }

            var compositor = _containerVisual.Compositor;

            // Setup the expression
            ExpressionNode expressionX = null;
            ExpressionNode expressionY = null;
            ExpressionNode expressionXVal;
            ExpressionNode expressionYVal;

            var propertySetModulo = compositor.CreatePropertySet();

            propertySetModulo.InsertScalar(imageWidthParam, (float)imageWidth);
            propertySetModulo.InsertScalar(offsetXParam, (float)OffsetX);
            propertySetModulo.InsertScalar(imageHeightParam, (float)imageHeight);
            propertySetModulo.InsertScalar(offsetYParam, (float)OffsetY);
            propertySetModulo.InsertScalar(speedParam, (float)ParallaxSpeedRatio);

            var propertySetNodeModulo = propertySetModulo.GetReference();

            var imageHeightNode = propertySetNodeModulo.GetScalarProperty(imageHeightParam);
            var imageWidthNode  = propertySetNodeModulo.GetScalarProperty(imageWidthParam);

            if (scrollViewer == null)
            {
                var offsetXNode = ExpressionFunctions.Ceil(propertySetNodeModulo.GetScalarProperty(offsetXParam));
                var offsetYNode = ExpressionFunctions.Ceil(propertySetNodeModulo.GetScalarProperty(offsetYParam));

                // expressions are created to simulate a positive and negative modulo with the size of the image and the offset
                expressionXVal = ExpressionFunctions.Conditional(
                    offsetXNode == 0,
                    0,
                    ExpressionFunctions.Conditional(
                        offsetXNode < 0,
                        -(ExpressionFunctions.Abs(offsetXNode - (ExpressionFunctions.Ceil(offsetXNode / imageWidthNode) * imageWidthNode)) % imageWidthNode),
                        -(imageWidthNode - (offsetXNode % imageWidthNode))));

                expressionYVal = ExpressionFunctions.Conditional(
                    offsetYNode == 0,
                    0,
                    ExpressionFunctions.Conditional(
                        offsetYNode < 0,
                        -(ExpressionFunctions.Abs(offsetYNode - (ExpressionFunctions.Ceil(offsetYNode / imageHeightNode) * imageHeightNode)) % imageHeightNode),
                        -(imageHeightNode - (offsetYNode % imageHeightNode))));
            }
            else
            {
                // expressions are created to simulate a positive and negative modulo with the size of the image and the offset and the ScrollViewer offset (Translation)
                var scrollProperties = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);
                var scrollPropSet    = scrollProperties.GetSpecializedReference <ManipulationPropertySetReferenceNode>();

                var speed   = propertySetNodeModulo.GetScalarProperty(speedParam);
                var xCommon = ExpressionFunctions.Ceil((scrollPropSet.Translation.X * speed) + propertySetNodeModulo.GetScalarProperty(offsetXParam));
                expressionXVal = ExpressionFunctions.Conditional(
                    xCommon == 0,
                    0,
                    ExpressionFunctions.Conditional(
                        xCommon < 0,
                        -(ExpressionFunctions.Abs(xCommon - (ExpressionFunctions.Ceil(xCommon / imageWidthNode) * imageWidthNode)) % imageWidthNode),
                        -(imageWidthNode - (xCommon % imageWidthNode))));

                var yCommon = ExpressionFunctions.Ceil((scrollPropSet.Translation.Y * speed) + propertySetNodeModulo.GetScalarProperty(offsetYParam));
                expressionYVal = ExpressionFunctions.Conditional(
                    yCommon == 0,
                    0,
                    ExpressionFunctions.Conditional(
                        yCommon < 0,
                        -(ExpressionFunctions.Abs(yCommon - (ExpressionFunctions.Ceil(yCommon / imageHeightNode) * imageHeightNode)) % imageHeightNode),
                        -(imageHeightNode - (yCommon % imageHeightNode))));
            }

            if (scrollOrientation == ScrollOrientation.Horizontal || scrollOrientation == ScrollOrientation.Both)
            {
                expressionX = expressionXVal;

                if (scrollOrientation == ScrollOrientation.Horizontal)
                {
                    // In horizontal mode we never move the offset y
                    expressionY             = (ScalarNode)0.0f;
                    _containerVisual.Offset = new Vector3((float)OffsetY, 0, 0);
                }
            }

            if (scrollOrientation == ScrollOrientation.Vertical || scrollOrientation == ScrollOrientation.Both)
            {
                expressionY = expressionYVal;

                if (scrollOrientation == ScrollOrientation.Vertical)
                {
                    // In vertical mode we never move the offset x
                    expressionX             = (ScalarNode)0.0f;
                    _containerVisual.Offset = new Vector3(0, (float)OffsetX, 0);
                }
            }

            _containerVisual.StopAnimation("Offset.X");
            _containerVisual.StopAnimation("Offset.Y");

            _containerVisual.StartAnimation("Offset.X", expressionX);
            _containerVisual.StartAnimation("Offset.Y", expressionY);

            _propertySetModulo = propertySetModulo;
        }
 public StandaloneUILogger(TextBox textBox, ScrollViewer scrollViewer)
 {
     _textBox      = textBox;
     _scrollViewer = scrollViewer;
     _uiDispatcher = Dispatcher.CurrentDispatcher;
 }
示例#29
0
        public async Task AdjustItemsScrollingDirection(Int32 Direction)
        {
            try
            {
                if (!AdjustingItemsScrollingDirection)
                {
                    if (Direction == 0)
                    {
                        Style TargetStyle = (Style)Application.Current.Resources["ListViewVertical"];
                        if (ListView_Items.Style != TargetStyle)
                        {
                            AdjustingItemsScrollingDirection = true;
                            Double[] CurrentOffset = EventsScrollViewer.GetCurrentOffset(ListView_Items);

                            ScrollViewer virtualScrollViewer = AVFunctions.FindVisualChild <ScrollViewer>(ListView_Items);
                            if (virtualScrollViewer != null)
                            {
                                ListView_Items.Style              = TargetStyle;
                                ListView_Items.ItemTemplate       = (DataTemplate)Application.Current.Resources["ListViewItemsVertical" + Convert.ToInt32(AppVariables.ApplicationSettings["ListViewStyle"])];
                                ListView_Items.ItemContainerStyle = (Style)Application.Current.Resources["ListViewItemStretchedVertical"];

                                await Task.Delay(10);

                                virtualScrollViewer.ChangeView(CurrentOffset[1], (CurrentOffset[0] + 2), null);
                                //Debug.WriteLine("Scrolling to vertical:" + (CurrentOffset[0] + 2));
                            }

                            //Adjust Status Current Item margin
                            button_StatusCurrentItem.Margin = new Thickness(6, 0, 0, 6);

                            AdjustingItemsScrollingDirection = false;
                        }
                    }
                    else if (Direction == 1)
                    {
                        Style TargetStyle = (Style)Application.Current.Resources["ListViewHorizontal"];
                        if (ListView_Items.Style != TargetStyle)
                        {
                            AdjustingItemsScrollingDirection = true;
                            Double[] CurrentOffset = EventsScrollViewer.GetCurrentOffset(ListView_Items);

                            ScrollViewer virtualScrollViewer = AVFunctions.FindVisualChild <ScrollViewer>(ListView_Items);
                            if (virtualScrollViewer != null)
                            {
                                ListView_Items.Style              = TargetStyle;
                                ListView_Items.ItemTemplate       = (DataTemplate)Application.Current.Resources["ListViewItemsHorizontal" + Convert.ToInt32(AppVariables.ApplicationSettings["ListViewStyle"])];
                                ListView_Items.ItemContainerStyle = (Style)Application.Current.Resources["ListViewItemStretchedHorizontal"];

                                await Task.Delay(10);

                                virtualScrollViewer.ChangeView((CurrentOffset[1] + 2), CurrentOffset[0], null);
                                //Debug.WriteLine("Scrolling to horizontal:" + (CurrentOffset[1] + 2));
                            }

                            //Adjust Status Current Item margin
                            if (AVFunctions.DevMobile())
                            {
                                button_StatusCurrentItem.Margin = new Thickness(6, 0, 0, 6);
                            }
                            else
                            {
                                button_StatusCurrentItem.Margin = new Thickness(16, 0, 0, 16);
                            }

                            AdjustingItemsScrollingDirection = false;
                        }
                    }
                    else if (Direction == 2)
                    {
                        Rect ScreenSize = AVFunctions.AppWindowResolution();
                        if (ScreenSize.Width > ScreenSize.Height)
                        {
                            await AdjustItemsScrollingDirection(1);
                        }
                        else
                        {
                            await AdjustItemsScrollingDirection(0);
                        }
                    }
                }
            }
            catch { AdjustingItemsScrollingDirection = false; }
        }
 private ItemsRepeater SetupRepeater(object dataSource, VirtualizingLayout layout, out ScrollViewer scrollViewer)
 {
     return(SetupRepeater(dataSource, layout, @"<Button Content='{Binding}' Height='100' />", out scrollViewer));
 }
        private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            ScrollViewer sv = sender as ScrollViewer;

            AppendAsyncEventMessage("ViewChanged ScrollViewer=" + sv.Name + ", H=" + sv.HorizontalOffset + ", V=" + sv.VerticalOffset + ", S=" + sv.ZoomFactor);
        }
示例#32
0
 /// <summary>
 /// Enables automatic scrolling on a targetted ScrollViewer.
 /// </summary>
 /// <param name="targetScrollViewer">
 /// The ScrollViewer to use automatic scrolling.
 /// </param>
 public AutoScroller(ScrollViewer targetScrollViewer)
 {
     this.myTargetScrollViewer = targetScrollViewer;
     ScrollPixelsPerTick       = 5;
     ScrollArea = 40;
 }
#pragma warning disable 1998 // considered for removal
        async void ScrollTo(object group, object item, ScrollToPosition toPosition, bool shouldAnimate, bool includeGroup = false, bool previouslyFailed = false)
#pragma warning restore 1998
        {
            ScrollViewer viewer = GetScrollViewer();

            if (viewer == null)
            {
                RoutedEventHandler loadedHandler = null;
                loadedHandler = async(o, e) =>
                {
                    List.Loaded -= loadedHandler;

                    // Here we try to avoid an exception, see explanation at bottom
                    await Dispatcher.RunIdleAsync(args => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup); });
                };
                List.Loaded += loadedHandler;
                return;
            }
            var templatedItems        = TemplatedItemsView.TemplatedItems;
            Tuple <int, int> location = templatedItems.GetGroupAndIndexOfItem(group, item);

            if (location.Item1 == -1 || location.Item2 == -1)
            {
                return;
            }

            object[] t = templatedItems.GetGroup(location.Item1).ItemsSource.Cast <object>().ToArray();
            object   c = t[location.Item2];

            // scroll to desired item with animation
            if (shouldAnimate && ScrollToItemWithAnimation(viewer, c))
            {
                return;
            }

            double viewportHeight = viewer.ViewportHeight;

            var semanticLocation = new SemanticZoomLocation {
                Item = c
            };

            // async scrolling
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                switch (toPosition)
                {
                case ScrollToPosition.Start:
                    {
                        List.ScrollIntoView(c, ScrollIntoViewAlignment.Leading);
                        return;
                    }

                case ScrollToPosition.MakeVisible:
                    {
                        List.ScrollIntoView(c, ScrollIntoViewAlignment.Default);
                        return;
                    }

                case ScrollToPosition.End:
                case ScrollToPosition.Center:
                    {
                        var content         = (FrameworkElement)List.ItemTemplate.LoadContent();
                        content.DataContext = c;
                        content.Measure(new Windows.Foundation.Size(viewer.ActualWidth, double.PositiveInfinity));

                        double tHeight = content.DesiredSize.Height;

                        if (toPosition == ScrollToPosition.Center)
                        {
                            semanticLocation.Bounds = new Rect(0, viewportHeight / 2 - tHeight / 2, 0, 0);
                        }
                        else
                        {
                            semanticLocation.Bounds = new Rect(0, viewportHeight - tHeight, 0, 0);
                        }

                        break;
                    }
                }
            });

            // Waiting for loaded doesn't seem to be enough anymore; the ScrollViewer does not appear until after Loaded.
            // Even if the ScrollViewer is present, an invoke at low priority fails (E_FAIL) presumably because the items are
            // still loading. An invoke at idle sometimes work, but isn't reliable enough, so we'll just have to commit
            // treason and use a blanket catch for the E_FAIL and try again.
            try
            {
                List.MakeVisible(semanticLocation);
            }
            catch (Exception)
            {
                if (previouslyFailed)
                {
                    return;
                }

                Task.Delay(1).ContinueWith(ct => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup, true); }, TaskScheduler.FromCurrentSynchronizationContext()).WatchForError();
            }
        }
示例#34
0
 /// <summary>Initializes a new instance of the <see cref="ScrolledToEndEventArgs"/> class. </summary>
 public ScrolledToEndEventArgs(ScrollViewer viewer)
 {
     ScrollViewer = viewer;
 }
        public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();
            _scrollViewer = (ScrollViewer)GetTemplateChild("ScrollViewer");

            UpdateInnerMargin();
            RegisterVerticalOffsetChangedHandler();
        }
示例#36
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var resolution = (Vector3)UIComponent.VirtualResolution;

            var canvas = new Canvas();
            var imgElt = new ImageElement { Name = "UV image", Source = new Sprite(Asset.Load<Texture>("uv")), Width = resolution.X / 5, Height = resolution.Y / 5, StretchType = StretchType.Fill };
            imgElt.DependencyProperties.Set(Canvas.PinOriginPropertyKey, 0.5f * Vector3.One);
            imgElt.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(resolution.X / 10, resolution.Y / 10, 0));
            imgElt.DependencyProperties.Set(Panel.ZIndexPropertyKey, -1);

            stackPanel = new StackPanel { Orientation = Orientation.Vertical };

            scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.Vertical };
            scrollViewer.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(resolution.X / 4, resolution.Y / 10, 0));
            scrollViewer.Content = stackPanel;

            var button1 = new Button { Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5), LocalMatrix = Matrix.Scaling(2, 2, 2) };
            var textOnly = new TextBlock { Text = "Text only button", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextColor = new Color(1f, 0, 0, 0.5f) };
            button1.Content = textOnly;

            var button2 = new Button { Name = "Button2", Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5) };
            var imageContent = new ImageElement { Name = "Image Button2", Source = new Sprite(Asset.Load<Texture>("uv")), StretchType = StretchType.FillOnStretch, MaximumHeight = 50 };
            button2.Content = imageContent;

            var button3 = new Button { Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5) };
            var stackContent = new StackPanel { Orientation = Orientation.Horizontal };
            var stackImage = new ImageElement { Name = "Image stack panel", Source = new Sprite(Asset.Load<Texture>("uv")), MaximumHeight = 50 };
            var stackText = new TextBlock { Text = "button text", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), Margin = Thickness.UniformRectangle(5) };
            stackContent.Children.Add(stackImage);
            stackContent.Children.Add(stackText);
            button3.Content = stackContent;

            var button4 = new Button { Margin = Thickness.UniformRectangle(5), HorizontalAlignment = HorizontalAlignment.Right, Padding = Thickness.UniformRectangle(5) };
            var imageContent2 = new ImageElement { Name = "button 4 uv image", Source = new Sprite(Asset.Load<Texture>("uv")), StretchType = StretchType.FillOnStretch, MaximumHeight = 40, Opacity = 0.5f };
            button4.Content = imageContent2;

            var button5 = new Button { Margin = Thickness.UniformRectangle(5), HorizontalAlignment = HorizontalAlignment.Left, Padding = Thickness.UniformRectangle(5) };
            var textOnly2 = new TextBlock { Text = "Left aligned", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") };
            button5.Content = textOnly2;

            var button6 = new ImageButton
            {
                Height = 50,
                Margin = Thickness.UniformRectangle(5),
                HorizontalAlignment = HorizontalAlignment.Center,
                PressedImage = new Sprite(Asset.Load<Texture>("ImageButtonPressed")),
                NotPressedImage = new Sprite(Asset.Load<Texture>("ImageButtonNotPressed")),
            };

            toggle = new ToggleButton
            {
                Content = new TextBlock { Text = "Toggle button test", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") },
                IsThreeState = true
            };

            scrollingText = new ScrollingText { Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), Text = "<<<--- Scrolling text in a button ", IsEnabled = IsUpdateAutomatic };
            var button7 = new Button { Margin = Thickness.UniformRectangle(5), Content = scrollingText };

            var uniformGrid = new UniformGrid { Rows = 2, Columns = 2 };
            var gridText = new TextBlock { Text = "Uniform grid", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center};
            gridText.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            var buttonLeft = new Button { Content = new TextBlock { Text = "unif-grid left", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center } };
            buttonLeft.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            var buttonRight = new Button { Content = new TextBlock { Text = "unif-grid right", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center } };
            buttonRight.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            buttonRight.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            uniformGrid.Children.Add(gridText);
            uniformGrid.Children.Add(buttonLeft);
            uniformGrid.Children.Add(buttonRight);

            stackPanel.Children.Add(button1);
            stackPanel.Children.Add(button2);
            stackPanel.Children.Add(button3);
            stackPanel.Children.Add(button4);
            stackPanel.Children.Add(button5);
            stackPanel.Children.Add(button6);
            stackPanel.Children.Add(toggle);
            stackPanel.Children.Add(button7);
            stackPanel.Children.Add(uniformGrid);

            canvas.Children.Add(imgElt);
            canvas.Children.Add(scrollViewer);

            UIComponent.RootElement = canvas;
        }
        public PageAirportGates(Airport airport)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            this.Airport = airport;

            InitializeComponent();

            // chs, 2011-27-10 added for the possibility of purchasing a terminal
            StackPanel panelGatesTerminals = new StackPanel();

            panelGatesTerminals.Margin = new Thickness(0, 10, 50, 0);

            panelGates = new StackPanel();

            panelGatesTerminals.Children.Add(panelGates);

            ScrollViewer svTerminals = new ScrollViewer();

            svTerminals.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            svTerminals.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            svTerminals.MaxHeight = (GraphicsHelpers.GetContentHeight() - 100) / 4;

            StackPanel panelAirlineGates = new StackPanel();

            panelAirlineGates.Margin = new Thickness(0, 0, 10, 0);

            TextBlock txtGatesHeader = new TextBlock();

            txtGatesHeader.Uid = "1007";
            txtGatesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtGatesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtGatesHeader.FontWeight = FontWeights.Bold;
            txtGatesHeader.Text       = Translator.GetInstance().GetString("PageAirportGates", txtGatesHeader.Uid);

            panelAirlineGates.Children.Add(txtGatesHeader);

            lbAirlineContracts = new ListBox();
            lbAirlineContracts.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbAirlineContracts.ItemTemplate = this.Resources["AirlineContractItem"] as DataTemplate;
            lbAirlineContracts.MaxHeight    = GraphicsHelpers.GetContentHeight() / 4;

            panelAirlineGates.Children.Add(lbAirlineContracts);

            //List<Airline> airlines = (from a in Airlines.GetAllAirlines() where this.Airport.Terminals.getNumberOfGates(a) > 0 orderby a.Profile.Name select a).ToList();

            //foreach (Airline airline in airlines)
            //lbAirlineContracts.Items.Add(new AirlineGates(airline, this.Airport.Terminals.getNumberOfGates(airline), this.Airport.Terminals.getNumberOfGates(airline) - this.Airport.Terminals.getNumberOfFreeGates(airline)));

            var contracts = (from c in this.Airport.AirlineContracts orderby c.Airline.Profile.Name select c);

            foreach (AirportContract contract in contracts)
            {
                lbAirlineContracts.Items.Add(contract);
            }

            svTerminals.Content = panelAirlineGates;

            panelGatesTerminals.Children.Add(svTerminals);

            WrapPanel panelButtons = new WrapPanel();

            panelButtons.Margin = new Thickness(0, 5, 0, 0);
            panelGatesTerminals.Children.Add(panelButtons);


            Button btnTerminal = new Button();

            btnTerminal.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnTerminal.Uid     = "201";
            btnTerminal.Height  = Double.NaN;
            btnTerminal.Width   = Double.NaN;
            btnTerminal.Content = Translator.GetInstance().GetString("PageAirportGates", btnTerminal.Uid);
            btnTerminal.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnTerminal.Click += new RoutedEventHandler(btnTerminal_Click);
            btnTerminal.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            //btnTerminal.Visibility = this.Airport.AirlineContract == null || this.Airport.AirlineContract.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed;
            panelButtons.Children.Add(btnTerminal);

            btnHub = new Button();
            btnHub.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnHub.Uid     = "204";
            btnHub.Width   = Double.NaN;
            btnHub.Height  = Double.NaN;
            btnHub.Content = Translator.GetInstance().GetString("PageAirportGates", btnHub.Uid);
            btnHub.Click  += new RoutedEventHandler(btnHub_Click);
            btnHub.Margin  = new Thickness(5, 0, 0, 0);
            btnHub.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelButtons.Children.Add(btnHub);

            btnContract        = new Button();
            btnContract.Margin = new Thickness(5, 0, 0, 0);
            btnContract.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnContract.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnContract.Width   = Double.NaN;
            btnContract.Height  = Double.NaN;
            btnContract.Uid     = "206";
            btnContract.Click  += btnContract_Click;
            btnContract.Content = Translator.GetInstance().GetString("PageAirportGates", btnContract.Uid);
            panelButtons.Children.Add(btnContract);
            btnContract.ToolTip = UICreator.CreateToolTip("1017");


            Airport allocateToAirport = Airports.GetAirports(a => a.Profile.Town == airport.Profile.Town && airport != a && a.Profile.Period.From.AddDays(30) > GameObject.GetInstance().GameTime).FirstOrDefault();

            Button btnReallocate = new Button();

            btnReallocate.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnReallocate.Uid        = "205";
            btnReallocate.Width      = Double.NaN;
            btnReallocate.Height     = Double.NaN;
            btnReallocate.Tag        = allocateToAirport;
            btnReallocate.Content    = string.Format(Translator.GetInstance().GetString("PageAirportGates", btnReallocate.Uid), allocateToAirport == null ? "" : new AirportCodeConverter().Convert(allocateToAirport).ToString());
            btnReallocate.Visibility = allocateToAirport == null || this.Airport.Terminals.getNumberOfGates(GameObject.GetInstance().HumanAirline) == 0 ? Visibility.Collapsed : Visibility.Visible;
            btnReallocate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnReallocate.Margin = new Thickness(5, 0, 0, 0);
            btnReallocate.Click += new RoutedEventHandler(btnReallocate_Click);
            panelButtons.Children.Add(btnReallocate);

            this.Content = panelGatesTerminals;

            showGatesInformation();
            showTerminals();
            showHubs();
            showContracts();
            sw.Stop();

            PerformanceCounters.AddPerformanceCounter(new PagePerformanceCounter("PageAirportGate", GameObject.GetInstance().GameTime, sw.ElapsedMilliseconds));
        }
示例#38
0
        public void TestScrolling()
        {
            const float elementWidth = 100;
            const float elementHeight = 200;
            const float elementDepth = 300;

            var rand = new Random();
            var scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.HorizontalVertical, Width = elementWidth, Height = elementHeight, Depth = elementDepth };
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            // tests that no crashes happen with no content
            scrollViewer.ScrollTo(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollOf(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);

            // tests with an arranged element
            const float contentWidth = 1000;
            const float contentHeight = 2000;
            const float contentDepth = 3000;
            var content = new ContentDecorator { Width = contentWidth, Height = contentHeight, Depth = contentDepth };
            scrollViewer.Content = content;
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            var scrollValue = new Vector3(123, 456, 789);
            scrollViewer.ScrollTo(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(0, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollOf(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            // tests with an not arranged element
            content.InvalidateArrange();
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollOf(2*scrollValue);
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(2*scrollValue.X, 2*scrollValue.Y, 0), scrollViewer.ScrollPosition);
        }
示例#39
0
        public void TestScrollOwner()
        {
            var grid = new UniformGrid();
            Assert.AreEqual(null, grid.ScrollOwner);

            var scrollViewer = new ScrollViewer { Content = grid };
            Assert.AreEqual(scrollViewer, grid.ScrollOwner);

            scrollViewer.Content = null;
            Assert.AreEqual(null, grid.ScrollOwner);

            var scrollViewer2 = new ScrollViewer { Content = grid };
            Assert.AreEqual(scrollViewer2, grid.ScrollOwner);
        }
 private void HookScrollViewerEvents(ScrollViewer scrollViewer)
 {
     scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
 }
示例#41
0
 /// <summary>
 /// Scrolls to the specified offset using an animation instead of
 /// immediately jumping to that offset as with ScrollToVerticalOffset().
 /// </summary>
 /// <remarks>
 /// Note that calling ScrollToVerticalOffset() does not update VerticalOffset immediately,
 /// so it is important to wait for it to change before calling this method.
 /// </remarks>
 /// <param name="scrollViewer"></param>
 /// <param name="offset"></param>
 /// <returns></returns>
 public static async Task ScrollToVerticalOffsetWithAnimation(
     this ScrollViewer scrollViewer,
     double offset)
 {
     await scrollViewer.ScrollToVerticalOffsetWithAnimation(offset, DefaultAnimatedScrollDuration);
 }
示例#42
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

              this.part_ScrollViewer = (ScrollViewer)this.GetTemplateChild("PART_SrollViewer");
              this.part_PropertyDescriptionBox = this.GetTemplateChild("PART_PropertyDescriptionBox") as PropertyDescriptionBox;
              this.part_PropertyFilterBox = this.GetTemplateChild("PART_PropertyFilterBox") as PropertyFilterBox;

              if (this.part_PropertyFilterBox != null) this.part_PropertyFilterBox.TextChanged += FlterBoxTextChanged;

              loaded = true;

              if (resetLoadedObject)
              {
            resetLoadedObject = false;
            this.ResetObject(this.SelectedObject);
              }
        }
 private void UnhookScrollViewerEvents(ScrollViewer scrollViewer)
 {
     scrollViewer.ViewChanged -= ScrollViewer_ViewChanged;
 }
示例#44
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var random = new Random(0);

            var Sprites = Asset.Load<SpriteSheet>("UIImages");
            var img1 = new ImageElement { Source = new Sprite(Asset.Load<Texture>("uv")) };
            var img2 = new ImageElement { Source = Sprites["GameScreenLeft"] };
            var img3 = new ImageElement { Source = Sprites["GameScreenRight"] };

            stackPanel1 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            stackPanel1.Children.Add(img1);
            stackPanel1.Children.Add(img2);
            stackPanel1.Children.Add(img3);

            stackPanel2 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (var i = 0; i < 1000; i++)
                stackPanel2.Children.Add(new Button { Name = "" + i, Height = 75, Content = new TextBlock { Text = "button number " + i, Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") } });

            stackPanel3 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true, VerticalAlignment = VerticalAlignment.Center };
            for (var i = 0; i < 103; i++)
                stackPanel3.Children.Add(new Button { Name = "" + i, Height = 50 + 500 * random.NextFloat(), Content = new TextBlock { Text = "random button number " + i, Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") } });

            stackPanel4 = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (var i = 0; i < 5; i++)
                stackPanel4.Children.Add(new Button { Name = "" + i, Height = i * 30, Content = new TextBlock { Text = "random button number " + i, Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") } });

            currentStackPanel = stackPanel1;

            scrollViewer = new ScrollViewer { Name = "sv", Content = currentStackPanel, ScrollMode = ScrollingMode.Vertical };

            UIComponent.RootElement = scrollViewer;
        }
示例#45
0
 public busquedaPapeletas(ScrollViewer scroll)
 {
     InitializeComponent();
     this.bsqPlaca         = false;
     this.scrollContenedor = scroll;
 }
示例#46
0
        public static void GetItemsInViewPort(this ItemsControl list, IList <WeakReference> items)
        {
            int index;
            FrameworkElement container;
            GeneralTransform itemTransform;
            Rect             boundingBox;

            if (VisualTreeHelper.GetChildrenCount(list) == 0)
            {
                // no child yet
                return;
            }

            ScrollViewer scrollHost = VisualTreeHelper.GetChild(list, 0) as ScrollViewer;

            list.UpdateLayout();

            if (scrollHost == null)
            {
                return;
            }

            for (index = 0; index < list.Items.Count; index++)
            {
                container = (FrameworkElement)list.ItemContainerGenerator.ContainerFromIndex(index);
                if (container != null)
                {
                    itemTransform = null;
                    try
                    {
                        itemTransform = container.TransformToVisual(scrollHost);
                    }
                    catch (ArgumentException)
                    {
                        // Ignore failures when not in the visual tree
                        return;
                    }

                    boundingBox = new Rect(itemTransform.Transform(new Point()), itemTransform.Transform(new Point(container.ActualWidth, container.ActualHeight)));

                    if (boundingBox.Bottom > 0)
                    {
                        items.Add(new WeakReference(container));
                        index++;
                        break;
                    }
                }
            }

            for (; index < list.Items.Count; index++)
            {
                container     = (FrameworkElement)list.ItemContainerGenerator.ContainerFromIndex(index);
                itemTransform = null;
                try
                {
                    itemTransform = container.TransformToVisual(scrollHost);
                }
                catch (ArgumentException)
                {
                    // Ignore failures when not in the visual tree
                    return;
                }

                boundingBox = new Rect(itemTransform.Transform(new Point()), itemTransform.Transform(new Point(container.ActualWidth, container.ActualHeight)));

                if (boundingBox.Top < scrollHost.ActualHeight)
                {
                    items.Add(new WeakReference(container));
                }
                else
                {
                    break;
                }
            }

            return;
        }
示例#47
0
 public MouseCapture(ScrollViewer scrollViewer, MouseButtonEventArgs arguments)
 {
     VerticalOffset   = scrollViewer.VerticalOffset;
     HorizontalOffset = scrollViewer.HorizontalOffset;
     Point            = arguments.GetPosition(scrollViewer);
 }
示例#48
0
        private static Control ScrollViewerTemplate(ScrollViewer control)
        {
            var result = new ScrollContentPresenter
            {
                Name = "PART_ContentPresenter",
                [~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
            };

            return result;
        }
示例#49
0
        private void CreateShipSelectionPopup()
        {
            // Create "Please select your SpaceShip" text
            var pleaseSelectText = new TextBlock
            {
                Font          = WesternFont,
                TextSize      = 48,
                TextColor     = Color.White,
                Text          = "Please select your ship",
                TextAlignment = TextAlignment.Center,
                WrapText      = true
            };

            // Layout elements in vertical StackPanel
            var contentStackpanel = new StackPanel {
                Orientation = Orientation.Vertical
            };

            // Create and Add SpaceShip to the stack layout
            foreach (var ship in shipList)
            {
                contentStackpanel.Children.Add(CreateShipButtonElement(ship));
            }

            // Uncomment those lines to have an example of stack panel item virtualization
            //var shipInitialCount = shipList.Count;
            //contentStackpanel.ItemVirtualizationEnabled = true;
            //for (int i = 0; i < 200; i++)
            //{
            //    shipList.Add(new SpaceShip { Name = shipList[i % shipInitialCount].Name });
            //    contentStackpanel.Children.Add(CreateShipButtonElement(shipList[shipList.Count - 1]));
            //}

            UpdateShipStatus();

            var contentScrollView = new ScrollViewer
            {
                MaximumHeight  = 425,
                Content        = contentStackpanel,
                ScrollMode     = ScrollingMode.Vertical,
                Margin         = new Thickness(12, 10, 7, 10),
                Padding        = new Thickness(0, 0, 6, 0),
                ScrollBarColor = Color.Orange
            };

            var scrollViewerBackgroundImage = MainSceneImages["scroll_background"];
            var scrollViewerDecorator       = new ContentDecorator {
                BackgroundImage = scrollViewerBackgroundImage, Content = contentScrollView,
            };

            scrollViewerDecorator.SetGridRow(2);

            var layoutGrid = new Grid();

            layoutGrid.ColumnDefinitions.Add(new StripDefinition());
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // white space
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Star));
            layoutGrid.LayerDefinitions.Add(new StripDefinition());
            layoutGrid.Children.Add(pleaseSelectText);
            layoutGrid.Children.Add(scrollViewerDecorator);

            var shipSelectPopupContent = new ContentDecorator
            {
                BackgroundImage = popupWindowImage,
                Content         = layoutGrid,
                Padding         = new Thickness(110, 120, 100, 140)
            };

            // Create SpaceShip selection popup
            shipSelectPopup = new ModalElement
            {
                Visibility = Visibility.Collapsed,
                Content    = shipSelectPopupContent
            };

            shipSelectPopup.SetPanelZIndex(1);
        }
 public virtual void ScrollIntoViewRequiresElement()
 {
     ScrollViewer viewer = new ScrollViewer();
     viewer.ScrollIntoView(null);
 }
示例#51
0
 private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_114_Items() {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // tabAllBuildings element
     TabItem tabAllBuildings = new TabItem();
     tabAllBuildings.Name = "tabAllBuildings";
     tabAllBuildings.Header = "All";
     // e_115 element
     ScrollViewer e_115 = new ScrollViewer();
     tabAllBuildings.Content = e_115;
     e_115.Name = "e_115";
     e_115.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_115_IsEnabled = new Binding("IsUIEnabled");
     e_115.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_115_IsEnabled);
     // e_116 element
     Grid e_116 = new Grid();
     e_115.Content = e_116;
     e_116.Name = "e_116";
     ColumnDefinition col_e_116_0 = new ColumnDefinition();
     e_116.ColumnDefinitions.Add(col_e_116_0);
     ColumnDefinition col_e_116_1 = new ColumnDefinition();
     e_116.ColumnDefinitions.Add(col_e_116_1);
     Binding binding_e_116_DataContext = new Binding("PlanetBuildingsData");
     e_116.SetBinding(Grid.DataContextProperty, binding_e_116_DataContext);
     // e_117 element
     ListBox e_117 = new ListBox();
     e_116.Children.Add(e_117);
     e_117.Name = "e_117";
     ToolTipService.SetInitialShowDelay(e_117, 0);
     Grid.SetColumn(e_117, 0);
     ScrollViewer.SetCanContentScroll(e_117, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_117, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_117, ScrollBarVisibility.Hidden);
     Binding binding_e_117_IsEnabled = new Binding("IsUIEnabled");
     e_117.SetBinding(ListBox.IsEnabledProperty, binding_e_117_IsEnabled);
     Binding binding_e_117_ItemsSource = new Binding("BuildingIcons");
     e_117.SetBinding(ListBox.ItemsSourceProperty, binding_e_117_ItemsSource);
     Binding binding_e_117_SelectedIndex = new Binding("SelectedBuilding");
     e_117.SetBinding(ListBox.SelectedIndexProperty, binding_e_117_SelectedIndex);
     // e_118 element
     ListBox e_118 = new ListBox();
     e_116.Children.Add(e_118);
     e_118.Name = "e_118";
     ToolTipService.SetInitialShowDelay(e_118, 0);
     Grid.SetColumn(e_118, 1);
     ScrollViewer.SetCanContentScroll(e_118, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_118, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_118, ScrollBarVisibility.Hidden);
     Binding binding_e_118_IsEnabled = new Binding("IsUIEnabled");
     e_118.SetBinding(ListBox.IsEnabledProperty, binding_e_118_IsEnabled);
     Binding binding_e_118_ItemsSource = new Binding("BuildingNames");
     e_118.SetBinding(ListBox.ItemsSourceProperty, binding_e_118_ItemsSource);
     Binding binding_e_118_SelectedIndex = new Binding("SelectedBuilding");
     e_118.SetBinding(ListBox.SelectedIndexProperty, binding_e_118_SelectedIndex);
     items.Add(tabAllBuildings);
     // tabResourceBuildings element
     TabItem tabResourceBuildings = new TabItem();
     tabResourceBuildings.Name = "tabResourceBuildings";
     tabResourceBuildings.Header = "Resources";
     // e_119 element
     ScrollViewer e_119 = new ScrollViewer();
     tabResourceBuildings.Content = e_119;
     e_119.Name = "e_119";
     e_119.Width = 490F;
     e_119.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_119_IsEnabled = new Binding("IsUIEnabled");
     e_119.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_119_IsEnabled);
     // e_120 element
     Grid e_120 = new Grid();
     e_119.Content = e_120;
     e_120.Name = "e_120";
     ColumnDefinition col_e_120_0 = new ColumnDefinition();
     col_e_120_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_120.ColumnDefinitions.Add(col_e_120_0);
     ColumnDefinition col_e_120_1 = new ColumnDefinition();
     col_e_120_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_120.ColumnDefinitions.Add(col_e_120_1);
     Binding binding_e_120_DataContext = new Binding("PlanetBuildingsData");
     e_120.SetBinding(Grid.DataContextProperty, binding_e_120_DataContext);
     // e_121 element
     ListBox e_121 = new ListBox();
     e_120.Children.Add(e_121);
     e_121.Name = "e_121";
     ToolTipService.SetInitialShowDelay(e_121, 0);
     Grid.SetColumn(e_121, 0);
     ScrollViewer.SetCanContentScroll(e_121, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_121, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_121, ScrollBarVisibility.Hidden);
     Binding binding_e_121_IsEnabled = new Binding("IsUIEnabled");
     e_121.SetBinding(ListBox.IsEnabledProperty, binding_e_121_IsEnabled);
     Binding binding_e_121_ItemsSource = new Binding("ResourcesBuildingIcons");
     e_121.SetBinding(ListBox.ItemsSourceProperty, binding_e_121_ItemsSource);
     Binding binding_e_121_SelectedIndex = new Binding("ResourcesSelectedBuilding");
     e_121.SetBinding(ListBox.SelectedIndexProperty, binding_e_121_SelectedIndex);
     // e_122 element
     ListBox e_122 = new ListBox();
     e_120.Children.Add(e_122);
     e_122.Name = "e_122";
     ToolTipService.SetInitialShowDelay(e_122, 0);
     Grid.SetColumn(e_122, 1);
     ScrollViewer.SetCanContentScroll(e_122, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_122, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_122, ScrollBarVisibility.Hidden);
     Binding binding_e_122_IsEnabled = new Binding("IsUIEnabled");
     e_122.SetBinding(ListBox.IsEnabledProperty, binding_e_122_IsEnabled);
     Binding binding_e_122_ItemsSource = new Binding("ResourcesBuildingNames");
     e_122.SetBinding(ListBox.ItemsSourceProperty, binding_e_122_ItemsSource);
     Binding binding_e_122_SelectedIndex = new Binding("ResourcesSelectedBuilding");
     e_122.SetBinding(ListBox.SelectedIndexProperty, binding_e_122_SelectedIndex);
     items.Add(tabResourceBuildings);
     // tabProductionBuildings element
     TabItem tabProductionBuildings = new TabItem();
     tabProductionBuildings.Name = "tabProductionBuildings";
     tabProductionBuildings.Header = "Production";
     // e_123 element
     ScrollViewer e_123 = new ScrollViewer();
     tabProductionBuildings.Content = e_123;
     e_123.Name = "e_123";
     e_123.Width = 490F;
     e_123.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_123_IsEnabled = new Binding("IsUIEnabled");
     e_123.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_123_IsEnabled);
     // e_124 element
     Grid e_124 = new Grid();
     e_123.Content = e_124;
     e_124.Name = "e_124";
     ColumnDefinition col_e_124_0 = new ColumnDefinition();
     col_e_124_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_124.ColumnDefinitions.Add(col_e_124_0);
     ColumnDefinition col_e_124_1 = new ColumnDefinition();
     col_e_124_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_124.ColumnDefinitions.Add(col_e_124_1);
     Binding binding_e_124_DataContext = new Binding("PlanetBuildingsData");
     e_124.SetBinding(Grid.DataContextProperty, binding_e_124_DataContext);
     // e_125 element
     ListBox e_125 = new ListBox();
     e_124.Children.Add(e_125);
     e_125.Name = "e_125";
     e_125.Background = new SolidColorBrush(new ColorW(255, 255, 255, 0));
     ToolTipService.SetInitialShowDelay(e_125, 0);
     Grid.SetColumn(e_125, 0);
     ScrollViewer.SetCanContentScroll(e_125, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_125, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_125, ScrollBarVisibility.Hidden);
     Binding binding_e_125_IsEnabled = new Binding("IsUIEnabled");
     e_125.SetBinding(ListBox.IsEnabledProperty, binding_e_125_IsEnabled);
     Binding binding_e_125_ItemsSource = new Binding("ProductionBuildingIcons");
     e_125.SetBinding(ListBox.ItemsSourceProperty, binding_e_125_ItemsSource);
     Binding binding_e_125_SelectedIndex = new Binding("ProductionSelectedBuilding");
     e_125.SetBinding(ListBox.SelectedIndexProperty, binding_e_125_SelectedIndex);
     // e_126 element
     ListBox e_126 = new ListBox();
     e_124.Children.Add(e_126);
     e_126.Name = "e_126";
     ToolTipService.SetInitialShowDelay(e_126, 0);
     Grid.SetColumn(e_126, 1);
     ScrollViewer.SetCanContentScroll(e_126, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_126, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_126, ScrollBarVisibility.Hidden);
     Binding binding_e_126_IsEnabled = new Binding("IsUIEnabled");
     e_126.SetBinding(ListBox.IsEnabledProperty, binding_e_126_IsEnabled);
     Binding binding_e_126_ItemsSource = new Binding("ProductionBuildingNames");
     e_126.SetBinding(ListBox.ItemsSourceProperty, binding_e_126_ItemsSource);
     Binding binding_e_126_SelectedIndex = new Binding("ProductionSelectedBuilding");
     e_126.SetBinding(ListBox.SelectedIndexProperty, binding_e_126_SelectedIndex);
     items.Add(tabProductionBuildings);
     // tabResearchBuildings element
     TabItem tabResearchBuildings = new TabItem();
     tabResearchBuildings.Name = "tabResearchBuildings";
     tabResearchBuildings.Header = "Research";
     // e_127 element
     ScrollViewer e_127 = new ScrollViewer();
     tabResearchBuildings.Content = e_127;
     e_127.Name = "e_127";
     e_127.Width = 490F;
     e_127.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_127_IsEnabled = new Binding("IsUIEnabled");
     e_127.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_127_IsEnabled);
     // e_128 element
     Grid e_128 = new Grid();
     e_127.Content = e_128;
     e_128.Name = "e_128";
     ColumnDefinition col_e_128_0 = new ColumnDefinition();
     col_e_128_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_128.ColumnDefinitions.Add(col_e_128_0);
     ColumnDefinition col_e_128_1 = new ColumnDefinition();
     col_e_128_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_128.ColumnDefinitions.Add(col_e_128_1);
     Binding binding_e_128_DataContext = new Binding("PlanetBuildingsData");
     e_128.SetBinding(Grid.DataContextProperty, binding_e_128_DataContext);
     // e_129 element
     ListBox e_129 = new ListBox();
     e_128.Children.Add(e_129);
     e_129.Name = "e_129";
     e_129.Background = new SolidColorBrush(new ColorW(255, 255, 255, 0));
     ToolTipService.SetInitialShowDelay(e_129, 0);
     Grid.SetColumn(e_129, 0);
     ScrollViewer.SetCanContentScroll(e_129, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_129, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_129, ScrollBarVisibility.Hidden);
     Binding binding_e_129_IsEnabled = new Binding("IsUIEnabled");
     e_129.SetBinding(ListBox.IsEnabledProperty, binding_e_129_IsEnabled);
     Binding binding_e_129_ItemsSource = new Binding("ResearchBuildingIcons");
     e_129.SetBinding(ListBox.ItemsSourceProperty, binding_e_129_ItemsSource);
     Binding binding_e_129_SelectedIndex = new Binding("ResearchSelectedBuilding");
     e_129.SetBinding(ListBox.SelectedIndexProperty, binding_e_129_SelectedIndex);
     // e_130 element
     ListBox e_130 = new ListBox();
     e_128.Children.Add(e_130);
     e_130.Name = "e_130";
     ToolTipService.SetInitialShowDelay(e_130, 0);
     Grid.SetColumn(e_130, 1);
     ScrollViewer.SetCanContentScroll(e_130, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_130, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_130, ScrollBarVisibility.Hidden);
     Binding binding_e_130_IsEnabled = new Binding("IsUIEnabled");
     e_130.SetBinding(ListBox.IsEnabledProperty, binding_e_130_IsEnabled);
     Binding binding_e_130_ItemsSource = new Binding("ResearchBuildingNames");
     e_130.SetBinding(ListBox.ItemsSourceProperty, binding_e_130_ItemsSource);
     Binding binding_e_130_SelectedIndex = new Binding("ResearchSelectedBuilding");
     e_130.SetBinding(ListBox.SelectedIndexProperty, binding_e_130_SelectedIndex);
     items.Add(tabResearchBuildings);
     // tabMilitaryBuildings element
     TabItem tabMilitaryBuildings = new TabItem();
     tabMilitaryBuildings.Name = "tabMilitaryBuildings";
     tabMilitaryBuildings.Header = "Military";
     // e_131 element
     ScrollViewer e_131 = new ScrollViewer();
     tabMilitaryBuildings.Content = e_131;
     e_131.Name = "e_131";
     e_131.Width = 490F;
     e_131.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_131_IsEnabled = new Binding("IsUIEnabled");
     e_131.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_131_IsEnabled);
     // e_132 element
     Grid e_132 = new Grid();
     e_131.Content = e_132;
     e_132.Name = "e_132";
     ColumnDefinition col_e_132_0 = new ColumnDefinition();
     col_e_132_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_132.ColumnDefinitions.Add(col_e_132_0);
     ColumnDefinition col_e_132_1 = new ColumnDefinition();
     col_e_132_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_132.ColumnDefinitions.Add(col_e_132_1);
     Binding binding_e_132_DataContext = new Binding("PlanetBuildingsData");
     e_132.SetBinding(Grid.DataContextProperty, binding_e_132_DataContext);
     // e_133 element
     ListBox e_133 = new ListBox();
     e_132.Children.Add(e_133);
     e_133.Name = "e_133";
     e_133.Background = new SolidColorBrush(new ColorW(255, 255, 255, 0));
     ToolTipService.SetInitialShowDelay(e_133, 0);
     Grid.SetColumn(e_133, 0);
     ScrollViewer.SetCanContentScroll(e_133, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_133, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_133, ScrollBarVisibility.Hidden);
     Binding binding_e_133_IsEnabled = new Binding("IsUIEnabled");
     e_133.SetBinding(ListBox.IsEnabledProperty, binding_e_133_IsEnabled);
     Binding binding_e_133_ItemsSource = new Binding("MilitaryBuildingIcons");
     e_133.SetBinding(ListBox.ItemsSourceProperty, binding_e_133_ItemsSource);
     Binding binding_e_133_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_133.SetBinding(ListBox.SelectedIndexProperty, binding_e_133_SelectedIndex);
     // e_134 element
     ListBox e_134 = new ListBox();
     e_132.Children.Add(e_134);
     e_134.Name = "e_134";
     ToolTipService.SetInitialShowDelay(e_134, 0);
     Grid.SetColumn(e_134, 1);
     ScrollViewer.SetCanContentScroll(e_134, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_134, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_134, ScrollBarVisibility.Hidden);
     Binding binding_e_134_IsEnabled = new Binding("IsUIEnabled");
     e_134.SetBinding(ListBox.IsEnabledProperty, binding_e_134_IsEnabled);
     Binding binding_e_134_ItemsSource = new Binding("MilitaryBuildingNames");
     e_134.SetBinding(ListBox.ItemsSourceProperty, binding_e_134_ItemsSource);
     Binding binding_e_134_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_134.SetBinding(ListBox.SelectedIndexProperty, binding_e_134_SelectedIndex);
     items.Add(tabMilitaryBuildings);
     // tabMilitaryBuildings1 element
     TabItem tabMilitaryBuildings1 = new TabItem();
     tabMilitaryBuildings1.Name = "tabMilitaryBuildings1";
     tabMilitaryBuildings1.Header = "Military";
     // e_135 element
     ScrollViewer e_135 = new ScrollViewer();
     tabMilitaryBuildings1.Content = e_135;
     e_135.Name = "e_135";
     e_135.Width = 490F;
     e_135.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_135_IsEnabled = new Binding("IsUIEnabled");
     e_135.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_135_IsEnabled);
     // e_136 element
     Grid e_136 = new Grid();
     e_135.Content = e_136;
     e_136.Name = "e_136";
     ColumnDefinition col_e_136_0 = new ColumnDefinition();
     col_e_136_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_136.ColumnDefinitions.Add(col_e_136_0);
     ColumnDefinition col_e_136_1 = new ColumnDefinition();
     col_e_136_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_136.ColumnDefinitions.Add(col_e_136_1);
     Binding binding_e_136_DataContext = new Binding("PlanetBuildingsData");
     e_136.SetBinding(Grid.DataContextProperty, binding_e_136_DataContext);
     // e_137 element
     ListBox e_137 = new ListBox();
     e_136.Children.Add(e_137);
     e_137.Name = "e_137";
     e_137.Background = new SolidColorBrush(new ColorW(255, 255, 255, 0));
     ToolTipService.SetInitialShowDelay(e_137, 0);
     Grid.SetColumn(e_137, 0);
     ScrollViewer.SetCanContentScroll(e_137, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_137, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_137, ScrollBarVisibility.Hidden);
     Binding binding_e_137_IsEnabled = new Binding("IsUIEnabled");
     e_137.SetBinding(ListBox.IsEnabledProperty, binding_e_137_IsEnabled);
     Binding binding_e_137_ItemsSource = new Binding("MilitaryBuildingIcons");
     e_137.SetBinding(ListBox.ItemsSourceProperty, binding_e_137_ItemsSource);
     Binding binding_e_137_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_137.SetBinding(ListBox.SelectedIndexProperty, binding_e_137_SelectedIndex);
     // e_138 element
     ListBox e_138 = new ListBox();
     e_136.Children.Add(e_138);
     e_138.Name = "e_138";
     ToolTipService.SetInitialShowDelay(e_138, 0);
     Grid.SetColumn(e_138, 1);
     ScrollViewer.SetCanContentScroll(e_138, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_138, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_138, ScrollBarVisibility.Hidden);
     Binding binding_e_138_IsEnabled = new Binding("IsUIEnabled");
     e_138.SetBinding(ListBox.IsEnabledProperty, binding_e_138_IsEnabled);
     Binding binding_e_138_ItemsSource = new Binding("MilitaryBuildingNames");
     e_138.SetBinding(ListBox.ItemsSourceProperty, binding_e_138_ItemsSource);
     Binding binding_e_138_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_138.SetBinding(ListBox.SelectedIndexProperty, binding_e_138_SelectedIndex);
     items.Add(tabMilitaryBuildings1);
     // tabMilitaryBuildings2 element
     TabItem tabMilitaryBuildings2 = new TabItem();
     tabMilitaryBuildings2.Name = "tabMilitaryBuildings2";
     tabMilitaryBuildings2.Header = "Military";
     // e_139 element
     ScrollViewer e_139 = new ScrollViewer();
     tabMilitaryBuildings2.Content = e_139;
     e_139.Name = "e_139";
     e_139.HorizontalAlignment = HorizontalAlignment.Stretch;
     Binding binding_e_139_IsEnabled = new Binding("IsUIEnabled");
     e_139.SetBinding(ScrollViewer.IsEnabledProperty, binding_e_139_IsEnabled);
     // e_140 element
     Grid e_140 = new Grid();
     e_139.Content = e_140;
     e_140.Name = "e_140";
     ColumnDefinition col_e_140_0 = new ColumnDefinition();
     col_e_140_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_140.ColumnDefinitions.Add(col_e_140_0);
     ColumnDefinition col_e_140_1 = new ColumnDefinition();
     col_e_140_1.Width = new GridLength(1F, GridUnitType.Auto);
     e_140.ColumnDefinitions.Add(col_e_140_1);
     Binding binding_e_140_DataContext = new Binding("PlanetBuildingsData");
     e_140.SetBinding(Grid.DataContextProperty, binding_e_140_DataContext);
     // e_141 element
     ListBox e_141 = new ListBox();
     e_140.Children.Add(e_141);
     e_141.Name = "e_141";
     e_141.Background = new SolidColorBrush(new ColorW(255, 255, 255, 0));
     ToolTipService.SetInitialShowDelay(e_141, 0);
     Grid.SetColumn(e_141, 0);
     ScrollViewer.SetCanContentScroll(e_141, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_141, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_141, ScrollBarVisibility.Hidden);
     Binding binding_e_141_IsEnabled = new Binding("IsUIEnabled");
     e_141.SetBinding(ListBox.IsEnabledProperty, binding_e_141_IsEnabled);
     Binding binding_e_141_ItemsSource = new Binding("MilitaryBuildingIcons");
     e_141.SetBinding(ListBox.ItemsSourceProperty, binding_e_141_ItemsSource);
     Binding binding_e_141_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_141.SetBinding(ListBox.SelectedIndexProperty, binding_e_141_SelectedIndex);
     // e_142 element
     ListBox e_142 = new ListBox();
     e_140.Children.Add(e_142);
     e_142.Name = "e_142";
     ToolTipService.SetInitialShowDelay(e_142, 0);
     Grid.SetColumn(e_142, 1);
     ScrollViewer.SetCanContentScroll(e_142, false);
     ScrollViewer.SetHorizontalScrollBarVisibility(e_142, ScrollBarVisibility.Hidden);
     ScrollViewer.SetVerticalScrollBarVisibility(e_142, ScrollBarVisibility.Hidden);
     Binding binding_e_142_IsEnabled = new Binding("IsUIEnabled");
     e_142.SetBinding(ListBox.IsEnabledProperty, binding_e_142_IsEnabled);
     Binding binding_e_142_ItemsSource = new Binding("MilitaryBuildingNames");
     e_142.SetBinding(ListBox.ItemsSourceProperty, binding_e_142_ItemsSource);
     Binding binding_e_142_SelectedIndex = new Binding("MilitarySelectedBuilding");
     e_142.SetBinding(ListBox.SelectedIndexProperty, binding_e_142_SelectedIndex);
     items.Add(tabMilitaryBuildings2);
     return items;
 }