public static void ReadWriteJson()
        {
            if (!File.Exists(path))
            {
                SettingJSON defaultSetting = new SettingJSON();
                defaultSetting.fixationTimeLength = Constants.DEFAULT_TIME_LENGTH;
                defaultSetting.fixationTimeOut    = Constants.DEFAULT_TIME_OUT;
                defaultSetting.leftClick          = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.doubleClick        = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.rightClick         = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.scoll             = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.micInput          = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.micInputOff       = Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.sidebar           = new string[] { "right_click", "left_click", "double_left_click", "scroll", "keyboard", "settings" };
                defaultSetting.maxZoom           = 2;
                defaultSetting.Crosshair         = 1;
                defaultSetting.zoomWindowSize    = 10;
                defaultSetting.stickyLeftClick   = false;
                defaultSetting.selectionFeedback = true;
                string JSONstr = JsonConvert.SerializeObject(defaultSetting);
                File.AppendAllText(path, JSONstr);

                readSettings = defaultSetting;
            }
            else
            {
                string s = File.ReadAllText(path);
                readSettings = JsonConvert.DeserializeObject <SettingJSON>(s);
            }
        }
Exemplo n.º 2
0
        public static void ReadWriteJson()
        {
            if (!File.Exists(path))
            {
                SettingJSON defaultSetting = new SettingJSON();
                //TODO: Need to be replaced

                //defaultSetting.language = "    English\r\n(United States)";
                //defaultSetting.position = "Right";
                //defaultSetting.precision = 0;
                //defaultSetting.selection = "GAZE";
                //defaultSetting.size = "SMALL";
                //defaultSetting.soundFeedback = false;
                //defaultSetting.speed = 0;
                //defaultSetting.typingSpeed = 0;
                //defaultSetting.wordPrediction = false;
                defaultSetting.fixationTimeLength = ValueNeverChange.DEFAULT_TIME_LENGTH;
                defaultSetting.fixationTimeOut    = ValueNeverChange.DEFAULT_TIME_OUT;
                defaultSetting.leftClick          = ValueNeverChange.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.doubleClick        = ValueNeverChange.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.rightClick         = ValueNeverChange.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                defaultSetting.scoll = ValueNeverChange.KEY_FUNCTION_UNASSIGNED_MESSAGE;
                string JSONstr = JsonConvert.SerializeObject(defaultSetting);
                File.AppendAllText(path, JSONstr);
            }
            else
            {
                string s = File.ReadAllText(path);
                readSettings = JsonConvert.DeserializeObject <SettingJSON>(s);
            }
        }
Exemplo n.º 3
0
        //private void btnSwitch_Click(object sender, EventArgs e)
        //{

        //    gazeOrSwitch = GazeOrSwitch.SWITCH;
        //    changeSitchGaze(gazeOrSwitch);
        //}

        //private void changeSitchGaze(GazeOrSwitch gs)
        //{
        //    switch (gs)
        //    {
        //        case GazeOrSwitch.GAZE:
        //            ChangeButtonColor(btnGaze, !onOff[0], false);
        //            ChangeButtonColor(btnSwitch, onOff[0], false);
        //            break;
        //        case GazeOrSwitch.SWITCH:
        //            ChangeButtonColor(btnGaze, onOff[0], false);
        //            ChangeButtonColor(btnSwitch, !onOff[0], false);
        //            break;
        //    }
        //}



        //private void lblOnOff(Label l, bool b)
        //{
        //    if(b)
        //    {
        //        l.Text = "On";
        //    }
        //    else
        //    {
        //        l.Text = "Off";
        //    }

        //}


        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SettingJSON setting = new SettingJSON();

                setting.fixationTimeLength = trackBarFixTimeLength.Value * Constants.GAP_TIME_LENGTH + Constants.MIN_TIME_LENGTH;
                setting.fixationTimeOut    = trackBarFixTimeOut.Value * Constants.GAP_TIME_OUT + Constants.MIN_TIME_OUT;
                setting.leftClick          = lbLeft.Text;
                setting.doubleClick        = lbDouble.Text;
                setting.rightClick         = lbRight.Text;
                setting.scoll             = lbScroll.Text;
                setting.micInput          = lbMicOn.Text;
                setting.micInputOff       = lbMicOff.Text;
                setting.sidebar           = selectedActions.ToArray <string>();
                setting.Crosshair         = trackBarCrosshair.Value;
                setting.maxZoom           = trackBarZoomAmount.Value;
                setting.zoomWindowSize    = trackBarZoomWindowSize.Value;
                setting.stickyLeftClick   = stickyLeft;
                setting.selectionFeedback = selectionFeedback;

                Program.readSettings.sidebar = selectedActions.ToArray <string>();
                Program.readSettings.maxZoom = setting.maxZoom;
                form1.ArrangeSidebar(Program.readSettings.sidebar);
                string settings = JsonConvert.SerializeObject(setting);
                File.WriteAllText(Program.path, settings);

                Program.readSettings = setting;
                form1.stateManager.RefreshZoom();

                form1.NotifyIcon.BalloonTipTitle = "Saving success";
                form1.NotifyIcon.BalloonTipText  = "Your settings are successfuly saved";
                this.Close();
                form1.NotifyIcon.ShowBalloonTip(2000);
            }
            catch (Exception exception)
            {
                form1.NotifyIcon.BalloonTipTitle = "Saving error";
                form1.NotifyIcon.BalloonTipText  = "For some reason, your settings are not successfuly saved, click me to show error message";
                form1.NotifyIcon.Tag             = exception.Message;
                this.Close();
                form1.NotifyIcon.BalloonTipClicked += NotifyIcon_BalloonTipClicked;
                form1.NotifyIcon.ShowBalloonTip(5000);
            }
        }
