public ColumnViewPivotModel(UserToken User) { user = User; Username = user.ScreenName; Resources = new SafeObservable <TwitterResource>(); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedResource" && selectedResource is TwitterResource) { if (FastAddMode) { AddResource((TwitterResource)selectedResource); } else { NavigateToResource((TwitterResource)selectedResource); } } }; GenerateCoreColumns(); GetLists(); GetSearches(); }
public UserListModel() : base("UserList") { whatUserList = ""; user = ""; PageTitle = whatUserList; list = new SafeObservable <TwitterUser>(); viewSource = new CollectionViewSource(); viewSource.Source = list; viewSource.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("ScreenName", System.ComponentModel.ListSortDirection.Ascending)); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedUser") { TwitterUser selected = SelectedUser as TwitterUser; if (selected != null) { Navigate("/Pages/Elements/User.xaml?user=" + selected.ScreenName); SelectedUser = null; } } }; }
public GroupedDM(UserToken mainUser) { user = mainUser; Messages = new SafeObservable<TwitterDirectMessage>(); lastId = -1; Messages.CollectionChanged += MessagesChanged; }
public GroupedDM(UserToken mainUser) { user = mainUser; Messages = new SafeObservable <TwitterDirectMessage>(); lastId = -1; Messages.CollectionChanged += MessagesChanged; }
public Model() { peers = new ObservableCollection<Node>(); shares = new SafeObservable<Share>(); messages = new SafeObservable<string>(); converstations = new SafeObservable<Conversation>(); transferSessions = new SafeObservable<TransferSession>(); node = new Node(); overlord = new Overlord(); }
public Model() { peers = new ObservableCollection <Node>(); shares = new SafeObservable <Share>(); messages = new SafeObservable <string>(); converstations = new SafeObservable <Conversation>(); transferSessions = new SafeObservable <TransferSession>(); node = new Node(); overlord = new Overlord(); }
private void ReceiveList(TwitterCursorList <TwitterUser> users, TwitterResponse response) { bool finish = false; if (users == null || response.StatusCode != HttpStatusCode.OK) { if (Error != null) { Error(this, response); } finish = true; return; } if (users.NextCursor != null && users.NextCursor != 0 && _service != null) { if (GetFollowing) { _service.ListFriends(new ListFriendsOptions { ScreenName = User.ScreenName, Cursor = (long)users.NextCursor }, ReceiveList); } if (GetFollowers) { _service.ListFollowers(new ListFollowersOptions { ScreenName = User.ScreenName, Cursor = (long)users.NextCursor }, ReceiveList); } } else { finish = true; } if (Users == null) { Users = new SafeObservable <TwitterUser>(); } foreach (var user in users) { if (!Users.Contains(user)) { Users.Add(user); } } if (finish && Finished != null) { Finished(this, new EventArgs()); } }
public TweetLoader() { loaded = 0; Source = new SafeObservable<ITweetable>(); requestsInProgress = 0; if (_rateResetTime == null) _rateResetTime = DateTime.MinValue; Error += new OnError(CheckForRateLimit); LoadDefaultSettings(); }
public ColumnViewModel() { Pivots = new SafeObservable <ColumnViewPivotModel>(); enableQuickAdd = new DelegateCommand((param) => FastAddMode = true); disableQuickAdd = new DelegateCommand((param) => FastAddMode = false); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "FastAddMode") { foreach (var p in Pivots) { p.FastAddMode = FastAddMode; } } }; foreach (var account in Config.Accounts) { var pivot = new ColumnViewPivotModel(account); pivot.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsLoading") { var p = sender as ColumnViewPivotModel; if (p == null) { return; } if (p.IsLoading) { pivotsLoading++; } else { pivotsLoading--; } IsLoading = pivotsLoading > 0; } }; Pivots.Add(pivot); } }
public AddColumnModel() : base("AddColumn") { Core = new ObservableCollection<TwitterResource>(); Lists = new SafeObservable<TwitterList>(); reloadLists = new DelegateCommand((param) => LoadLists(), (param) => !IsLoading); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "ListSelection") AddSelectedList(); else if (e.PropertyName == "CoreSelection") AddSelectedCoreResource(); }; }
public MainPageModel() { Samples = new SafeObservable <SampleItem>(); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedSample" && SelectedSample != null) { SelectedSample.Navigate(); } }; Samples.Add(SampleItem.Create <AppBarModel>("app bar")); Samples.Add(SampleItem.Create <ConverterModel>("converter")); Samples.Add(SampleItem.Create <AutoSettingsModel>("automatic settings")); Samples.Add(SampleItem.Create <ProgressModel>("progress indicator")); }
public void Initialize() { AppBarMode = ApplicationBarMode.Default; if (DataTransfer.Status == null) { MessageService.ShowError(Localization.Resources.ErrorLoadingTweet); GoBack(); return; } if (DataTransfer.Status.RetweetedStatus != null) { Tweet = DataTransfer.Status.RetweetedStatus; WhoRetweeted = " " + String.Format(Localization.Resources.RetweetBy, DataTransfer.Status.Author.ScreenName); HasRetweets = true; } else { Tweet = DataTransfer.Status; WhoRetweeted = ""; } SetAvatar(); HasReplies = (Tweet.InReplyToStatusId != null); HasImage = (Tweet.Entities != null && Tweet.Entities.Media.Any()); IsFavorited = Tweet.IsFavorited; RetweetCount = Tweet.RetweetCount; if (Tweet.User == null || Tweet.User.Name == null) { FillUser(); } UsersWhoRetweeted = new ObservableCollection <ITweeter>(); Replies = new SafeObservable <ITweetable>(); Images = new SafeObservable <string>(); UsersWhoRetweeted.CollectionChanged += (s, e) => { RetweetCount = UsersWhoRetweeted.Count; }; CreateCommands(); }
public AddColumnModel() : base("AddColumn") { Core = new ObservableCollection <TwitterResource>(); Lists = new SafeObservable <TwitterList>(); reloadLists = new DelegateCommand((param) => LoadLists(), (param) => !IsLoading); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "ListSelection") { AddSelectedList(); } else if (e.PropertyName == "CoreSelection") { AddSelectedCoreResource(); } }; }
public AutoSettingsModel() { var boolConfig = new ConfigItem <bool?> { Key = "bool", DefaultValue = false }; var numConfig = new ConfigItem <int?> { Key = "int", DefaultValue = 42 }; var strConfig = new ConfigItem <string> { Key = "str", DefaultValue = "hello" }; var multipleChoiceConfig = new ConfigItem <ChoicesEnum?> { Key = "enum", DefaultValue = ChoicesEnum.Choice2 }; Settings = new SafeObservable <Setting> { new BoolSetting("This is a boolean setting", boolConfig), new NumericSetting("A numeric setting", numConfig), new StringSetting("String time!", strConfig), new SeparatorSetting("More interesting things"), new MultipleChoiceSetting <ChoicesEnum?>("Choose one!", multipleChoiceConfig, new Dictionary <ChoicesEnum?, string> { { ChoicesEnum.Choice1, "This is 1" }, { ChoicesEnum.Choice2, "And this is 2" }, { ChoicesEnum.Choice3, "Third choice!" } }) }; }
public ColumnViewModel() { Pivots = new SafeObservable<ColumnViewPivotModel>(); enableQuickAdd = new DelegateCommand((param) => FastAddMode = true); disableQuickAdd = new DelegateCommand((param) => FastAddMode = false); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "FastAddMode") foreach (var p in Pivots) p.FastAddMode = FastAddMode; }; foreach (var account in Config.Accounts) { var pivot = new ColumnViewPivotModel(account); pivot.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsLoading") { var p = sender as ColumnViewPivotModel; if (p == null) return; if (p.IsLoading) pivotsLoading++; else pivotsLoading--; IsLoading = pivotsLoading > 0; } }; Pivots.Add(pivot); } }
public MainPageVM() { this.PropertyChanged += (s, e) => { if (e.PropertyName == "SelectedProject" && SelectedProject != null) { ProjectVM.Project = SelectedProject; Navigator.NavigateTo("/Views/Project.xaml"); } }; AddProject = new RelayCommand(() => { Navigator.NavigateTo("/Views/AddProject.xaml"); }); ScanImage = new RelayCommand(() => { Navigator.NavigateTo("/Views/Scan.xaml"); }); Projects = new SafeObservable <StreetPay.Library.Project>(); }
public MainPageVM() { this.PropertyChanged += (s, e) => { if (e.PropertyName == "SelectedProject" && SelectedProject != null) { ProjectVM.Project = SelectedProject; Navigator.NavigateTo("/Views/Project.xaml"); } }; AddProject = new RelayCommand(() => { Navigator.NavigateTo("/Views/AddProject.xaml"); }); ScanImage = new RelayCommand(() => { Navigator.NavigateTo("/Views/Scan.xaml"); }); Projects = new SafeObservable<StreetPay.Library.Project>(); }
public UserListModel() : base("UserList") { whatUserList =""; user = ""; PageTitle = whatUserList; list = new SafeObservable<TwitterUser>(); viewSource = new CollectionViewSource(); viewSource.Source = list; viewSource.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("ScreenName", System.ComponentModel.ListSortDirection.Ascending)); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedUser") { TwitterUser selected = SelectedUser as TwitterUser; if (selected != null) { Navigate("/Pages/Elements/User.xaml?user=" + selected.ScreenName); SelectedUser = null; } } }; }
public override bool Init() { if (MainDescription.IsUIForm) { DataCollections = new SafeObservable <DataCollection>(); dockableManager = MainFrmUI as IDockableManager; var views = "223:Mini 794:Middle"; foreach (var item in views.Split(' ')) { var item2 = item.Split(':'); var name = item2[0]; var control = FrmState.Mini; Enum.TryParse(item2[1], out control); var itemName = "key_" + name; itemName = GlobalHelper.Get(itemName); var view = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get(itemName)); var userControl = view as UserControl; if (userControl != null) { if (name == "223") { dynamic dcontrol = userControl; dataListBox = dcontrol.dataListBox as ListBox; } userControl.DataContext = MainFrmUI; dockableManager.AddDockAbleContent(control, view, itemName); } } } else { DataCollections = new ObservableCollection <DataCollection>(); } processManager = MainFrmUI.PluginDictionary["DataProcessManager"] as IProcessManager; commands = new List <ICommand>(); var dbaction = new BindingAction(); dbaction.ChildActions.Add(new Command(GlobalHelper.Get("key_224"), obj => { var w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null, "edit")); dbaction.ChildActions.Add( new Command(GlobalHelper.Get("key_142"), obj => RefreshConnect(obj as IDataBaseConnector), obj => obj != null, "refresh")); dbaction.ChildActions.Add( new Command(GlobalHelper.Get("key_213"), obj => { var query = new QueryEntity(); query.Connector = obj as IDataBaseConnector; query.GetQueryFunc = d => { if (d == null) { return; } if (d.Any() == false) { return; } AddDataCollection(d, GetNewName()); }; PropertyGridFactory.GetPropertyWindow(query).ShowDialog(); }, obj => obj != null, "magnify")); dbaction.ChildActions.Add( new Command(GlobalHelper.Get("key_225"), obj => { if ( MessageBox.Show(GlobalHelper.Get("key_226"), GlobalHelper.Get("key_99"), MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes) { var con = obj as DBConnectorBase; _dbConnections.Remove(con); } }, obj => obj != null, "delete")); var dataaction = new BindingAction(); var tableAction = new BindingAction(); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("view"), async obj => { var items = obj as TableInfo; List <IFreeDocument> dataAll = null; try { dataAll = await GetDataFromDB(items.Connector, items.Name, true, items.Connector is FileManager ? -1 : 200); } catch (Exception ex) { MessageBox.Show(GlobalHelper.Get("key_228") + ex.Message); return; } if (dataAll == null || dataAll.Count == 0) { XLogSys.Print.Warn(GlobalHelper.Get("key_229")); return; } if (items.Connector is FileManager) { var file = (items.Connector as FileManager).LastFileName; var name = Path.GetFileNameWithoutExtension(file); AddDataCollection(dataAll, name, isCover: true); return; } var excel = PluginProvider.GetObjectInstance <IDataViewer>(GlobalHelper.Get("key_230")); if (excel == null) { return; } var view = excel.SetCurrentView(dataAll.Select(d => d).ToList()); if (ControlExtended.DockableManager != null) { ControlExtended.DockableManager.AddDockAbleContent( FrmState.Custom, view, items.Name); } }, obj => obj != null)); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("key_231"), async obj => { var items = obj as TableInfo; var datas = await GetDataFromDB(items.Connector, items.Name, true); if (datas == null) { return; } AddDataCollection(datas, items.Name); }, obj => obj != null, "add")); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("key_232"), obj => { var con = obj as TableInfo; ReadCollection(con.Connector, con.Name, true); }, obj => obj != null, "layer_add")); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("key_233"), obj => { var items = obj as TableInfo; DropTable(items.Connector, items.Name); }, obj => obj != null, "delete")); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("key_234"), obj => { var w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null, "edit")); tableAction.ChildActions.Add(new Command( GlobalHelper.Get("key_213"), obj => { var query = new QueryEntity(); query.TableInfo = obj as TableInfo; query.Connector = query.TableInfo.Connector; query.GetQueryFunc = d => { if (d == null) { return; } if (d.Any() == false) { return; } AddDataCollection(d, GetNewName()); }; PropertyGridFactory.GetPropertyWindow(query).ShowDialog(); }, obj => obj != null, "magnify")); var visitData = new BindingAction(GlobalHelper.Get("key_235")); var visitCommands = PluginProvider.GetPluginCollection(typeof(IDataViewer)).Select( d => { var comm = new Command(d.Name); comm.Execute = d2 => { var data = d2 as DataCollection; if (data.Count == 0) { MessageBox.Show(GlobalHelper.Get("key_236"), GlobalHelper.Get("key_99")); return; } ControlExtended.UIInvoke(() => { var view = PluginProvider.GetObjectInstance <IDataViewer>(d.Name); var r = view.SetCurrentView(data.ComputeData); if (ControlExtended.DockableManager != null) { var window = new Window { Title = data.Name + " " + d.Name }; window.WindowState = WindowState.Maximized; window.Content = r; window.Activate(); window.ShowDialog(); } }); }; return(comm); }); visitData.Execute = obj => visitCommands.FirstOrDefault(d => d.Text == GlobalHelper.Get("key_230")).Execute(obj); foreach (var visitCommand in visitCommands) { visitData.ChildActions.Add(visitCommand); } dataaction.ChildActions.Add(new Command( GlobalHelper.Get("smartetl_name"), obj => { var collection = GetSelectedCollection(obj).FirstOrDefault(); if (collection == null) { return; } var plugin = processManager.GetOneInstance("SmartETLTool", true, true, true) as SmartETLTool; dynamic generator = PluginProvider.GetObjectByType <IColumnProcess>("TableGE"); generator.Father = plugin; generator.TableSelector.SelectItem = collection.Name; plugin.CurrentETLTools.Add(generator); plugin.ETLMount++; plugin.Init(); //plugin.RefreshSamples(true); ControlExtended.DockableManager.ActiveModelContent(plugin); }, obj => true, "new")); var saveData = new Command(GlobalHelper.Get("key_237"), d => { var collection = GetSelectedCollection(d).FirstOrDefault(); if (collection == null) { return; } var ofd = new SaveFileDialog { Filter = FileConnector.GetDataFilter(), DefaultExt = "*" }; ofd.FileName = collection.Name + ".xlsx"; if (ofd.ShowDialog() == true) { var filename = ofd.FileName; SaveFile(collection.Name, filename); } }, obj => true, "save"); dataaction.ChildActions.Add(saveData); dataaction.ChildActions.Add(visitData); dataaction.ChildActions.Add(new Command( GlobalHelper.Get("key_238"), obj => { if (obj != null) { foreach (var collection in GetSelectedCollection(obj)) { if (collection == null) { return; } var n = collection.Clone(true); n.Name = GetNewName(collection.Name); DataCollections.Add(n); } } else { DataCollections.Add(new DataCollection(new List <IFreeDocument>()) { Name = GetNewName(GlobalHelper.Get("key_239")) }); } ; }, obj => true, "add")); dataaction.ChildActions.Add(new Command( GlobalHelper.Get("key_240"), obj => { var collection = GetSelectedCollection(obj).ToList(); if (!collection.Any()) { return; } PropertyGridFactory.GetPropertyWindow(collection.FirstOrDefault()).ShowDialog(); }, obj => true, "settings")); dataaction.ChildActions.Add(new Command( GlobalHelper.Get("key_169"), obj => { foreach (var collection in GetSelectedCollection(obj)) { if (collection != null) { DataCollections.Remove(collection); } } }, obj => true, "delete")); var convert = new BindingAction(GlobalHelper.Get("key_241")); dataaction.ChildActions.Add(convert); convert.ChildActions.Add(new Command(GlobalHelper.Get("key_242"), obj => { var coll = GetSelectedCollection(obj).FirstOrDefault(); if (coll == null) { return; } if (coll.Count > 500000) { if ( MessageBox.Show(GlobalHelper.Get("key_243"), GlobalHelper.Get("key_99"), MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { return; } } var docuts = new List <IFreeDocument>(); var task = TemporaryTask <FreeDocument> .AddTempTaskSimple(GlobalHelper.Get("key_242"), coll.ComputeData, d => { if (d != null) { docuts.Add(d); } }, result => { var collection = new DataCollection(docuts) { Name = coll.Name + '1' }; AddDataCollection(collection); DataCollections.Remove(coll); }); processManager.CurrentProcessTasks.Add(task); })); var insertdb = new BindingAction(GlobalHelper.Get("key_244")); insertdb.SetChildActionSource(() => { return(_dbConnections.Select(dataBaseConnector => new Command(dataBaseConnector.Name, obj => { var data = obj as DataCollection; processManager.CurrentProcessTasks.Add( TemporaryTask <FreeDocument> .AddTempTaskSimple(data.Name + GlobalHelper.Get("key_245"), dataBaseConnector.InserDataCollection(data), null, continueAction: (a) => dataBaseConnector.RefreshTableNames(), count: data.Count / 1000)); }, obj => dataBaseConnector.IsUseable, icon: "database")).Cast <ICommand>().ToList()); }); dataaction.ChildActions.Add(insertdb); var otherDataAction = new BindingAction(); otherDataAction.ChildActions.Add(new Command(GlobalHelper.Get("key_132"), obj => CleanData(), obj => DataCollections.Count > 0, "clear")); commands.Add(dbaction); commands.Add(tableAction); commands.Add(dataaction); commands.Add(otherDataAction); var dblistAction = new BindingAction(GlobalHelper.Get("key_246")); var addnew = new BindingAction(GlobalHelper.Get("key_247")) { Icon = "add" }; dblistAction.ChildActions.Add(addnew); foreach (var item in PluginProvider.GetPluginCollection(typeof(IDataBaseConnector))) { addnew.ChildActions.Add(new Command(item.Name) { Execute = obj => { var con = PluginProvider.GetObjectInstance(item.MyType) as DBConnectorBase; con.Name = item.Name; _dbConnections.Add(con); }, Icon = "connect" }); } commands.Add(dblistAction); dockableManager = MainFrmUI as IDockableManager; if (processManager?.CurrentProject != null) { LoadDataConnections(processManager.CurrentProject.DBConnections); } if (MainDescription.IsUIForm) { ConfigUI = PropertyGridFactory.GetInstance(_dbConnections.FirstOrDefault()); } var changed = DataCollections as INotifyCollectionChanged; changed.CollectionChanged += (s, e) => OnDataSourceChanged(new EventArgs()); return(true); }
public DefaultModel() : base("Default") { RetweetsAsMentions = Config.RetweetAsMentions == true; BackgroundUpdateTiles = Config.BackgroundLoadColumns == true; if (Config.TweetsPerRequest == null) Config.TweetsPerRequest = 30; TweetsPerRequest = Config.TweetsPerRequest.ToString(); Accounts = new SafeObservable<UserToken>(Config.Accounts); NotifyOptions = new List<string> { "None", "Only Tile", "Toast and Tile" }; SelectedMuteTime = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime); if (Config.ReadLaterCredentials.Instapaper != null) { InstapaperUser = Config.ReadLaterCredentials.Instapaper.User; InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password; } if (Config.ReadLaterCredentials.Pocket != null) { PocketUser = Config.ReadLaterCredentials.Pocket.User; PocketPassword = Config.ReadLaterCredentials.Pocket.Password; } this.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "RetweetsAsMentions": Config.RetweetAsMentions = RetweetsAsMentions; break; case "BackgroundUpdateTiles": Config.BackgroundLoadColumns = BackgroundUpdateTiles; break; case "TweetsPerRequest": int number; if (int.TryParse(TweetsPerRequest, out number)) Config.TweetsPerRequest = number; break; case "SelectedAccount": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { MentionNotifyOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences; MessageNotifyOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences; } break; case "MentionNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) Config.Accounts[SelectedAccount].Preferences.MentionsPreferences = (NotificationType)MentionNotifyOption; break; case "MessageNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) Config.Accounts[SelectedAccount].Preferences.MessagesPreferences = (NotificationType)MessageNotifyOption; Config.SaveAccounts(); break; case "SelectedMuteTime": Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime); break; } }; SelectedAccount = -1; if(Config.Accounts.Count > 0) SelectedAccount = 0; SetCommands(); }
public ColumnViewPivotModel(UserToken User) { user = User; Username = user.ScreenName; Resources = new SafeObservable<TwitterResource>(); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedResource" && selectedResource is TwitterResource) { if (FastAddMode) AddResource((TwitterResource)selectedResource); else NavigateToResource((TwitterResource)selectedResource); } }; GenerateCoreColumns(); GetLists(); GetSearches(); }
public DefaultModel() : base("Default") { SelectedFontSize = FontSizeToIndex(((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize); RetweetsAsMentions = Config.RetweetAsMentions == true; BackgroundUpdateTiles = Config.BackgroundLoadColumns == true; if (Config.TweetsPerRequest == null) { Config.TweetsPerRequest = 40; } TweetsPerRequest = Config.TweetsPerRequest.ToString(); Accounts = new SafeObservable <UserToken>(Config.Accounts); NotifyOptions = new List <string> { Resources.None, Resources.OnlyTile, Resources.ToastAndTile }; SelectedMuteTime = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime); ShowResumePositionButton = Config.RecoverReadPositions == true; GeoTaggingEnabled = Config.EnabledGeolocation == true; SelectedReloadOption = (int)Config.ReloadOptions; PushAvailable = TrialInformation.IsFullFeatured; PushEnabled = PushAvailable && (Config.PushEnabled == true); if (Config.ReadLaterCredentials.Instapaper != null) { InstapaperUser = Config.ReadLaterCredentials.Instapaper.User; InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password; } if (Config.ReadLaterCredentials.Pocket != null) { PocketUser = Config.ReadLaterCredentials.Pocket.User; PocketPassword = Config.ReadLaterCredentials.Pocket.Password; } this.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "RetweetsAsMentions": Config.RetweetAsMentions = RetweetsAsMentions; break; case "BackgroundUpdateTiles": Config.BackgroundLoadColumns = BackgroundUpdateTiles; break; case "TweetsPerRequest": int number; if (int.TryParse(TweetsPerRequest, out number)) { Config.TweetsPerRequest = number; } break; case "SelectedAccount": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { int newOption; newOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences; if (newOption != MentionNotifyOption) { mentionFirstChange = true; MentionNotifyOption = newOption; } newOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences; if (newOption != MessageNotifyOption) { messageFirstChange = true; MessageNotifyOption = newOption; } } break; case "MentionNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { SetMentionNotifyPref((NotificationType)MentionNotifyOption, SelectedAccount); } break; case "MessageNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { SetMessageNotifyPref((NotificationType)MessageNotifyOption, SelectedAccount); } Config.SaveAccounts(); break; case "SelectedMuteTime": Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime); break; case "SelectedFontSize": ((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize = IndexToFontSize(SelectedFontSize); break; case "ShowResumePositionButton": Config.RecoverReadPositions = ShowResumePositionButton; break; case "GeoTaggingEnabled": Config.EnabledGeolocation = GeoTaggingEnabled; break; case "PushEnabled": if (!TrialInformation.IsFullFeatured) { if (PushEnabled) { TrialInformation.ShowBuyDialog(); PushEnabled = false; } return; } Config.PushEnabled = PushEnabled; if (PushEnabled == false) { PushNotifications.UnregisterAll(); } else { PushNotifications.AutoRegisterForNotifications(); } break; case "SelectedReloadOption": Config.ReloadOptions = (ColumnReloadOptions)SelectedReloadOption; break; } }; SelectedAccount = -1; if (Config.Accounts.Count > 0) { SelectedAccount = 0; } SetCommands(); }
public AppBarModel() { MenuItems = new SafeObservable <BindableAppBarMenuItem>(); Buttons = new SafeObservable <BindableAppBarButton>(); AddButton = new DelegateCommand(() => { if (Buttons.Count < 4) { Buttons.Add(new BindableAppBarButton { Text = NewItemText, IconUri = new Uri("/Toolkit.Content/ApplicationBar.Select.png", UriKind.Relative) }); } else { Notificator.ShowError("Woops, too many buttons."); } }); AddMenuItem = new DelegateCommand(() => MenuItems.Add(new BindableAppBarMenuItem { Text = NewItemText })); var button = new BindableAppBarToggleButton { Text1 = "not toggled", Text2 = "toggled", IconUri1 = new Uri("/Toolkit.Content/ApplicationBar.Add.png", UriKind.Relative), IconUri2 = new Uri("/Toolkit.Content/ApplicationBar.Delete.png", UriKind.Relative) }; var hlButton = new BindableAppBarHyperlinkButton { Text = "external link", IconUri = new Uri("/Toolkit.Content/ApplicationBar.Check.png", UriKind.Relative), Uri = "http://github.com/gjulianm/AncoraMVVM" }; var hlIButton = new BindableAppBarHyperlinkButton { Text = "internal link", IconUri = new Uri("/Toolkit.Content/ApplicationBar.Check.png", UriKind.Relative), Uri = "/Views/MainPage.xaml" }; Buttons.Add(button); Buttons.Add(hlButton); Buttons.Add(hlIButton); MenuItems.Add(new BindableAppBarHyperlinkMenuItem { Text = "external link", Uri = "http://github.com/gjulianm/AncoraMVVM" }); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "Toggled") { button.Toggled = Toggled; } }; Opacity = 0.5; }
public MockUserProvider() { Users = new SafeObservable<TwitterUser>(); }
public MockUserProvider() { Users = new SafeObservable <TwitterUser>(); }
public UserProvider() { GetFollowers = true; GetFollowing = true; Users = new SafeObservable<TwitterUser>(); }
public DefaultModel() : base("Default") { RetweetsAsMentions = Config.RetweetAsMentions == true; BackgroundUpdateTiles = Config.BackgroundLoadColumns == true; if (Config.TweetsPerRequest == null) { Config.TweetsPerRequest = 30; } TweetsPerRequest = Config.TweetsPerRequest.ToString(); Accounts = new SafeObservable <UserToken>(Config.Accounts); NotifyOptions = new List <string> { "None", "Only Tile", "Toast and Tile" }; SelectedMuteTime = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime); if (Config.ReadLaterCredentials.Instapaper != null) { InstapaperUser = Config.ReadLaterCredentials.Instapaper.User; InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password; } if (Config.ReadLaterCredentials.Pocket != null) { PocketUser = Config.ReadLaterCredentials.Pocket.User; PocketPassword = Config.ReadLaterCredentials.Pocket.Password; } this.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "RetweetsAsMentions": Config.RetweetAsMentions = RetweetsAsMentions; break; case "BackgroundUpdateTiles": Config.BackgroundLoadColumns = BackgroundUpdateTiles; break; case "TweetsPerRequest": int number; if (int.TryParse(TweetsPerRequest, out number)) { Config.TweetsPerRequest = number; } break; case "SelectedAccount": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { MentionNotifyOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences; MessageNotifyOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences; } break; case "MentionNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { Config.Accounts[SelectedAccount].Preferences.MentionsPreferences = (NotificationType)MentionNotifyOption; } break; case "MessageNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { Config.Accounts[SelectedAccount].Preferences.MessagesPreferences = (NotificationType)MessageNotifyOption; } Config.SaveAccounts(); break; case "SelectedMuteTime": Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime); break; } }; SelectedAccount = -1; if (Config.Accounts.Count > 0) { SelectedAccount = 0; } SetCommands(); }
public SortedFilteredObservable(IComparer <T> comparer) : base() { Comparer = comparer; discardedItems = new SafeObservable <T>(); }
public UserProvider() { GetFollowers = true; GetFollowing = true; Users = new SafeObservable <TwitterUser>(); }
public void Initialize() { AppBarMode = ApplicationBarMode.Default; if (DataTransfer.Status == null) { MessageService.ShowError(Localization.Resources.ErrorLoadingTweet); GoBack(); return; } if (DataTransfer.Status.RetweetedStatus != null) { Tweet = DataTransfer.Status.RetweetedStatus; WhoRetweeted = " " + String.Format(Localization.Resources.RetweetBy, DataTransfer.Status.Author.ScreenName); HasRetweets = true; } else { Tweet = DataTransfer.Status; WhoRetweeted = ""; } SetAvatar(); HasReplies = (Tweet.InReplyToStatusId != null); HasImage = (Tweet.Entities != null && Tweet.Entities.Media.Any()); IsFavorited = Tweet.IsFavorited; RetweetCount = Tweet.RetweetCount; if (Tweet.User == null || Tweet.User.Name == null) FillUser(); UsersWhoRetweeted = new ObservableCollection<ITweeter>(); Replies = new SafeObservable<ITweetable>(); Images = new SafeObservable<string>(); UsersWhoRetweeted.CollectionChanged += (s, e) => { RetweetCount = UsersWhoRetweeted.Count; }; CreateCommands(); }
public SearchQueryDebug(string correlation, Dispatcher dispatcher) { Correlation = correlation; _boundVariables = new SafeObservable <string>(dispatcher); _queryTemplateHelper = new SafeObservable <string>(dispatcher); }
private void ReceiveList(TwitterCursorList<TwitterUser> users, TwitterResponse response) { bool finish = false; if (users == null || response.StatusCode != HttpStatusCode.OK) { if (Error != null) Error(this, response); finish = true; return; } if (users.NextCursor != null && users.NextCursor != 0 && _service != null) { if (GetFollowing) _service.ListFriends(new ListFriendsOptions { ScreenName = User.ScreenName, Cursor = (long)users.NextCursor }, ReceiveList); if (GetFollowers) _service.ListFollowers(new ListFollowersOptions { ScreenName = User.ScreenName, Cursor = (long)users.NextCursor }, ReceiveList); } else finish = true; if (Users == null) Users = new SafeObservable<TwitterUser>(); foreach (var user in users) if(!Users.Contains(user)) Users.Add(user); if (finish && Finished != null) Finished(this, new EventArgs()); }
public DefaultModel() : base("Default") { SelectedFontSize = FontSizeToIndex(((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize); RetweetsAsMentions = Config.RetweetAsMentions == true; BackgroundUpdateTiles = Config.BackgroundLoadColumns == true; if (Config.TweetsPerRequest == null) Config.TweetsPerRequest = 40; TweetsPerRequest = Config.TweetsPerRequest.ToString(); Accounts = new SafeObservable<UserToken>(Config.Accounts); NotifyOptions = new List<string> { Resources.None, Resources.OnlyTile, Resources.ToastAndTile }; SelectedMuteTime = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime); ShowResumePositionButton = Config.RecoverReadPositions == true; GeoTaggingEnabled = Config.EnabledGeolocation == true; SelectedReloadOption = (int)Config.ReloadOptions; PushAvailable = TrialInformation.IsFullFeatured; PushEnabled = PushAvailable && (Config.PushEnabled == true); if (Config.ReadLaterCredentials.Instapaper != null) { InstapaperUser = Config.ReadLaterCredentials.Instapaper.User; InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password; } if (Config.ReadLaterCredentials.Pocket != null) { PocketUser = Config.ReadLaterCredentials.Pocket.User; PocketPassword = Config.ReadLaterCredentials.Pocket.Password; } this.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "RetweetsAsMentions": Config.RetweetAsMentions = RetweetsAsMentions; break; case "BackgroundUpdateTiles": Config.BackgroundLoadColumns = BackgroundUpdateTiles; break; case "TweetsPerRequest": int number; if (int.TryParse(TweetsPerRequest, out number)) Config.TweetsPerRequest = number; break; case "SelectedAccount": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { int newOption; newOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences; if (newOption != MentionNotifyOption) { mentionFirstChange = true; MentionNotifyOption = newOption; } newOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences; if (newOption != MessageNotifyOption) { messageFirstChange = true; MessageNotifyOption = newOption; } } break; case "MentionNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) SetMentionNotifyPref((NotificationType)MentionNotifyOption, SelectedAccount); break; case "MessageNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) SetMessageNotifyPref((NotificationType)MessageNotifyOption, SelectedAccount); Config.SaveAccounts(); break; case "SelectedMuteTime": Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime); break; case "SelectedFontSize": ((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize = IndexToFontSize(SelectedFontSize); break; case "ShowResumePositionButton": Config.RecoverReadPositions = ShowResumePositionButton; break; case "GeoTaggingEnabled": Config.EnabledGeolocation = GeoTaggingEnabled; break; case "PushEnabled": if (!TrialInformation.IsFullFeatured) { if (PushEnabled) { TrialInformation.ShowBuyDialog(); PushEnabled = false; } return; } Config.PushEnabled = PushEnabled; if (PushEnabled == false) PushNotifications.UnregisterAll(); else PushNotifications.AutoRegisterForNotifications(); break; case "SelectedReloadOption": Config.ReloadOptions = (ColumnReloadOptions)SelectedReloadOption; break; } }; SelectedAccount = -1; if(Config.Accounts.Count > 0) SelectedAccount = 0; SetCommands(); }
public void Navigated() { Accounts = new SafeObservable <UserToken>(Config.Accounts); }
public Autocompleter() { Suggestions = new SafeObservable<string>(); IsAutocompleting = false; }
public override bool Init() { if (MainDescription.IsUIForm) { DataCollections = new SafeObservable<DataCollection>(); dockableManager = MainFrmUI as IDockableManager; var view = PluginProvider.GetObjectInstance<ICustomView>("系统状态视图"); var userControl = view as UserControl; if (userControl != null) { userControl.DataContext = MainFrmUI; dockableManager.AddDockAbleContent(FrmState.Mini, view, "系统状态视图"); } } else { DataCollections = new ObservableCollection<DataCollection>(); } processManager = MainFrmUI.PluginDictionary["模块管理"] as IProcessManager; commands = new List<ICommand>(); var dbaction = new BindingAction(); dbaction.ChildActions.Add(new Command("配置连接", obj => { Window w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null)); dbaction.ChildActions.Add( new Command("刷新", obj => RefreshConnect(obj as IDataBaseConnector), obj => obj != null)); dbaction.ChildActions.Add( new Command("执行查询", obj => { var query = new QueryEntity(); query.Connector = obj as IDataBaseConnector; query.GetQueryFunc = d => { if (d == null) return; if (d.Any() == false) return; AddDataCollection(d, GetNewName()); }; propertyGridWindow.SetObjectView(query); }, obj => obj != null)); dbaction.ChildActions.Add( new Command("删除连接", obj => { if (MessageBox.Show("确定要删除该连接吗?", "提示信息", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes) { var con = obj as DBConnectorBase; _dbConnections.Remove(con); } }, obj => obj != null)); var dataaction = new BindingAction(); var tableAction = new BindingAction(); tableAction.ChildActions.Add(new Command( "查看", async obj => { var items = obj as TableInfo; List<IFreeDocument> dataAll = await GetDataFromDB(items.Connector, items.Name, true, items.Connector is FileManager ? -1 : 200); if (dataAll == null || dataAll.Count == 0) { XLogSys.Print.Warn("没有在表中的发现可用的数据"); return; } if (items.Connector is FileManager) { string file = (items.Connector as FileManager).LastFileName; var name = Path.GetFileNameWithoutExtension(file); AddDataCollection(dataAll, name); return; } var excel = PluginProvider.GetObjectInstance<IDataViewer>("可编辑列表"); if (excel == null) return; object view = excel.SetCurrentView(dataAll.Select(d=>d as IFreeDocument).ToList()); if (ControlExtended.DockableManager != null) { ControlExtended.DockableManager.AddDockAbleContent( FrmState.Custom, view, items.Name); } }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "添加到数据集", async obj => { var items = obj as TableInfo; List<IFreeDocument> datas = await GetDataFromDB(items.Connector, items.Name, true); if (datas == null) return; AddDataCollection(datas, items.Name); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "添加虚拟数据集", obj => { var con = obj as TableInfo; ReadCollection(con.Connector, con.Name, true); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "删除表", obj => { var items = obj as TableInfo; DropTable(items.Connector, items.Name); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "查看属性", obj => { Window w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "执行查询", obj => { var query = new QueryEntity(); query.TableInfo = obj as TableInfo; query.Connector = query.TableInfo.Connector; query.GetQueryFunc = d => { if (d == null) return; if (d.Any() == false) return; AddDataCollection(d, GetNewName()); }; propertyGridWindow.SetObjectView(query); }, obj => obj != null)); var visitData = new BindingAction("浏览方式"); IEnumerable<Command> visitCommands = PluginProvider.GetPluginCollection(typeof (IDataViewer)).Select( d => { var comm = new Command(d.Name); comm.Execute = d2 => { var data = d2 as DataCollection; if (data.Count == 0) { MessageBox.Show("不存在任何数据", "提示信息"); return; } ControlExtended.UIInvoke(() => { var view = PluginProvider.GetObjectInstance<IDataViewer>(d.Name); object r = view.SetCurrentView(data.ComputeData); if (ControlExtended.DockableManager != null) { ControlExtended.DockableManager.AddDockAbleContent( FrmState.Float, r, data.Name + " " + d.Name); } }); }; return comm; }); visitData.Execute = obj => visitCommands.FirstOrDefault(d => d.Text == "可编辑列表").Execute(obj); foreach (Command visitCommand in visitCommands) { visitData.ChildActions.Add(visitCommand); } dataaction.ChildActions.Add(new Command( "数据清洗", obj => { DataCollection collection = GetCollection(obj); if (collection == null) return; var plugin = processManager.GetOneInstance("SmartETLTool", true, true) as SmartETLTool; dynamic generator = PluginProvider.GetObjectByType<IColumnProcess>("TableGE"); generator.TableSelector.SelectItem = collection; plugin.CurrentETLTools.Add(generator); plugin.RefreshSamples(true); ControlExtended.DockableManager.ActiveModelContent(plugin); }, obj => true, "new")); dataaction.ChildActions.Add(new Command( "拷贝", obj => { DataCollection collection = GetCollection(obj); if (collection == null) return; DataCollection n = collection.Clone(true); n.Name = GetNewName(collection.Name); DataCollections.Add(n); }, obj => true, "page_new")); var saveData = new Command("另存为", d => { DataCollection collection = GetCollection(d); if (collection == null) return; var ofd = new SaveFileDialog {Filter = FileConnector.GetDataFilter(), DefaultExt = "*"}; ofd.FileName = collection.Name + ".xlsx"; if (ofd.ShowDialog() == true) { string filename = ofd.FileName; SaveFile(collection.Name, filename); } }, obj => true, "save"); dataaction.ChildActions.Add(saveData); dataaction.ChildActions.Add(visitData); dataaction.ChildActions.Add(new Command( "新建", obj => DataCollections.Add(new DataCollection(new List<IFreeDocument>()) { Name = GetNewName("新建数据集") }), obj => true, "box")); dataaction.ChildActions.Add(new Command( "配置", obj => { DataCollection collection = GetCollection(obj); if (collection != null) propertyGridWindow.SetObjectView(collection); }, obj => true, "settings")); dataaction.ChildActions.Add(new Command( "删除", obj => { DataCollection collection = GetCollection(obj); if (collection != null) DataCollections.Remove(collection); }, obj => true, "delete")); var convert = new BindingAction("转换表类型"); dataaction.ChildActions.Add(convert); convert.ChildActions.Add(new Command("转为非虚拟数据集", obj => { DataCollection coll = GetCollection(obj); if (coll.Count > 500000) { if ( MessageBox.Show("本集合数据量较大,转换可能会占用较高的内存和导致程序崩溃,确定继续吗?", "提示信息", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { return; } } var docuts = new List<IFreeDocument>(); var task=TemporaryTask.AddTempTask("转为非虚拟数据集", coll.ComputeData, d => { if (d != null) docuts.Add(d as IFreeDocument); }, result => { var collection = new DataCollection(docuts) {Name = coll.Name + '1'}; AddDataCollection(collection); this.DataCollections.Remove(coll); }); processManager.CurrentProcessTasks.Add(task); })); var insertdb = new BindingAction("保存到数据库"); insertdb.SetChildActionSource(() => { return _dbConnections.Select(dataBaseConnector => new Command(dataBaseConnector.Name, obj => { var data = obj as DataCollection; processManager.CurrentProcessTasks.Add(TemporaryTask.AddTempTask(data.Name + "插入到数据库", dataBaseConnector.InserDataCollection(data), result => dataBaseConnector.RefreshTableNames(), count: data.Count/1000)); })).Cast<ICommand>().ToList(); }); dataaction.ChildActions.Add(insertdb); var otherDataAction = new BindingAction(); otherDataAction.ChildActions.Add(new Command("清空数据", obj => CleanData(), obj => DataCollections.Count > 0)); commands.Add(dbaction); commands.Add(tableAction); commands.Add(dataaction); commands.Add(otherDataAction); var dblistAction = new BindingAction("数据库管理"); var addnew = new BindingAction("增加新连接"); dblistAction.ChildActions.Add(addnew); foreach (XFrmWorkAttribute item in PluginProvider.GetPluginCollection(typeof (IDataBaseConnector))) { addnew.ChildActions.Add(new Command(item.Name) { Execute = obj => { var con = PluginProvider.GetObjectInstance(item.MyType) as DBConnectorBase; con.Name = item.Name; _dbConnections.Add(con); } }); } commands.Add(dblistAction); dockableManager = MainFrmUI as IDockableManager; if (processManager?.CurrentProject != null) { LoadDataConnections(); } processManager.OnCurrentProjectChanged += (s, e) => LoadDataConnections(); ConfigUI = PropertyGridFactory.GetInstance(_dbConnections.FirstOrDefault()); propertyGridWindow = MainFrmUI.PluginDictionary["属性配置器"] as XFrmWorkPropertyGrid; var changed = DataCollections as INotifyCollectionChanged; changed.CollectionChanged += (s, e) => OnDataSourceChanged(new EventArgs()); return true; }
public override bool Init() { if (MainDescription.IsUIForm) { DataCollections = new SafeObservable <DataCollection>(); dockableManager = MainFrmUI as IDockableManager; var view = PluginProvider.GetObjectInstance <ICustomView>("系统状态视图"); var userControl = view as UserControl; if (userControl != null) { userControl.DataContext = MainFrmUI; dockableManager.AddDockAbleContent(FrmState.Mini, view, "系统状态视图"); } } else { DataCollections = new ObservableCollection <DataCollection>(); } processManager = MainFrmUI.PluginDictionary["模块管理"] as IProcessManager; commands = new List <ICommand>(); var dbaction = new BindingAction(); dbaction.ChildActions.Add(new Command("配置连接", obj => { Window w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null)); dbaction.ChildActions.Add( new Command("刷新", obj => RefreshConnect(obj as IDataBaseConnector), obj => obj != null)); dbaction.ChildActions.Add( new Command("执行查询", obj => { var query = new QueryEntity(); query.Connector = obj as IDataBaseConnector; query.GetQueryFunc = d => { if (d == null) { return; } if (d.Any() == false) { return; } AddDataCollection(d, GetNewName()); }; propertyGridWindow.SetObjectView(query); }, obj => obj != null)); dbaction.ChildActions.Add( new Command("删除连接", obj => { if (MessageBox.Show("确定要删除该连接吗?", "提示信息", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes) { var con = obj as DBConnectorBase; _dbConnections.Remove(con); } }, obj => obj != null)); var dataaction = new BindingAction(); var tableAction = new BindingAction(); tableAction.ChildActions.Add(new Command( "查看", async obj => { var items = obj as TableInfo; List <IFreeDocument> dataAll = null; try { dataAll = await GetDataFromDB(items.Connector, items.Name, true, items.Connector is FileManager ? -1 : 200); } catch (Exception ex) { MessageBox.Show("文件打开失败" + ex.Message); return; } if (dataAll == null || dataAll.Count == 0) { XLogSys.Print.Warn("没有在表中的发现可用的数据"); return; } if (items.Connector is FileManager) { string file = (items.Connector as FileManager).LastFileName; var name = Path.GetFileNameWithoutExtension(file); AddDataCollection(dataAll, name); return; } var excel = PluginProvider.GetObjectInstance <IDataViewer>("可编辑列表"); if (excel == null) { return; } object view = excel.SetCurrentView(dataAll.Select(d => d as IFreeDocument).ToList()); if (ControlExtended.DockableManager != null) { ControlExtended.DockableManager.AddDockAbleContent( FrmState.Custom, view, items.Name); } }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "添加到数据集", async obj => { var items = obj as TableInfo; List <IFreeDocument> datas = await GetDataFromDB(items.Connector, items.Name, true); if (datas == null) { return; } AddDataCollection(datas, items.Name); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "添加虚拟数据集", obj => { var con = obj as TableInfo; ReadCollection(con.Connector, con.Name, true); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "删除表", obj => { var items = obj as TableInfo; DropTable(items.Connector, items.Name); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "查看属性", obj => { Window w = PropertyGridFactory.GetPropertyWindow(obj); w.ShowDialog(); }, obj => obj != null)); tableAction.ChildActions.Add(new Command( "执行查询", obj => { var query = new QueryEntity(); query.TableInfo = obj as TableInfo; query.Connector = query.TableInfo.Connector; query.GetQueryFunc = d => { if (d == null) { return; } if (d.Any() == false) { return; } AddDataCollection(d, GetNewName()); }; propertyGridWindow.SetObjectView(query); }, obj => obj != null)); var visitData = new BindingAction("浏览方式"); IEnumerable <Command> visitCommands = PluginProvider.GetPluginCollection(typeof(IDataViewer)).Select( d => { var comm = new Command(d.Name); comm.Execute = d2 => { var data = d2 as DataCollection; if (data.Count == 0) { MessageBox.Show("不存在任何数据", "提示信息"); return; } ControlExtended.UIInvoke(() => { var view = PluginProvider.GetObjectInstance <IDataViewer>(d.Name); object r = view.SetCurrentView(data.ComputeData); if (ControlExtended.DockableManager != null) { ControlExtended.DockableManager.AddDockAbleContent( FrmState.Float, r, data.Name + " " + d.Name); } }); }; return(comm); }); visitData.Execute = obj => visitCommands.FirstOrDefault(d => d.Text == "可编辑列表").Execute(obj); foreach (Command visitCommand in visitCommands) { visitData.ChildActions.Add(visitCommand); } dataaction.ChildActions.Add(new Command( "数据清洗", obj => { DataCollection collection = GetCollection(obj); if (collection == null) { return; } var plugin = processManager.GetOneInstance("SmartETLTool", true, true) as SmartETLTool; dynamic generator = PluginProvider.GetObjectByType <IColumnProcess>("TableGE"); generator.TableSelector.SelectItem = collection; plugin.CurrentETLTools.Add(generator); plugin.RefreshSamples(true); ControlExtended.DockableManager.ActiveModelContent(plugin); }, obj => true, "new")); dataaction.ChildActions.Add(new Command( "拷贝", obj => { DataCollection collection = GetCollection(obj); if (collection == null) { return; } DataCollection n = collection.Clone(true); n.Name = GetNewName(collection.Name); DataCollections.Add(n); }, obj => true, "page_new")); var saveData = new Command("另存为", d => { DataCollection collection = GetCollection(d); if (collection == null) { return; } var ofd = new SaveFileDialog { Filter = FileConnector.GetDataFilter(), DefaultExt = "*" }; ofd.FileName = collection.Name + ".xlsx"; if (ofd.ShowDialog() == true) { string filename = ofd.FileName; SaveFile(collection.Name, filename); } }, obj => true, "save"); dataaction.ChildActions.Add(saveData); dataaction.ChildActions.Add(visitData); dataaction.ChildActions.Add(new Command( "新建", obj => DataCollections.Add(new DataCollection(new List <IFreeDocument>()) { Name = GetNewName("新建数据集") }), obj => true, "box")); dataaction.ChildActions.Add(new Command( "配置", obj => { DataCollection collection = GetCollection(obj); if (collection != null) { propertyGridWindow.SetObjectView(collection); } }, obj => true, "settings")); dataaction.ChildActions.Add(new Command( "删除", obj => { DataCollection collection = GetCollection(obj); if (collection != null) { DataCollections.Remove(collection); } }, obj => true, "delete")); var convert = new BindingAction("转换表类型"); dataaction.ChildActions.Add(convert); convert.ChildActions.Add(new Command("转为非虚拟数据集", obj => { DataCollection coll = GetCollection(obj); if (coll.Count > 500000) { if ( MessageBox.Show("本集合数据量较大,转换可能会占用较高的内存和导致程序崩溃,确定继续吗?", "提示信息", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { return; } } var docuts = new List <IFreeDocument>(); var task = TemporaryTask.AddTempTask("转为非虚拟数据集", coll.ComputeData, d => { if (d != null) { docuts.Add(d as IFreeDocument); } }, result => { var collection = new DataCollection(docuts) { Name = coll.Name + '1' }; AddDataCollection(collection); this.DataCollections.Remove(coll); }); processManager.CurrentProcessTasks.Add(task); })); var insertdb = new BindingAction("保存到数据库"); insertdb.SetChildActionSource(() => { return(_dbConnections.Select(dataBaseConnector => new Command(dataBaseConnector.Name, obj => { var data = obj as DataCollection; processManager.CurrentProcessTasks.Add(TemporaryTask.AddTempTask(data.Name + "插入到数据库", dataBaseConnector.InserDataCollection(data), result => dataBaseConnector.RefreshTableNames(), count: data.Count / 1000)); })).Cast <ICommand>().ToList()); }); dataaction.ChildActions.Add(insertdb); var otherDataAction = new BindingAction(); otherDataAction.ChildActions.Add(new Command("清空数据", obj => CleanData(), obj => DataCollections.Count > 0)); commands.Add(dbaction); commands.Add(tableAction); commands.Add(dataaction); commands.Add(otherDataAction); var dblistAction = new BindingAction("数据库管理"); var addnew = new BindingAction("增加新连接"); dblistAction.ChildActions.Add(addnew); foreach (XFrmWorkAttribute item in PluginProvider.GetPluginCollection(typeof(IDataBaseConnector))) { addnew.ChildActions.Add(new Command(item.Name) { Execute = obj => { var con = PluginProvider.GetObjectInstance(item.MyType) as DBConnectorBase; con.Name = item.Name; _dbConnections.Add(con); } }); } commands.Add(dblistAction); dockableManager = MainFrmUI as IDockableManager; if (processManager?.CurrentProject != null) { LoadDataConnections(); } processManager.OnCurrentProjectChanged += (s, e) => LoadDataConnections(); ConfigUI = PropertyGridFactory.GetInstance(_dbConnections.FirstOrDefault()); propertyGridWindow = MainFrmUI.PluginDictionary["属性配置器"] as XFrmWorkPropertyGrid; var changed = DataCollections as INotifyCollectionChanged; changed.CollectionChanged += (s, e) => OnDataSourceChanged(new EventArgs()); return(true); }
public void Navigated() { Accounts = new SafeObservable<UserToken>(Config.Accounts); }