public void HandleUpdateConfig(HttpListenerContext context)
        {
            string              json           = null;
            ClockAppConfig      clockAppConfig = new ClockAppConfig();
            HttpListenerRequest request        = context.Request;

            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");
            context.Response.AppendHeader("Access-Control-Allow-Headers", "Content-Type, Accept");

            try
            {
                using (var reader = new StreamReader(request.InputStream))
                {
                    json = reader.ReadToEnd();
                }
            }
            catch { }
            finally
            {
                json = json.Replace("\"on\"", "\"true\"").Replace("\"off\"", "\"false\"");

                clockAppConfig = JsonConvert.DeserializeObject <ClockAppConfig>(json);

                File.WriteAllText(_myClockDisplay.clockAppConfig.getProgramPath() + "\\clockconfig.json", json);

                _myClockDisplay.clockAppConfig = clockAppConfig;
            }

            this.SendTextResponse(context, JsonConvert.SerializeObject(clockAppConfig));
        }
Beispiel #2
0
        private void defaultAppConfig()
        {
            if (File.Exists(startUpPath + "\\clockconfig.json"))
            {
                clockAppConfig = JsonConvert.DeserializeObject <ClockAppConfig>(File.ReadAllText(startUpPath + "\\clockconfig.json"));
            }
            else
            {
                string json = JsonConvert.SerializeObject(clockAppConfig);
                File.WriteAllText(startUpPath + "\\clockconfig.json", json);
            }

            if (!Directory.Exists(clockAppConfig.ProfileRoot))
            {
                Directory.CreateDirectory(clockAppConfig.ProfileRoot);
            }
        }
Beispiel #3
0
        public ClockDisplay()
        {
            InitializeComponent();

            /* First things first, deal with that pesky windows firewall */
            firewallConfig(true);

            /* Turn the timer off while we prepare everything necessary */
            clockTimer.Enabled = false;

            clockAppConfig = new ClockAppConfig();

            /* Load the default / saved config for the clock itself - profileroot, webroot, etc... */
            defaultAppConfig();

            /* Hide/Display panels if required */
            pnlFormControls.Visible = clockAppConfig.ShowTopBar;
            pnlPowerpoint.Visible   = clockAppConfig.ShowTopBar;
            pnlSetupSlides.Visible  = clockAppConfig.ShowTopBar;
            pnlBatteryInfo.Visible  = clockAppConfig.ShowTopBar;

            this.KeyUp += new KeyEventHandler(OnKeyPressHandler);

            /* Preload all discovered Json Profiles into the necessary class objects */
            preloadJsonProfiles();

            /* Run the Web and REST servers */
            runBackgroundWorkers();

            lblServerIP2.Text = "http://" + getListeningIP();

            LinkLabel.Link link = new LinkLabel.Link();
            link.LinkData = "http://" + getListeningIP();

            lblServerIP2.Links.Add(link);

            getPresentationPowerpoints();

            /* Finally we have finished doing stuff, re-enable the timer to let the clock do stuff! */
            clockTimer.Enabled = true;

            pnlClock.Invalidate();
        }