예제 #1
0
파일: Message.cs 프로젝트: peperbol/OCDgame
    public void Setup(MessageNode node )
    {
        this.node = node;
        text.text = node.DisplayText;
        sender.text = node.DisplaySender;

        GameObject.FindObjectOfType<EventSystem>().SetSelectedGameObject(focus.gameObject);
        counting = true;

        switch (node.type)
        {
          case NodeType.OneOptionMessage:
        if (((OneOptionMessageNode)node).ShowOptionText)
        {
          option[0].text = ((OneOptionMessageNode)node).GetDisplayOption();
        }
        break;
          case NodeType.TwoOptionMessage:
        for (int i = 0; i < 2; i++)
        {
          option[i].text = ((TwoOptionMessageNode)node).GetDisplayOption(i);
        }
        break;
          case NodeType.FourOptionMessage:
        for (int i = 0; i < 4; i++)
        {
          option[i].text = ((FourOptionMessageNode)node).GetDisplayOption(i);
        }
        break;
          case NodeType.TextboxMessage:
        break;
        }
    }
예제 #2
0
        void ParseEnum(FileNode filenode, MessageNode msgNode)
        {
            var node = new EnumNode();

            ParseCommentAndEOL(node);

            // message的头注释
            Consume(TokenType.Enum);
            MarkLocation(node);

            node.Name = FetchToken(TokenType.Identifier, "require enum type name").Value;

            _tool.CheckDuplicate(node.Loc, filenode.Package, node.Name);

            if (_fileNode.IsTopScope())
            {
                filenode.AddEnum(node);
            }
            else
            {
                msgNode.Add(node);
            }

            _fileNode.AddSymbol(filenode.Package, node.Name, node);

            TryConsume(TokenType.EOL);
            ParseCommentAndEOL(node);
            Consume(TokenType.LBrace);
            TryConsume(TokenType.EOL);


            while (CurrToken.Type != TokenType.RBrace)
            {
                var valueNode = new EnumValueNode();

                // 字段的头注释
                ParseCommentAndEOL(valueNode);


                MarkLocation(valueNode);
                valueNode.Name = FetchToken(TokenType.Identifier, "require enum name").Value;

                CheckDuplicate(node, _lexer.Loc, valueNode.Name);

                Consume(TokenType.Assign);
                valueNode.Number = FetchToken(TokenType.Number, "require enum value").ToInteger();

                Consume(TokenType.SemiColon);

                node.AddValue(valueNode);


                // 尾注释
                ParseTrailingComment(valueNode);

                ParseCommentAndEOL(valueNode);
            }

            Consume(TokenType.RBrace); TryConsume(TokenType.EOL);
        }
예제 #3
0
        internal Message ReceiveInternal(MessageCallback callback, int timeout = 60000)
        {
            Waiter waiter = null;

            lock (this.ThisLock)
            {
                this.ThrowIfDetaching("Receive");
                MessageNode first = (MessageNode)this.receivedMessages.First;
                if (first != null)
                {
                    this.receivedMessages.Remove(first);
                    this.OnDeliverMessage();
                    return(first.Message);
                }

                if (timeout > 0)
                {
#if NETFX || NETFX40 || DOTNET || NETFX_CORE || WINDOWS_STORE || WINDOWS_PHONE
                    waiter = callback == null ? (Waiter) new SyncWaiter() : new AsyncWaiter(this, callback);
#else
                    waiter = new SyncWaiter();
#endif
                    this.waiterList.Add(waiter);
                }
            }

            // send credit after waiter creation to avoid race condition
            if (this.totalCredit < 0)
            {
                this.SetCredit(DefaultCredit, true);
            }

            return(timeout > 0 ? waiter.Wait(timeout) : null);
        }
예제 #4
0
파일: PFPrinter.cs 프로젝트: ycllz/ProtoF
        public override void Print(MessageNode node, StringBuilder sb, PrintOption opt, params object[] values)
        {
            sb.AppendFormat("message {0}\n", node.Name);
            sb.Append("{\n");

            var subopt = new PrintOption(opt);

            int maxNameLength = 0;
            int maxTypeLength = 0;

            if (node.Field.Count > 0)
            {
                maxNameLength = node.Field.Select(x => x.Name.Length).Max();
                maxTypeLength = node.Field.Select(x => x.CompleteTypeName.Length).Max();
            }

            foreach (var n in node.Child)
            {
                n.PrintVisit(this, sb, subopt,
                             maxNameLength,
                             maxTypeLength);
            }

            sb.Append("}\n");
        }
예제 #5
0
        public EditInboxPage(MessageNode node, InboxNameRecordInfo inboxItem) : base("EditInboxPage")
        {
            Subscribe <InboxRenameEvent>(InboxRenamed);

            _node      = node;
            _inboxItem = inboxItem;
            _title     = inboxItem.Title;

            AddTitleRow("Title");

            AddHeaderRow("RenameHeader");

            _titleRow = AddEntryRow(_title, "RenameEntry");

            Status.Add(_titleRow.Edit, T("RenameStatus"), (sv, edit, newText, oldText) =>
            {
                if (!string.IsNullOrEmpty(newText) && newText.Length <= MessageServiceInfo.MaxInboxNameLength && newText != _title)
                {
                    return(true);
                }

                return(false);
            });

            AddSubmitRow("RenameButton", Rename);

            AddFooterRow();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("OGNIA...");

            var  root                = new ExampleTree("teo");
            Node showMessage         = new MessageNode(root, "Welcome", "This is start node...");
            Node asterisks           = new AsteriskPrinterkNode(root, "Asterisks", 50);
            Node question            = new YesOrNoMenuNode(root, "Question about asterisk", "Do you want to write asterisks?");
            Node notAsterisksMessage = new MessageNode(root, "Not asterisk", "You didn't want to asterisks.");
            Node wrongChoiceMessage  = new MessageNode(root, "Bad choice.", "Bad choice. Try once again.");
            Node endMessage          = new MessageNode(root, "End", "Fine.");

            showMessage.JoinChildNode(question);
            question.JoinChildNode(YesOrNoMenuNode.YES_OUTPUT, asterisks);
            question.JoinChildNode(YesOrNoMenuNode.NO_OUTPUT, notAsterisksMessage);
            question.JoinChildNode(wrongChoiceMessage);
            wrongChoiceMessage.JoinChildNode(question);
            asterisks.JoinChildNode(endMessage);
            notAsterisksMessage.JoinChildNode(endMessage);

            root.SetStartNode(showMessage);
            root.Run();

            while (true)
            {
                root.OnKeyboard(Console.ReadKey().KeyChar);
            }
        }
예제 #7
0
        internal Message ReceiveInternal(MessageCallback callback, int timeout = 60000)
        {
            this.ThrowIfDetaching("Receive");
            if (this.totalCredit < 0)
            {
                this.SetCredit(DefaultCredit, true);
            }

            Waiter waiter = null;

            lock (this.ThisLock)
            {
                MessageNode first = (MessageNode)this.receivedMessages.First;
                if (first != null)
                {
                    this.receivedMessages.Remove(first);
                    this.OnDeliverMessage();
                    return(first.Message);
                }

                if (timeout == 0)
                {
                    return(null);
                }

#if DOTNET || NETFX_CORE
                waiter = callback == null ? (Waiter) new SyncWaiter() : new AsyncWaiter(this, callback);
#else
                waiter = new SyncWaiter();
#endif
                this.waiterList.Add(waiter);
            }

            return(waiter.Wait(timeout));
        }
예제 #8
0
        static RemoveActivation AddActivation(RoutingEngineConfigurator configurator,
                                              Activation <Message <T> > consumerNode)
        {
            var messageActivation = new MessageNode <T>(consumerNode);

            return(configurator.Add(messageActivation));
        }
