Ejemplo n.º 1
0
        private void reloadTasksList()
        {
            int         index = 0;
            ProcessData pd    = Program.GetProgramData();

            foreach (TaskData td in pd.TaskData)
            {
                PictureBox pb = new PictureBox();

                string imagePath = Program.PathImageKey(td.ImageKey);
                Bitmap bmp       = new Bitmap(imagePath);
                bmp       = ImageManager.ScaleImage(bmp, tlpTasks.Width, 200);
                pb.Image  = bmp;
                pb.Anchor = (AnchorStyles.Left | AnchorStyles.Top);
                pb.SetBounds(0, 0, bmp.Width, bmp.Height);
                pb.Name = td.ImageKey + " " + td.ClickPositionX + " " + td.ClickPositionY;

                DataGridViewImageColumn img = new DataGridViewImageColumn();
                img.Image = bmp;
                img.Width = bmp.Width;

                //tlpTasks.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));

                tlpTasks.Controls.Add(pb, index, 0);

                /*
                 * dgvTasks.Rows.Add(img);
                 * dgvTasks.Rows[index].Height = bmp.Height;
                 * dgvTasks.Rows[index].Cells[0].Value = bmp;
                 * index++;
                 */
            }
            tlpTasks.AutoScroll  = true;
            tlpTasks.MaximumSize = new Size(tlpTasks.Parent.Width, tlpTasks.Parent.Height);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  Add new task by index from json and return object
        /// </summary>
        /// <param name="taskData"></param>
        /// <returns></returns>
        public static ProcessData AddTaskData(TaskData taskData)
        {
            ProcessData programData = GetProgramData();

            programData.TaskData.Add(taskData);
            SaveProgramData(programData);
            return(programData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove task by index from json and return object
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public static ProcessData RemoveTaskData(int index)
        {
            ProcessData programData = GetProgramData();

            programData.TaskData.RemoveAt(index);
            SaveProgramData(programData);
            return(programData);
        }
Ejemplo n.º 4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            ProcessData pd = Program.GetProgramData();

            try {
                pd.ProcessRefreshTimeMS = int.Parse(tbRefreshTime.Text);
                pd.AfkDelayMS           = int.Parse(tbAfkDelay.Text);
                Program.SaveProgramData(pd);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get ProcessData object from json file
        /// </summary>
        /// <returns> Retrun empty if file not exist </returns>
        public static ProcessData GetProgramData()
        {
            ProcessData result = new ProcessData();

            try
            {
                if (File.Exists(PROGRAM_DATA_PATH))
                {
                    using (StreamReader r = new StreamReader(PROGRAM_DATA_PATH))
                    {
                        string jsonString = r.ReadToEnd();
                        if (jsonString != string.Empty)
                        {
                            result = JsonConvert.DeserializeObject <ProcessData>(jsonString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Save ProcessData object to json file
        /// </summary>
        /// <param name="processData"></param>
        public static void SaveProgramData(ProcessData processData)
        {
            string json = JsonConvert.SerializeObject(processData);

            File.WriteAllText(PROGRAM_DATA_PATH, json);
        }
 public ProcessManager()
 {
     processData = Program.GetProgramData();
 }