Exemplo n.º 1
0
        private void GetCurrentSchema()
        {
            try
            {
                ColorConfig config = new ColorConfig();

                string localLocation = System.Environment.ExpandEnvironmentVariables("%userprofile%/downloads/") + "ColorProfile.json";

                if (File.Exists(localLocation))
                {
                    using (StreamReader file = File.OpenText(localLocation))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        config = (ColorConfig)serializer.Deserialize(file, typeof(ColorConfig));
                    }

                    if (config.Name != null)
                    {
                        linkCurrentSchema.Text = config.Name;
                    }
                }
                else
                {
                    linkCurrentSchema.Text = string.Empty;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        private void linkCurrentSchema_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (string.IsNullOrEmpty(linkCurrentSchema.Text))
            {
                return;
            }
            string localLocation = System.Environment.ExpandEnvironmentVariables("%userprofile%/downloads/") + "ColorProfile.json";


            using (StreamReader file = File.OpenText(localLocation))
            {
                JsonSerializer serializer = new JsonSerializer();
                _config = (ColorConfig)serializer.Deserialize(file, typeof(ColorConfig));
            }

            if (_config != null)
            {
                frmManage form = new frmManage();
                form._config               = _config;
                form._create               = false;
                form._readonly             = true;
                form.Text                  = "Busylight Color Schema Editor - READ ONLY";
                form._configurationManager = _configurationManager;

                form.Show();
                RefreshSchemas();
            }
        }
Exemplo n.º 3
0
        private void cbColorSchema_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!loading)
            {
                if (cbColorSchema.SelectedIndex == -1)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(cbColorSchema.SelectedValue.ToString()))
                {
                    string fileLocation = cbColorSchema.SelectedValue.ToString();

                    using (StreamReader file = File.OpenText(fileLocation))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        _config = (ColorConfig)serializer.Deserialize(file, typeof(ColorConfig));
                    }
                }

                if (string.Equals(_config.Name, "Default") || string.IsNullOrEmpty(cbColorSchema.Text))
                {
                    linkDelete.Enabled = false;
                    linkEdit.Enabled   = false;
                }
                else
                {
                    linkDelete.Enabled = _roles;
                    linkEdit.Enabled   = _roles;
                }
            }
        }
Exemplo n.º 4
0
        private void linkNew_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorConfig colorSchema = new ColorConfig();

            frmManage form = new frmManage();

            //lets see if the default exists and pull that in for them to change
            string fileLocation = @"I:\apps\ININColorSchemes\Default.json";

            if (File.Exists(@fileLocation))
            {
                using (StreamReader file = File.OpenText(fileLocation))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    _config      = (ColorConfig)serializer.Deserialize(file, typeof(ColorConfig));
                    _config.Name = "New";
                    form._config = _config;
                }
            }
            else
            {
                colorSchema.Name = "New";
                colorSchema.DefaultBlinkThreshold = 0;

                List <ColorConfigItems> types = new List <ColorConfigItems>();
                types.Add(new ColorConfigItems {
                    Name = "AVAILABLE", BlinkDelay = 0, Color = "GREEN"
                });
                types.Add(new ColorConfigItems {
                    Name = "BREAK", BlinkDelay = 0, Color = "RED"
                });
                types.Add(new ColorConfigItems {
                    Name = "FOLLOWUP", BlinkDelay = 0, Color = "YELLOW"
                });
                types.Add(new ColorConfigItems {
                    Name = "TRAINING", BlinkDelay = 0, Color = "BLUE"
                });
                types.Add(new ColorConfigItems {
                    Name = "UNAVAILABLE", BlinkDelay = 0, Color = "RED"
                });


                colorSchema.StatusTypes = types;

                List <ColorConfigMessageItems> messages = new List <ColorConfigMessageItems>();
                colorSchema.StatusMessages = messages;

                form._config = colorSchema;
            }


            form._create = true;
            form._configurationManager = _configurationManager;

            form.Show();
            RefreshSchemas();
        }
Exemplo n.º 5
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbColorSchema.Text))
            {
                return;
            }

            try
            {
                string fileLocation = @cbColorSchema.SelectedValue.ToString();

                string localLocation = System.Environment.ExpandEnvironmentVariables("%userprofile%/downloads/") + "ColorProfile.json";


                using (StreamReader file = File.OpenText(fileLocation))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    _config = (ColorConfig)serializer.Deserialize(file, typeof(ColorConfig));
                }


                //Delete the old file to make way for the new one
                if (File.Exists(localLocation))
                {
                    File.Delete(localLocation);
                }

                File.WriteAllText(localLocation, JsonConvert.SerializeObject(_config));

                using (StreamWriter file = File.CreateText(localLocation))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, _config);
                }

                //Clean up and let them know
                MessageBox.Show("Please restart Interaction Desktop to begin using the new color schema.", "New Schema Selected.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbColorSchema.SelectedIndex = -1;

                GetCurrentSchema();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An Error occured" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                throw;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Validate
            if (CheckErrors())
            {
                try
                {
                    //Build out the object to serialize into a json file
                    ColorConfig config = new ColorConfig();

                    config.Name = txtName.Text;
                    config.DefaultBlinkThreshold = int.Parse(txtDefaultBlinkingThreshold.Text);
                    config.StatusTypes           = (List <ColorConfigItems>)dgTypes.DataSource;
                    config.StatusMessages        = (List <ColorConfigMessageItems>)dgMessages.DataSource;

                    string fileLocation = @"I:\apps\ININColorSchemes\" + txtName.Text + ".json";

                    //Delete the old file to make way for the new one
                    if (File.Exists(@fileLocation))
                    {
                        if (_originalName != txtName.Text)
                        {
                            var result = MessageBox.Show("Profile with that name already exists. do you want to Overwrite it?", "Already Exists", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                            if (result == DialogResult.Yes)
                            {
                                File.Delete(@fileLocation);
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            File.Delete(@fileLocation);
                        }
                    }

                    //Make it available for use
                    File.WriteAllText(@fileLocation, JsonConvert.SerializeObject(config));

                    //Make sure it was written and then let the user know
                    if (File.Exists(@fileLocation))
                    {
                        var message    = _create ? "Schema has been created successfully." : "Schema has been modified sucessfully.";
                        var messagecap = _create ? "Created" : "Updated";
                        var result     = MessageBox.Show(message, messagecap, MessageBoxButtons.OK, MessageBoxIcon.Information);

                        if (result == DialogResult.OK)
                        {
                            this.Close();
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                MessageBox.Show("Please correct the errors on the page before saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }