예제 #1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            bool result;

            if (_id != null)
            {
                Rule _newrule = _rcvm.Rule;
                _newrule.Id = _id;
                result      = _bridge.ModifyObject(_newrule);
            }
            else
            {
                result = _bridge.CreateObject(_rcvm.Rule);
                if (result)
                {
                    _id = _bridge.LastCommandMessages.LastSuccess.value;
                }
            }

            if (result)
            {
                DialogResult = true;
                Close();
            }
            else
            {
                _bridge.ShowErrorMessages();
            }
        }
예제 #2
0
        private void btnSaveScene_Click(object sender, RoutedEventArgs e)
        {
            Scene newScene = _scvm.Scene;
            bool  result;

            log.Info("Scene to be created : " + newScene);

            if (_currentsceneid == string.Empty)
            {
                result = _bridge.CreateObject(newScene);
            }
            else
            {
                newScene.Id = _currentsceneid;
                result      = _bridge.ModifyObject(newScene);
            }

            if (result)
            {
                string id = _currentsceneid != string.Empty ? _currentsceneid : _bridge.LastCommandMessages.LastSuccess.value;
                log.Info("Id of the scene" + id);

                foreach (KeyValuePair <string, State> obj in newScene.lightstates)
                {
                    _bridge.SetSceneLightState(id, obj.Key, obj.Value);
                }
                _currentsceneid = id;
                DialogResult    = true;
                Close();
            }
            else
            {
                _bridge.ShowErrorMessages();
                log.Error(_bridge.LastCommandMessages);
            }
        }