Example #1
0
        public void Connect()
        {
            var endpoint = $"http://{Config.ServerHost}:{Config.ServerPort}/";

            Console.WriteLine($"Connecting to {endpoint}");

            _connection = new HubConnection(endpoint);

            _proxy = _connection.CreateHubProxy("CameraHub");

            _connection.Start().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Console.WriteLine("There was an error opening the connection:{0}", task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Connected");
                    _connected = true;
                }
            }).Wait();


            InformIp();

            _proxy.On <ProcessingMode>("setMode", param => { SetMode?.Invoke(this, param); });

            _proxy.On <PanTiltSettingCommand>("panTiltCommand", s => PanTiltCommand?.Invoke(this, s));

            _proxy.On <PiSettings>("updateSettings", settings => SettingsChanged?.Invoke(this, settings));

            _proxy.On <Rectangle>("setRegionOfInterest", r => SetRegionOfInterest?.Invoke(this, r));

            _proxy.On <CaptureConfig>("updateCapture", c => UpdateCapture?.Invoke(this, c));
        }
Example #2
0
 private void ButtonClick(object sender, RoutedEventArgs e)
 {
     Button b = (Button)sender;
     if (b == Shield)
         nRet = SetMode.Shield;
     else if (b == Reset)
         nRet = SetMode.Reset;
     this.Close();
 }
Example #3
0
 public CharRange(char from, char to, SetMode mode = SetMode.Included)
 {
     if (from > to)
     {
         throw  new ArgumentException(nameof(from));
     }
     From = from;
     To   = to;
     Mode = mode;
 }
Example #4
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="name">項目名</param>
 /// <param name="rem">説明</param>
 /// <param name="mode">設定モード</param>
 /// <param name="data">データ</param>
 public CheckInfo(string name, string rem, SetMode mode, string data = "<Empty>")
 {
     Name = name;
     Rem  = rem;
     Mode = mode;
     if (data != null)
     {
         Data = data;
     }
 }
Example #5
0
        public void Connect()
        {
            if (_connection != null)
            {
                _connection.Dispose();
            }

            if (!Config.IsValid)
            {
                Log("Bad config - environment variables expected- see Web.Client.Config.cs");
                return;
            }
            var endpoint = $"http://{Config.ServerHost}:{Config.ServerPort}/";

            Log($"Connecting to {endpoint}");

            _connection = new HubConnection(endpoint);

            _connection.Error          += _connection_Error;
            _connection.Closed         += _connection_Closed;
            _connection.StateChanged   += _connection_StateChanged;
            _connection.ConnectionSlow += _connection_ConnectionSlow;

            _proxy = _connection.CreateHubProxy("CameraHub");

            _connection.Start().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Log($"There was an error opening the connection:{task.Exception.GetBaseException()}");
                }
                else
                {
                    Log("Connected");
                    _connected = true;
                }
            }).Wait();


            InformIp();

            _proxy.On <ProcessingMode>("setMode", param => { SetMode?.Invoke(this, param); });

            _proxy.On <PanTiltSettingCommand>("panTiltCommand", s => PanTiltCommand?.Invoke(this, s));

            _proxy.On <PiSettings>("updateSettings", settings => SettingsChanged?.Invoke(this, settings));

            _proxy.On <Rectangle>("setRegionOfInterest", r => SetRegionOfInterest?.Invoke(this, r));

            _proxy.On <CaptureConfig>("updateCapture", c => UpdateCapture?.Invoke(this, c));
        }
Example #6
0
        private bool IsXXcluded(SetMode mode, char from, char to)
        {
            var index = 0;

            while (index < list.Count && from > list[index].To)
            {
                index++;
            }
            if (index >= list.Count)
            {
                return(false);
            }
            var range = list[index];

            return(from >= range.From && to <= range.To && range.Mode == mode);
        }
Example #7
0
        private void Settings(SetMode mode)
        {
            switch (mode)
            {
            case SetMode.Save:
                Properties.Settings.Default.x          = this.Left;
                Properties.Settings.Default.y          = this.Top;
                Properties.Settings.Default.longformat = radLong.Checked;
                Properties.Settings.Default.Save();
                break;

            case SetMode.Load:
                this.Left        = Properties.Settings.Default.x;
                this.Top         = Properties.Settings.Default.y;
                radLong.Checked  = Properties.Settings.Default.longformat;
                radShort.Checked = !radLong.Checked;
                break;

            default:
                break;
            }
        }