예제 #9
0
        private void ParseFieldType(FileNode fn, MessageNode node, FieldNode fieldNode)
        {
            string packageName = fn.Package;

            // 字段类型
            fieldNode.Type     = GetFieldType();
            fieldNode.TypeName = CurrToken.Value;

            var maybePackageName = CurrToken.Value;


            Next();

            if (CurrToken.Type == TokenType.Dot)
            {
                Next();
                fieldNode.TypeName = CurrToken.Value;
                packageName        = maybePackageName;

                Next();
            }

            if (fieldNode.Type == FieldType.None && !ResolveFieldType(packageName, fieldNode))
            {
                AddUnsolveNode(fieldNode);
            }

            node.AddField(fieldNode);
        }
예제 #10
0
        void ParseOption(MessageNode node, FieldNode fieldNode)
        {
            // [
            Consume(TokenType.LSqualBracket);

            fieldNode.HasOption = true;

            while (CurrToken.Type != TokenType.RSqualBracket)
            {
                Location loc = _lexer.Loc;

                var key = FetchToken(TokenType.Identifier, "require option identify");
                Consume(TokenType.Assign);

                if (key.Value == "default")
                {
                    fieldNode.DefaultValue = ReadDefaultValue(fieldNode);
                    Next();
                }
                else
                {
                    Reporter.Error(ErrorType.Parse, loc, "unknown field option '{0}'", key.Value);
                }
            }

            // ]
            Consume(TokenType.RSqualBracket);
        }
예제 #11
0
        private static void DisplayMessageInternal(Window owner, string title, HResult hr, bool isTheHresultAWarning, string errorPreamble, Action postAction)
        {
            if (instance == null)
            {
                var dialog = new StatusDialog(owner, title, null, hr, null, errorPreamble, postAction);
                if (isTheHresultAWarning)
                {
                    dialog.SwitchToError(hr, true);
                }
                dialog.ShowDialog();
            }
            else
            {
                if (instance.additionalMessages == null)
                {
                    instance.additionalMessages = new Queue <MessageNode>();
                }

                var newMessage = new MessageNode
                {
                    Preamble         = errorPreamble ?? StringResources.UnknownErrorOccurred,
                    Result           = hr,
                    PostAction       = postAction,
                    IsWarningMessage = isTheHresultAWarning,
                };
                instance.additionalMessages.Enqueue(newMessage);
            }
        }
예제 #12
0
        private HandlerResult ReceivedDiscoRequest(Account account, Message message)
        {
            if (message.SubType == MessageSubType.Get && message.Node.FirstChild != null &&
                message.Node.FirstChild.Name == "query" &&
                message.Node.FirstChild.GetAttribute("xmlns") == Namespace.DiscoInfo)
            {
                string from = message.Node.GetAttribute("from");
                string id   = message.Node.GetAttribute("id");

                Console.WriteLine("Received disco info request from " + from);


                Message resultMessage = new Message(from, MessageType.Iq, MessageSubType.Result);
                resultMessage.Node.SetAttribute("id", id);
                MessageNode queryNode = resultMessage.Node.AddChild("query", null);
                queryNode.SetAttribute("xmlns", Namespace.DiscoInfo);

                foreach (Identity identity in m_Account.Identities)
                {
                    MessageNode identityNode = queryNode.AddChild("identity", null);
                    identityNode.SetAttribute("category", identity.Category.ToString());
                    identityNode.SetAttribute("type", identity.Type.ToString());
                    identityNode.SetAttribute("name", identity.Name);
                }

                foreach (string featureName in m_Account.Features.SelectMany(x => x.FeatureNames))
                {
                    MessageNode featureNode = queryNode.AddChild("feature", null);
                    featureNode.SetAttribute("var", featureName);
                }

                account.Send(resultMessage);
            }
            return(HandlerResult.AllowMoreHandlers);
        }
