Esempio n. 1
0
        public CustomManagerProperty(TextBox textBox, string grfPath, string ext, int row, int col, int rSpan, int cSpan)
        {
            _image = new Image {
                Stretch = Stretch.None, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            _image.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);
            _viewer = new ScrollViewer();

            Grid grid = new Grid();

            //grid.ColumnDefinitions.Add(new ColumnDefinition)
            WpfUtilities.SetGridPosition(_viewer, row, rSpan, col, cSpan);

            _viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            _viewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            _viewer.Content = _image;

            _textBox              = textBox;
            _grfPath              = grfPath.Trim('\\');
            _ext                  = ext;
            _attribute            = null;
            _textBox.TextChanged += _textBox_TextChanged;
            VirtualFileDataObject.SetDraggable(_image, _wrapper);

            _viewer.SizeChanged += delegate { _viewer.MaxHeight = _viewer.ActualHeight; };
        }
        public CustomResourceProperty(Image imagePreview, string grfPath1, string grfPath2, string ext, int row, int column, DbAttribute attribute)
        {
            _imageResource        = new Image();
            _imageResource.Margin = new Thickness(3);
            _imageResource.Width  = 22;
            _imagePreview         = imagePreview;
            _grfPath1             = grfPath1;
            _grfPath2             = grfPath2;
            _textBox        = new TextBox();
            _textBox.Margin = new Thickness(3);

            _imageResource.Stretch             = Stretch.None;
            _imageResource.HorizontalAlignment = HorizontalAlignment.Left;
            _imageResource.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

            imagePreview.Stretch             = Stretch.None;
            imagePreview.HorizontalAlignment = HorizontalAlignment.Left;
            imagePreview.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

            _gridRow    = row;
            _gridColumn = column;
            _ext        = ext;
            _attribute  = attribute;

            _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged);
            VirtualFileDataObject.SetDraggable(_imageResource, _wrapper1);
            VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper2);
        }
        public MultiGrfExplorer(MultiGrfReader metaGrf, string explorerPath, string filter, string selected)
            : base("Meta GRF explorer", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar = true;
            _explorerPath = explorerPath.ToLower();
            _metaGrf      = metaGrf;
            //metaGrf.Lock();

            if (filter != "")
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry).Where(p => p.RelativePath.IndexOf(filter, StringComparison.OrdinalIgnoreCase) > -1));
            }
            else
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry));
            }

            _entriesAll.AddRange(_entries);

            foreach (FileEntry entry in _entries)
            {
                entry.DataImage = entry.DisplayRelativePath;
            }

            _loadEncoding();

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_items, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "File name", DisplayExpression = "DataImage", ToolTipBinding = "RelativePath", IsFill = true, MinWidth = 60, TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Type", DisplayExpression = "FileType", FixedWidth = 40, TextAlignment = TextAlignment.Right, ToolTipBinding = "FileType"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "DisplaySize"
                },
            }, new MetaGrfSorter(), new string[] { });

            _items.MouseDoubleClick += new MouseButtonEventHandler(_items_MouseDoubleClick);

            _items.ItemsSource = _entries;
            VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper);

            ApplicationShortcut.Link(ApplicationShortcut.Copy, _copyItems, _items);
            ApplicationShortcut.Link(ApplicationShortcut.Confirm, () => _buttonSelect_Click(null, null), _items);

            this.Loaded += delegate {
                _items.SelectedItem = _entries.FirstOrDefault(p => String.CompareOrdinal(p.DisplayRelativePath, selected.ToDisplayEncoding(true) + ".bmp") == 0);
                _items.ScrollToCenterOfView(_items.SelectedItem);
            };

            this.Owner = WpfUtilities.TopWindow;
        }