示例#1
0
        internal void OnSocket_Accepted()
        {
            if (PacketValidator == null)
            {
                throw new AegisException(AegisResult.InvalidArgument, "PacketValidator is not set.");
            }

            try
            {
                Activated?.Invoke(this);

                SpinWorker.Dispatch(() =>
                {
                    lock (this)
                    {
                        EventAccept?.Invoke(new IOEventResult(this, IOEventType.Accept, AegisResult.Ok));

                        _method.WaitForReceive();
                    }
                });
            }
            catch (Exception e)
            {
                Logger.Err(LogMask.Aegis, e.ToString());
            }
        }
示例#2
0
        public void Listen()
        {
            Reset();


            var stream = PipeStream as NamedPipeServerStream;

            if (stream == null)
            {
                return;
            }


            stream.BeginWaitForConnection((asyncResult) =>
            {
                AegisTask.SafeAction(() =>
                {
                    stream.EndWaitForConnection(asyncResult);

                    EventAccept?.Invoke(new IOEventResult(this, IOEventType.Accept, AegisResult.Ok));
                    WaitForReceive();
                });
            }, null);
        }
示例#3
0
        private void DrawFooter(Rect rect)
        {
            try
            {
                GUI.BeginGroup(rect);

                if (state == BlueprintHandlerState.Normal)
                {
                    if (CloseButtonVisible)
                    {
                        Rect closeButtonRect = new Rect(ButtonIndent, rect.height / 2 - ButtonSize.y / 2, ButtonSize.x, ButtonSize.y);
                        if (Widgets.ButtonText(closeButtonRect, "Close".Translate()))
                        {
                            EventClose?.Invoke();
                        }
                    }

                    if (EditButtonVisible)
                    {
                        Rect editButtonRect = new Rect(rect.width - ButtonSize.x - ButtonIndent, rect.height / 2 - ButtonSize.y / 2, ButtonSize.x, ButtonSize.y);
                        if (Widgets.ButtonText(editButtonRect, "Edit".Translate()))
                        {
                            EventEdit?.Invoke();
                        }
                    }
                }
                else if (state == BlueprintHandlerState.New || state == BlueprintHandlerState.Edit)
                {
                    if (CancelButtonVisible)
                    {
                        Rect cancelButtonRect = new Rect(ButtonIndent, rect.height / 2 - ButtonSize.y / 2, ButtonSize.x, ButtonSize.y);
                        if (Widgets.ButtonText(cancelButtonRect, "Cancel".Translate()))
                        {
                            EventCancel?.Invoke();
                        }
                    }

                    if (AcceptButtonVisible)
                    {
                        Rect acceptButtonRect = new Rect(rect.width - ButtonSize.x - ButtonIndent, rect.height / 2 - ButtonSize.y / 2, ButtonSize.x, ButtonSize.y);
                        if (Widgets.ButtonText(acceptButtonRect, "Accept".Translate()))
                        {
                            EventAccept?.Invoke();
                        }
                    }
                }

                //Draw cpu, power draw and max power draw bars
                float remainingSpace = FooterRectHeight - DrawBarHeight * 2;
                float cpuY           = Mathf.Floor((FooterRectHeight / 2 - DrawBarHeight - remainingSpace / 3 / 2));
                Rect  cpuDrawRect    = new Rect(DisplayAreaWidth + SectionMargin, cpuY, PartSelectorAreaWidth, DrawBarHeight);
                var   cpuUsage       = Blueprint.GetUsedCPU;
                cpuBar.DrawProgressBar(cpuDrawRect, cpuUsage.value, Blueprint.GetMaxCPU.value, cpuUsage, Blueprint.CPUTooltip);

                Rect powerDrawRect = new Rect(cpuDrawRect.x, cpuDrawRect.yMax + remainingSpace / 3, cpuDrawRect.width, cpuDrawRect.height);
                var  powerDrain    = Blueprint.GetPowerDrain;
                powerBar.DrawProgressBar(powerDrawRect, powerDrain.value, Blueprint.GetMaxPowerDrain.value, powerDrain, Blueprint.PowerDrainTooltip);
            }
            finally
            {
                GUI.EndGroup();
            }
        }