예제 #13
0
        static void Main(string[] args)
        {
            var keyPair = Utilities.GenerateOrLoadKeyPair("id_rsa");

            Console.WriteLine($"[PUBLIC] {keyPair.Public.GetHashString()}");
            var keyStore = new TrustedKeyStore("authorized_nodes");

            var node = new MessageNode <TestingMessage>(keyPair, IPAddress.Any, 12345);

            node.TrustedKeys      = keyStore;
            node.NodeJoined      += Node_NodeJoined;
            node.NodeLeft        += Node_NodeLeft;
            node.MessageReceived += Node_MessageReceived;

            node.Setup();

            while (true)
            {
                var line = Console.ReadLine();
                node.SendMessage(null, new TestingMessage()
                {
                    Text = line
                });
            }
        }
예제 #14
0
        void ParseField(FileNode fn, MessageNode node)
        {
            var fieldNode = new FieldNode();

            // 字段的头注释
            ParseCommentAndEOL(node);

            ParseFieldType(fn, node, fieldNode);

            ParseFieldName(node, fieldNode);

            switch (CurrToken.Type)
            {
            case TokenType.Assign:
                ParseNumber(node, fieldNode);

                if (CurrToken.Type == TokenType.LSqualBracket)
                {
                    ParseOption(node, fieldNode);
                }

                break;

            case TokenType.LSqualBracket:
                ParseOption(node, fieldNode);
                break;
            }


            // 尾注释
            ParseTrailingComment(fieldNode);

            // 字段的头注释
            ParseCommentAndEOL(node);
        }
예제 #15
0
 public void DisableHideMessagesOnMessageReceived(NodeAddedEvent e, MessageNode battleChatMessageGUI, [JoinByScreen] SingleNode <BattleChatUIComponent> battleChat, [JoinByScreen] ChatContentNode chatContentNode, [JoinByScreen] ChatContentWithSheduleNode chatContentWithSheduleNode, [JoinAll] Optional <SingleNode <BattleActionsStateComponent> > battleActionsState, [JoinAll] Optional <SingleNode <BattleShaftAimingStateComponent> > battleAimState)
 {
     if (battleActionsState.IsPresent() || battleAimState.IsPresent())
     {
         this.DisableHideMessagesSchedule(chatContentWithSheduleNode);
     }
 }
예제 #16
0
        private void ParseFieldType(FileNode fn, MessageNode node, FieldNode fieldNode)
        {
            // 类型
            if (CurrToken.Type == TokenType.Array)
            {
                fieldNode.Container = FieldContainer.Array;
                fieldNode.PBLabel   = PBFieldLabel.Repeated;
                Next();
                Consume(TokenType.LAngleBracket);
            }
            else
            {
                fieldNode.Container = FieldContainer.None;
            }


            // 字段类型
            fieldNode.Type     = GetFieldType();
            fieldNode.TypeName = CurrToken.Value;

            if (fieldNode.Type == FieldType.None && !ResolveFieldType(fn.Package, fieldNode))
            {
                AddUnsolveNode(fieldNode);
            }

            node.AddField(fieldNode);


            Next();

            if (fieldNode.Container == FieldContainer.Array)
            {
                Consume(TokenType.RAngleBracket);
            }
        }
예제 #17
0
        void FillFieldNumber(MessageNode node)
        {
            int autoNumber = 1;

            foreach (var field in node.Field)
            {
                if (field.Number == 0)
                {
                    field.Number          = autoNumber;
                    field.NumberIsAutoGen = true;
                }
                else
                {
                    if (field.Number < autoNumber)
                    {
                        Reporter.Error(ErrorType.Parse, field.Loc, "field number < auto gen number {0}", autoNumber);
                        continue;
                    }

                    autoNumber = field.Number;
                }

                autoNumber++;
            }
        }
