private void searchCriteriaItemRoot_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { var item = this.DataContext as ISqlSearch; var core = ((App)Application.Current).Core; this.IsSVO = core.IsSVOLanguage; this.disposables.Clear(); if (item == null) { this.BackGroundColor = new SolidColorBrush(Colors.Gray); this.IsComplex = false; this.Mode = null; this.Property = null; } else if (item.IsUnit) { this.BackGroundColor = (Brush)Application.Current.Resources["UnitSearchItemColor"]; this.IsComplex = false; var unit = (UnitSearch)item; var isVString = core.GetResourceString("IsV"); unit.ObserveProperty(x => x.Property) .Select(x => x.GetPropertyLabel() + isVString) .Subscribe(x => this.Property = x) .AddTo(this.disposables); unit.ObserveProperty(x => x.Mode) .CombineLatest(unit.ObserveProperty(x => x.Property), (m, p) => p.GetCompareLabel(m)) .Subscribe(x => this.Mode = x) .AddTo(this.disposables); } else { this.BackGroundColor = (Brush)Application.Current.Resources["ComplexSearchItemColor"]; this.IsComplex = true; this.Property = null; var pack = (ComplexSearch)item; pack.ObserveProperty(x => x.IsOr) .Select(x => FilePropertyManager.GetMatchLabel(x)) .Subscribe(x => this.Mode = x) .AddTo(this.disposables); } //this.rootGrid.DataContext = null; //this.rootGrid.DataContext = item; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var isOr = value as bool?; if (isOr.HasValue) { return(FilePropertyManager.GetMatchLabel(isOr.Value)); } return(""); }
public SortEditor() { if (PropertyList == null) { PropertyList = FilePropertyManager.GetPropertyListToSort().Select(x => x.Value).ToList(); } InitializeComponent(); this.SortSettings = new ObservableCollection <SortSetting>(); this.itemsList.ItemsSource = this.SortSettings; }
private void InitializeResourceString() { FilePropertyManager.InitializeLabels(x => this.GetResourceString(x)); CompareModeManager.InitializeLabels(x => this.GetResourceString(x)); var language = GetResourceString("Language"); if (language.ToLower().Contains("ja")) { this.IsSVOLanguage = false; } else { this.IsSVOLanguage = true; } }
public static SortSetting FromText(string text) { if (text == null || text.Length <= 0) { return(null); } var items = text.Split('-'); if (items.Length < 2) { return(null); } var property = FilePropertyManager.FromName(items[0]); var isDescending = items[1].Equals("D"); return(new SortSetting() { Property = property, IsDescending = isDescending }); }
public EditSearchViewModel(ISqlSearch source) { var core = ((App)Application.Current).Core; this.library = core.Library; this.settings = core; this.unsubscribers = new CompositeDisposable(); this.PropertyList = FilePropertyManager.GetPropertyListToSearch() .Select(x => new KeyValuePair <string, PropertyContainer>(x.Key, new PropertyContainer(x.Value))) .ToList(); if (!source.IsUnit) { this.PropertyList.Add (new KeyValuePair <string, PropertyContainer> (settings.GetResourceString("MatchAll"), new PropertyContainer(ComplexMode.And))); this.PropertyList.Add (new KeyValuePair <string, PropertyContainer> (settings.GetResourceString("MatchAny"), new PropertyContainer(ComplexMode.Or))); } this.PropertyComboBoxDefault = settings.GetResourceString("Property"); this.TagComboBoxDefault = settings.GetResourceString("Tag"); this.CompareOperator = new List <KeyValuePair <string, CompareMode> >(); this.AddCompareSymbol(CompareMode.Great); this.AddCompareSymbol(CompareMode.GreatEqual); this.AddCompareSymbol(CompareMode.Equal); this.AddCompareSymbol(CompareMode.LessEqual); this.AddCompareSymbol(CompareMode.Less); this.AddCompareSymbol(CompareMode.NotEqual); this.EqualitySelector = new ObservableCollection <string>() { "", "" }; this.isSVO = settings.IsSVOLanguage; this.BelowRefString = settings.GetResourceString("BelowRef"); this.IsVString = settings.GetResourceString("IsV"); this.SourceItem = source; var unit = source.IsUnit ? (UnitSearch)source : null; this.Init(unit); this.IsEditing = new ReactiveProperty <bool>(true).AddTo(this.unsubscribers); this.OkCommand = this.PropertyListSelectedIndex .Select(x => x >= 0) .ToReactiveCommand() .WithSubscribe(_ => { this.Commit(); this.IsEditing.Value = false; }, this.unsubscribers); this.CancelCommand = new ReactiveCommand() .WithSubscribe(_ => this.IsEditing.Value = false, this.unsubscribers); var propertyObserver = this.PropertyListSelectedIndex .Select(x => { var container = this.GetProperty(x); return(new { Property = container.Property, Enable = (container.Complex == ComplexMode.None && container.IsValid) }); }) .Publish().RefCount(); this.CompareListVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property.IsComperable())) .ToReactiveProperty().AddTo(this.unsubscribers); this.EqualityListVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && !x.Property.IsComperable())) .ToReactiveProperty().AddTo(this.unsubscribers); this.NumericTextVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property.IsInteger())) .ToReactiveProperty().AddTo(this.unsubscribers); this.FloatTextVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property.IsFloat())) .ToReactiveProperty().AddTo(this.unsubscribers); this.DirectoryListVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property == FileProperty.DirectoryPathStartsWith)) .ToReactiveProperty().AddTo(this.unsubscribers); this.TagListVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property == FileProperty.ContainsTag)) .ToReactiveProperty().AddTo(this.unsubscribers); this.TextBoxVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property.IsText())) .ToReactiveProperty().AddTo(this.unsubscribers); this.DateVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && x.Property.IsDate())) .ToReactiveProperty().AddTo(this.unsubscribers); this.IsVStringVisibility = propertyObserver .Select(x => VisibilityHelper.Set(x.Enable && !this.isSVO)) .ToReactiveProperty().AddTo(this.unsubscribers); this.PropertyComboBoxDefaultVisibility = this.PropertyListSelectedIndex .Select(x => VisibilityHelper.Set(x < 0)) .ToReactiveProperty() .AddTo(this.unsubscribers); this.TagComboBoxDefaultVisibility = new[] { this.TagListSelectedIndex.Select(x => x < 0), propertyObserver.Select(x => x.Enable && x.Property == FileProperty.ContainsTag) } .CombineLatestValuesAreAllTrue() .Select(x => VisibilityHelper.Set(x)) .ToReactiveProperty() .AddTo(this.unsubscribers); propertyObserver.Subscribe(x => { if (x.Enable) { var currentIndex = this.EqualitySelectedIndex.Value; this.EqualitySelector[this.GetEqualitySelectorIndex(true)] = x.Property.GetEqualityLabel(true); this.EqualitySelector[this.GetEqualitySelectorIndex(false)] = x.Property.GetEqualityLabel(false); this.EqualitySelectedIndex.Value = currentIndex; } }).AddTo(this.unsubscribers); this.PropertyListSelectedIndex.Value = unit == null ? -1 : this.PropertyList.FindIndex(x => x.Value.Property == unit.Property); }