Beispiel #1
0
        }         // ListViewLayoutWindow

        // ----------------------------------------------------------------------
        private void SetupCustomers(ListView listView)
        {
            new ListViewLayoutManager(listView);               // apply layout manager

            GridView gridView = new GridView();

            gridView.Columns.Add(FixedColumn.ApplyWidth(new CustomerStateGridViewColumn("State"), 25));
            gridView.Columns.Add(ProportionalColumn.ApplyWidth(new CustomerGridViewColumn(CustomerColumn.FirstName, "Fist Name (Proportional=1)"), 1));
            gridView.Columns.Add(ProportionalColumn.ApplyWidth(new CustomerGridViewColumn(CustomerColumn.LastName, "Last Name (Proportional=1)"), 1));
            gridView.Columns.Add(ProportionalColumn.ApplyWidth(new CustomerGridViewColumn(CustomerColumn.Address, "Address (Proportional=2)"), 2));

            listView.View        = gridView;
            listView.ItemsSource = Customers;
        }         // SetupCustomers
        private static GridViewColumn CreateColumn(EntityCustomField customField)
        {
            var template = new DataTemplate {
                DataType = typeof(string)
            };
            var fef = new FrameworkElementFactory(typeof(TextBlock));

            fef.SetBinding(TextBlock.TextProperty, new Binding("[" + customField.Name + "]")
            {
                StringFormat = customField.EditingFormat
            });
            template.VisualTree = fef;
            var c = new GridViewColumn {
                Header = customField.Name, CellTemplate = template
            };

            ProportionalColumn.ApplyWidth(c, 1);
            return(c);
        }
 private void ReduceHitlist(bool toggle)
 {
     if (toggle)
     {
         Column1.Header = "S";
         ProportionalColumn.ApplyWidth(Column0, 1);
         ProportionalColumn.ApplyWidth(Column1, 2);
         ProportionalColumn.ApplyWidth(Column2, 0);
         ProportionalColumn.ApplyWidth(Column3, 0);
         ProportionalColumn.ApplyWidth(Column4, 0);
         ProportionalColumn.ApplyWidth(Column5, 0);
     }
     else
     {
         Column1.Header = "Score";
         ProportionalColumn.ApplyWidth(Column0, 1);
         ProportionalColumn.ApplyWidth(Column1, 2);
         ProportionalColumn.ApplyWidth(Column2, 2);
         ProportionalColumn.ApplyWidth(Column3, 3);
         ProportionalColumn.ApplyWidth(Column4, 3);
         ProportionalColumn.ApplyWidth(Column5, 2);
     }
 }
        public BonusBoxHunter()
        {
            InitializeComponent();

            ItemIdMap         = new Dictionary <String, ItemInformation>();
            HeaderPropertyMap = new Dictionary <String, String>();

            ListViewColumnItem[] Columns = new ListViewColumnItem[]
            {
                new ListViewColumnItem("ID", "ID", 5, HorizontalAlignment.Center),
                new ListViewColumnItem("地图", "Map", 20, HorizontalAlignment.Center),
                new ListViewColumnItem("物品", "Item", 20, HorizontalAlignment.Left),
                new ListViewColumnItem("状态", "Status", 1, HorizontalAlignment.Center),
                new ListViewColumnItem("X", "ActorX", 1, HorizontalAlignment.Left),
                new ListViewColumnItem("Y", "ActorY", 1, HorizontalAlignment.Left),
                new ListViewColumnItem("Z", "ActorZ", 1, HorizontalAlignment.Left),
                new ListViewColumnItem("描述", "Description", 50, HorizontalAlignment.Center),
            };

            Func <Double, long> GetWidth = (Double percent) =>
            {
                return((long)Math.Ceiling(percent * Columns.Length / 100));
            };

            var lvlmgr = new ListViewLayoutManager(bonusBoxList);

            lvlmgr.VerticalScrollBarVisibility     = ScrollBarVisibility.Auto;
            lvlmgr.HorizontalScrollBarVisibility   = ScrollBarVisibility.Auto;
            lvlmgr.AttachScrollViewerScrollChanged = true;

            Style headerStyle = new Style();

            headerStyle.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.White));

            bonusBoxGridView.SetValue(GridView.ColumnHeaderContainerStyleProperty, headerStyle);

            foreach (var col in Columns)
            {
                HeaderPropertyMap[col.Header] = col.Binding;

                GridViewColumn column = new GridViewColumn();

                column.Header       = col.Header;
                column.CellTemplate = CreateColumnTemplate(col.Binding, col.Alignment);
                column.SetValue(GridViewColumn.HeaderContainerStyleProperty, headerStyle);

                bonusBoxGridView.Columns.Add(ProportionalColumn.ApplyWidth(column, GetWidth(col.WidthPercent)));
            }

            //String boxinfo = @"E:\Desktop\Source\Hooks\EDAO\Decompiler\GameData\box.json";
            String boxinfo = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\box.json";

            try
            {
                InitializeBonusBoxInfo(boxinfo);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Resizes the grid view columns.
        /// </summary>
        /// <param name="pColumnIndex">The specific index of the resized column, or -1 if the whole control is resized.</param>
        private void ResizeColumns(int pColumnIndex)
        {
            if (this.mListView.View == null || this.mListView.View.Columns.Count == 0)
            {
                return;
            }

            // Computing the listview width.
            double lActualWidth = double.PositiveInfinity;

            if (mScrollViewer != null)
            {
                lActualWidth = this.mScrollViewer.ViewportWidth;
            }
            if (double.IsInfinity(lActualWidth))
            {
                lActualWidth = this.mListView.ActualWidth;
            }
            if (double.IsInfinity(lActualWidth) || lActualWidth <= 0)
            {
                return;
            }

            // Computing column sizes.
            double lResizeableRegionCount = 0;
            double lOtherColumnsWidth     = 0;

            foreach (GridViewColumn lColumn in this.mListView.View.Columns)
            {
                if (ProportionalColumn.IsProportionalColumn(lColumn))
                {
                    double?lProportionalWidth = ProportionalColumn.GetProportionalWidth(lColumn);
                    if (lProportionalWidth != null)
                    {
                        lResizeableRegionCount += lProportionalWidth.Value;
                    }
                }
                else
                {
                    lOtherColumnsWidth += lColumn.ActualWidth;
                }
            }

            if (lResizeableRegionCount <= 0)
            {
                // No proportional columns present : commit the regulation to the scroll viewer.
                if (this.mScrollViewer != null)
                {
                    this.mScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                }

                // Searching for the first fill column.
                GridViewColumn lFillColumn = null;
                for (int lIter = 0; lIter < this.mListView.View.Columns.Count; lIter++)
                {
                    GridViewColumn lColumn = this.mListView.View.Columns[lIter];
                    if (IsFillColumn(lColumn))
                    {
                        lFillColumn = lColumn;
                        break;
                    }
                }

                if (lFillColumn != null)
                {
                    // Applying the width to the fill column taking in account the range.
                    double lOtherColumnsWithoutFillWidth = lOtherColumnsWidth - lFillColumn.ActualWidth;
                    double lFillWidth = lActualWidth - lOtherColumnsWithoutFillWidth;
                    if (lFillWidth > 0)
                    {
                        double?lMinWidth = RangeColumn.GetRangeMinWidth(lFillColumn);
                        double?lMaxWidth = RangeColumn.GetRangeMaxWidth(lFillColumn);

                        bool lSetWidth = (lMinWidth.HasValue && lFillWidth < lMinWidth.Value) == false;
                        if (lMaxWidth.HasValue && lFillWidth > lMaxWidth.Value)
                        {
                            lSetWidth = false;
                        }

                        if (lSetWidth)
                        {
                            if (this.mScrollViewer != null)
                            {
                                this.mScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
                            }
                            lFillColumn.Width = lFillWidth;
                        }
                    }
                }
                return;
            }

            // Some proportional columns have been defined.
            double lResizeableColumnsWidth = lActualWidth - lOtherColumnsWidth;

            if (lResizeableColumnsWidth <= 0)
            {
                // Missing space.
                return;
            }

            // Resize proportional columns.
            double lResizeableRegionWidth = lResizeableColumnsWidth / lResizeableRegionCount;

            foreach (GridViewColumn lColumn in this.mListView.View.Columns)
            {
                if (ProportionalColumn.IsProportionalColumn(lColumn))
                {
                    if (pColumnIndex == -1)
                    {
                        // Computing the initial width.
                        double?lProportionalWidth = ProportionalColumn.GetProportionalWidth(lColumn);
                        if (lProportionalWidth != null)
                        {
                            lColumn.Width = lProportionalWidth.Value * lResizeableRegionWidth;
                        }
                    }
                    else
                    {
                        int lCurrentIndex = this.mListView.View.Columns.IndexOf(lColumn);
                        if (pColumnIndex == lCurrentIndex)
                        {
                            // Adapting the ratio so that the column can be resized.
                            ProportionalColumn.ApplyWidth(lColumn, lColumn.Width / lResizeableRegionWidth);
                        }
                        else if (lCurrentIndex > pColumnIndex)
                        {
                            // Computing the initial width for the colums after the one resized.
                            double?proportionalWidth = ProportionalColumn.GetProportionalWidth(lColumn);
                            if (proportionalWidth != null)
                            {
                                lColumn.Width = proportionalWidth.Value * lResizeableRegionWidth;
                            }
                        }
                    }
                }
            }
        }