Beispiel #1
0
        private void CreateMessage(string Content, string Name)
        {
            Line SeperateLine = new Line()
            {
                X1 = 0,
                Y1 = 0,
                X2 = 200,
                Y2 = 0,
                StrokeThickness = 1,
                StrokeDashArray = new DoubleCollection()
                {
                    4, 4
                },
                Stroke = Brushes.Blue,
                Width  = 200,
            };

            Label NameLb = new Label();

            NameLb.Content    = Name;
            NameLb.FontWeight = FontWeights.SemiBold;
            DockPanel.SetDock(NameLb, Dock.Left);

            Label TimeLb = new Label();

            TimeLb.FontSize = 10;
            TimeLb.Content  = DateTime.Now.ToLongTimeString();
            DockPanel.SetDock(TimeLb, Dock.Right);

            DockPanel Dp = new DockPanel();

            Dp.LastChildFill = false;
            Dp.Children.Add(NameLb);
            Dp.Children.Add(TimeLb);

            TextBox ContentTb = new TextBox();

            ContentTb.Text         = Content;
            ContentTb.TextWrapping = TextWrapping.Wrap;
            ContentTb.BorderBrush  = Brushes.Transparent;


            StackPanel Sp = new StackPanel();

            Sp.Children.Add(SeperateLine);
            Sp.Children.Add(Dp);
            Sp.Children.Add(ContentTb);
            Sp.Margin = new Thickness(10, 10, 0, 10);
            DockPanel.SetDock(Sp, Dock.Top);

            ChatPanel.Children.Add(Sp);
            ChatRow.ScrollToEnd();
        }
        /// <summary>
        /// Evaluates whether a given working order is eligible for a cross with another order.
        /// </summary>
        public static void CrossChat(Object[] key, params Object[] parameters)
        {
            // An instance of the data model is required for CRUD operations.
            DataModel dataModel = new DataModel();

            // The logic below will examine the order and see if a contra order is available for a match.  These values will indicate whether a match is
            // possible after all the locks have been released.
            Guid chatId = (Guid)key[0];

            // A transaction is required to lock the records and change the data model.
            using (TransactionScope transactionScope = new TransactionScope())
            {
                // This variable holds context information for the current transaction.
                DataModelTransaction dataModelTransaction = DataModelTransaction.Current;

                // This is the working order that will be tested for a possible buyer or seller (contra party).
                ChatRow chatRow = DataModel.Chat.ChatKey.Find(chatId);
                if (chatRow == null)
                {
                    throw new Exception(string.Format("Chat {0} has been deleted", chatId));
                }
                chatRow.AcquireReaderLock(dataModelTransaction);

                // The match record contains the identifier for the counter party.  The counter party is needed in order to create an
                // entry in the conversation that is private to that user.
                MatchRow matchRow = DataModel.Match.MatchKey.Find(chatRow.MatchId);
                matchRow.AcquireReaderLock(dataModelTransaction);

                // This is the counter party to the match.
                MatchRow contraMatchRow = DataModel.Match.MatchKey.Find(matchRow.ContraMatchId);
                contraMatchRow.AcquireReaderLock(dataModelTransaction);

                // Each side needs a private copy of the conversation in order to pass through the Chinese wall.  This will create an entry in the conversation
                // for the contra side of the conversation.
                Guid     contraChatId = Guid.NewGuid();
                DateTime createdTime  = DateTime.UtcNow;
                dataModel.CreateChat(
                    contraMatchRow.BlotterId,
                    contraChatId,
                    createdTime,
                    true,
                    contraMatchRow.MatchId,
                    chatRow.Message);

                // The working order that triggered this action has completed a scan of the data model and has notified all possible counter parties of the its
                // new status.  Once the transaction is completed, a negotiation session will be started if a new counter party is found.
                transactionScope.Complete();
            }
        }
Beispiel #3
0
    public void DisplayText(string name, string text)
    {
        // create new chat box
        this.text = text;
        GameObject go = Instantiate(chatBoxPrefab, chatBoxParent);

        chatbox = go.GetComponent <ChatRow>();
        chatbox.Set(name, text, dialogSprites.GetByName(name));
        // stop old text scroll animation if it is still running
        if (textScroll != null)
        {
            StopCoroutine(textScroll);
            textScroll = null;
        }
        // use speed as Mathf.Infinity to turn off scrolling
        textScroll = StartCoroutine(ScrollText(text, 75f));
    }