Example #8
0
        private void Settings(SetMode mode)
        {
            switch (mode)
            {
            case SetMode.Save:
                Properties.Settings.Default.xPos    = this.Left;
                Properties.Settings.Default.yPos    = this.Top;
                Properties.Settings.Default.tFormat = this.rbLong.Checked;
                Properties.Settings.Default.hHeight = this.Height;
                Properties.Settings.Default.wWidth  = this.Width;
                Properties.Settings.Default.Save();
                break;

            case SetMode.Load:
                this.Left           = Properties.Settings.Default.xPos;
                this.Top            = Properties.Settings.Default.yPos;
                this.Width          = Properties.Settings.Default.wWidth;
                this.Height         = Properties.Settings.Default.hHeight;
                this.rbLong.Checked = Properties.Settings.Default.tFormat;
                break;
            }
        }
Example #9
0
 public RemapDlg()
 {
     nRet = SetMode.NoSet;
     InitializeComponent();
 }
Example #10
0
        private async Task CmdUpdateAccountAsync(SocketCommandContext context, Match match, CancellationToken cancellationToken = default)
        {
            using IDisposable logScope = _log.BeginCommandScope(context, this);
            _log.LogDebug("Updating Netlix account credentials");
            if (context.IsPrivate)
            {
                _log.LogTrace("Aborting Netflix account credentials updating: Group only");
                await SendErrorAsync($"{_einherjiOptions.FailureSymbol} You can't do this in private message.\nGo to {GetAllowedChannelsMentionsText()}.", context.Channel).ConfigureAwait(false);

                return;
            }
            SocketGuildUser user = await context.Guild.GetGuildUserAsync(context.User).ConfigureAwait(false);

            if (!_netflixAccountOptions.CanModify(user))
            {
                _log.LogTrace("Aborting Netflix account credentials updating: User not privileged");
                await SendErrorAsync($"{_einherjiOptions.FailureSymbol} You need {GetAllowedRolesMentionsText()} role to do this.", context.Channel).ConfigureAwait(false);

                return;
            }
            if (!_netflixAccountOptions.IsChannelAllowed(context.Channel))
            {
                _log.LogTrace("Aborting Netflix account credentials updating: Wrong channel");
                await SendErrorAsync($"You can't do this here.\nGo to {GetAllowedChannelsMentionsText()}.", context.Channel).ConfigureAwait(false);

                return;
            }

            // retrieve info from store
            NetflixAccount account = await _netflixAccountStore.GetAsync(cancellationToken).ConfigureAwait(false);

            // update and save
            SetMode mode         = StringToSetMode(match.Groups[1].Value);
            string  value        = match.Groups[2].Value;
            string  responseText = null;

            if (mode == SetMode.Login)
            {
                account.SetLogin(value, context.User.Id);
                responseText = $"{_einherjiOptions.SuccessSymbol} You have set Netflix account login to `{value}`.";
            }
            if (mode == SetMode.Password)
            {
                account.SetPassword(value, context.User.Id);
                responseText = $"{_einherjiOptions.SuccessSymbol} You have set Netflix account password to `{value}`.";
            }

            await _netflixAccountStore.SetAsync(account, cancellationToken).ConfigureAwait(false);

            // create message
            EmbedBuilder embed = CreateConfirmationEmbed(account, context.User);

            embed.WithDescription(responseText);
            string          text    = this.IsAutoRemoving ? GetAutoremoveText() : null;
            RestUserMessage sentMsg = await context.ReplyAsync(text, false, embed.Build(), cancellationToken).ConfigureAwait(false);

            // auto remove
            if (this.IsAutoRemoving)
            {
                RemoveMessagesDelayed(_netflixAccountOptions.AutoRemoveDelay, cancellationToken, sentMsg, context.Message);
            }
        }
Example #11
0
 public static SetMode Negate(this SetMode @this)
 {
     return(@this == SetMode.Excluded ? SetMode.Included : SetMode.Excluded);
 }
Example #12
0
 private void SetKeys(object o, SetMode sm)
 {
     if (!(o is DependencyObject)) return;
     if (o is KeyButton)
         SetKey((KeyButton)o, sm);
     foreach (object child in LogicalTreeHelper.GetChildren(o as DependencyObject))
         SetKeys(child, sm);
 }
Example #13
0
 //方法
 private void SetKey(KeyButton kb, SetMode sm)
 {
     int rep = hook.SetKeyMap(kb.vkCode, sm);
     kb.Foreground = (rep == kb.vkCode) ? Brushes.Black : Brushes.DeepSkyBlue;
     kb.Content = vkNames[rep];
 }