예제 #18
0
        public void TestComplexArgs()
        {
            MessageNode msg = MessagePatternUtil.BuildMessageNode(
                "I don't {a,plural,other{w'{'on't #'#'}} and " +
                "{b,select,other{shan't'}'}} '{'''know'''}' and " +
                "{c,choice,0#can't'|'}" +
                "{z,number,#'#'###.00'}'}.");
            ExpectMessageNode expect = new ExpectMessageNode().
                                       ExpectTextThatContains("I don't ").
                                       ExpectPluralArg("a").
                                       ExpectVariant("other").
                                       ExpectTextThatContains("w{on't ").ExpectReplaceNumber().
                                       ExpectTextThatContains("#").FinishVariant().
                                       finishComplexArg().
                                       ExpectTextThatContains(" and ").
                                       ExpectSelectArg("b").
                                       ExpectVariant("other").ExpectTextThatContains("shan't}").FinishVariant().
                                       finishComplexArg().
                                       ExpectTextThatContains(" {'know'} and ").
                                       ExpectChoiceArg("c").
                                       ExpectVariant("#", 0).ExpectTextThatContains("can't|").FinishVariant().
                                       finishComplexArg().
                                       ExpectSimpleArg("z", "number", "#'#'###.00'}'").
                                       ExpectTextThatContains(".");

            expect.CheckMatches(msg);
        }
 protected virtual bool Visit <T>(MessageNode <T> node)
 {
     IncreaseDepth();
     Visit(node.Output);
     DecreaseDepth();
     return(true);
 }
예제 #20
0
        void ParseField(FileNode fn, MessageNode node)
        {
            var fieldNode = new FieldNode();

            // 字段的头注释
            ParseCommentAndEOL(node);

            ParseLabel(fn, fieldNode);

            ParseFieldType(fn, node, fieldNode);

            ParseFieldName(node, fieldNode);

            ParseNumber(node, fieldNode);

            if (CurrToken.Type == TokenType.LSqualBracket)
            {
                ParseOption(node, fieldNode);
            }

            Consume(TokenType.SemiColon);


            // 尾注释
            ParseTrailingComment(fieldNode);

            ParseCommentAndEOL(node);
        }
예제 #21
0
        void ParseFieldName(MessageNode node, FieldNode fieldNode)
        {
            MarkLocation(fieldNode);
            // 字段名
            fieldNode.Name = FetchToken(TokenType.Identifier, "require field name").Value;

            CheckDuplicate(node, _lexer.Loc, fieldNode.Name);
        }
예제 #22
0
        public void TestHelloWithApos()
        {
            // Literal ASCII apostrophe.
            MessageNode       msg    = MessagePatternUtil.BuildMessageNode("Hel'lo!");
            ExpectMessageNode expect = new ExpectMessageNode().ExpectTextThatContains("Hel'lo");

            expect.CheckMatches(msg);
        }
예제 #23
0
        public void TestSimpleArg()
        {
            MessageNode       msg    = MessagePatternUtil.BuildMessageNode("a'{bc''de'f{0,number,g'hi''jk'l#}");
            ExpectMessageNode expect = new ExpectMessageNode().
                                       ExpectTextThatContains("a{bc'def").ExpectSimpleArg(0, "number", "g'hi''jk'l#");

            expect.CheckMatches(msg);
        }
예제 #24
0
        public void SetData(string xml, MessageHandlerFunc callback)
        {
            Message     message = new Message(null, MessageType.Iq, MessageSubType.Set);
            MessageNode query   = message.Node.AddChild("query", xml);

            query.SetAttribute("xmlns", Namespace.PrivateXmlStorage);
            m_Account.Send(message, callback);
        }
예제 #25
0
        public void TestHello()
        {
            // No syntax.
            MessageNode       msg    = MessagePatternUtil.BuildMessageNode("Hello!");
            ExpectMessageNode expect = new ExpectMessageNode().ExpectTextThatContains("Hello");

            expect.CheckMatches(msg);
        }
예제 #26
0
        protected override bool Visit <T>(MessageNode <T> node)
        {
            _current = GetVertex(node.GetHashCode(), () => "P", typeof(MessageNode <>), typeof(T));

            LinkFromParent();

            return(WithVertex(() => base.Visit(node)));
        }
예제 #27
0
        public void GetInfo(Jid entity, string node, MessageHandlerFunc callback)
        {
            Message     m         = new Message(entity.ToString(), MessageType.Iq, MessageSubType.Get);
            MessageNode queryNode = m.Node.AddChild("query", null);

            queryNode.SetAttribute("xmlns", Namespace.DiscoInfo);
            queryNode.SetAttribute("node", node);
            m_Account.Send(m, callback);
        }
예제 #28
0
        public void TestPluralArg()
        {
            // Plural with only keywords.
            MessageNode msg = MessagePatternUtil.BuildMessageNode(
                "abc{num_people, plural, offset:17 few{fff} other {oooo}}xyz");
            ExpectMessageNode expect = new ExpectMessageNode().
                                       ExpectTextThatContains("abc").
                                       ExpectPluralArg("num_people").
                                       ExpectOffset(17).
                                       ExpectVariant("few").ExpectTextThatContains("fff").FinishVariant().
                                       ExpectVariant("other").ExpectTextThatContains("oooo").FinishVariant().
                                       finishComplexArg().
                                       ExpectTextThatContains("xyz");

            expect.CheckMatches(msg);
            // Plural with explicit-value selectors.
            msg = MessagePatternUtil.BuildMessageNode(
                "abc{ num , plural , offset: 2 =1 {1} =-1 {-1} =3.14 {3.14} other {oo} }xyz");
            expect = new ExpectMessageNode().
                     ExpectTextThatContains("abc").
                     ExpectPluralArg("num").
                     ExpectOffset(2).
                     ExpectVariant("=1", 1).ExpectTextThatContains("1").FinishVariant().
                     ExpectVariant("=-1", -1).ExpectTextThatContains("-1").FinishVariant().
                     ExpectVariant("=3.14", 3.14).ExpectTextThatContains("3.14").FinishVariant().
                     ExpectVariant("other").ExpectTextThatContains("oo").FinishVariant().
                     finishComplexArg().
                     ExpectTextThatContains("xyz");
            expect.CheckMatches(msg);
            // Plural with number replacement.
            msg = MessagePatternUtil.BuildMessageNode(
                "a_{0,plural,other{num=#'#'=#'#'={1,number,##}!}}_z");
            expect = new ExpectMessageNode().
                     ExpectTextThatContains("a_").
                     ExpectPluralArg(0).
                     ExpectVariant("other").
                     ExpectTextThatContains("num=").ExpectReplaceNumber().
                     ExpectTextThatContains("#=").ExpectReplaceNumber().
                     ExpectTextThatContains("#=").ExpectSimpleArg(1, "number", "##").
                     ExpectTextThatContains("!").FinishVariant().
                     finishComplexArg().
                     ExpectTextThatContains("_z");
            expect.CheckMatches(msg);
            // Plural with explicit offset:0.
            msg = MessagePatternUtil.BuildMessageNode(
                "a_{0,plural,offset:0 other{num=#!}}_z");
            expect = new ExpectMessageNode().
                     ExpectTextThatContains("a_").
                     ExpectPluralArg(0).
                     ExpectOffset(0).
                     ExpectVariant("other").
                     ExpectTextThatContains("num=").ExpectReplaceNumber().
                     ExpectTextThatContains("!").FinishVariant().
                     finishComplexArg().
                     ExpectTextThatContains("_z");
            expect.CheckMatches(msg);
        }
