public ITabCommand AddTabCommand(string id) { var cmd = new TabCommand(); commands.Add(id, cmd); return(cmd); }
//Method which handles the event TabPagePrivateReceiveMessageServerEvent, which being fired in FrmServer public void TabPagePrivateReceiveMessageServerDoAction(string clientName, string clientNamePrivate, string message, TabCommand command) { Invoke(new Action((delegate { _RichTextPrivChtServer.SelectionStart = _CursorPosition; switch (command) { case TabCommand.Resumed: _RichTextPrivChtServer.SelectionBackColor = Color.LightGreen; _RichTextPrivChtServer.SelectedText = Time.NowTime() + " " + clientName + " have resumed the chat" + Environment.NewLine; _CursorPosition = _RichTextPrivChtServer.SelectionStart; break; case TabCommand.Message: if (clientNamePrivate == ClientName) { _RichTextPrivChtServer.SelectionColor = Color.Blue; _RichTextPrivChtServer.SelectedText = Time.NowTime() + " " + ClientName + @": " + message + Environment.NewLine; _CursorPosition = _RichTextPrivChtServer.SelectionStart; } else { _RichTextPrivChtServer.SelectionColor = Color.Red; _RichTextPrivChtServer.SelectedText = Time.NowTime() + " " + ClientNamePrivate + @": " + message + Environment.NewLine; _CursorPosition = _RichTextPrivChtServer.SelectionStart; } break; case TabCommand.Closed: _RichTextPrivChtServer.SelectionBackColor = Color.OrangeRed; _RichTextPrivChtServer.SelectedText = Time.NowTime() + " " + clientName + " have closed the chat" + Environment.NewLine; _CursorPosition = _RichTextPrivChtServer.SelectionStart; break; } }))); }
/// <summary> /// Get commands for the apache session using the list of vizqlsessionIDs /// /// </summary> /// <param name="browserSession">Browser session</param> /// <param name="mongoDatabase"></param> /// <param name="vizqlSessionIds">vizqlSessionIDs used in case of correlated vizql sessions</param> /// <returns></returns> private List <TabCommand> GetVizqlServerCommands(BrowserSession browserSession, IMongoDatabase mongoDatabase, List <string> vizqlSessionIds) { var commands = new List <TabCommand>(); var vizqlSessionCollection = mongoDatabase.GetCollection <BsonDocument>("vizqlserver_cpp"); foreach (var vizqlSessionId in vizqlSessionIds) { // making query compatible with old and newer command name, suggest to remove command-pre when tableau version < 2018.3 becomes less relevant var commandQuery = Query.And(Query.Regex("sess", vizqlSessionId + "*"), Query.Or(Query.Eq("k", "command-pre"), Query.Eq("k", "begin-commands-controller.invoke-command"))); var commandsLogs = vizqlSessionCollection.Find(commandQuery).ToList(); Log.DebugFormat("Getting commands for vizqlserver session {0}", vizqlSessionId); foreach (var commandLog in commandsLogs) { //convert the current time to UTC var browserStartTime = (DateTime)commandLog.GetElement("ts").Value - _timeOffset; var timeStr = browserStartTime.ToUniversalTime().ToString(UtcDateFormat); var jsonCmd = commandLog["v"]["args"].ToString(); var command = BuildCommand(jsonCmd); if (command == null) { Log.WarnFormat("Failed to build command from-- {0}", jsonCmd); continue; } //get the user name if it is not already there if (browserSession.User == null) { var user = (string)commandLog.GetValue("user", null); if (user != null) { browserSession.User = user; } } var commandValue = new TabCommand(timeStr, command); commands.Add(commandValue); } } //sort them as due to querying multiple vizqlsession the commands might come in different order commands.Sort(); return(commands); }
/// <summary> /// Get commands for the apache session using the list of vizqlsessionIDs /// </summary> private List <TabCommand> GetVizqlServerCommands(BrowserSession browserSession, List <string> vizqlSessionIds) { var commands = new List <TabCommand>(); foreach (var vizqlSessionId in vizqlSessionIds) { if (!_beginCommandController.ContainsKey(vizqlSessionId)) { continue; } var commandsLogs = _beginCommandController[vizqlSessionId]; _logger.LogDebug("Getting commands for vizqlserver session {0}", vizqlSessionId); foreach (var(startTime, jsonCmd, user) in commandsLogs) { //convert the current time to UTC var browserStartTime = startTime - _timeOffset; var browserStartTimeStr = browserStartTime.ToString(UtcDateFormat); var command = BuildCommand(jsonCmd); if (command == null) { _logger.LogWarning("Failed to build command from-- {0}", jsonCmd); continue; } //get the user name if it is not already there if (browserSession.User == null) { if (user != null) { browserSession.User = user; } } var commandValue = new TabCommand(browserStartTimeStr, command); commands.Add(commandValue); } } //sort them as due to querying multiple vizqlsession the commands might come in different order commands.Sort(); return(commands); }
//Method which handles the event TabPagePrivateReceiveMessageClientEvent, which being fired in FrmChat public void TabPageTabPagePrivateReceiveMessageClient(string tabName, string privateName, string message, TabCommand command) { Invoke(new Action((delegate { _RichTextPrivChtClient.SelectionStart = _CursorPosition; switch (command) { case TabCommand.Message: if (tabName == Client.Name && privateName == Name) { _RichTextPrivChtClient.SelectionColor = Color.Blue; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + Client.Name + @": " + message + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; } if (tabName == Name && privateName == Client.Name) { _RichTextPrivChtClient.SelectionColor = Color.Red; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + Name + @": " + message + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; } break; case TabCommand.Closed: if (tabName == Name) { _BtnPrivateSendMessage.Enabled = false; _BtnPrivateSendImage.Enabled = false; _RichTextPrivChtClient.SelectionBackColor = Color.Red; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + tabName + " has closed the chat" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; } break; case TabCommand.Resumed: _BtnPrivateSendMessage.Enabled = true; _BtnPrivateSendImage.Enabled = true; _RichTextPrivChtClient.SelectionColor = Color.Black; _RichTextPrivChtClient.SelectionBackColor = Color.LightGreen; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + tabName + " has resumed the chat" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; break; case TabCommand.Disconnected: if (tabName == Name) { _BtnPrivateSendMessage.Enabled = false; _BtnPrivateSendImage.Enabled = false; _RichTextPrivChtClient.SelectionBackColor = Color.Red; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + tabName + " have been disconnected" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; } break; case TabCommand.NameChange: if (Name == tabName) { _RichTextPrivChtClient.SelectionColor = Color.Red; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + Name + @" have changed his name to " + message + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; } break; case TabCommand.ImageMessage: _RichTextPrivChtClient.SelectionColor = Color.Black; _RichTextPrivChtClient.SelectionBackColor = Color.Yellow; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + Name + " has sent an image" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; break; case TabCommand.ImageMessageSent: _RichTextPrivChtClient.SelectionColor = Color.Black; _RichTextPrivChtClient.SelectionBackColor = Color.Yellow; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " " + "ImageMessage sent successfully" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; break; case TabCommand.Disconnect: _BtnPrivateSendMessage.Enabled = false; _BtnPrivateSendImage.Enabled = false; _RichTextPrivChtClient.SelectionBackColor = Color.Red; _RichTextPrivChtClient.SelectedText = Time.NowTime() + " have been disconnected" + Environment.NewLine; _CursorPosition = _RichTextPrivChtClient.SelectionStart; break; } }))); }
private void GenrateBarStepper() { StackLayout Outerstack = new StackLayout { }; StackLayout stack = new StackLayout { Margin = new Thickness(15, 0), Spacing = 0, Orientation = StackOrientation.Horizontal }; for (int i = 0; i < Steps; i++) { var frame = new Frame { HorizontalOptions = LayoutOptions.Center, CornerRadius = 50, HasShadow = false }; if (ImageSourceCollection != null && ImageSourceCollection?.Count != 0) { var img = new Image { Source = i < CurrentStep?SelectedImageSourceCollection[i]:ImageSourceCollection[i], }; img.SetBinding(Image.StyleProperty, new Binding(ImageStyleProperty.PropertyName, source: this)); frame.Padding = new Thickness(0); frame.BackgroundColor = Color.Transparent; frame.Content = img; } else { frame.SetBinding(Frame.PaddingProperty, new Binding(CircleWidthProperty.PropertyName, source: this)); if (i < CurrentStep) { frame.SetBinding(Frame.BackgroundColorProperty, new Binding(SelectedStapsColorProperty.PropertyName, source: this)); } else { frame.SetBinding(Frame.BackgroundColorProperty, new Binding(StepsColorProperty.PropertyName, source: this)); } } if (i == 0) { stack.Children.Add(frame); continue; } var boxview = new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, }; boxview.SetBinding(BoxView.HeightRequestProperty, new Binding(StripWidthProperty.PropertyName, source: this)); if (i < CurrentStep) { boxview.SetBinding(BoxView.ColorProperty, new Binding(SelectedStapsColorProperty.PropertyName, source: this)); } else { boxview.SetBinding(BoxView.ColorProperty, new Binding(StripColorProperty.PropertyName, source: this)); } stack.Children.Add(boxview); stack.Children.Add(frame); stack.Children.ToList().ForEach((frm) => { frm.GestureRecognizers?.Clear(); if (frm.GetType() == typeof(Frame)) { TapGestureRecognizer tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += (s, e) => { var index = stack.Children.Where(view => view.GetType() == typeof(Frame)).ToList()?.IndexOf(frm); TabEventHandler?.Invoke(this, new TabEventArgs { TabIndex = index }); TabCommand?.Execute(TabCommandParameter); }; frm.GestureRecognizers.Add(tapGesture); } }); } Outerstack.Children.Add(stack); if (TagsSource != null || TagsSource?.Count >= Steps) { StackLayout tagstack = new StackLayout { Orientation = StackOrientation.Horizontal }; for (int i = 0; i < Steps; i++) { var label = new Label { Text = TagsSource[i], HorizontalOptions = LayoutOptions.CenterAndExpand }; if (i == 0) { label.HorizontalOptions = LayoutOptions.StartAndExpand; } if (i == Steps - 1) { label.HorizontalOptions = LayoutOptions.EndAndExpand; } label.SetBinding(Label.StyleProperty, new Binding(LabelStyleProperty.PropertyName, source: null)); tagstack.Children.Add(label); } Outerstack.Children.Add(tagstack); } Content = Outerstack; }