Example #14
0
 public SetControll()
 {
     mSetMode = new SetMode();
     AddListener();
 }
        public virtual IEnumerator<ITask> SetModeHandler(SetMode setMode)
        {
            _state.SensorMode = setMode.Body.Mode;

            // Convert Sensor Mode to a Sensor Type
            // The Color Sensor has several sensor types just for it
            LegoSensorType st;
            switch (_state.SensorMode)
            {
                case ColorSensorMode.Color:
                    st = LegoSensorType.ColorFull;
                    break;
                case ColorSensorMode.Red:
                    st = LegoSensorType.ColorRed;
                    break;
                case ColorSensorMode.Green:
                    st = LegoSensorType.ColorGreen;
                    break;
                case ColorSensorMode.Blue:
                    st = LegoSensorType.ColorBlue;
                    break;
                case ColorSensorMode.None:
                    st = LegoSensorType.ColorNone;
                    break;
                default:
                    st = LegoSensorType.ColorFull;
                    break;
            }

            LegoSetInputMode cmd = new LegoSetInputMode(_state.SensorPort, st, LegoSensorMode.RawMode);
            _legoBrickPort.SendNxtCommand(cmd);

            yield return Arbiter.Choice(_legoBrickPort.SendNxtCommand(cmd),
                delegate(LegoResponse response)
                {
                    if (response.Success)
                    {
                        setMode.ResponsePort.Post(DefaultUpdateResponseType.Instance);
                        // SetMode notifications are only sent to subscribers to the native service
                        SendNotification<SetMode>(_subMgrPort, setMode);
                    }
                    else
                    {
                        setMode.ResponsePort.Post(
                            Fault.FromException(
                                new InvalidOperationException(response.ErrorCode.ToString())));
                    }
                },
                delegate(Fault fault)
                {
                    setMode.ResponsePort.Post(fault);
                });

            yield break;
        }
Example #16
0
        private void Change(SetMode mode, char from, char to)
        {
            if (from > to)
            {
                throw new ArgumentException("Range limit order is invalid!", nameof(from));
            }

            var leftMostIndex = 0;

            while (leftMostIndex < list.Count && from > list[leftMostIndex].To)
            {
                leftMostIndex++;
            }

            var rightMostIndex = list.Count - 1;

            while (rightMostIndex >= 0 && to < list[rightMostIndex].From)
            {
                rightMostIndex--;
            }

            var leftMostRange  = list[leftMostIndex];
            var rightMostRange = list[rightMostIndex];
            var leftMost       = leftMostRange.From;
            var rightMost      = rightMostRange.To;

            list.RemoveRange(leftMostIndex, rightMostIndex - leftMostIndex + 1);

            if (leftMost < from)
            {
                if (rightMost > to)
                {
                    list.InsertRange(leftMostIndex, new[]
                    {
                        new CharRange(leftMost, (char)(from - 1), leftMostRange.Mode),
                        new CharRange(from, to, mode),
                        new CharRange((char)(to + 1), rightMost, rightMostRange.Mode)
                    });
                }
                else
                {
                    list.InsertRange(leftMostIndex, new[]
                    {
                        new CharRange(leftMost, (char)(from - 1), leftMostRange.Mode),
                        new CharRange(from, to, mode)
                    });
                }
            }
            else
            {
                if (rightMost > to)
                {
                    list.InsertRange(leftMostIndex, new[]
                    {
                        new CharRange(from, to, mode),
                        new CharRange((char)(to + 1), rightMost, rightMostRange.Mode)
                    });
                }
                else
                {
                    list.InsertRange(leftMostIndex, new[]
                    {
                        new CharRange(from, to, mode)
                    });
                }
            }

            TryMergeRange(Math.Max(0, leftMostIndex - 1), 4);
        }
Example #17
0
 private void WindowKeyDown(object sender, KeyEventArgs e)
 {
     nRet = SetMode.SetCurrent;
     this.Close();
 }
Example #18
0
        public static void DisableAllComponentsByTag <T>(this GameObject[] gameObjects, string tag, SetMode mode = SetMode.Inclusive) where T : Behaviour
        {
            foreach (GameObject gameObject in gameObjects)
            {
                switch (mode)
                {
                case SetMode.Inclusive:

                    gameObjects.DisableAllComponentsWithTag <T>(tag);
                    break;

                case SetMode.Exclusive:

                    gameObjects.DisableAllComponentsWithoutTag <T>(tag);
                    break;

                default:
                    string message = "Trying to apply new SetMode to disable components by tag; no changes were made.";

                    Debug.Log(message);
                    break;
                }
            }
        }