예제 #29
0
 public void ShowBattleChatMessagesOnMessageReceived(NodeAddedEvent e, MessageNode battleChatMessageGUI, [JoinByScreen] SingleNode <BattleChatUIComponent> battleChat, [JoinByScreen] ChatContentNode chatContentNode, [JoinAll] Optional <SingleNode <BattleActionsStateComponent> > battleActionsState, [JoinAll] Optional <SingleNode <BattleShaftAimingStateComponent> > battleAimState)
 {
     if ((battleActionsState.IsPresent() || battleAimState.IsPresent()) && !battleChatMessageGUI.chatMessageUI.showed)
     {
         battleChatMessageGUI.chatMessageUI.showed = true;
         chatContentNode.visibilityPrerequisites.AddShowPrerequisite(BATTLE_CHAT_SHOW_MESSAGES_PREREQUISITE, false);
         this.HideMessagesDelayed(chatContentNode);
     }
 }
예제 #30
0
        private Root GetRootWithOneMessageNode(INode a_nextNode)
        {
            Root  root = new ExampleTree("TEST ROOT NAME");
            INode node = new MessageNode(root, "MESSAGE NODE NAME", "SOME MESSAGE");

            node.JoinChildNode(a_nextNode);
            root.SetStartNode(node);

            return(root);
        }
예제 #31
0
        public void GetData(string elementName, string elementNamespace, MessageHandlerFunc callback)
        {
            Message     message = new Message(null, MessageType.Iq, MessageSubType.Get);
            MessageNode query   = message.Node.AddChild("query", null);

            query.SetAttribute("xmlns", Namespace.PrivateXmlStorage);
            MessageNode child = query.AddChild(elementName, null);

            child.SetAttribute("xmlns", elementNamespace);
            m_Account.Send(message, callback);
        }
        private StatusDialog(Window owner, string title, BackgroundRequest request, HResult hr, string message, string errorPreamble, Action postAction)
        {
            instance = this;

            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.Owner = owner;
            this.Title = title;
            this.ErrorStatus = new ErrorStatus();
            this.ErrorStatus.Preamble = message;
            this.ErrorStatus.SetStatus(ErrorSeverity.Info, null, null);

            this.request = request;
            this.reportProgress = request as IReportProgress;
            this.DataContext = this;
            this.originalMessage = message;

            this.currentMessage = new MessageNode
            {
                Preamble = errorPreamble ?? StringResources.UnknownErrorOccurred,
                PostAction = postAction
            };

            InitializeComponent();

            if (request != null)
            {
                request.Dispatched += OnRequestDispatched;

                if (reportProgress != null)
                {
                    reportProgress.Progress += OnProgressReport;
                }

                if (request.IsDispatchComplete)
                {
                    // We were asked to wait on a request that has already been dispatched.  Simulate notification
                    // of the dispatch.  Can't call it directly because Close() right now is bad news.
                    this.Dispatcher.BeginInvoke((Action)(() => { this.OnRequestDispatched(request, EventArgs.Empty); }), DispatcherPriority.Background);
                }
            }
            else
            {
                SwitchToError(hr, false);
            }

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopyExecuted));
        }
