void TabHost_TabItemSelected(object sender, TabItemEventArgs e) { stopwatch.Stop(); if (e.TabItem.Content == null && e.TabItem.Tag is IViewPlugin) { // Lazy-initialize the contents of the tabitem var view = (IViewPlugin)e.TabItem.Tag; e.TabItem.Content = view.CreateView(); } string tabName; if (e.TabItem.Content is IControllableTab) { var tab = (IControllableTab)e.TabItem.Content; TabHost.HeaderContent = tab.CustomHeaderContent ?? dock; tabName = tab.Title; } else { TabHost.HeaderContent = dock; tabName = dock.GetType().ToString().Split('.').Last(); } // Switch focus to first responder (if any) if (e.TabItem.Content as FrameworkElement != null) { e.TabItem.FocusFirstResponder(); } stopwatch.Start(); ClientStats.LogEventWithTime("Trace Closed", (int)stopwatch.Elapsed.TotalMinutes); ClientStats.CreateNewTrace(); ClientStats.LogEventWithSegment("Switch to tab", e.TabItem.WellKnownView.ToString()); EventBroker.Publish(AppEvents.TabChanged, tabName); }
void AutoCompletionListBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { // goto selected entity var item = AutoCompletionListBox.SelectedItem as CoolSearchResult; if (item != null) { ClientStats.LogEvent("Select search result (dock/keyboard)"); item.NavigateTo(); SearchTextBox.Text = String.Empty; e.Handled = true; } } }
/// <summary> /// Handles the Click event of the CancelButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> void CancelButton_Click(object sender, RoutedEventArgs e) { ClientStats.LogEvent("Check credentials cancel (setup)"); if (IsInEditModus) { if (OnCancel != null) { OnCancel(this, EventArgs.Empty); } } else { if (OnCancel != null) { OnCancel(this, EventArgs.Empty); } } }
void RadioButton_Click(object sender, RoutedEventArgs e) { viewFilter.Filter.CurrentView = GetActivityView((RadioButton)e.OriginalSource); viewFilter.Filter.Label = viewFilter.Filter.CurrentView == ActivityView.Label ? ((LabelsContainer)((RadioButton)e.OriginalSource).Tag).Labelname : String.Empty; viewFilter.RebuildCurrentViewAsync(); if (viewFilter.Filter.CurrentView == ActivityView.Label) { ClientStats.LogEvent("Goto label (mouse)"); } else { ClientStats.LogEventWithSegment("Goto folder (mouse)", viewFilter.Filter.CurrentView.ToString().ToLower()); } EventBroker.Publish(AppEvents.RequestFocus); }
void GotoLabel_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEventWithSegment("Goto folder (keyboard)", ActivityView.Label.ToString()); LogicalTreeWalker.Walk((FrameworkElement)TabHost.HeaderContent, delegate(UIElement element) { if (Responder.GetIsSearchResponder(element)) { FocusHelper.Focus(element); if (element is TextBox) { var tb = (TextBox)element; tb.Text = "label: "; tb.SelectionStart = tb.Text.Length; } } }); }
void AddLabel_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Add label in stream"); using (new ListViewIndexFix(streamView.StreamListView)) { if (State.SelectedMessages.Count == 1) { var lvItem = (ListViewItem)streamView.StreamListView.ItemContainerGenerator.ContainerFromItem(State.SelectedMessage); var editor = (LabelsEditorControl)VisualTreeWalker.FindName("LabelsEditor", lvItem); editor.Visibility = Visibility.Visible; FocusHelper.Focus(editor); } else { // Show modal labels adder EventBroker.Publish(AppEvents.RequestAddLabels, State.SelectedMessages.ToList()); } } }
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ClientStats.LogEvent("Change realtime stream selection"); var lv = (ListView)sender; if (lv.SelectedItem != null) { var status = (UserStatus)lv.SelectedItem; if (!status.IsRead) { status.MarkRead(); AsyncUpdateQueue.Enqueue(status); // Forces update of unread counts EventBroker.Publish(AppEvents.SyncStatusUpdatesFinished); } } }
void AddProfile_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Join profile"); var profile = (Profile)e.Parameter; profile.JoinWith(Person); if (PersonRedirected != null) { PersonRedirected(this, EventArgs.Empty); } Person.RebuildScore(); PerformSearch(); if (ProfileMerged != null) { ProfileMerged(this, EventArgs.Empty); } }
void OlderConversation_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Older conversation in message details view"); List <Conversation> conversations; using (mailbox.Conversations.ReaderLock) conversations = mailbox.Conversations .OrderByDescending(c => c.SortDate) .ToList(); var index = conversations.IndexOf(SelectedMessage.Conversation); if (index > 0 && index < conversations.Count - 1) { var newerConversation = conversations[index - 1]; LoadData(new OverviewDataHelper { MessageId = newerConversation.Last.MessageId.Value }); } }
void Task_FinishedSuccess(object sender, EventArgs e) { var task = (IContextTask)sender; Thread.CurrentThread.ExecuteOnUIThread(delegate { // Make sure this channel has not allready been configured (if not in edit mode) string username = (ChannelConfiguration.Charasteristics.CanCustomize && IsManuallyCustomized) ? ManualEntryIncomingUsername : Username; if (!IsInEditModus && ChannelsManager.Channels.Any( c => c.Configuration.DisplayName == ChannelConfiguration.DisplayName && c.Configuration.InputChannel.Authentication.Username == username)) { ClientStats.LogEvent("Check credentials failure - duplicate account (setup)"); Inbox2MessageBox.Show(Strings.AccountAlreadyAdded, Inbox2MessageBoxButton.OK); } else { ClientStats.LogEvent("Check credentials success (setup)"); IsValidated = true; CheckCanvas.Visibility = Visibility.Visible; if (IsInEditModus) { UpdateChannel(); } else { SaveChannel(task.Values); } if (OnValidationFinished != null) { OnValidationFinished(this, EventArgs.Empty); } } }); }
void UploadDocment_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Upload document"); var dialog = new OpenFileDialog(); dialog.Multiselect = true; var result = dialog.ShowDialog(); if (result == true) { if (dialog.FileNames != null && dialog.FileNames.Length > 0) { foreach (var filename in dialog.FileNames) { var fi = new FileInfo(filename); if (fi.Exists) { var document = new Document { Filename = fi.Name, ContentType = ContentType.Attachment, DateCreated = DateTime.Now, DateSent = DateTime.Now, DocumentFolder = Folders.SentItems }; document.StreamName = Guid.NewGuid().GetHash(12) + "_" + Path.GetExtension(document.Filename); document.ContentStream = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); EventBroker.Publish(AppEvents.DocumentReceived, document); } } } } }
private int ComputeCurrentAnimalClientPairPrefectStats(AnimalStats animal, ClientStats client) { int numberPerfectStats = 0; if (client.ClientPersonality != ClientPersonality.Bad) { if (animal.HouseType == client.HouseType) { numberPerfectStats += 1; } if (animal.HasGarden == client.HasGarden) { numberPerfectStats += 1; } if (animal.HasChildren == client.HasChildren) { numberPerfectStats += 1; } if (animal.HasOtherAnimals == client.HasOtherAnimals) { numberPerfectStats += 1; } if (animal.Cost <= client.Income) { numberPerfectStats += 1; } if (animal.AnimalPersonality == client.AnimalPersonalityWanted) { numberPerfectStats += 1; } } else { numberPerfectStats = -1; } return(numberPerfectStats); }
public bool EvaluateExpression(GrmRuleSetContext context) { try { if (context != null) { context.ContextJson = this.ContextJson; } int num = (int)Enum.Parse(typeof(GrmOperand), this.LeftOperand, true); GrmOperator grmOperator = (GrmOperator)Enum.Parse(typeof(GrmOperator), this.Operator, true); return(EvaluatorFactory.CreateandReturnEvaluator((GrmOperand)num).Evaluate(context, grmOperator, this.RightOperand)); } catch (Exception ex) { Logger.Error("Exception while parsing operand for grmrule. operand: {0} operator: {1} rulesetid:{2} exception: {3}", (object)this.LeftOperand, (object)this.Operator, (object)context?.RuleSetId, (object)ex.Message); if (!GrmExpression._rulesetsWithException.Contains(context?.RuleSetId)) { GrmExpression._rulesetsWithException.Add(context?.RuleSetId); ClientStats.SendMiscellaneousStatsAsync("grm_evaluation_error", RegistryManager.Instance.UserGuid, context?.RuleSetId, RegistryManager.Instance.ClientVersion, RegistryManager.Instance.Version, "bgp", context?.PackageName, ex.Message, (string)null, context?.VmName); } return(false); } }
void Cancel_Click(object sender, RoutedEventArgs e) { ClientStats.LogEvent("Cancel status update in realtime streams overview column"); if (ShowViral) { ShowViral = false; OnPropertyChanged("ShowViral"); SettingsManager.ClientSettings.AppConfiguration.IsFirstStatusUpdate = false; SettingsManager.Save(); } else { ReplyTo = null; OnPropertyChanged("ReplyTo"); } PART_StatusUpdateTextbox.Text = String.Empty; // Put focus back on listview FocusHelper.Focus(((TabItem)StreamsTab.SelectedItem)); }
public static void LoadStats() { // Check if we have a saved logs if (SettingsManager.ClientSettings.ContextSettings.ContainsKey("/Application/StoredStats")) { var storedlogs = SettingsManager.ClientSettings.ContextSettings["/Application/StoredStats"]; if (storedlogs != null) { // Deserialize logs using (var sr = new StringReader((string)storedlogs)) { var ser = new JsonSerializer(); var logs = (List <TraceInfo>)ser.Deserialize(sr, typeof(List <TraceInfo>)); ClientStats.ReEnqueue(logs); SettingsManager.ClientSettings.ContextSettings.Remove("/Application/StoredStats"); SettingsManager.Save(); } } } }
void AccountsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.RemovedItems.Count > 0) { ClientStats.LogEvent("Toggle channel (streamview)"); var instance = AccountsComboBox.SelectedItem as ChannelInstance; foreach (var channel in ChannelsManager.Channels) { channel.IsVisible = instance == null; } if (instance != null) { instance.IsVisible = true; } viewFilter.RebuildCurrentViewAsync(); EventBroker.Publish(AppEvents.RequestFocus); } }
void Attachments_PreviewKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { ClientStats.LogEvent("Delete attachment from new message"); var attachment = (AttachmentDataHelper)AttachmentsListView.SelectedItem; AttachedFiles.Remove(attachment); if (IsDraft && attachment.DocumentId.HasValue) { // Also remove version that is attached to our draft message var document = SourceMessage.Documents.FirstOrDefault(d => d.DocumentId == attachment.DocumentId); if (document != null) { document.DeleteFrom(SourceMessage); } } e.Handled = true; } }
void Forward_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Forward in realtime stream"); var status = (UserStatus)e.Parameter; StringBuilder rt = new StringBuilder(); rt.Append("RT @"); // Search results or twitter updates if (status.SourceChannel == null || status.SourceChannel.DisplayName == "Twitter") { rt.AppendFormat("{0} ", status.From.Address); } else { rt.AppendFormat("{0} ({1}) ", status.From.DisplayName, status.SourceChannel.DisplayName); } rt.Append(status.Status); OnStatusUpdated(status, rt.ToString(), status.SourceChannelId, StatusUpdateAction.Share); }
void Reply_Click(object sender, RoutedEventArgs e) { ClientStats.LogEvent("Compose status update from user profile"); EventBroker.Publish(AppEvents.RequestStatusUpdate, String.Format("@{0} ", Profile.ScreenName), Channel.ChannelId, LastStatus); }
public Client() { Stats = new ClientStats(); }
/// <summary> /// Checks the user input. /// </summary> void CheckUserInput() { ClientStats.LogEventWithSegment("Check user credentials (setup)", ChannelConfiguration.DisplayName); bool isValid = true; if (IsValidated && !IsInEditModus) { return; } if (IsChecking) { Inbox2MessageBox.Show("Credentials are being validated.", Inbox2MessageBoxButton.OK); return; } if (ChannelConfiguration == null) { Inbox2MessageBox.Show("No credentials configured.", Inbox2MessageBoxButton.OK); return; } if (ChannelConfiguration.DisplayStyle == DisplayStyle.Other || (ChannelConfiguration.Charasteristics.CanCustomize && IsManuallyCustomized)) { isValid = !(String.IsNullOrEmpty(ManualEntryIncomingUsernameTextBox.Text) || String.IsNullOrEmpty(ManualEntryIncomingPasswordTextBox.Password) || String.IsNullOrEmpty(ManualEntryIncomingServerTextBox.Text) || String.IsNullOrEmpty(ManualEntryIncomingPortTextBox.Text) || String.IsNullOrEmpty(ManualEntryOutgoingUsernameTextBox.Text) || String.IsNullOrEmpty(ManualEntryOutgoingPasswordTextBox.Password) || String.IsNullOrEmpty(ManualEntryOutgoingServerTextBox.Text) || String.IsNullOrEmpty(ManualEntryOutgoingPortTextBox.Text)); } else if (ChannelConfiguration.DisplayStyle == DisplayStyle.Advanced) { isValid = !(String.IsNullOrEmpty(UsernameTextBox.Text) || String.IsNullOrEmpty(PasswordTextBox.Password) || String.IsNullOrEmpty(HostnameTextBox.Text)); } else if (ChannelConfiguration.DisplayStyle == DisplayStyle.Simple) { isValid = !(String.IsNullOrEmpty(UsernameTextBox.Text) || String.IsNullOrEmpty(PasswordTextBox.Password)); } else if (ChannelConfiguration.DisplayStyle == DisplayStyle.RedirectWithPin) { isValid = (PinGrid.Visibility == Visibility.Visible) ? !String.IsNullOrEmpty(PincodeTextBox.Text) : true; } if (!isValid) { Inbox2MessageBox.Show(Strings.PleaseFillConfigurationCorrectly, Inbox2MessageBoxButton.OK); } else { ValidateChannel(); } }
void Delete_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Delete"); streamView.DeleteStreamSelection(); }
void New_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Compose message from user profile"); EventBroker.Publish(AppEvents.New, (SourceAddress)e.Parameter); }
void ToggleChannel9_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Toggle channel in realtime streams overview column"); ToggleChanneIndex(9); }
public DateTime LoadCSV(string file) { mServerStats.Clear(); bool skip = true; foreach (var line in File.ReadAllLines(file)) { if (skip) { skip = false; string[] split = line.Split(','); mSessionID = UUID.Parse(split[split.Length - 1]); continue; } ServerStats s = new ServerStats(line, mConfig); mServerStats.Add(s); ClientStats c = new ClientStats(line, mConfig); mClientStats.Add(c); } string[] splitFilename = Path.GetFileNameWithoutExtension(file).Split(new char[] { '-' }, 2); mConfig.RunInfo = splitFilename[0]; DateTime ret = DateTime.ParseExact(splitFilename[1], mConfig.TimestampFormat, new DateTimeFormatInfo()); Logger.Info("Loaded pre recorded statistics from: " + file + "."); return ret; }
public static string CombineStats(ExperimentalConfig config, ServerStats server, ClientStats client, int count) { DateTime ts = server.TimeStamp; string line = client.TimeStamp.ToString(config.TimestampFormat) + ","; line += (config.Timestamp - ts).TotalMilliseconds + ","; line += count + ","; foreach (var key in config.OutputKeys) { switch (key.ToUpper()) { case "CFPS": line += client.CFPS.Aggregate("", (s, v) => s + v + ",", f => f); break; case "POLYGONS": line += client.Polys.Aggregate("", (s, v) => s + v + ",", f => f); break; case "PING": line += client.Ping.Aggregate("", (s, v) => s + v + ",", f => f); break; case "FT": line += server.FrameTime.ToString() + ","; break; case "SFPS": line += server.SFPS.ToString() + ","; break; } } return line + "," + ((server.TimeStamp - client.TimeStamp).TotalMilliseconds); }
void SaveDocument_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Save document in images view"); EventBroker.Publish(AppEvents.Save, State.SelectedDocument); }
void ViewAllButton_Click(object sender, RoutedEventArgs e) { ClientStats.LogEvent("View everything from user profile"); EventBroker.Publish(AppEvents.View, Profile.Person); }
void SaveDocument_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Save document in stream"); EventBroker.Publish(AppEvents.Save, (Document)e.Parameter); }
void ShortenUrls_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Shorten url in realtime streams overview column"); CommandHelper.ShortenUrlExecute(e); }
private void ProcessClientStatsMessage(string msg, string[] values) { var clientStats = ClientStatsMessage.CreateClientStatsMessage(values); ClientStats?.Invoke(clientStats); }
void DeleteDocument_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Delete document in images view"); State.Delete(); }
void ForwardInline_Executed(object sender, ExecutedRoutedEventArgs e) { ClientStats.LogEvent("Inline forward (keyboard)"); Forward_Executed(sender, e); }