示例#1
0
        void rightPanel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            StackPanel curPanel = sender as StackPanel;

            MouseDowned = true;
            curPanel.CaptureMouse();
            oldMousePos = e.GetPosition(drawingPanel);
        }
示例#2
0
        private void InitMaps()
        {
            MapTileGrid.Children.Clear();

            var filter = MapFilterTextBox.Text;

            var children = new List <StackPanel>();

            for (var i = 0; i < Storage.DbcStorage.Map.NumRows; ++i)
            {
                var row   = Storage.DbcStorage.Map.GetRow(i);
                var title = row.GetString(Storage.MapFormatGuess.FieldMapTitle);
                if (string.IsNullOrEmpty(filter) == false && title.ToLowerInvariant().Contains(filter.ToLowerInvariant()) == false)
                {
                    continue;
                }

                var panel = new StackPanel
                {
                    Orientation = Orientation.Vertical,
                    Width       = 120,
                    Height      = 120,
                    Background  = new SolidColorBrush(Color.FromRgb(80, 80, 80)),
                    Margin      = new Thickness(5, 5, 0, 0)
                };

                var titleLabel = new TextBlock
                {
                    Text = title,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    FontSize            = 16,
                    Foreground          = Brushes.White,
                    TextWrapping        = TextWrapping.Wrap,
                    Margin = new Thickness(3, 3, 3, 3)
                };

                panel.Children.Add(titleLabel);
                panel.Tag = false;

                panel.MouseEnter += (sender, args) =>
                {
                    var down = panel.Tag as Boolean?;
                    if (down ?? true)
                    {
                        return;
                    }

                    panel.Background = new SolidColorBrush(Color.FromRgb(120, 120, 120));
                };

                panel.MouseLeave += (sender, args) =>
                {
                    var down = panel.Tag as Boolean?;
                    if (down ?? true)
                    {
                        return;
                    }
                    panel.Background = new SolidColorBrush(Color.FromRgb(80, 80, 80));
                };

                panel.MouseDown += (sender, args) =>
                {
                    panel.Background = new SolidColorBrush(Color.FromRgb(60, 60, 60));
                    panel.Tag        = true;
                    panel.CaptureMouse();
                };

                panel.MouseUp += (sender, args) =>
                {
                    if ((panel.Tag as Boolean?) ?? false)
                    {
                        EntrySelectView.MapSelected(row.GetInt32(0));
                        var scroll = MapTileGrid.Parent as ScrollViewer;
                        if (scroll == null)
                        {
                            return;
                        }

                        var g = scroll.Parent as Grid;
                        if (g != null)
                        {
                            g.Visibility = Visibility.Collapsed;
                        }

                        EntrySelectView.Visibility = Visibility.Visible;
                    }

                    panel.Background =
                        new SolidColorBrush(panel.IsMouseOver ? Color.FromRgb(120, 120, 120) : Color.FromRgb(80, 80, 80));
                    panel.Tag = false;
                    panel.ReleaseMouseCapture();
                };

                children.Add(panel);
            }

            if (MapSortTypeCheckBox.IsChecked ?? false)
            {
                children.Sort((e1, e2) => String.Compare(((TextBlock)e1.Children[0]).Text, ((TextBlock)e2.Children[0]).Text, StringComparison.Ordinal));
            }

            children.ForEach(c => MapTileGrid.Children.Add(c));

            var scroller = MapTileGrid.Parent as ScrollViewer;

            if (scroller == null)
            {
                return;
            }

            var grid = scroller.Parent as Grid;

            if (grid != null)
            {
                grid.Visibility = Visibility.Visible;
            }
        }