예제 #33
0
    private float DrawMessageNode(MessageNode node, float x, float y)
    {
        float fieldwidth = NODEWIDTH - PADDING * 2;

        node.MessageText = EditorGUI.TextArea(new Rect(x + PADDING, y, fieldwidth, FIELDHEIGHT * 3), node.MessageText);
        y += FIELDHEIGHT * 3 + PADDING;

        EditorGUI.LabelField(new Rect(x + PADDING, y, fieldwidth * LABELWIDTH, FIELDHEIGHT), "Sender");
        node.Sender = EditorGUI.TextField(new Rect(x + PADDING + fieldwidth * LABELWIDTH, y, fieldwidth - fieldwidth * LABELWIDTH, FIELDHEIGHT), node.Sender);
        y += FIELDHEIGHT + PADDING;

        TimeStamp  t = node.TimeConsumed;
        EditorGUI.LabelField                    (new Rect(x + PADDING,                                                                                        y, fieldwidth * LABELWIDTH,                           FIELDHEIGHT), "Duration");
        t.MinutesInThisHour = EditorGUI.IntField(new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (0 + 2 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 5,        FIELDHEIGHT), t.MinutesInThisHour);
        EditorGUI.LabelField                    (new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (0 + 0 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 7.5f,     FIELDHEIGHT), "M");
        t.HoursInThisDay = EditorGUI.IntField   (new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (1 + 4 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 5,        FIELDHEIGHT), t.HoursInThisDay);
        EditorGUI.LabelField                    (new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (1 + 2 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 7.5f,     FIELDHEIGHT), "H");
        t.Days = EditorGUI.IntField             (new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (2 + 6 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 5,        FIELDHEIGHT), t.Days);
        EditorGUI.LabelField                    (new Rect(x + PADDING + fieldwidth * LABELWIDTH + (fieldwidth - fieldwidth * LABELWIDTH) / 5 * (2 + 4 / 3f),  y, (fieldwidth - fieldwidth * LABELWIDTH) / 7.5f,     FIELDHEIGHT), "D");

        node.TimeConsumed = t;

        y += FIELDHEIGHT + PADDING;

        return y;
    }
        protected override void OnClosing(CancelEventArgs e)
        {
            if (ignoreClose)
            {
                // Since Close/Cancel button is marked IsCancel, we can get TWO
                // attempts to close from WPF.
                e.Cancel = true;
                return;
            }

            this.Footnote = null;
            if (!canceled)
            {
                if (request != null)
                {
                    request.Cancel();
                    canceled = true;
                    e.Cancel = true;
                    this.progressBar.Foreground = Brushes.Red;
                    this.cancelButton.IsEnabled = false;
                    this.cancelButton.Content = StringResources.CancellingButtonText;
                    this.timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, OnCancelTimerTick, this.Dispatcher);
                    this.timer.Start();
                    IgnoreExtraCloseAttempts();
                }
            }
            else if (request != null && !request.IsDispatchComplete)
            {
                // Don't allow closing until the cancellation is dispatched
                e.Cancel = true;

                if (request.Processor != null)
                {
                    request.Processor.Shutdown();
                }
                IgnoreExtraCloseAttempts();
            }
            else
            {
                if (this.currentMessage.PostAction != null)
                {
                    if (this.postActions == null)
                        this.postActions = new Queue<Action>();

                    this.postActions.Enqueue(this.currentMessage.PostAction);
                }

                if (this.additionalMessages != null && this.additionalMessages.Count > 0)
                {
                    this.currentMessage = this.additionalMessages.Dequeue();
                    SwitchToError(this.currentMessage.Result, this.currentMessage.IsWarningMessage);
                    e.Cancel = true;
                    IgnoreExtraCloseAttempts();
                }
                else
                {
                    if (this.postActions != null)
                    {
                        while (this.postActions.Count > 0)
                            this.postActions.Dequeue()();
                    }
                }
            }
        }
        private static void DisplayMessageInternal(Window owner, string title, HResult hr, bool isTheHresultAWarning, string errorPreamble, Action postAction)
        {
            if (instance == null)
            {
                var dialog = new StatusDialog(owner, title, null, hr, null, errorPreamble, postAction);
                if (isTheHresultAWarning)
                {
                    dialog.SwitchToError(hr, true);
                }
                dialog.ShowDialog();
            }
            else
            {
                if (instance.additionalMessages == null)
                {
                    instance.additionalMessages = new Queue<MessageNode>();
                }

                var newMessage = new MessageNode
                {
                    Preamble = errorPreamble ?? StringResources.UnknownErrorOccurred,
                    Result = hr,
                    PostAction = postAction,
                    IsWarningMessage = isTheHresultAWarning,
                };
                instance.additionalMessages.Enqueue(newMessage);
            }
        }