예제 #1
0
        public Arguments(string[] args)
        {
            tasks = new TaskHandler();
            _args = args;
            string FirstArgument = GetFirstArgument();

            if (FirstArgument == "")
            {
                PrintUsage();
                return;
            }
            if (FirstArgument == "-l")
            {
                List();
                return;
            }
            if (FirstArgument == "-a")
            {
                Add();
                return;
            }
            if (FirstArgument == "-r")
            {
                Remove();
                return;
            }
            if (FirstArgument == "-c")
            {
                Check();
                return;
            }
            if (FirstArgument[0] == '-')
            {
                Console.WriteLine("Unsupported argument.");
                Console.WriteLine();
            }
            PrintUsage();
        }
예제 #2
0
        //Constructor
        public MainForm()
        {
            InitializeComponent();
            List <Task> tasks = TaskHandler.GetUnfinishedTasks();

            //CreateMyPanel(tasks);
            leftBorderBtn      = new Panel();
            leftBorderBtn.Size = new Size(7, 60); //60 to rozmiar przycisku

            //Usunięcie góry formularza
            this.Text            = string.Empty;
            this.ControlBox      = false;
            this.DoubleBuffered  = true;
            this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;

            iconButtonExit.BackgroundImage       = Image.FromFile(".\\pics\\Exit.png");
            iconButtonExit.BackgroundImageLayout = ImageLayout.Stretch;

            iconButtonMinimize.BackgroundImage       = Image.FromFile(".\\pics\\Minimize.png");
            iconButtonMinimize.BackgroundImageLayout = ImageLayout.Stretch;

            iconButtonMaximize.BackgroundImage       = Image.FromFile(".\\pics\\Maximize.png");
            iconButtonMaximize.BackgroundImageLayout = ImageLayout.Stretch;
        }
예제 #3
0
        static void Main(string[] args)
        {
            var print  = new Printer();
            var handle = new TaskHandler();

            if (args.Length == 0)
            {
                print.NoArgument();
            }
            else if (args[0] != "-l" && args[0] != "-a" && args[0] != "-r" && args[0] != "-c")
            {
                Console.WriteLine("Unsupported argument");
                Console.WriteLine();
                print.NoArgument();
            }
            else if (args[0] == "-l")
            {
                print.ListTasks();
            }
            else if (args[0] == "-a")
            {
                try
                {
                    handle.AddTask(args[1]);
                }
                catch (Exception)
                {
                    Console.WriteLine("Unable to add: no task provided");
                }
            }
            else if (args[0] == "-r")
            {
                try
                {
                    handle.RemoveTask(Convert.ToInt32(args[1]));
                }
                catch (IndexOutOfRangeException)
                {
                    Console.WriteLine("Unable to remove: no index provided");
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Unable to remove: index is out of bound");
                }
                catch (FormatException)
                {
                    Console.WriteLine("Unable to remove: index is not a number");
                }
            }
            else if (args[0] == "-c")
            {
                try
                {
                    handle.CheckTask(Convert.ToInt32(args[1]));
                }
                catch (IndexOutOfRangeException)
                {
                    Console.WriteLine("Unable to check: no index provided");
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Unable to check: index is out of bound");
                }
                catch (FormatException)
                {
                    Console.WriteLine("Unable to check: index is not a number");
                }
            }
        }
