/// <summary> /// 新しい検索を開始してページを移動 /// </summary> /// <param name="criteria"></param> public bool StartNewSearch(ISqlSearch criteria) { var search = new SearchInformation(new ComplexSearch(false)); if (criteria != null) { search.Root.Add(criteria); } //// 同じ内容の検索は無視 //if (this.front.FeaturedGroup == null && this.front.SearchInformation != null) //{ // if (this.SelectedPage.Value == PageType.Catalog // && this.front.SearchInformation.SettingEquals(search)) // { // Debug.WriteLine("same search"); // return false; // } //} this.SetNewSearch(search); this.ChangePage(PageType.Catalog, null, 0); return(true); }
public ComplexSearch Add(ISqlSearch method) { this.InnerChildren.Add(method); method.Parent = this; this.IsEditedInner = true; return(this); }
public void Remove(ISqlSearch item) { if (this.InnerChildren.Contains(item)) { this.InnerChildren.Remove(item); this.IsEditedInner = true; } }
private void EditSearch(ISqlSearch search) { var editor = new SearchSettingEditor() { DataContext = new EditSearchViewModel(search), }; this.parent.PopupOwner.PopupDialog.Show(editor, default(Thickness), HorizontalAlignment.Center, VerticalAlignment.Center); }
public bool ValueEquals(ISqlSearch other) { if (this.IsUnit != other.IsUnit) { return(false); } var ot = (UnitSearch)other; return(this.Property == ot.Property && this.Mode == ot.Mode && this.ReferenceLabel.Equals(ot.ReferenceLabel)); }
public bool ValueEquals(ISqlSearch other) { if (object.ReferenceEquals(this, other)) { return(true); } if (this.IsUnit != other.IsUnit) { return(false); } var ot = (ComplexSearch)other; return(this.IsOr == ot.IsOr && this.InnerChildren.SequenceEqual(ot.InnerChildren, (x, y) => x.ValueEquals(y))); }
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); }