private void LayoutScreen() { var levelBlockHeight = (int)(screen.Height * 0.8); var levelBlockWidth = (int)(screen.Width * 0.6); var statsBlockHeight = (int)(levelBlockHeight * 0.6); levelViewportPanel = new LevelViewportPanel(new ScreenZone(-1, -1, levelBlockWidth, levelBlockHeight), screen, () => level); messagesPanel = new MessagesPanel( new ScreenZone(-1, levelBlockHeight - 2, screen.Width + 2, screen.Height - levelBlockHeight + 2), screen); statsPanel = new StatsPanel( new ScreenZone(levelBlockWidth - 2, -1, screen.Width - levelBlockWidth + 2, statsBlockHeight), screen, () => level?.Player); infoPanel = new InfoPanel( new ScreenZone(levelBlockWidth - 2, statsBlockHeight - 2, screen.Width - levelBlockWidth + 2, levelBlockHeight - statsBlockHeight + 1), screen, () => level, () => levelViewportPanel.TranslateCoords(cursorLeft - levelViewportPanel.ClientZone.Left, cursorTop - levelViewportPanel.ClientZone.Top)); }
/// <summary> /// Moves list box to last item. /// </summary> private void _ScrollIntoView() { MessagesPanel.UpdateLayout(); object item = MessagesPanel.Items.LastOrDefault(); if (item != null) { MessagesPanel.ScrollIntoView(item); } }
private Label GetLabel(Model.Message message) { return(new Label() { Anchor = AnchorStyles.Left | AnchorStyles.Right, //BorderStyle = BorderStyle.FixedSingle, Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204), Name = message.ID.ToString(), MinimumSize = new Size(0, LabelSizeY), Text = message.Text, TextAlign = ContentAlignment.MiddleLeft, Width = MessagesPanel.GetColumnWidths()[0] - 20 }); }
private void SendMessage() { if ((String.IsNullOrWhiteSpace(MessageTextBox.Text) || MessageTextBox.Text == MessageTextBoxPlaceholder) && _attachedFile == null) { return; } Message m = new Message { Text = MessageTextBox.Text, ChatToID = _chat.ID, UserFromID = Properties.Settings.Default.CurrentUser.ID }; if (_attachedFile != null) { m.AttachType = _attachedFile.Type; m.Attach = _attachedFile.File; m.AttachName = _attachedFile.Path.Split('\\').Last(); AttachButton.BackgroundImage = Properties.Resources.attach; _attachedFile = null; } Message returned = ServiceClient.SendMessage(m); AddMessage(returned); if (_chat.TimeToLive > 0) { Dictionary <Guid, int> arg = new Dictionary <Guid, int>() { { returned.ID, MessagesPanel.GetRow(MessagesPanel.Controls.Find(returned.ID.ToString(), true).First()) } }; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += SelfDestroyMessage_DoWork; bgw.RunWorkerCompleted += SelfDestroyMessage_RunWorkerCompleted; bgw.RunWorkerAsync(arg); } MessageTextBox.Text = ""; }
private void TextBlock_Loaded(object sender, System.Windows.RoutedEventArgs e) { TextBlock curBlock = sender as TextBlock; if (null != curBlock) { string query = App.Current.EntityService.SearchQuery; int index = curBlock.Text.ToLower().IndexOf(query.ToLower()); if (index > -1) { string begin = curBlock.Text.Substring(0, index); string selection = curBlock.Text.Substring(index, query.Length); string end = curBlock.Text.Substring(index + query.Length); curBlock.Inlines.Clear(); curBlock.Inlines.Add(new Run() { Text = begin, Foreground = App.Current.GrayBrush }); curBlock.Inlines.Add(new Run() { Text = selection, Foreground = App.Current.BlueBrush }); curBlock.Inlines.Add(new Run() { Text = end, Foreground = App.Current.GrayBrush }); } else { string text = curBlock.Text; curBlock.Inlines.Clear(); curBlock.Inlines.Add(new Run() { Text = text, Foreground = App.Current.GrayBrush }); } MessagesPanel.UpdateLayout(); } }
private void MessagesPanel_ControlAdded(object sender, ControlEventArgs e) { //MessagesPanel.ScrollControlIntoView(e.Control); MessagesPanel.VerticalScroll.Value = MessagesPanel.VerticalScroll.Maximum; MessagesPanel.PerformLayout(); }