Ejemplo n.º 1
0
        private void checkAutoStartStatus()
        {
            String appName = "be.beeles-place.ArduinoControlCenter";
            String runKey  = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";

            Microsoft.Win32.RegistryKey startupKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey);

            if (_settingsModel.startOnBoot == true)
            {
                if (startupKey.GetValue(appName) == null)
                {
                    startupKey.Close();
                    startupKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey, true);
                    startupKey.SetValue(appName, Application.ExecutablePath.ToString());
                    startupKey.Close();
                }
            }
            else
            {
                startupKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey, true);
                startupKey.DeleteValue(appName, false);
                startupKey.Close();
            }
            _messageHub.Publish(new SettingsModelMessage(this, "update"));
        }
Ejemplo n.º 2
0
        public void TriggerPublish()
        {
            Console.WriteLine("Outer:TriggerPublish");
            var x = 1;
            var y = 2;

            Action <object> callback = outerResponse =>
            {
                Console.WriteLine("Outer:OuterResponse Callback");
                var resp = (IDoSomethingOuterResponse)outerResponse;
                IDoSomethingOuterResponseReceived msg = new DoSomethingOuterResponseReceived(this)
                {
                    Message = String.Format("{0}*{1}={2}", x, y, resp.Response)
                };
                _msgr.Publish <IDoSomethingOuterResponseReceived>(msg);
            };

            var sessionUid = Guid.NewGuid();

            _callbacks.Add(sessionUid, callback);

            IDoSomethingOuter outerMsg = new DoSomethingOuter(this)
            {
                x          = x,
                y          = y,
                SessionUid = sessionUid
            };

            _msgr.Publish <IDoSomethingOuter>(outerMsg);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            messenger.Subscribe <MyMessage>(m => { Console.WriteLine("recieved"); });
            messenger.Publish(new MyMessage());
            Console.WriteLine("Hello World!");
            Timer t = new Timer(TimerCallback, null, 0, 2000);

            Console.ReadLine();
        }
Ejemplo n.º 4
0
        private void onDoSomethingInnerResponse(IDoSomethingInnerResponse obj)
        {
            Console.WriteLine("Handler:onDoSomethingInnerResponse");

            IDoSomethingOuterResponse msg = new DoSomethingOuterResponse(this)
            {
                Response   = obj.Result,
                SessionUid = obj.SessionUid
            };

            _msgr.Publish <IDoSomethingOuterResponse>(msg);
        }
        public void Publish_ExceptionThrownByMessageHandler_PassedToExceptionReporter()
        {
            var exceptionReporter = new MessageDeliveryExceptionReporter();
            var hub = new TinyMessengerHub(exceptionReporter);
            var listener = new ExceptionThrowingListener();

            hub.Register(listener);
            hub.Publish(new TestMessage());

            Assert.IsNotNull(exceptionReporter.ReportedException);
        }
        private void run()
        {
            _isRunning = true;
            while (_isRunning)
            {
                _computer.Accept(_visitor);
                _provider.Update();

                if (_sensors != null && _sensors.Count > 0)
                {
                    int calculatedTemp = 0;
                    int highestTemp    = 0;
                    foreach (ISensor sensor in _sensors)
                    {
                        int sensorTemp = (int)sensor.Value;
                        calculatedTemp += (int)sensorTemp;
                        if (sensorTemp > highestTemp)
                        {
                            highestTemp = sensorTemp;
                        }
                    }
                    calculatedTemp = calculatedTemp / _sensors.Count;
                    _hardwareModel.calculatedCPUTemperature = calculatedTemp;
                    _hardwareModel.highestCoreTemp          = highestTemp;

                    //TODO: paramterise temperature override for quiet mode! For now we override at 85°C!
                    if (_hardwareModel.quietModeEnabled && _hardwareModel.highestCoreTemp < 85)
                    {
                        _hardwareModel.calculatedSpeed = _hardwareModel.quietModeSpeed;
                    }
                    else if (_hardwareModel.highestCoreTemp < 85)
                    {
                        _hardwareModel.calculatedSpeed = _linearDataInterpolator.extrapolateSpeedFromTemperature(highestTemp).speed;
                    }
                    else
                    {
                        //When the temp is higher then the max safe override to 100% fan speed!
                        _hardwareModel.calculatedSpeed = 100;
                    }
                }
                else
                {
                    //If no sensors are found, set the calculated and highest temps to -1 and the fan speed to a static 70%
                    _hardwareModel.calculatedCPUTemperature = -1;
                    _hardwareModel.highestCoreTemp          = -1;
                    _hardwareModel.quietModeEnabled         = true;
                    _hardwareModel.calculatedSpeed          = 70;
                }

                _messageHub.Publish(new HardwareModelMessage(this, "update"));
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 7
0
 //TODO remove publish
 public void Publish <TMessage>(TMessage message)
     where TMessage : class, ITinyMessage
 {
     hub.Publish(message);
     HoloNetAppModule.instance.objectPool.Push((IPoolObject)message);
 }
Ejemplo n.º 8
0
 public void autoStartMode()
 {
     this._mode = ColorModel.COLORMODES.manual;
     _messageHub.Publish(new ColorModelMessage(this, COLOR_FIELDS.COLOR));
 }