string CreateHeadAttrs(IFieldInfoEx field, int index, int sortField, ListSortInfo sortRow) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); Tk5FieldInfoEx tk5Field = field.Convert<Tk5FieldInfoEx>(); builder.Add("class", "text-left text-nowrap"); //if (tk5Field.DataType == TkDataType.Text || (tk5Field.ListDetail != null && tk5Field.ListDetail.TextHead)) //{ // builder.Add("class", "text-left text-nowrap"); //} //else //{ // builder.Add("data-sort", index.ToString()); // string order = sortRow.Order; // string sortClass = string.Empty; // if (index == sortField) // { // order = order == "DESC" ? "ASC" : "DESC"; // sortClass = "sort-" + order; // } // builder.Add("data-order", order); // builder.Add("class", HtmlUtil.MergeClass("text-left text-nowrap", sortClass.ToLower())); //} return builder.CreateAttribute(); }
string CreateHeadAttrs(IFieldInfoEx field, int index, int sortField, ListSortInfo sortRow) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); Tk5FieldInfoEx tk5Field = field.Convert <Tk5FieldInfoEx>(); builder.Add("class", "text-left text-nowrap"); //if (tk5Field.DataType == TkDataType.Text || (tk5Field.ListDetail != null && tk5Field.ListDetail.TextHead)) //{ // builder.Add("class", "text-left text-nowrap"); //} //else //{ // builder.Add("data-sort", index.ToString()); // string order = sortRow.Order; // string sortClass = string.Empty; // if (index == sortField) // { // order = order == "DESC" ? "ASC" : "DESC"; // sortClass = "sort-" + order; // } // builder.Add("data-order", order); // builder.Add("class", HtmlUtil.MergeClass("text-left text-nowrap", sortClass.ToLower())); //} return(builder.CreateAttribute()); }
public Tuple<ListSortInfo, CountInfo, object> CreatePageInfo(IInputData input, int pageNumber, int pageSize) { ListSortInfo list = new ListSortInfo(input); CountInfo pageInfo = new CountInfo(Count, 0, Count == 0 ? 1 : Count); return Tuple.Create<ListSortInfo, CountInfo, object>(list, pageInfo, null); }
public Tuple <ListSortInfo, CountInfo, object> CreatePageInfo(IInputData input, int pageNumber, int pageSize) { ListSortInfo list = new ListSortInfo(input); CountInfo pageInfo = new CountInfo(Count, 0, Count == 0 ? 1 : Count); return(Tuple.Create <ListSortInfo, CountInfo, object>(list, pageInfo, null)); }
public void Init() { { this.SelectedItem = new ReactiveProperty <SearchCondition <SearchRange <long> > >().AddTo(_disposable); this.SelectedItem.Where(n => n != null).Subscribe(n => { this.Contains.Value = n.IsContains; this.MinInput.Value = n.Value.Min; this.MaxInput.Value = n.Value.Max; }).AddTo(_disposable); this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.Contains = new ReactiveProperty <bool>(true).AddTo(_disposable); this.MinInput = new ReactiveProperty <long>(0).AddTo(_disposable); this.MaxInput = new ReactiveProperty <long>(long.MaxValue).AddTo(_disposable); this.AddCommand = new ReactiveCommand().AddTo(_disposable); this.AddCommand.Subscribe(() => this.Add()).AddTo(_disposable); this.EditCommand = this.SelectedItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.EditCommand.Subscribe(() => this.Edit()).AddTo(_disposable); this.DeleteCommand = this.SelectedItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.DeleteCommand.Subscribe(() => this.Delete()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(LengthSearchConditionsControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _sortInfo = _settings.Load("SortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Contains" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } { this.Sort(null); } }
public void Init() { { this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.DeleteCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.DeleteCommand.Subscribe(() => this.Delete()).AddTo(_disposable); this.CopyCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.CopyCommand.Subscribe(() => this.Copy()).AddTo(_disposable); this.PasteCommand = new ReactiveCommand().AddTo(_disposable); this.PasteCommand.Subscribe(() => this.Paste()).AddTo(_disposable); this.ContainsCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.ContainsCommand.Subscribe(() => this.ChangeContains()).AddTo(_disposable); this.NotContainsCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.NotContainsCommand.Subscribe(() => this.ChangeNotContains()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(SignatureSearchConditionsControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _sortInfo = _settings.Load("SortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Contains" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } { this.Sort(null); } }
private void Init() { { this.SelectedItem = new ReactiveProperty <string>().AddTo(_disposable); this.SubscribeSignaturesSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SubscribeSignaturesSortCommand.Subscribe((propertyName) => this.SubscribeSignaturesSort(propertyName)).AddTo(_disposable); this.SubscribeDeleteCommand = new ReactiveCommand().AddTo(_disposable); this.SubscribeDeleteCommand.Subscribe(() => this.SubscribeDelete()).AddTo(_disposable); this.SubscribeCopyCommand = new ReactiveCommand().AddTo(_disposable); this.SubscribeCopyCommand.Subscribe(() => this.SubscribeCopy()).AddTo(_disposable); this.SubscribePasteCommand = new ReactiveCommand().AddTo(_disposable); this.SubscribePasteCommand.Subscribe(() => this.SubscribePaste()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(ViewOptionsControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _subscribeSignaturesSortInfo = _settings.Load("SubscribeSignaturesSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Signature" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } this.GetOptions(); { Backup.Instance.SaveEvent += this.Save; } { this.SubscribeSignaturesSort(null); } }
private void Init() { { this.ConnectionSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.ConnectionSortCommand.Subscribe((propertyName) => this.ConnectionSort(propertyName)).AddTo(_disposable); this.ConnectionCopyCommand = this.ConnectionSelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.ConnectionCopyCommand.Subscribe(() => this.ConnectionCopy()).AddTo(_disposable); this.ConnectionPasteCommand = new ReactiveCommand().AddTo(_disposable); this.ConnectionPasteCommand.Subscribe(() => this.ConnectionPaste()).AddTo(_disposable); this.StateCopyCommand = this.StateSelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.StateCopyCommand.Subscribe(() => this.StateCopy()).AddTo(_disposable); this.LogCopyCommand = this.LogSelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.LogCopyCommand.Subscribe(() => this.LogCopy()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(CloudControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _connectionSortInfo = _settings.Load("ConnectionSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Type" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } { this.Setting_Log(); } }
private void Init(IEnumerable <Tag> tags) { { _contents.AddRange(tags); this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.CopyCommand = new ReactiveCommand().AddTo(_disposable); this.CopyCommand.Subscribe(() => this.Copy()).AddTo(_disposable); this.JoinCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.JoinCommand.Subscribe(() => this.Join()).AddTo(_disposable); this.CloseCommand = new ReactiveCommand().AddTo(_disposable); this.CloseCommand.Subscribe(() => this.Close()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "View", nameof(ChatTagListWindow)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _sortInfo = _settings.Load("SortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(this.DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { EventHooks.Instance.SaveEvent += this.Save; } { this.Sort(null); } }
public override void Execute() { ObjectListModel model = (ObjectListModel)Model; CountInfo countRow = model.Count; ListSortInfo sortRow = model.Sort; int sortField = sortRow.SortField; string tableName = ViewBag.MetaData.Table.TableName; IEnumerable <ObjectContainer> dataTable = model.List; UrlInfo urlInfo = model.CallerInfo.URL; string url = urlInfo.DSelfUrl; PageInfo pageInfo = model.CallerInfo.Info; string condition = sortRow.SqlCon; IEnumerable <IFieldInfoEx> fields = ViewBag.MetaData.Table.TableList; NormalListData pageData = (NormalListData)ViewBag.PageData; WriteLiteral("\r\n"); DefineSection("DefaultListHeader", () => { WriteLiteral("\r\n <tr>\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <th"); WriteLiteral(" class=\"text-center text-nowrap\""); WriteLiteral(">\r\n <div>"); Write(pageData.OperationCaption); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" "); int index = 0; WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { WriteLiteral(" <th "); Write(CreateHeadAttrs(field, index++, sortField, sortRow)); WriteLiteral(">\r\n <div>"); Write(field.DisplayName); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" "); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <th"); WriteLiteral(" class=\"text-center text-nowrap\""); WriteLiteral(">\r\n <div>"); Write(pageData.OperationCaption); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" </tr>\r\n"); }); DefineSection("DefaultListWidth", () => { WriteLiteral("\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <col "); Write(OperatorWidth(pageData.OperatorWidth)); WriteLiteral(" />\r\n"); } WriteLiteral(" "); int index = 0; WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { WriteLiteral(" <col "); Write(CreateColAttrs(field, index++, sortField)); WriteLiteral(" />\r\n"); } WriteLiteral(" "); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <col "); Write(OperatorWidth(pageData.OperatorWidth)); WriteLiteral(" />\r\n"); } }); DefineSection("DefaultTabSheet", () => { WriteLiteral("\r\n "); WriteLiteral("\r\n"); }); Write(RenderSectionOrDefault("TabSheet", "DefaultTabSheet")); WriteLiteral("\r\n<table"); WriteAttribute("class", Tuple.Create(" class=\"", 4099), Tuple.Create("\"", 4185) , Tuple.Create(Tuple.Create("", 4107), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("list-table table", pageData.Display.TableDisplayClass()) , 4107), false) ); WriteLiteral(">\r\n <colgroup>\r\n"); WriteLiteral(" "); Write(RenderSectionOrDefault("ListWidth", "DefaultListWidth")); WriteLiteral("\r\n </colgroup>\r\n"); if (pageData.ShowListHeader) { WriteLiteral(" <thead>\r\n"); WriteLiteral(" "); Write(RenderSectionOrDefault("ListHeader", "DefaultListHeader")); WriteLiteral("\r\n </thead>\r\n"); } WriteLiteral(" <tbody"); WriteLiteral(" id=\"pageList\""); WriteLiteral(" data-totalcount=\""); Write(countRow.TotalCount); WriteLiteral("\""); WriteLiteral(" data-totalpage=\""); Write(countRow.TotalPage); WriteLiteral("\""); WriteLiteral(" data-sort=\""); Write(sortField); WriteLiteral("\""); WriteLiteral(" data-order=\""); Write(sortRow.Order); WriteLiteral("\""); WriteLiteral(" data-page=\""); Write(countRow.CurrentPage); WriteLiteral("\""); WriteLiteral(" data-url=\""); Write(url); WriteLiteral("\""); WriteLiteral(" data-condition=\""); Write(condition); WriteLiteral("\""); WriteLiteral(" data-source=\""); Write(pageInfo.Source); WriteLiteral("\""); WriteLiteral(" "); WriteLiteral(">\r\n"); if (dataTable != null) { foreach (ObjectContainer row in dataTable) { string rowString = @RenderRow(row); if (rowString != null) { Write(rowString); } else { WriteLiteral(" <tr>\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <td"); WriteLiteral(" class=\"text-nowrap text-center\""); WriteLiteral(">"); Write(BootcssUtil.CreateRowOperators(model.RowOperators, row)); WriteLiteral("</td>\r\n"); } WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { Tk5FieldInfoEx fieldInfo = field.Convert <Tk5FieldInfoEx>(); string fieldString = @RenderFieldItem(row, fieldInfo); if (fieldString == null) { WriteLiteral(" <td>"); Write(fieldInfo.DisplayValue(row)); WriteLiteral("</td>\r\n"); } else { Write(fieldString); } } WriteLiteral("\r\n"); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <td"); WriteLiteral(" class=\"text-nowrap text-center\""); WriteLiteral(">"); Write(BootcssUtil.CreateRowOperators(model.RowOperators, row)); WriteLiteral("</td>\r\n"); } WriteLiteral("\r\n </tr>\r\n"); } } } WriteLiteral(" </tbody>\r\n</table>\r\n"); if (countRow.TotalCount == 0) { WriteLiteral(" <div"); WriteLiteral(" class=\"p30\""); WriteLiteral(">"); Write(pageData.NoDataCaption); WriteLiteral("</div>\r\n"); } else { if (@pageData.ShowPage) { } } }
private void Init() { { this.SelectedItem = new ReactiveProperty <string>().AddTo(_disposable); this.SignatureNewCommand = new ReactiveCommand().AddTo(_disposable); this.SignatureNewCommand.Subscribe(() => this.SignatureNew()).AddTo(_disposable); this.SignatureImportCommand = new ReactiveCommand().AddTo(_disposable); this.SignatureImportCommand.Subscribe(() => this.SignatureImport()).AddTo(_disposable); this.SignatureExportCommand = new ReactiveCommand().AddTo(_disposable); this.SignatureExportCommand.Subscribe(() => this.SignatureExport()).AddTo(_disposable); this.TrustSignaturesSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.TrustSignaturesSortCommand.Subscribe((propertyName) => this.TrustSignaturesSort(propertyName)).AddTo(_disposable); this.TrustSignaturesDeleteCommand = new ReactiveCommand().AddTo(_disposable); this.TrustSignaturesDeleteCommand.Subscribe(() => this.TrustSignaturesDelete()).AddTo(_disposable); this.TrustSignaturesCopyCommand = new ReactiveCommand().AddTo(_disposable); this.TrustSignaturesCopyCommand.Subscribe(() => this.TrustSignaturesCopy()).AddTo(_disposable); this.TrustSignaturesPasteCommand = new ReactiveCommand().AddTo(_disposable); this.TrustSignaturesPasteCommand.Subscribe(() => this.TrustSignaturesPaste()).AddTo(_disposable); this.UntrustSignaturesSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.UntrustSignaturesSortCommand.Subscribe((propertyName) => this.UntrustSignaturesSort(propertyName)).AddTo(_disposable); this.UntrustSignaturesDeleteCommand = new ReactiveCommand().AddTo(_disposable); this.UntrustSignaturesDeleteCommand.Subscribe(() => this.UntrustSignaturesDelete()).AddTo(_disposable); this.UntrustSignaturesCopyCommand = new ReactiveCommand().AddTo(_disposable); this.UntrustSignaturesCopyCommand.Subscribe(() => this.UntrustSignaturesCopy()).AddTo(_disposable); this.UntrustSignaturesPasteCommand = new ReactiveCommand().AddTo(_disposable); this.UntrustSignaturesPasteCommand.Subscribe(() => this.UntrustSignaturesPaste()).AddTo(_disposable); this.TagsSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.TagsSortCommand.Subscribe((propertyName) => this.TagsSort(propertyName)).AddTo(_disposable); this.TagNewCommand = new ReactiveCommand().AddTo(_disposable); this.TagNewCommand.Subscribe(() => this.TagNew()).AddTo(_disposable); this.TagsDeleteCommand = new ReactiveCommand().AddTo(_disposable); this.TagsDeleteCommand.Subscribe(() => this.TagsDelete()).AddTo(_disposable); this.TagsCopyCommand = new ReactiveCommand().AddTo(_disposable); this.TagsCopyCommand.Subscribe(() => this.TagsCopy()).AddTo(_disposable); this.TagsPasteCommand = new ReactiveCommand().AddTo(_disposable); this.TagsPasteCommand.Subscribe(() => this.TagsPaste()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "View", nameof(AccountOptionsControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _trustSignaturesSortInfo = _settings.Load("TrustSignaturesSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Signature" }); _untrustSignaturesSortInfo = _settings.Load("UntrustSignaturesSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Signature" }); _tagsSortInfo = _settings.Load("TagsSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(this.DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { EventHooks.Instance.SaveEvent += this.Save; } { this.TrustSignaturesSort(null); this.UntrustSignaturesSort(null); this.TagsSort(null); } }
private void Init() { { this.QuickSearchControlViewModel = new QuickSearchControlViewModel().AddTo(_disposable); this.QuickSearchControlViewModel.Text.Subscribe((words) => this.Search(words)).AddTo(_disposable); foreach (var rootSignature in SettingsManager.Instance.SubscribeSignatures) { _contents.AddRange(_builder.GetProfileViewModels(rootSignature)); } this.SelectedItem = new ReactiveProperty <ProfileViewModel>().AddTo(_disposable); this.SelectedItem.Subscribe((viewModel) => this.SelectChanged(viewModel)); this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.CopyCommand = this.SelectedItem.ObserveProperty(n => n.Value).Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.CopyCommand.Subscribe(() => this.Copy()).AddTo(_disposable); this.TrustSignaturesSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.TrustSignaturesSortCommand.Subscribe((propertyName) => this.TrustSignaturesSort(propertyName)).AddTo(_disposable); this.TrustCopyCommand = this.SelectedTrustSignatureItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.TrustCopyCommand.Subscribe(() => this.TrustCopy()).AddTo(_disposable); this.UntrustSignaturesSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.UntrustSignaturesSortCommand.Subscribe((propertyName) => this.UntrustSignaturesSort(propertyName)).AddTo(_disposable); this.UntrustCopyCommand = this.SelectedUntrustSignatureItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.UntrustCopyCommand.Subscribe(() => this.UntrustCopy()).AddTo(_disposable); this.TagsSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.TagsSortCommand.Subscribe((propertyName) => this.TagsSort(propertyName)).AddTo(_disposable); this.TagCopyCommand = this.SelectedTagItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.TagCopyCommand.Subscribe(() => this.TagCopy()).AddTo(_disposable); this.Comment = new ReactiveProperty <string>().AddTo(_disposable); this.DependencyViewModels = _dependencyModels.ToReadOnlyReactiveCollection(n => new RelationSignatureViewModel(null, n)).AddTo(_disposable); this.SelectedDependencyItem = new ReactiveProperty <TreeViewModelBase>().AddTo(_disposable); this.DependencyCopyCommand = this.SelectedDependencyItem.ObserveProperty(n => n.Value).Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.DependencyCopyCommand.Subscribe(() => this.DependencyCopy()).AddTo(_disposable); this.CloseCommand = new ReactiveCommand().AddTo(_disposable); this.CloseCommand.Subscribe(() => this.Close()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(RelationWindow)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _sortInfo = _settings.Load("SortInfo ", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Ranking" }); _trustSignaturesSortInfo = _settings.Load("TrustSignaturesSortInfo ", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Signature" }); _untrustSignaturesSortInfo = _settings.Load("UntrustSignaturesSortInfo ", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Signature" }); _tagsSortInfo = _settings.Load("TagsSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } { this.Sort(null); this.TrustSignaturesSort(null); this.UntrustSignaturesSort(null); this.TagsSort(null); } }
private void Init() { { IObservable <object> clipboardObservable; { var returnObservable = Observable.Return((object)null); var watchObservable = Observable.FromEventPattern <EventHandler, EventArgs>(h => Clipboard.ClipboardChanged += h, h => Clipboard.ClipboardChanged -= h).Select(n => (object)null); clipboardObservable = Observable.Merge(returnObservable, watchObservable); } this.SearchInput = new ReactiveProperty <string>().AddTo(_disposable); this.SearchCommand = this.SearchInput.Select(n => !string.IsNullOrWhiteSpace(n)).ToReactiveCommand().AddTo(_disposable); this.SearchCommand.Subscribe(() => this.Search()); this.TabViewModel = new ReactiveProperty <SearchViewModel>().AddTo(_disposable); this.TabSelectedItem = new ReactiveProperty <TreeViewModelBase>().AddTo(_disposable); this.TabSelectedItem.Subscribe((viewModel) => this.TabSelectChanged(viewModel)).AddTo(_disposable); this.TabClickCommand = new ReactiveCommand().AddTo(_disposable); this.TabClickCommand.Where(n => n == this.TabSelectedItem.Value).Subscribe((_) => this.Refresh()).AddTo(_disposable); this.TabNewSearchCommand = this.TabSelectedItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.TabNewSearchCommand.Subscribe(() => this.TabNewSearch()).AddTo(_disposable); this.TabEditCommand = this.TabSelectedItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.TabEditCommand.Subscribe(() => this.TabEdit()).AddTo(_disposable); this.TabDeleteCommand = this.TabSelectedItem.Select(n => n != this.TabViewModel.Value).ToReactiveCommand().AddTo(_disposable); this.TabDeleteCommand.Subscribe(() => this.TabDelete()).AddTo(_disposable); this.TabCutCommand = this.TabSelectedItem.Select(n => n != this.TabViewModel.Value).ToReactiveCommand().AddTo(_disposable); this.TabCutCommand.Subscribe(() => this.TabCut()).AddTo(_disposable); this.TabCopyCommand = this.TabSelectedItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.TabCopyCommand.Subscribe(() => this.TabCopy()).AddTo(_disposable); this.TabPasteCommand = this.TabSelectedItem.Select(n => n != null) .CombineLatest(clipboardObservable.Select(n => Clipboard.ContainsSearchInfo()), (r1, r2) => r1 && r2).ToReactiveCommand().AddTo(_disposable); this.TabPasteCommand.Subscribe(() => this.TabPaste()).AddTo(_disposable); this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.CopyCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.CopyCommand.Subscribe(() => this.Copy()).AddTo(_disposable); this.DownloadCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.DownloadCommand.Subscribe(() => this.Download()).AddTo(_disposable); this.AdvancedCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.AdvancedCopyCommand = new ReactiveCommand <string>().AddTo(_disposable); this.AdvancedCopyCommand.Subscribe((type) => this.AdvancedCopy(type)).AddTo(_disposable); this.RemoveCacheItemCommand = new ReactiveCommand().AddTo(_disposable); this.RemoveCacheItemCommand.Subscribe(() => this.RemoveCacheItem()).AddTo(_disposable); this.RemoveDownloadingItemCommand = new ReactiveCommand().AddTo(_disposable); this.RemoveDownloadingItemCommand.Subscribe(() => this.RemoveDownloadingItem()).AddTo(_disposable); this.RemoveDownloadedItemCommand = new ReactiveCommand().AddTo(_disposable); this.RemoveDownloadedItemCommand.Subscribe(() => this.RemoveDownloadedItem()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(SearchControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); { var model = _settings.Load("SearchInfo", () => { var searchInfo = new SearchInfo() { Name = "Search", IsExpanded = true }; { var pictureSearchItem = new SearchInfo() { Name = "Type - \"Picture\"" }; pictureSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(jpeg|jpg|jfif|gif|png|bmp)$", true))); searchInfo.Children.Add(pictureSearchItem); var movieSearchItem = new SearchInfo() { Name = "Type - \"Movie\"" }; movieSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(mpeg|mpg|avi|divx|asf|wmv|rm|ogm|mov|flv|vob)$", true))); searchInfo.Children.Add(movieSearchItem); var musicSearchItem = new SearchInfo() { Name = "Type - \"Music\"" }; musicSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(mp3|wma|m4a|ogg|wav|mid|mod|flac|sid)$", true))); searchInfo.Children.Add(musicSearchItem); var archiveSearchItem = new SearchInfo() { Name = "Type - \"Archive\"" }; archiveSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(zip|rar|7z|lzh|iso|gz|bz|xz|tar|tgz|tbz|txz)$", true))); searchInfo.Children.Add(archiveSearchItem); var documentSearchItem = new SearchInfo() { Name = "Type - \"Document\"" }; documentSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(doc|txt|pdf|odt|rtf)$", true))); searchInfo.Children.Add(documentSearchItem); var executableSearchItem = new SearchInfo() { Name = "Type - \"Executable\"" }; executableSearchItem.Conditions.SearchRegexes.Add(new SearchCondition <SearchRegex>(true, new SearchRegex(@"\.(exe|jar|sh|bat)$", true))); searchInfo.Children.Add(executableSearchItem); } return(searchInfo); }); this.TabViewModel.Value = new SearchViewModel(null, model); } _sortInfo = _settings.Load("SortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } }
private void Init() { { IObservable <object> clipboardObservable; { var returnObservable = Observable.Return((object)null); var watchObservable = Observable.FromEventPattern <EventHandler, EventArgs>(h => Clipboard.ClipboardChanged += h, h => Clipboard.ClipboardChanged -= h).Select(n => (object)null); clipboardObservable = Observable.Merge(returnObservable, watchObservable); } this.TabViewModel = new ReactiveProperty <StoreCategoryViewModel>().AddTo(_disposable); this.TabSelectedItem = new ReactiveProperty <TreeViewModelBase>().AddTo(_disposable); this.TabSelectedItem.Subscribe((viewModel) => this.TabSelectChanged(viewModel)).AddTo(_disposable); this.TabClickCommand = new ReactiveCommand().AddTo(_disposable); this.TabClickCommand.Where(n => n == this.TabSelectedItem.Value).Subscribe((_) => this.Refresh()).AddTo(_disposable); this.TabNewCategoryCommand = this.TabSelectedItem.Select(n => n is StoreCategoryViewModel).ToReactiveCommand().AddTo(_disposable); this.TabNewCategoryCommand.Subscribe(() => this.TabNewCategory()).AddTo(_disposable); this.TabEditCommand = this.TabSelectedItem.Select(n => n is StoreCategoryViewModel).ToReactiveCommand().AddTo(_disposable); this.TabEditCommand.Subscribe(() => this.TabEdit()).AddTo(_disposable); this.TabDeleteCommand = this.TabSelectedItem.Select(n => n != this.TabViewModel.Value && (n is StoreCategoryViewModel || n is StoreSignatureViewModel)).ToReactiveCommand().AddTo(_disposable); this.TabDeleteCommand.Subscribe(() => this.TabDelete()).AddTo(_disposable); this.TabCutCommand = this.TabSelectedItem.Select(n => n != this.TabViewModel.Value && (n is StoreCategoryViewModel || n is StoreSignatureViewModel)).ToReactiveCommand().AddTo(_disposable); this.TabCutCommand.Subscribe(() => this.TabCut()).AddTo(_disposable); this.TabCopyCommand = new ReactiveCommand().AddTo(_disposable); this.TabCopyCommand.Subscribe(() => this.TabCopy()).AddTo(_disposable); this.TabPasteCommand = this.TabSelectedItem.Select(n => n is StoreCategoryViewModel) .CombineLatest(clipboardObservable.Select(n => Clipboard.ContainsStoreCategoryInfo() || Clipboard.ContainsStoreSignatureInfo() || Clipboard.ContainsSignatures()), (r1, r2) => (r1 && r2)).ToReactiveCommand().AddTo(_disposable); this.TabPasteCommand.Subscribe(() => this.TabPaste()).AddTo(_disposable); this.SortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.SortCommand.Subscribe((propertyName) => this.Sort(propertyName)).AddTo(_disposable); this.ListViewDoubleClickCommand = new ReactiveCommand <StoreListViewItemInfo>().AddTo(_disposable); this.ListViewDoubleClickCommand.Subscribe((target) => this.ListViewDoubleClick(target)); this.UpMoveCommand = this.TabSelectedItem.Select(n => n?.Parent != null).ToReactiveCommand().AddTo(_disposable); this.UpMoveCommand.Subscribe(() => this.UpMove()).AddTo(_disposable); this.NewCategoryCommand = this.TabSelectedItem.Select(n => n is StoreCategoryViewModel) .CombineLatest(this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n == 0 || n == 1 && SelectedMatch(typeof(StoreCategoryInfo))), (r1, r2) => (r1 && r2)).ToReactiveCommand().AddTo(_disposable); this.NewCategoryCommand.Subscribe(() => this.NewCategory()).AddTo(_disposable); this.EditCommand = this.SelectedItems.ObserveProperty(n => n.Count) .Select(n => n == 1 && SelectedMatch(typeof(StoreCategoryInfo))).ToReactiveCommand().AddTo(_disposable); this.EditCommand.Subscribe(() => this.Edit()).AddTo(_disposable); this.DeleteCommand = this.SelectedItems.ObserveProperty(n => n.Count) .Select(n => n != 0 && (this.TabSelectedItem.Value is StoreCategoryViewModel)).ToReactiveCommand().AddTo(_disposable); this.DeleteCommand.Subscribe(() => this.Delete()).AddTo(_disposable); this.CutCommand = this.SelectedItems.ObserveProperty(n => n.Count) .Select(n => n != 0 && (this.TabSelectedItem.Value is StoreCategoryViewModel)).ToReactiveCommand().AddTo(_disposable); this.CutCommand.Subscribe(() => this.Cut()).AddTo(_disposable); this.CopyCommand = this.SelectedItems.ObserveProperty(n => n.Count) .Select(n => n != 0 && SelectedMatch(typeof(StoreCategoryInfo), typeof(Seed))).ToReactiveCommand().AddTo(_disposable); this.CopyCommand.Subscribe(() => this.Copy()).AddTo(_disposable); this.PasteCommand = this.TabSelectedItem.Select(n => n is StoreCategoryViewModel) .CombineLatest(this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n == 0 || n == 1 && SelectedMatch(typeof(StoreCategoryInfo))), (r1, r2) => (r1 && r2)) .CombineLatest(clipboardObservable.Select(n => Clipboard.ContainsStoreCategoryInfo() || Clipboard.ContainsStoreSignatureInfo() || Clipboard.ContainsSignatures()), (r1, r2) => (r1 && r2)).ToReactiveCommand().AddTo(_disposable); this.PasteCommand.Subscribe(() => this.Paste()).AddTo(_disposable); this.DownloadCommand = this.SelectedItems.ObserveProperty(n => n.Count) .Select(n => n != 0).ToReactiveCommand().AddTo(_disposable); this.DownloadCommand.Subscribe(() => this.Download()).AddTo(_disposable); this.AdvancedCommand = this.SelectedItems.ObserveProperty(n => n.Count).Select(n => n != 0) .ToReactiveCommand().AddTo(_disposable); this.AdvancedCopyCommand = new ReactiveCommand <string>().AddTo(_disposable); this.AdvancedCopyCommand.Subscribe((type) => this.AdvancedCopy(type)).AddTo(_disposable); bool SelectedMatch(params Type[] types) { object selectedModel = this.SelectedItems.OfType <StoreListViewItemInfo>().First().Model; return(types.Any(n => n == selectedModel.GetType())); } } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "View", nameof(StoreControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); { var model = _settings.Load("StoreCategoryInfo", () => { var categoryInfo = new StoreCategoryInfo() { Name = "Category", IsExpanded = true }; categoryInfo.SignatureInfos.Add(new StoreSignatureInfo() { AuthorSignature = Signature.Parse("Lyrise@i-2IpSdusn_TKfn6NSECLYRVO4r51cpHZ5wFgBo_0eU") }); return(categoryInfo); }); this.TabViewModel.Value = new StoreCategoryViewModel(null, model); } _sortInfo = _settings.Load("SortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(this.DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { EventHooks.Instance.SaveEvent += this.Save; } { this.Refresh(); } }
private void Init() { { this.SelectedItem = new ReactiveProperty <string>().AddTo(_disposable); this.SelectedLocationUriItem = new ReactiveProperty <string>().AddTo(_disposable); this.SelectedLocationUriItem.Where(n => n != null).Subscribe(n => { this.LocationUriInput.Value = n; }).AddTo(_disposable); this.LocationUrisSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.LocationUrisSortCommand.Subscribe((propertyName) => this.LocationUrisSort(propertyName)).AddTo(_disposable); this.LocationUriInput = new ReactiveProperty <string>().AddTo(_disposable); this.LocationUriAddCommand = this.LocationUriInput.Select(n => !string.IsNullOrWhiteSpace(n)).ToReactiveCommand().AddTo(_disposable); this.LocationUriAddCommand.Subscribe(() => this.LocationUriAdd()).AddTo(_disposable); this.LocationUriEditCommand = this.SelectedLocationUriItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.LocationUriEditCommand.Subscribe(() => this.LocationUriEdit()).AddTo(_disposable); this.LocationUriDeleteCommand = this.SelectedLocationUriItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.LocationUriDeleteCommand.Subscribe(() => this.LocationUriDelete()).AddTo(_disposable); this.SelectedConnectionFilterItem = new ReactiveProperty <ConnectionFilter>(); this.SelectedConnectionFilterItem.Where(n => n != null).Subscribe(n => { this.ConnectionFilterSchemeInput.Value = n.Scheme; this.ConnectionFilterTypeInput.Value = n.Type; this.ConnectionFilterProxyUriInput.Value = n.ProxyUri; }).AddTo(_disposable); this.ConnectionFilterSchemeInput = new ReactiveProperty <string>().AddTo(_disposable); this.ConnectionFilterTypeInput = new ReactiveProperty <ConnectionType>().AddTo(_disposable); this.ConnectionFilterProxyUriInput = new ReactiveProperty <string>().AddTo(_disposable); this.ConnectionFilterUpCommand = this.SelectedConnectionFilterItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ConnectionFilterUpCommand.Subscribe(() => this.ConnectionFilterUp()).AddTo(_disposable); this.ConnectionFilterDownCommand = this.SelectedConnectionFilterItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ConnectionFilterDownCommand.Subscribe(() => this.ConnectionFilterDown()).AddTo(_disposable); this.ConnectionFilterAddCommand = Observable.CombineLatest(this.ConnectionFilterSchemeInput, this.ConnectionFilterProxyUriInput).Select(n => n.All(m => !string.IsNullOrWhiteSpace(m))).ToReactiveCommand().AddTo(_disposable); this.ConnectionFilterAddCommand.Subscribe(() => this.ConnectionFilterAdd()).AddTo(_disposable); this.ConnectionFilterEditCommand = this.SelectedConnectionFilterItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ConnectionFilterEditCommand.Subscribe(() => this.ConnectionFilterEdit()).AddTo(_disposable); this.ConnectionFilterDeleteCommand = this.SelectedConnectionFilterItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ConnectionFilterDeleteCommand.Subscribe(() => this.ConnectionFilterDelete()).AddTo(_disposable); this.SelectedListenUriItem = new ReactiveProperty <string>().AddTo(_disposable); this.SelectedListenUriItem.Where(n => n != null).Subscribe(n => { this.ListenUriInput.Value = n; }).AddTo(_disposable); this.ListenUrisSortCommand = new ReactiveCommand <string>().AddTo(_disposable); this.ListenUrisSortCommand.Subscribe((propertyName) => this.ListenUrisSort(propertyName)).AddTo(_disposable); this.ListenUriInput = new ReactiveProperty <string>().AddTo(_disposable); this.ListenUriAddCommand = this.ListenUriInput.Select(n => !string.IsNullOrWhiteSpace(n)).ToReactiveCommand().AddTo(_disposable); this.ListenUriAddCommand.Subscribe(() => this.ListenUriAdd()).AddTo(_disposable); this.ListenUriEditCommand = this.SelectedListenUriItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ListenUriEditCommand.Subscribe(() => this.ListenUriEdit()).AddTo(_disposable); this.ListenUriDeleteCommand = this.SelectedListenUriItem.Select(n => n != null).ToReactiveCommand().AddTo(_disposable); this.ListenUriDeleteCommand.Subscribe(() => this.ListenUriDelete()).AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", nameof(ConnectionOptionsControl)); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); _locationUrisSortInfo = _settings.Load("LocationUrisSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Uri" }); _listenUrisSortInfo = _settings.Load("ListenUrisSortInfo", () => new ListSortInfo() { Direction = ListSortDirection.Ascending, PropertyName = "Uri" }); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { Backup.Instance.SaveEvent += this.Save; } { this.LocationUrisSort(null); this.ListenUrisSort(null); } }