Beispiel #1
0
 public override void GetValue(ConfigChange cc)
 {
     base.GetValue (cc);
     if ( (_toggle.isOn && Value == "1") || (!_toggle.isOn && Value == "0") )
         return;
     _toggle.isOn = (Value == "1") ? true : false;
 }
        /// <summary>
        /// Update SteamVR.vrsettings file as requested
        /// </summary>
        /// <param name="request">Requested settings change</param>
        /// <returns>Whether update was successful</returns>
        public static bool UpdateSteamVRConfigFile(ConfigChange request)
        {
            string vr_settings_path = SteamVRSettingsFilePath();

            if (vr_settings_path == null)
            {
                Common.ShowMessageBox(Common.MSG_ERROR_LOCATING_STEAMVR_CONFIG, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            string existing_configuration_json = File.ReadAllText(vr_settings_path);

            if (existing_configuration_json == null)
            {
                Common.ShowMessageBox(Common.MSG_ERROR_READING_STEAMVR_CONFIG, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            string updated_configuration_json = UpdateSteamVRConfigJSON(existing_configuration_json, request);

            File.WriteAllText(vr_settings_path, updated_configuration_json);

            if (File.ReadAllText(vr_settings_path) != updated_configuration_json)
            {
                Common.ShowMessageBox(Common.MSG_ERROR_UPDATING_STEAMVR_CONFIG, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else
            {
                Common.ShowMessageBox(Common.MSG_STEAMVR_CONFIG_UPDATED, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
        }
Beispiel #3
0
 public override void GetValue(ConfigChange cc)
 {
     base.GetValue(cc);
     if (float.Parse(Value) == _s.value)
         return;
     _s.value = float.Parse(Value);
 }
Beispiel #4
0
        //internal ConfigChangedItem(string nameSpace,
        //    string propertyName,
        //    string oldValue,
        //    string newValue,
        //    ConfigChangeType changeType)
        //{
        //    this.Namespace = nameSpace;
        //    this.PropertyName = propertyName;
        //    this.OldValue = oldValue;
        //    this.NewValue = newValue;
        //    this.ChangeType = changeType;
        //}

        internal ConfigChangedItem(ConfigChange raw)
        {
            this.Namespace    = raw.Namespace;
            this.OldValue     = raw.OldValue;
            this.NewValue     = raw.NewValue;
            this.PropertyName = raw.PropertyName;
            this.ChangeType   = (ConfigChangeType)(int)raw.ChangeType;
        }
Beispiel #5
0
 private static void OnChanged(object sender, ConfigChangeEventArgs changeEvent)
 {
     Console.WriteLine("Changes for namespace {0}", changeEvent.Namespace);
     foreach (string key in changeEvent.ChangedKeys)
     {
         ConfigChange change = changeEvent.GetChange(key);
         Console.WriteLine("Change - key: {0}, oldValue: {1}, newValue: {2}, changeType: {3}", change.PropertyName, change.OldValue, change.NewValue, change.ChangeType);
     }
 }
Beispiel #6
0
            public static ConfigChange create(JObject jObject)
            {
                JProperty handshakeProperty = jObject.Property("handshake");

                if (handshakeProperty == null)
                {
                    return(null);
                }

                ConfigChange configChange = new ConfigChange();

                configChange.handshake = handshakeProperty.Value.ToObject <SimCapiHandshake>();

                return(configChange);
            }
        public async Task StartConfig(ConfigOption option)
        {
            _configHub = Connect(SpearType.Config);
            var provider = new SpearConfigProvider();

            ConfigHelper.Instance.Builder.Sources.Insert(0, provider);
            //订阅配置更新
            _configHub.On <IDictionary <string, object> >("UPDATE", configs =>
            {
                _logger.LogInformation(configs.ToJson());
                foreach (var config in configs)
                {
                    provider.LoadConfig(config.Key, config.Value);
                    ConfigChange?.Invoke(config);
                }
            });
            _configHub.Closed += async ex =>
            {
                _logger.LogInformation("connect closed");
                await ConnectConfig(option);
            };
            await ConnectConfig(option);
        }
        /// <summary>
        /// Update the JSON from SteamVR's configuration file (steamvr.vrsettings).
        /// </summary>
        /// <param name="json_str">Current configuration JSON string</param>
        /// <param name="request">Requested configuration change</param>
        /// <returns></returns>
        private static string UpdateSteamVRConfigJSON(string json_str, ConfigChange request)
        {
            // Parse settings file
            JObject json;

            try
            {
                json = JObject.Parse(json_str);
            }
            catch (Exception)
            {
                return(null);
            }

            switch (request)
            {
            case ConfigChange.Invert:
            {
                // Create or overwrite driver_osvr block
                JToken token;
                if (json.TryGetValue(DRIVER_OSVR_JSON_BLOCK_KEY, out token))
                {
                    JObject driver_osvr_json = (JObject)token;
                    ToggleDriverOSVRDisplayInverted(driver_osvr_json);
                }
                else
                {
                    JObject driver_osvr_json = new JObject();
                    ToggleDriverOSVRDisplayInverted(driver_osvr_json);
                    json.Add(DRIVER_OSVR_JSON_BLOCK_KEY, driver_osvr_json);
                }
            }
            break;
            }

            return(json.ToString());
        }
Beispiel #9
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            // 读取Dxf文件内块的种类和数量
            DxfMapper dxf = new DxfMapper();

            dxf.ReadFile(dxfPath.Text);
            Dictionary <string, int> blocks = dxf.BlockCount();
            // 读取配置文件中的键值对,把块名替换为编号
            ConfigChange dte = new ConfigChange();

            dte.MainPage = this;    // 把当前页面传给工具类,工具类可以调用本页面内输出窗口
            dte.ChangeMap(configPath.Text);
            Dictionary <string, int> datas = dte.BlockToId(blocks);
            // 把数据写入到模板中,并生成新文件在D盘根目录下

            Dictionary <string, int> haveNo = ExcelMapper.WriteData(formworkPath.Text, datas);

            if (haveNo.Count != 0)
            {
                outputBox.AppendText("=======================\n");
                this.outputBox.AppendText(haveNo + "没有在模板中找到对应的编号\n");
            }
            MessageBox.Show("转换完成");
        }
Beispiel #10
0
 protected virtual void OnConfigChange(object sender, ConfigChangeEventArgs eventArgs)
 {
     ConfigChange.DispatchOnContext <ConfigChangeEventArgs>(this, EventContext, eventArgs);
 }
Beispiel #11
0
        protected override void OnMessage(MessageEventArgs e)
        {
            if (!e.IsText)
            {
                return;
            }

            var msg = e.Data;

            logger.Debug(new LogReceivedMessage
            {
                Message = msg,
                Session = ID
            }.ToJson());

            string msgType = null;

            try
            {
                msgType = JObject.Parse(msg)["type"]?.ToObject <string>();

                switch (msgType)
                {
                case "Authorization":
                    OnAuthorization?.Invoke(this, Authorization.FromJson(msg));
                    return;

                case "Client.Initialized":
                    OnClientInitialized?.Invoke(this, ClientInitialized.FromJson(msg));
                    return;

                case "Client.Register":
                    OnClientRegister?.Invoke(this, ClientRegister.FromJson(msg));
                    return;

                case "Config.Change":
                    if (Configurer)
                    {
                        OnConfigChange?.Invoke(this, ConfigChange.FromJson(msg));
                    }

                    return;

                case "Config.Register":
                    Configurer = true;
                    Subscriber = true;
                    OnConfigRegister?.Invoke(this);
                    return;

                case "Config.Start":
                    if (Configurer)
                    {
                        OnConfigStart?.Invoke(this);
                    }

                    return;

                case "Config.Stop":
                    if (Configurer)
                    {
                        OnConfigStop?.Invoke(this);
                    }

                    return;

                case "Execution.StartRequest":
                    OnExecutionRequest?.Invoke(this, ExecutionStartRequest.FromJson(msg));
                    return;

                case "Execution.Started":
                    OnExecutionStarted?.Invoke(this, ExecutionStarted.FromJson(msg));
                    return;

                case "Execution.Stopped":
                    OnExecutionStopped?.Invoke(this, ExecutionStopped.FromJson(msg));
                    return;

                case "Info.Message":
                    OnInfo?.Invoke(this, InfoMessage.FromJson(msg));
                    return;

                case "Info.Subscribe":
                    if (!Subscriber)
                    {
                        Subscriber = true;
                        OnSubscribe?.Invoke(this);
                    }

                    return;

                case "Info.Unsubscribe":
                    Subscriber = false;
                    return;

                default:
                    logger.Info(new LogReceivedUnknownMessageType
                    {
                        MessageType = msgType,
                        Session     = ID
                    }.ToJson());

                    return;
                }
            }
            catch (Exception ex)
            {
                //logger.Error()
                logger.Error(new LogMessageHandlingError
                {
                    Exception   = ex,
                    MessageType = msgType,
                    Session     = ID
                }.ToJson());
            }
        }
Beispiel #12
0
 private void editFormat1_ConfigChange(object sender, System.EventArgs e)
 {
     ConfigChange?.Invoke(sender, e);
 }
Beispiel #13
0
 public void SignDown(ConfigChange Handler)
 {
     handlers -= Handler;
 }
Beispiel #14
0
 public void SignUp(ConfigChange Handler)
 {
     handlers += Handler;
 }
Beispiel #15
0
        public static System.Object deserialize(string jsonString, ref SimCapiMessageType messageType)
        {
            JObject jObject;

            try
            {
                jObject = JsonConvert.DeserializeObject <JObject>(jsonString);
            }
            catch (System.Exception)
            {
                return(null);
            }

            JProperty type = jObject.Property("type");

            if (type == null)
            {
                throw new System.Exception("Invalid message structure");
            }

            JToken typeValue = jObject["type"];

            if (typeValue.Type != JTokenType.Integer)
            {
                throw new System.Exception("type property should be an Integer");
            }


            messageType = typeValue.ToObject <SimCapiMessageType>();



            switch (messageType)
            {
            case SimCapiMessageType.HANDSHAKE_RESPONSE:
                return(HandshakeResponse.create(jObject));

            case SimCapiMessageType.VALUE_CHANGE:
                return(ValueChange.create(jObject));

            case SimCapiMessageType.CONFIG_CHANGE:
                return(ConfigChange.create(jObject));

            case SimCapiMessageType.VALUE_CHANGE_REQUEST:
                return(ValueChangeRequest.create(jObject));

            case SimCapiMessageType.CHECK_COMPLETE_RESPONSE:
                return(CheckCompleteResponse.create(jObject));

            case SimCapiMessageType.CHECK_START_RESPONSE:
                return(CheckStartResponse.create(jObject));

            case SimCapiMessageType.GET_DATA_RESPONSE:
                return(GetDataResponse.create(jObject));

            case SimCapiMessageType.SET_DATA_RESPONSE:
                return(SetDataResponse.create(jObject));

            case SimCapiMessageType.API_CALL_RESPONSE:
                return(null);

            case SimCapiMessageType.INITIAL_SETUP_COMPLETE:
                return(InitialSetupComplete.create(jObject));

            case SimCapiMessageType.RESIZE_PARENT_CONTAINER_RESPONSE:
                return(ResizeParentContainerResponse.create(jObject));

            case SimCapiMessageType.ALLOW_INTERNAL_ACCESS:
                return(AllowInternalAccess.create(jObject));

            case SimCapiMessageType.REGISTERED_LOCAL_DATA_CHANGED:
                return(RegisteredLocalDataChanged.create(jObject));
            }

            throw new System.Exception("Invalid message type");
        }