private void TimelineStart(object sender, EventArgs e) { TimelineBase startTimeline = (TimelineBase)sender; Debug.Assert(null != startTimeline); if (null != startTimeline.Target) { IHTMLElement iElement = (IHTMLElement)startTimeline.Target.DomElement; IHTMLStyle iStyle = iElement.style; iStyle.display = string.Empty; iStyle = null; iElement = null; } //foreach ( var timeline in m_listTimelines ) //{ // if ( !timeline.IsStop && // !string.IsNullOrEmpty(timeline.TargetName) && // timeline.TargetName.Equals( startTimeline.TargetName, StringComparison.OrdinalIgnoreCase ) ) // { // timeline.Cancel(); // break; // } //} }
public void DeleteTimeline(TimelineBase timeline) { GetNowTab().TimelineList.Remove(timeline); timeline.DeleteTimeLine(); ResetTimeline(); Messenger.Notify("DeleteTimeline", timeline); }
public void AddTimeline(TimelineBase timeline) { GetNowTab().TimelineList.Add(timeline); timeline.AddTimeLine(); ResetTimeline(); Messenger.Notify("AddTimeline", timeline); }
public virtual bool Open(XmlNode argNode) { Debug.Assert(null != argNode); Log.UIService.LogDebug("Prepare for opening a storyboard"); if (!argNode.HasChildNodes) { Log.UIService.LogDebug("A storyboard has at least a Timeline node"); return(false); } if (m_isOpen) { Log.UIService.LogDebug("The storyboard has been opened"); return(true); } try { //load name attribute XmlAttribute nameAttri = argNode.Attributes[UIServiceCfgDefines.s_nameAttri]; if (null == nameAttri || string.IsNullOrEmpty(nameAttri.Value)) { throw new Exception("Name must exist!"); } else { m_name = nameAttri.Value; } //load target attribute XmlAttribute targetAttri = argNode.Attributes[UIServiceCfgDefines.s_targetAttri]; if (null != targetAttri && !string.IsNullOrEmpty(targetAttri.Value)) { m_targetName = targetAttri.Value; } //load repeat attribute XmlAttribute repeatAttri = argNode.Attributes[UIServiceCfgDefines.s_reperatBehaveAttri]; if (null != repeatAttri && !string.IsNullOrEmpty(repeatAttri.Value)) { m_repeatCount = ConvertReperatValue(repeatAttri.Value); } //load needAdjustTime attribute XmlAttribute needAdjustTimeAttri = argNode.Attributes[UIServiceCfgDefines.s_needAdjustTimeAttri]; if (null != needAdjustTimeAttri && !string.IsNullOrEmpty(needAdjustTimeAttri.Value)) { int temp = 0; if (int.TryParse(needAdjustTimeAttri.Value, out temp) && temp >= 0) { m_needAdjustTime = temp == 0 ? false : true; } } var updateXml = argNode.Attributes[UIServiceCfgDefines.s_updateXml]; if (updateXml != null && !string.IsNullOrWhiteSpace(updateXml.Value) && updateXml.Value != "0") { m_updateXml = true; } //scan all Timeline nodes XmlNodeList listNodes = argNode.SelectNodes("*"); TimelineBase timeline = null; bool needAdjustTime = false; foreach (XmlNode node in listNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } if (s_dicCreateHandle.ContainsKey(node.Name)) { timeline = s_dicCreateHandle[node.Name].Invoke(this, node); if (timeline is SlideshowTimeline) { m_ownerScreen.ResouceManager.languageChanged += new ResourceManagerProtocol.LanguageChangedHandler(timeline.ResouceManager_languageChanged); } if (null != timeline && timeline.IsValid) { timeline.TimelineEnd += TimelineEnd; timeline.TimelineStart += TimelineStart; timeline.CanStartPlay = timeline.CanStart; m_listTimelines.Add(timeline); } else { needAdjustTime = true; } } } if (m_listTimelines.Count == 0) { throw new Exception("A storyboard must have a Timeline"); } else { m_listTimelines.Sort(new TimelineComparer()); } if (m_needAdjustTime && needAdjustTime) { AdjustTimeOfTimelines(); } } catch (System.Exception ex) { Log.UIService.LogError("Failed to open a storyboard", ex); return(false); } m_state = playState.Stop; m_isOpen = true; return(true); }
private async void btnAdd_Click(object sender, RoutedEventArgs e) { bool isInputOK = true; if (textTimelineName.Text == string.Empty) { MessageDialog dialog = new MessageDialog("タイムライン名が入力されていません", "入力エラー"); await dialog.ShowAsync(); isInputOK = false; } foreach (var t in viewModel.NowTimelineList) { if (t.ListTitle == textTimelineName.Text) { MessageDialog dialog = new MessageDialog("タイムライン名が競合しています。固有のタイムライン名を入力してください", "入力エラー"); await dialog.ShowAsync(); isInputOK = false; } } if (this.comboBoxAccount.SelectedIndex == -1) { MessageDialog dialog = new MessageDialog("アカウント名が選択されていません", "入力エラー"); await dialog.ShowAsync(); isInputOK = false; } if (this.comboBoxTimelineType.SelectedIndex == -1) { MessageDialog dialog = new MessageDialog("タイムラインタイプが選択されていません", "入力エラー"); await dialog.ShowAsync(); isInputOK = false; } if (isInputOK == true) { TimelineBase resultModel = null; TwitterAccount account = (TwitterAccount)comboBoxAccount.SelectedItem; switch (comboBoxTimelineType.SelectedIndex) { case 0: resultModel = new HomeTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 1: resultModel = new MentionTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 2: resultModel = new NotificationTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 3: if (textSearchWord.Text == string.Empty) { MessageDialog dialog = new MessageDialog("検索ワードが入力されていません", "入力エラー"); await dialog.ShowAsync(); return; } resultModel = new SearchTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textSearchWord.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 4: if (comboList.SelectedIndex == -1) { MessageDialog dialog = new MessageDialog("リストが選択されていません", "入力エラー"); await dialog.ShowAsync(); return; } resultModel = new ListTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, (TwitterList)comboList.SelectedItem, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 5: resultModel = new DirectMessageTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 6: if (textUser.Text == string.Empty) { MessageDialog dialog = new MessageDialog("ユーザー名が入力されていません", "入力エラー"); await dialog.ShowAsync(); return; } resultModel = new UserTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textUser.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 7: resultModel = new ImageTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; case 8: resultModel = new LinkTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction); break; } if (toggleTimelineFiltering.IsOn) { resultModel.ExtractionAccountScreenNameStr = textExtractionAccount.Text; resultModel.ExcludeAccountScreenNameStr = textExcludeAccount.Text; resultModel.ExtractionWordStr = textExtractionWord.Text; resultModel.ExcludeWordStr = textExcludeWord.Text; resultModel.IsTimelineFiltering = toggleTimelineFiltering.IsOn; resultModel.IsNewNotification = toggleNotification.IsOn; } viewModel.AddTimelineCommand.Execute(resultModel); onCreateCallBack(resultModel); this.Hide(); } }
private void CommandInitialize() { AddAccountCommand = new RelayCommand <TwitterAccount>(account => { account.OnTweetBegin += (status) => MessengerInstance.Send <PostStatusBase>(status, "OnTweetBegin"); account.OnTweetFailed += async(status) => { await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = "ツイートの送信に失敗しました" }); MessengerInstance.Send <PostStatusBase>(status, "OnTweetFailed"); }; account.OnTweetCompleted += (status) => MessengerInstance.Send <PostStatusBase>(status, "OnTweetCompleted"); account.OnHttpGetError += async(e) => { await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = e.Message }); MessengerInstance.Send <HttpRequestException>(e, "OnHttpGetError"); }; account.OnHttpPostError += async(e) => { await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = e.Message }); MessengerInstance.Send <HttpRequestException>(e, "OnHttpPostError"); }; account.OnUserStreamHttpError += async(e) => { await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = e.Message }); MessengerInstance.Send <HttpRequestException>(e, "OnUserStreamHttpError"); }; account.OnFollowStreamHttpError += async(e) => { await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = e.Message }); MessengerInstance.Send <HttpRequestException>(e, "OnFollowStreamHttpError"); }; account.ChangeUserStreamEvent += async(state) => { switch (state) { case StreamState.Connect: // await NotificationAsync("Stream Connected"); await SharedDispatcher.RunAsync(() => { ConnectionStatusStr = "Stream Connected"; }); break; case StreamState.TryConnect: // await NotificationAsync("Stream TryConnected"); await SharedDispatcher.RunAsync(() => { ConnectionStatusStr = "Stream TryConnected"; }); break; case StreamState.DisConnect: // await NotificationAsync("Stream DisConnect"); await SharedDispatcher.RunAsync(() => { ConnectionStatusStr = "Stream DisConnected"; }); break; } }; this.AccountList.Add(account); }); DeleteAccountCommand = new RelayCommand <TwitterAccount>(account => { this.AccountList.Remove(account); }); PostStatusCommand = new RelayCommand(async() => { if (!AccountList.Where(q => q.IsActive == true).Select(q => q).Any()) { Tweet tweet = Tweet.ZeroTweet; await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = "アカウントが選択されていません" }); } else { PostStatusBase status = TwitterUIComponent.GetPostStatus(); status.Status += " " + Setting.Footer; DeletePostImageCommand.Execute(null); TwitterUIComponent.ResetPostText(); await ActionSelectedAccountAsync(async(client) => { if (status is PostStatus) { await client.UpdateStatusAsync(status as PostStatus); } else if (status is PostStatusWithReply) { await client.UpdateStatusAsync(status as PostStatusWithReply); } else if (status is PostStatusMedia) { await client.UpdateStatusWithMediaAsync(status as PostStatusMedia); } else if (status is PostStatusMediaWithReply) { await client.UpdateStatusWithMediaAsync(status as PostStatusMediaWithReply); } }); } }); AddTimelineTabCommand = new RelayCommand <TimelineTab>(tab => { AddTimelineTab(tab); }); DeleteTimelineTabCommand = new RelayCommand <TimelineTab>(tab => { foreach (TimelineBase timeline in tab.TimelineList) { timeline.DeleteTimeLine(); } TimelineListTab.Remove(tab); if (TimelineListTab.Count > 0) { var t = TimelineListTab.Take(1).Single(); ChangeTabAsync(t); } MessengerInstance.Send <TimelineTab>(tab, "DeleteTimelineTab"); }); AddTimelineCommand = new RelayCommand <TimelineBase>(timeline => { GetNowTab().TimelineList.Add(timeline); timeline.AddTimeLine(); ResetTimeline(); MessengerInstance.Send <TimelineBase>(timeline, "AddTimeline"); }); DeleteTimelineCommand = new RelayCommand <TimelineBase>(timeline => { GetNowTab().TimelineList.Remove(timeline); timeline.DeleteTimeLine(); ResetTimeline(); MessengerInstance.Send <TimelineBase>(timeline, "DeleteTimeline"); }); ChangeTabCommand = new RelayCommand <TimelineTab>(tab => { ChangeTabAsync(tab); MessengerInstance.Send <TimelineTab>(tab, "ChangeTab"); }); EditTimelineTabCommand = new RelayCommand <TimelineTab>(tab => { this.nowEditTimelineTab = tab; MessengerInstance.Send <TimelineTab>(tab, "EditTimelineTab"); }); EditTimelineCommand = new RelayCommand <TimelineBase>(timeline => { this.nowEditTimeline = timeline; MessengerInstance.Send <TimelineBase>(timeline, "EditTimeline"); }); FavoriteCommand = new RelayCommand <Tweet>(async tweet => { await ActionSelectedAccountWithUiAsync(async client => { if (tweet.favorited == false) { tweet.favorited = true; await client.CreateFavoriteAsync(tweet); } else { tweet.favorited = false; await client.DestroyFavoriteAsync(tweet); } }); }); RetweetCommand = new RelayCommand <Tweet>(async tweet => { await ActionSelectedAccountWithUiAsync(async client => { if (tweet.retweeted == false) { tweet.retweeted = true; await client.CreateRetweetAsync(tweet); } else { tweet.retweeted = false; //await client.DestroyRetweetAsync(tweet); } }); }); QuoteCommand = new RelayCommand <Tweet>(tweet => this.TwitterUIComponent.SetPostText(" RT @" + tweet.user.screen_name + " " + tweet.text)); TweetDetailCommand = new RelayCommand <TweetDetailParameter>(async tweet => { this.MessengerInstance.Send <TweetDetail>(TweetDetail, "ShowTweetDetail"); this.TweetDetail.OwnerAccount = GetAccount(tweet.OwnerScreenName); this.TweetDetail.Set(new TimelineRow(tweet.tweet, "", Setting, CallRowAction), (await GetAccount(tweet.OwnerScreenName).TwitterClient.GetConversationAsync(tweet.tweet)).Select(q => new TimelineRow(q, tweet.OwnerScreenName, Setting, CallRowAction)).ToList()); }); ReplyCommand = new RelayCommand <Tweet>(tweet => { this.TwitterUIComponent.AddPostText("@" + tweet.user.screen_name + " ", tweet); Messenger.Default.Send <int>(TwitterUIComponent.PostText.Length, "SetPostTextCursor"); }); DescriptionDommand = new RelayCommand <Tweet>(tweet => { this.TwitterUIComponent.SetPostText("(@" + tweet.user.screen_name + ")"); Messenger.Default.Send <int>(0, "SetPostTextCursor"); }); UserDetailCommand = new RelayCommand <UserDetailParameter>(async screen_name => { this.MessengerInstance.Send <UserDetail>(UserDetail, "ShowUserDetail"); this.UserDetail.OwnerAccount = GetAccount(screen_name.OwnerScreenName); this.UserDetail.Set(await GetAccount(screen_name.OwnerScreenName).TwitterClient.GetAccountInformationAsync(screen_name.ScreenName), (await GetAccount(screen_name.OwnerScreenName).TwitterClient.GetUserTimeLineAsync(screen_name.ScreenName, 100)).Select(q => new TimelineRow(q, screen_name.OwnerScreenName, Setting, CallRowAction)).ToList()); }); SearchCommand = new RelayCommand <SearchDetailParameter>(async searchWord => { this.MessengerInstance.Send <SearchDetail>(SearchDetail, "ShowSearchDetail"); this.SearchDetail.OwnerAccount = GetAccount(searchWord.OwnerScreenName); this.SearchDetail.Set(searchWord.SearchWord, (await GetAccountFirst().TwitterClient.GetSearchAsync(searchWord.SearchWord, 100)).statuses.Select(q => new TimelineRow(q, searchWord.OwnerScreenName, Setting, CallRowAction)).ToList()); }); BrowseCommand = new RelayCommand <string>(url => this.MessengerInstance.Send <string>(url, "BrowsUrl")); BeginAuthCommand = new RelayCommand(async() => { string requestUrl = await Authorizer.BeginAuthorizedAsync(this.ConsumerData); this.MessengerInstance.Send <string>(requestUrl, "GetAuthorizedUrl"); }); PinAuthCommand = new RelayCommand <string>(async pin => { TokenResponse <AccessToken> res = null; try { res = await Authorizer.PinAuthorizedAsync(pin); var name = res.ExtraData["screen_name"].ElementAt(0); var account = new TwitterAccount(ConsumerData, new AccessTokenData(res.Token.Key, res.Token.Secret), name); await account.InitializeAsync(); account.IsActive = true; AddAccountCommand.Execute(account); var tab = new TimelineTab(name + " - MainTab", CallTabAction, CallTimelineAction, CallRowAction); AddTimelineTab(tab); AddTimelineCommand.Execute(new HomeTimeline(account, "Home", tab.TabTitle, Setting, CallTimelineAction, CallRowAction)); AddTimelineCommand.Execute(new MentionTimeline(account, "Mention", tab.TabTitle, Setting, CallTimelineAction, CallRowAction) { IsNewNotification = true }); var tab2 = new TimelineTab(name + " - SubTab", CallTabAction, CallTimelineAction, CallRowAction); AddTimelineTab(tab2); AddTimelineCommand.Execute(new NotificationTimeline(account, "Notification", tab2.TabTitle, Setting, CallTimelineAction, CallRowAction) { IsNewNotification = true }); AddTimelineCommand.Execute(new UserTimeline(account, "@" + name, tab2.TabTitle, name, Setting, CallTimelineAction, CallRowAction)); ChangeTabAsync(tab); this.MessengerInstance.Send <bool>(true, "AuthorizedCompleted"); } catch (Exception e) { this.MessengerInstance.Send <bool>(false, "AuthorizedCompleted"); } }); SetPostImageCommand = new RelayCommand <PostMedia>(media => { TwitterUIComponent.SetPostMedia(media); }); DeletePostImageCommand = new RelayCommand(() => { TwitterUIComponent.ResetPostMedia(); MessengerInstance.Send <string>("", "DeletePostImage"); }); SelectSuggestCommand = new RelayCommand <string>(item => { if (item.StartsWith("@") && TwitterUIComponent.PostText.Contains("@")) { var ss = TwitterUIComponent.PostText; int index = ss.LastIndexOf("@", System.StringComparison.Ordinal); string s = ss.Substring(0, index); TwitterUIComponent.PostText = s + item + " "; } else if (item.StartsWith("#") && TwitterUIComponent.PostText.Contains("#")) { var ss = TwitterUIComponent.PostText; int index = ss.LastIndexOf("#", System.StringComparison.Ordinal); string s = ss.Substring(0, index); TwitterUIComponent.PostText = s + item + " "; } }); ToggleAccountActivityCommand = new RelayCommand <TwitterAccount>(account => account.ToggleActivity()); DirectMessageDetailCommand = new RelayCommand <DirectMessageDetailParameter>(async dm => { MessengerInstance.Send <DirectMessage>(dm.Message, "ShowDirectMessageDetail"); this.directMesssageDetail.OwnerAccount = GetAccount(dm.OwnerScreenName); this.directMesssageDetail.DMessage = dm.Message; this.directMesssageDetail.Conversations.Clear(); var dms = (await GetAccount(dm.OwnerScreenName).TwitterClient.GetDirectMessages()); var conv = dms.Where(q => (q.sender_screen_name == dm.Message.sender_screen_name && q.recipient_screen_name == dm.Message.recipient_screen_name) || (q.sender_screen_name == dm.Message.recipient_screen_name && q.recipient_screen_name == dm.Message.sender_screen_name) ).Select(q => q).ToList(); foreach (var c in conv) { this.directMesssageDetail.Conversations.Add(new DirectMessageRow(c, dm.OwnerScreenName, Setting, CallRowAction)); } }); SendDirectMessageCommand = new RelayCommand <SendDirectMessage>(async message => { await GetAccount(message.SenderScreenName).TwitterClient.PostDirectMessageNew(message.RecipientScreenName, message.Message); }); ChangeTimelineWidthCommand = new RelayCommand <double>(size => { this.TimelineWidth = size; foreach (var timeline in NowTimelineList) { timeline.TimelineWidth = size; } }); ExitCommand = new RelayCommand(async() => { await SaveSettingDataAsync(); await SaveTwitterDataAsync(); Application.Current.Exit(); }); AddSuggestPostText = new RelayCommand <string>(str => { TwitterUIComponent.SetPostText(TwitterUIComponent.PostText.Substring(0, TwitterUIComponent.PostText.Count() - 1)); TwitterUIComponent.AddPostText(str + " "); }); ChangeUIBrushImageCommand = new RelayCommand <string>(str => { MessengerInstance.Send <string>(str, "ChangeUIBrushImage"); }); ResetThemeSettingCommand = new RelayCommand(() => { Setting.SettingInitialize(); }); PurchaseApplicationThemeCommand = new RelayCommand(async() => { if (!LicenseInfo.ProductLicenses["ApplicationTheme"].IsActive) { var result = await CurrentApp.RequestProductPurchaseAsync("ApplicationTheme"); if (result.Status == ProductPurchaseStatus.Succeeded) { MessageDialog dialog = new MessageDialog("Thank you for purchase Neuronia CusomAppTheme! Enjoy Neuronia and Twitter Life!", "Thank You!"); await dialog.ShowAsync(); IsPurchase = LicenseInfo.ProductLicenses["ApplicationTheme"].IsActive; } } }); AddMuteAccountCommand = new RelayCommand <string>(async(screenName) => { Setting.MuteAccountList.Add(screenName); await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = "Mute Complate @" + screenName }); }); CopyClipBoardCommand = new RelayCommand <string>(async str => { var package = new DataPackage(); package.SetText(str); Clipboard.SetContent(package); await NotificationAsync(new NotificationMessage { TweetMessage = Tweet.ZeroTweet, Message = "Copy Completed! " + str }); }); NextTabCommand = new RelayCommand(() => { var num = TimelineListTab.TakeWhile(q => q.IsNowTab).Select(q => q).Count() - 1; if (num != TimelineListTab.Count - 1) { ChangeTabAsync(TimelineListTab.ElementAt(++num)); } }); PrevTabCommand = new RelayCommand(() => { var num = TimelineListTab.TakeWhile(q => q.IsNowTab).Select(q => q).Count() + 1; if (num != 0) { ChangeTabAsync(TimelineListTab.ElementAt(--num)); } }); }
public void EditTimeline(TimelineBase timeline) { this.nowEditTimeline = timeline; Messenger.Notify("EditTimeline", timeline); }