예제 #4
0
        public void CreateMyPanel(List <Task> tasks)
        {
            //List<Category> categories

            List <Category> categories = CategoryHandler.GetCategories();

            int i = 0;

            Panel[]  taskPanel        = new Panel[tasks.Count];
            Button[] failButton       = new Button[tasks.Count];
            Button[] finishButton     = new System.Windows.Forms.Button[tasks.Count];
            Button[] editButton       = new System.Windows.Forms.Button[tasks.Count];
            Label[]  statusLabel      = new System.Windows.Forms.Label[tasks.Count];
            Label[]  isImportantLabel = new System.Windows.Forms.Label[tasks.Count];
            Label[]  deadlineLabel    = new System.Windows.Forms.Label[tasks.Count];
            Label[]  descriptionLabel = new System.Windows.Forms.Label[tasks.Count];
            Label[]  nameLabel        = new System.Windows.Forms.Label[tasks.Count];
            Label[]  categoryLabel    = new System.Windows.Forms.Label[tasks.Count];
            foreach (Task task in tasks)
            {
                taskPanel[i] = new Panel
                {
                    BackColor = System.Drawing.Color.LightSkyBlue,
                    Location  = new Point(13, 13 + 144 * i),
                    Name      = "tasktaskPanel" + (int)task.Id,
                    Size      = new System.Drawing.Size(727, 142),
                    TabIndex  = 9 + (int)task.Id * 9 + 5
                };
                taskPanel[i].SuspendLayout();

                failButton[i] = new Button
                {
                    Location = new Point(615, 60),
                    Name     = "failButton" + (int)task.Id,
                    Size     = new System.Drawing.Size(75, 78),
                    TabIndex = 8 + (int)task.Id * 9 + 5,
                    Text     = "nie udane",
                    UseVisualStyleBackColor = true,
                    Font      = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold),
                    ForeColor = System.Drawing.Color.White,
                    //BackgroundImage = ((System.Drawing.Image)(TaskView.resources.GetObject("failButton.BackgroundImage")));
                };
                failButton[i].Click += (object sender, EventArgs e) =>
                {
                    TaskHandler.SetTaskFailed((int)task.Id);
                    RefreshPanel();
                };

                finishButton[i] = new Button
                {
                    Location = new System.Drawing.Point(534, 60),
                    Name     = "finishButton" + (int)task.Id,
                    Size     = new System.Drawing.Size(75, 78),
                    TabIndex = 7 + (int)task.Id * 9 + 5,
                    Text     = "zrobione",
                    UseVisualStyleBackColor = true,
                    Font      = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold),
                    ForeColor = System.Drawing.Color.White
                };
                finishButton[i].Click += (object sender, EventArgs e) =>
                {
                    TaskHandler.SetTaskFinished((int)task.Id);
                    RefreshPanel();
                };

                editButton[i] = new Button
                {
                    Location = new System.Drawing.Point(615, 3),
                    Name     = "editButton" + (int)task.Id,
                    Size     = new System.Drawing.Size(79, 23),
                    TabIndex = 6 + (int)task.Id * 9 + 5,
                    Text     = "edytuj",
                    UseVisualStyleBackColor = true,
                    Font = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold)
                };

                statusLabel[i] = new Label
                {
                    Location    = new System.Drawing.Point(322, 32),
                    Name        = "statusLabel" + (int)task.Id,
                    Size        = new System.Drawing.Size(100, 22),
                    BorderStyle = System.Windows.Forms.BorderStyle.None,
                    TabIndex    = 5 + (int)task.Id * 9 + 5,
                    Font        = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold)
                };
                if (task.Status == 'f')
                {
                    statusLabel[i].Text = "zadanie nieudane";
                }
                if (task.Status == 's')
                {
                    statusLabel[i].Text = "ukończone";
                }

                isImportantLabel[i] = new Label
                {
                    Location = new System.Drawing.Point(322, 4),
                    Name     = "isImportatnLabel" + (int)task.Id,
                    Size     = new System.Drawing.Size(100, 22),
                    TabIndex = 4 + (int)task.Id * 9 + 5,
                    Font     = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold)
                };
                if ((bool)task.IsImportant)
                {
                    isImportantLabel[i].Text = "ważne";
                }

                deadlineLabel[i] = new Label
                {
                    Location = new System.Drawing.Point(428, 3),
                    Name     = "deadlineLabel" + (int)task.Id,
                    Size     = new System.Drawing.Size(100, 22),
                    TabIndex = 3 + (int)task.Id * 9 + 5,
                    Font     = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold)
                };
                if (task.Deadline != null)
                {
                    deadlineLabel[i].Text = task.Deadline.ToString();
                }

                descriptionLabel[i] = new Label
                {
                    Location = new System.Drawing.Point(4, 60),
                    Name     = "decsriptionLabel" + (int)task.Id,
                    Size     = new System.Drawing.Size(524, 78),
                    TabIndex = 1 + (int)task.Id * 9 + 5,
                    Text     = task.Description,
                    Font     = new System.Drawing.Font("Microsoft JhengHei", 7.8F)
                };

                nameLabel[i] = new Label
                {
                    Location = new System.Drawing.Point(4, 3),
                    //Multiline = true,
                    Name = "nameLabel" + (int)task.Id,
                    // ReadOnly = true,
                    Size     = new System.Drawing.Size(312, 51),
                    TabIndex = 0 + (int)task.Id * 9 + 5,
                    Text     = task.Name,
                    Font     = new System.Drawing.Font("Microsoft JhengHei", 7.8F, System.Drawing.FontStyle.Bold)
                };

                categoryLabel[i] = new Label
                {
                    Location = new System.Drawing.Point(428, 32),
                    Name     = "categoryLabel" + (int)task.Id,
                    Size     = new System.Drawing.Size(100, 22),
                    TabIndex = 2 + (int)task.Id * 9 + 5
                };
                if (categories.Exists(x => (int)x.Id == (int)task.CategoryId))
                {
                    categoryLabel[i].Text = categories.Find(x => (int)x.Id == (int)task.CategoryId).Name;
                }

                taskPanel[i].Controls.Add(failButton[i]);
                taskPanel[i].Controls.Add(finishButton[i]);
                taskPanel[i].Controls.Add(editButton[i]);
                taskPanel[i].Controls.Add(statusLabel[i]);
                taskPanel[i].Controls.Add(isImportantLabel[i]);
                taskPanel[i].Controls.Add(deadlineLabel[i]);
                taskPanel[i].Controls.Add(descriptionLabel[i]);
                taskPanel[i].Controls.Add(nameLabel[i]);
                taskPanel[i].Controls.Add(categoryLabel[i]);


                panelmain.Controls.Add(taskPanel[i]);
                taskPanel[i].ResumeLayout(false);
                //taskPanel[i].PerformLayout();
                i++;
            }
        }