Exemplo n.º 4
0
        //private void btnSwitch_Click(object sender, EventArgs e)
        //{

        //    gazeOrSwitch = GazeOrSwitch.SWITCH;
        //    changeSitchGaze(gazeOrSwitch);
        //}

        //private void changeSitchGaze(GazeOrSwitch gs)
        //{
        //    switch (gs)
        //    {
        //        case GazeOrSwitch.GAZE:
        //            ChangeButtonColor(btnGaze, !onOff[0], false);
        //            ChangeButtonColor(btnSwitch, onOff[0], false);
        //            break;
        //        case GazeOrSwitch.SWITCH:
        //            ChangeButtonColor(btnGaze, onOff[0], false);
        //            ChangeButtonColor(btnSwitch, !onOff[0], false);
        //            break;
        //    }
        //}



        //private void lblOnOff(Label l, bool b)
        //{
        //    if(b)
        //    {
        //        l.Text = "On";
        //    }
        //    else
        //    {
        //        l.Text = "Off";
        //    }

        //}


        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SettingJSON setting = new SettingJSON();

                //TODO: Need to be replaced

                //setting.position = lblIndicationLeftOrRight.Text.Substring(3);
                //setting.precision = trackBarFixTimeLength.Value;
                //setting.selection = gazeOrSwitch.ToString();
                //setting.size = sizes.ToString();
                //setting.soundFeedback = onOff[3];
                //setting.speed = trackBarFixTimeOut.Value;
                //setting.wordPrediction = onOff[2];

                setting.fixationTimeLength = trackBarFixTimeLength.Value * ValueNeverChange.GAP_TIME_LENGTH + ValueNeverChange.MIN_TIME_LENGTH;
                setting.fixationTimeOut    = trackBarFixTimeOut.Value * ValueNeverChange.GAP_TIME_OUT + ValueNeverChange.MIN_TIME_OUT;
                setting.leftClick          = lbLeft.Text;
                setting.doubleClick        = lbDouble.Text;
                setting.rightClick         = lbRight.Text;
                setting.scoll = lbScroll.Text;

                string settings = JsonConvert.SerializeObject(setting);
                File.WriteAllText(Program.path, settings);
                //MessageBox.Show("Save Success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                form1.NotifyIcon.BalloonTipTitle = "Saving success";
                form1.NotifyIcon.BalloonTipText  = "Your settins are successfuly saved";
                this.Close();
                form1.NotifyIcon.ShowBalloonTip(2000);
            }
            catch (Exception exception)
            {
                form1.NotifyIcon.BalloonTipTitle = "Saving error";
                form1.NotifyIcon.BalloonTipText  = "For some reason, your settings are not successfuly saved, click me to show error message";
                form1.NotifyIcon.Tag             = exception.Message;
                this.Close();
                form1.NotifyIcon.BalloonTipClicked += NotifyIcon_BalloonTipClicked;
                form1.NotifyIcon.ShowBalloonTip(5000);
                //MessageBox.Show(exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }