//
// Copyright 2014 Perforce Software Inc.
//
using Perforce.ViewModel;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace Perforce.View {
///
/// Interaction logic for SearchView.xaml
///
public partial class SearchView : UserControl, SidebarView {
private SearchSelectorViewModel _model;
public SearchView(SearchSelectorViewModel model) {
InitializeComponent();
_model = model;
this.DataContext = _model;
}
public SearchSelectorViewModel Model {
get { return _model; }
set {
_model = value;
this.DataContext = _model;
}
}
public Grid ListingGrid {
get { return ResultsGrid; }
set { ResultsGrid = value; }
}
private void ShowMoreButton_Click(object sender, RoutedEventArgs e) {
if (ShowMoreButton.IsChecked.Value) {
SearchOptions.Visibility = System.Windows.Visibility.Visible;
} else {
SearchOptions.Visibility = System.Windows.Visibility.Collapsed;
}
}
private void UIEvent_Click(object sender, RoutedEventArgs e) {
_model.Refresh();
}
private void SearchTags_SelectionChanged(object sender, SelectionChangedEventArgs e) {
var combo = (sender as ComboBox);
var obj = (SelectableObject) combo.SelectedItem;
if (obj != null) {
obj.IsSelected = !obj.IsSelected;
if (obj.IsSelected) {
_model.AddTagFilter(obj.ObjectData);
} else {
_model.RemoveTagFilter(obj.ObjectData);
}
(sender as ComboBox).SelectedItem = null;
_model.Refresh();
}
}
private void ResultsGrid_Loaded(object sender, RoutedEventArgs e) {
Console.WriteLine("#### RESULTS LOADED");
}
private void SearchTags_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) {
_model.ForceReload("TagList");
}
private void TagCheckBox_Checked(object sender, RoutedEventArgs e) {
Console.WriteLine("### CHECKBOX CHECK/UNCHECK");
//StringBuilder sb = new StringBuilder();
//foreach (SelectableObject obj in SearchTags.Items)
// if (obj.IsSelected)
// sb.AppendFormat("{0}, ", obj.ObjectData);
//SearchTags.Text = sb.ToString().Trim().TrimEnd(',');
}
private void TagCheckBox_Click(object sender, RoutedEventArgs e) {
Console.WriteLine("### CHECKBOX CLICK");
}
}
}