Ejemplo n.º 1
0
        public DistributionRegionExplorer(TaxaPlugin plugin, User user) : base(user, "Distribution Region Explorer")
        {
            InitializeComponent();

            this.Plugin = plugin;

            Loaded           += new RoutedEventHandler(DistributionRegionExplorer_Loaded);
            this.Unloaded    += new RoutedEventHandler(DistributionRegionExplorer_Unloaded);
            ChangesCommitted += new PendingChangesCommittedHandler(DistributionRegionExplorer_ChangesCommitted);

            TreeViewDragHelper.Bind(tvwRegions, TreeViewDragHelper.CreatePinnableGenerator(plugin.Name, LookupType.DistributionRegion));
            TreeViewDragHelper.Bind(tvwFind, TreeViewDragHelper.CreatePinnableGenerator(plugin.Name, LookupType.DistributionRegion));

            txtFind.PreviewKeyDown += new KeyEventHandler(txtFind_PreviewKeyDown);
        }
        public MaterialExplorer(MaterialPlugin owner)
            : base(owner.User)
        {
            InitializeComponent();

            BuildDropMap();

            this.ChangeRegistered += new PendingChangedRegisteredHandler((s, action) => {
                btnApply.IsEnabled  = true;
                btnCancel.IsEnabled = true;
            });

            this.ChangesCommitted += new PendingChangesCommittedHandler((list) => {
                ReloadModel();
                btnApply.IsEnabled  = false;
                btnCancel.IsEnabled = false;
            });

            this.Owner = owner;

            this.RememberExpanded = Config.GetGlobal <bool>("Material.RememberExpandedNodes", true);

            var findScopes = new List <MaterialFindScope>();

            findScopes.Add(new MaterialFindScope("Find in all", ""));
            findScopes.Add(new MaterialFindScope("Site name", "site"));
            findScopes.Add(new MaterialFindScope("Trap name", "trap"));
            findScopes.Add(new MaterialFindScope("Visit name", "visit"));
            findScopes.Add(new MaterialFindScope("Material name", "material"));
            findScopes.Add(new MaterialFindScope("Accession No.", "accessionno"));
            findScopes.Add(new MaterialFindScope("Registraton No.", "regno"));
            findScopes.Add(new MaterialFindScope("Region name", "region"));
            findScopes.Add(new MaterialFindScope("Site group name", "group"));
            findScopes.Add(new MaterialFindScope("Collector #", "collector"));

            cmbFindScope.ItemsSource       = findScopes;
            cmbFindScope.DisplayMemberPath = "Label";
            cmbFindScope.PreviewKeyDown   += new KeyEventHandler(cmbFindScope_PreviewKeyDown);

            int lastSelectedIndex = Config.GetUser(User, "Material.Find.LastFilter", -1);

            if (lastSelectedIndex < 0 || lastSelectedIndex >= findScopes.Count)
            {
                cmbFindScope.SelectedIndex = 0;
            }
            else
            {
                cmbFindScope.SelectedIndex = lastSelectedIndex;
            }

            TreeViewDragHelper.Bind(tvwFind, CreatePinnableDragObject);
            TreeViewDragHelper.Bind(tvwMaterial, CreatePinnableDragObject);

            tvwMaterial.PreviewDragOver  += new DragEventHandler(tvwMaterial_PreviewDragOver);
            tvwMaterial.PreviewDragEnter += new DragEventHandler(tvwMaterial_PreviewDragOver);

            tvwFind.PreviewDragOver  += new DragEventHandler(tvwFind_PreviewDragOver);
            tvwFind.PreviewDragEnter += new DragEventHandler(tvwFind_PreviewDragOver);

            this.Drop += new DragEventHandler(MaterialExplorer_Drop);

            var service = new MaterialService(User);

            tvwMaterial.AllowDrop = true;
            _favorites            = new MaterialFavorites(User, this);
            tabMaterial.AddTabItem("Favorites", _favorites);

            txtFind.PreviewKeyDown += new KeyEventHandler(txtFind_PreviewKeyDown);

            tvwFind.MouseDoubleClick     += new MouseButtonEventHandler((sender, e) => PerformDefaultAction(sender as TreeView));
            tvwMaterial.MouseDoubleClick += new MouseButtonEventHandler((sender, e) => PerformDefaultAction(sender as TreeView));
        }