Ejemplo n.º 1
0
        /// <summary>
        /// This is used to print out common information in your current location (Board, List & Card)
        /// This is called in the get methods within this document
        /// </summary>
        /// <param name="boardName"></param>
        /// <param name="listName"></param>
        /// <param name="cardName"></param>
        public void commentDestination()
        {
            Console.WriteLine();
            if (Program.boardName != null)
            {
                Console.WriteLine("In location:");
            }

            if (Program.cardName != null)
            {
                Console.Write("[" + ++Program.cardNum + "] ");
                EyeCandy.color("green");
                Console.Write(Program.cardName);
                EyeCandy.reset();
                Console.WriteLine();
            }

            if (Program.listName != null)
            {
                Console.Write("[" + ++Program.listNum + "] ");
                EyeCandy.color("green");
                Console.Write(Program.listName);
                EyeCandy.reset();
                Console.WriteLine();
            }

            if (Program.boardName != null)
            {
                Console.Write("[" + ++Program.boardNum + "] ");
                EyeCandy.color("green"); //red
                Console.Write(Program.boardName);
                EyeCandy.reset();
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Print out comments.
        /// Called from the card() method i.e.
        /// </summary>
        /// <param name="comments">The list of comments to print out</param>
        public void comments(List <Comment> comments)
        {
            int br = 0;

            Console.WriteLine();

            if (comments.Count > 0)
            {
                Console.WriteLine("Comment(s):");
            }
            else
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --comment to add a new comment ]");
                EyeCandy.reset();
            }

            foreach (Comment comment in comments)
            {
                br++;
                string outCount    = "  [" + br + "] ";
                int    outCountLen = outCount.Length;
                Console.WriteLine(outCount + comment.created);
                Console.WriteLine(EyeCandy.indent(outCountLen) + comment.comment);
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        public void showSettings(int yPos, string defaultBoard, string autoLogin, string autoPush)
        {
            Console.WriteLine("Available settings:");

            string first  = "Default board set         : " + defaultBoard;
            string second = "Auto login                : "******"Auto push changes to cloud: " + autoPush;

            string[] settings = { first, second, third };

            int br = 0;

            foreach (string s in settings)
            {
                int indent = 2;
                if (yPos == br)
                {
                    indent = 0;
                    EyeCandy.cursor();
                }

                Console.WriteLine(EyeCandy.indent(indent) + s);
                br++;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// If a user wants to update an element,
        /// first run this, display info and ask to confirm.
        /// </summary>
        /// <param name="from">The name to change from</param>
        /// <param name="to">The name to change to</param>
        /// <returns>True/False if the user selected yes (or empty)</returns>
        public bool confirmUpdate(string from, string to)
        {
            Console.WriteLine("Change: " + from);
            Console.WriteLine("To: " + to + "?");

            return(EyeCandy.confirm());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Used to write the headline (name) of a card.
        /// (Inside a box kinda thing).
        /// The length of the box will match the length of the name.
        /// </summary>
        /// <param name="headline">The text to print inside the box</param>
        public void cardHeadline(string headline)
        {
            int hLen = headline.Length + 2;

            Console.Write(EyeCandy.indent(4) + "╔");
            for (int i = 0; i < hLen; i++)
            {
                Console.Write("═");
            }
            Console.Write("╗");

            Console.WriteLine();
            EyeCandy.color("yellow");
            Console.Write(EyeCandy.indent(6) + headline);
            EyeCandy.reset();

            Console.WriteLine();
            Console.Write(EyeCandy.indent(4) + "╚");
            for (int i = 0; i < hLen; i++)
            {
                Console.Write("═");
            }
            Console.Write("╝");
            Console.WriteLine();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// If the user pressed d at an element, this will run.
        /// </summary>
        /// <param name="element">The element at the cursor position</param>
        private void deleteElement(object element)
        {
            Console.WriteLine();

            if (element is Checklist)
            {
                Checklist c = (Checklist)element;
                Console.WriteLine("Are you sure you wanna delete checklist: " + c.name);
                if (!EyeCandy.confirm())
                {
                    return;
                }

                if (settings.autoPushToCloud())
                {
                    c.active = false;
                    pushToCloud(c, "board/updatechecklist/");
                }

                caController.deleteChecklist(c.id);
            }

            if (element is ChecklistPoint)
            {
                ChecklistPoint point = (ChecklistPoint)element;
                Console.WriteLine("Are you sure you wanna delete point: " + point.name);
                if (!EyeCandy.confirm())
                {
                    return;
                }

                if (settings.autoPushToCloud())
                {
                    point.active = false;
                    pushToCloud(point, "board/updatepoint/");
                }

                caController.deletePoint(point.id);
            }

            if (element is Comment)
            {
                Comment comment = (Comment)element;
                Console.WriteLine("Are you sure you wanna delete comment created on: " + comment.created);
                if (!EyeCandy.confirm())
                {
                    return;
                }

                if (settings.autoPushToCloud())
                {
                    comment.active = false;
                    pushToCloud(comment, "board/updatecomment/");
                }

                caController.deleteComment(comment.id);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// If an error has been encountered on the way,
 /// send it to this method - It will print it and exit the program.
 /// </summary>
 /// <param name="message">The error message to print out before exiting</param>
 public void error(string message)
 {
     Console.WriteLine();
     Console.Write("Error: ");
     EyeCandy.color();
     Console.Write(message);
     Console.WriteLine();
     EyeCandy.reset();
     Environment.Exit(0);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Print out all available lists in a board
        /// </summary>
        /// <param name="lists">The list of lists to print out</param>
        public void allLists(List <List> lists)
        {
            Console.WriteLine("Available lists:");

            if (lists.Count == 0)
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-list to add a new list ]");
                EyeCandy.reset();
            }

            int br = 0;

            foreach (List list in lists)
            {
                br++;
                Console.WriteLine("  [" + br + "] " + list.name);
            }

            Console.WriteLine();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Print out all available boards (overview)
        /// </summary>
        /// <param name="boards">The list of all boards (overview controller</param>
        public void allBoards(List <Board> boards)
        {
            int br = 0;

            Console.WriteLine("Available boards:");

            if (boards.Count == 0)
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-board to add a new board ]");
                EyeCandy.reset();
            }

            foreach (Board board in boards)
            {
                br++;
                Console.WriteLine("  [" + br + "] " + board.name);
            }

            Console.WriteLine();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Write out all the boards
        /// </summary>
        /// <param name="boards">A list of Board (the boards to print)</param>
        /// <param name="linePosition">yPos from controls(user location)</param>
        public void writeBoards(List <Board> boards, int linePosition)
        {
            int br = 0;

            Console.WriteLine("Available boards:");
            foreach (Board board in boards)
            {
                int indent = 0;
                if (br == linePosition)
                {
                    EyeCandy.cursor();
                }
                else
                {
                    indent = 2;
                }

                Console.Write(EyeCandy.indent(indent) + board.name);
                Console.WriteLine();
                br++;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Print out comments.
        /// Called from the card() method i.e.
        /// </summary>
        /// <param name="comments">The list of comments to print out</param>
        public void comments(List <Comment> comments, int startPos, int yPos)
        {
            int br = 0;

            Console.WriteLine();

            if (comments.Count > 0)
            {
                Console.WriteLine("Comment(s):");
            }
            else
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(2) + "[ No comments ]");
                EyeCandy.reset();
            }

            foreach (Comment comment in comments)
            {
                br++;


                int indent = 0;
                if (yPos - startPos == br)
                {
                    EyeCandy.cursor();
                }
                else
                {
                    indent = 2;
                }

                Console.WriteLine(EyeCandy.indent(indent) + comment.created);
                Console.WriteLine(EyeCandy.indent(2) + comment.comment);
                Console.WriteLine();
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Print out all available cards in a list
        /// </summary>
        /// <param name="cards"></param>
        public void allCards(List <Card> cards)
        {
            Console.WriteLine("Available cards:");

            if (cards.Count == 0)
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-card to add a new card ]");
                EyeCandy.reset();
            }

            int br = 0;

            foreach (Card card in cards)
            {
                br++;
                string cardCount    = "  [" + br + "] ";
                int    cardCountLen = cardCount.Length;

                Console.Write(cardCount);

                if (card.label != null)
                {
                    EyeCandy.color(card.label.label);
                }

                Console.WriteLine(card.name);
                EyeCandy.reset();

                if (card.description != null && !card.description.Equals(""))
                {
                    Console.WriteLine(EyeCandy.indent(cardCountLen) + card.description);
                }
            }

            Console.WriteLine();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// This will write out a line of the menu options
 /// </summary>
 /// <param name="toWrite">The line to write</param>
 private void writeMenu(string toWrite)
 {
     Console.WriteLine();
     Console.Write("[ " + toWrite);
     Console.Write(EyeCandy.indent(80 - toWrite.Length) + " ]");
 }
Ejemplo n.º 14
0
        /// <summary>
        /// On user input, this is run.
        /// It will determine the user input and the do associated action.
        /// It will set the value for x and y axis (which item the user resides on)
        /// and to do that properly, it has to know where the limit for the x and y axis is.
        /// The limit (xMaxPos and yMaxPos) is the count of items on the y and x axis.
        /// </summary>
        /// <param name="keyPush">The user input (push key)</param>
        /// <param name="xMaxPos">The max position on the x axis</param>
        /// <param name="yMaxPos">The max position on the y axis</param>
        /// <returns>
        /// -1 if navigation,
        /// 1 if select,
        /// 2 if edit,
        /// 3 if delete
        /// 4 if create 1 (i)
        /// 5 if create 2 (o)
        /// </returns>
        public int cursorAction(ConsoleKey keyPush, int xMaxPos, int yMaxPos)
        {
            #region up, down, left, right navigation.

            // move left
            if (keyPush == ConsoleKey.LeftArrow || keyPush == ConsoleKey.H)
            {
                if (xPos - 1 >= 0)
                {
                    xPos--;
                }
            }

            // move right
            if (keyPush == ConsoleKey.RightArrow || keyPush == ConsoleKey.L)
            {
                if (xPos + 1 < xMaxPos)
                {
                    xPos++;
                }
            }

            // move up
            if (keyPush == ConsoleKey.UpArrow || keyPush == ConsoleKey.K)
            {
                if (yPos - 1 >= 0)
                {
                    yPos--;
                }
            }

            // move down
            if (keyPush == ConsoleKey.DownArrow || keyPush == ConsoleKey.J)
            {
                if (yPos + 1 < yMaxPos)
                {
                    yPos++;
                }
            }

            #endregion

            if (keyPush == ConsoleKey.Enter || keyPush == ConsoleKey.Spacebar)
            {
                prevXPos = xPos;
                prevYPos = yPos;
                return(1);
            }

            // Quit
            if (keyPush == ConsoleKey.Q)
            {
                Console.WriteLine();
                Console.WriteLine("You will be missed. Are you sure you wanna quit? ");
                if (EyeCandy.confirm())
                {
                    Environment.Exit(0);
                }
            }

            // Navigate one step back
            if (keyPush == ConsoleKey.B)
            {
                goBack();
            }

            #region Additional navigations. An additional Christmas present.

            if (keyPush == ConsoleKey.R)
            {
                xPos = 0;
            }

            if (keyPush == ConsoleKey.T)
            {
                xPos = xMaxPos - 1;
            }

            if (keyPush == ConsoleKey.F)
            {
                yPos = 0;
            }

            if (keyPush == ConsoleKey.G)
            {
                yPos = yMaxPos - 1;
            }

            #endregion

            if (keyPush == ConsoleKey.U)
            {
                return(2);
            }

            if (keyPush == ConsoleKey.D)
            {
                return(3);
            }

            if (keyPush == ConsoleKey.I)
            {
                return(4);
            }

            if (keyPush == ConsoleKey.O)
            {
                return(5);
            }

            if (keyPush == ConsoleKey.S)
            {
                return(6);
            }

            /*if (xPos >= xMaxPos && xPos > 0)
             *  xPos--;
             * if (yPos >= yMaxPos)
             *  yPos--;*/

            return(-1);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// When deleting, this will display info, then confirm.
 /// </summary>
 /// <param name="name">The name of the item you're about to delete.</param>
 /// <returns>True/false if user selected yas or no</returns>
 public bool confirmDelete(string name)
 {
     Console.WriteLine("Delete: " + name + "?");
     return(EyeCandy.confirm());
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Write out lists in a board. This is a bit.. well.
        /// TODO: could maybe load all card for a board and display em, instead of the drop down boxes.
        /// </summary>
        /// <param name="lists">All the lists to print out</param>
        /// <param name="startPos">3 lists are shown, this is the first position to display</param>
        /// <param name="xPos">X position from controls</param>
        /// <param name="yPos">Y position from controls</param>
        /// <param name="cardsInList">All the cards associated to the list at x-position</param>
        public void writeList(List <List> lists, int xPos, int yPos, int startPos, List <Card> cardsInList = null)
        //public void writeLists(List<List> lists, int startPos, int xPos, int yPos, List<Card> cardsInList = null)
        {
            int listsCount = lists.Count;
            int toDisplay  = 3;

            if (listsCount < toDisplay)
            {
                toDisplay = listsCount;
            }

            /*Console.WriteLine("xpos: "+xPos);
             * Console.WriteLine("todisplay: "+toDisplay);
             * //Console.WriteLine("start: "+startPos);
             * Console.WriteLine("count: " + listsCount);*/

            // Top of boxes
            Console.WriteLine();
            for (int i = 0; i < toDisplay; i++)
            {
                EyeCandy.boxTop(30);
            }

            // Headlines / names
            Console.WriteLine();
            int listBr = 0;

            foreach (List list in lists)
            {
                string name       = EyeCandy.subString(list.name, 28);
                int    nameLength = name.Length; // kek, I set the length in the line above. Good job jeppesen.. Good job indeed.
                int    indent     = 0;
                if (startPos + listBr == xPos && yPos == 0)
                {
                    EyeCandy.cursor(2);
                }
                else
                {
                    indent = 4;
                }

                listBr++;
                Console.Write(EyeCandy.indent(indent) + name);
                Console.Write(EyeCandy.indent(30 - nameLength - 2));
            }

            /*for (int i = 0; i < toDisplay; i++)
             * {
             *  string name = EyeCandy.subString(lists[xPos].name, 28);
             *  int nameLength = name.Length; // kek, I set the length in the line above. Good job jeppesen.. Good job indeed.
             *  int indent = 0;
             *  if (xPos -startPos == i  && yPos == 0)
             *      cursor(2);
             *  else
             *      indent = 4;
             *
             *  Console.Write(EyeCandy.indent(indent) + name);
             *  Console.Write(EyeCandy.indent(30 - nameLength - 2));
             * }*/

            // Bottom of boxes
            Console.WriteLine();
            for (int i = 0; i < toDisplay; i++)
            {
                EyeCandy.boxBottom(30);
            }


            // Cards
            int column = xPos - startPos;

            if (cardsInList != null)
            {
                int indent = column * 32;
                int br     = 0;
                foreach (Card card in cardsInList)
                {
                    br++;

                    // Top of card box
                    Console.WriteLine();
                    Console.Write(EyeCandy.indent(indent + 2) + "|" + EyeCandy.indent(28) + "|");

                    string name       = EyeCandy.subString(card.name, 24);
                    int    nameLength = name.Length;

                    // Left side of box with name line
                    Console.WriteLine();
                    Console.Write(EyeCandy.indent(indent + 2) + "|");

                    // To write cursor or not to write cursor, that is the question
                    int ind = 0;
                    if (yPos == br)
                    {
                        EyeCandy.cursor();
                    }
                    else
                    {
                        ind = 2;
                    }

                    // Print the name of the card, and the end of the box with the name line (right side)
                    Console.Write(EyeCandy.indent(ind) + name);
                    Console.Write(EyeCandy.indent(30 - nameLength - 4) + "|");

                    // Bottom of the card box
                    Console.WriteLine();
                    Console.Write(EyeCandy.indent(indent + 2) + "|");
                    for (int i = 0; i < 14; i++)
                    {
                        Console.Write("_ ");
                    }
                    Console.Write("|");
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// This will keep the application running in a constant loop (until user exits of course).
        /// This is horrible put together (so far at least), and just barely working. Best of luck with this piece of garbage.
        /// </summary>
        public void loopApp()
        {
            // Run this sucker in forever, and ever, and ever, and ever...
            while (true)
            {
                Console.Clear();

                // Write top logo
                if (isCard)
                {
                    Ascii.clkCard();
                }
                else if (isBoard)
                {
                    Ascii.clkBoard();
                }
                else if (!isCard && !isBoard && !isSettings)
                {
                    Ascii.clkBoards();
                }
                else
                {
                    Ascii.clk();
                }


                // These will later be determined. How many steps a user can go right and down (X and Y positions)
                int xMaxPos = 0;
                int yMaxPos = 0;


                // Show settings, if invoked with S
                if (isSettings)
                {
                    boardNum = -1;
                    cardNum  = -1;
                    isBoard  = false;
                    isCard   = false;

                    // The default board value
                    string defaultBoard = "not set";
                    if (!settings.defaultBoard().Equals("") &&
                        ovController.getBoards().Any(x => x.id == settings.defaultBoard()))
                    {
                        defaultBoard = ovController.getBoards().Find(x => x.id == settings.defaultBoard()).name;
                    }

                    // Auto login value (email if set)
                    string autoLogin = "******";
                    if (settings.autoLoginPossible())
                    {
                        autoLogin = settings.getCredencials();
                    }

                    // Auto push to cloud value
                    string autoPush = "False";
                    if (settings.autoPushToCloud())
                    {
                        autoPush = "True";
                    }

                    yMaxPos = 3; // TODO: should change this. There is 3 settings currently.
                    write.showSettings(controls.yPos, defaultBoard, autoLogin, autoPush);
                }


                // If the BOARD is not set, display ALL BOARDS
                if (!isBoard && !isSettings)
                {
                    write.writeBoards(ovController.getBoards(), controls.yPos);
                    yMaxPos = ovController.getBoards().Count;
                }


                // If BOARD is set, display LISTS
                if (isBoard && !isCard)
                {
                    listNum = controls.xPos;
                    iniLiController(boardId);
                    xMaxPos = liController.getLists().Count;

                    iniCaController(listId);
                    yMaxPos = caController.getCards().Count + 1; // +1 for the list line

                    // Write out the board name that we are working in
                    Console.WriteLine();
                    EyeCandy.color("yellow");
                    Console.WriteLine("  -> " + boardName);
                    EyeCandy.reset();

                    // If you change list, make sure yPos is within limits
                    if (controls.yPos >= yMaxPos)
                    {
                        controls.yPos = yMaxPos - 1;
                    }

                    // Display 3 lists at the time.
                    // And set the correct index for the first shown list.
                    int startPos = 0;
                    if (controls.xPos - 3 >= 0)
                    {
                        startPos = controls.xPos - 2;
                    }

                    // Write out the lists, and the cards associated to the current selected list
                    List <Card> cardsToRead = caController.getCards();

                    if (!cardsToRead.Any())
                    {
                        controls.yPos = 0;
                    }

                    int range = 3;
                    if (liController.getLists().Count < 3)
                    {
                        range = liController.getLists().Count;
                    }

                    write.writeList(liController.getLists().GetRange(startPos, range), controls.xPos, controls.yPos, startPos, cardsToRead);
                    //write.writeLists(liController.getLists(), startPos, controls.xPos, controls.yPos, cardsToRead);
                }


                // If CARD is set, display its content
                if (isCard && isList)
                {
                    Card card = caController.cards.Find(x => x.id == cardId);

                    int chkCount     = caController.getChecklists(cardId).Count;
                    int pointCount   = caController.getChecklistPointsInCard(cardId).Count;
                    int commentCount = caController.getComments(cardId).Count;

                    yMaxPos = 2 + chkCount + pointCount + commentCount; // +2 for headline and description

                    write.writeCard(card, caController, controls.yPos, yMaxPos);
                }


                // Display menu
                if (!isSettings)
                {
                    write.writeMenu(isBoard, isCard);
                }

                // Ask for user input
                Console.WriteLine();
                Console.WriteLine();
                ConsoleKey answer = Console.ReadKey().Key;

                // If the user just navigated (x and y pos in controls)
                // Continue to reload the user interface.
                int response = controls.cursorAction(answer, xMaxPos, yMaxPos);
                if (response == -1)
                {
                    continue;
                }

                // Show settings
                if (response == 6)
                {
                    isSettings = true;
                    continue;
                }

                // Handle changes in Settings panel
                if (isSettings)
                {
                    if (response == 1 && controls.yPos == 0)
                    {
                        setDefaultBoard();
                    }
                    if (response == 1 && controls.yPos == 1)
                    {
                        setAutoLogin();
                    }
                    if (response == 1 && controls.yPos == 2)
                    {
                        changeAutoPushToDb();
                    }
                }

                // If we selected enter without the board is set,
                // Select a board
                if (!isBoard && !isSettings)
                {
                    // Create a new board
                    if (response == 4)
                    {
                        string newBoard = write.createValue("Board");
                        if (newBoard.Equals(""))
                        {
                            continue;
                        }

                        ovController.createBoard(newBoard);
                        boardNum = ovController.getBoards().Count - 1;
                        iniOvController();

                        if (settings.autoPushToCloud())
                        {
                            boardNum = ovController.getBoards().Count - 1;
                            saveBoard();
                        }

                        continue;
                    }

                    // Update board name
                    if (response == 2)
                    {
                        Board  b       = ovController.getBoards()[controls.yPos];
                        string newName = write.updateValue(b.name);
                        if (newName.Equals(""))
                        {
                            continue;
                        }

                        ovController.updateBoard(newName, b.id);

                        if (settings.autoPushToCloud())
                        {
                            boardNum = ovController.getBoards().IndexOf(b);
                            saveBoard();
                        }

                        continue;
                    }

                    // Delete a board
                    if (response == 3)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Are you sure you wanna delete this board: " + ovController.getBoards()[controls.yPos].name);
                        if (!EyeCandy.confirm())
                        {
                            continue;
                        }


                        // TODO: A auto push to cloud is needed - The REST just need the method to delete a board first..

                        ovController.deleteBoard(ovController.getBoards()[controls.yPos].id);
                        if (controls.yPos != 0)
                        {
                            controls.yPos--;
                        }

                        continue;
                    }

                    if (response == 1)
                    {
                        boardNum = controls.yPos;
                        iniOvController();
                        continue;
                    }
                }

                // If the user select a card, initialize the card controller
                if (isBoard && !isCard)
                {
                    // Update list name
                    if (response == 2 && controls.yPos == 0)
                    {
                        string newName = write.updateValue(listName);
                        if (newName.Equals(""))
                        {
                            continue;
                        }

                        liController.updateList(newName, listId);

                        if (settings.autoPushToCloud())
                        {
                            List l = liController.getLists().Find(x => x.id == listId);
                            pushToCloud(l, "board/updatelist/");
                        }

                        continue;
                    }

                    // If the user deletes a list
                    if (response == 3 && controls.yPos == 0)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Are you sure you wanna delete this list: " + listName);
                        if (!EyeCandy.confirm())
                        {
                            continue;
                        }

                        if (settings.autoPushToCloud())
                        {
                            List l = liController.getLists().Find(x => x.id == listId);
                            l.active = false;
                            pushToCloud(l, "board/updatelist/");
                        }

                        liController.deleteList(listId);
                        if (controls.xPos != 0)
                        {
                            controls.xPos--;
                        }

                        listId   = null;
                        listName = null;
                        listNum  = -1;

                        continue;
                    }

                    // If the user deletes a card.
                    if (response == 3 && controls.yPos != 0)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Are you sure you wanna delete this card: " + caController.getCards()[controls.yPos - 1].name);
                        if (!EyeCandy.confirm())
                        {
                            continue;
                        }

                        Card c = caController.getCards()[controls.yPos - 1];

                        if (settings.autoPushToCloud())
                        {
                            pushToCloud(c, "board/updatecard/");
                        }

                        caController.deleteCard(c.id);
                        continue;
                    }

                    // If the user creates a new list
                    if (response == 4)
                    {
                        string list = write.createValue("List");
                        if (list.Equals(""))
                        {
                            continue;
                        }

                        liController.createList(list);
                        controls.xPos = liController.getLists().Count - 1;

                        if (settings.autoPushToCloud())
                        {
                            List l = liController.getLists().Last();
                            pushToCloud(l, "board/createlist/");
                        }

                        continue;
                    }

                    // Create a new card
                    if (response == 5)
                    {
                        if (!isList)
                        {
                            continue;
                        }

                        string card = write.createValue("Card");
                        if (card.Equals(""))
                        {
                            continue;
                        }

                        caController.createCard(card);
                        controls.yPos = caController.getCards().Count;

                        if (settings.autoPushToCloud())
                        {
                            Card c = caController.getCards().Last();
                            pushToCloud(c, "board/createcard/");
                        }

                        continue;
                    }

                    // Select a card
                    if (response == 1 && controls.yPos != 0)
                    {
                        cardNum = controls.yPos - 1; // -1 to correct index (top (0) is list headline)
                        iniCaController(listId);
                        controls.yPos = 1;           // Start at description
                    }
                }


                // Okay then boi, do some magic. When card is selected.
                // We should get various returns from Controls. Act accordingly here.
                if (isCard)
                {
                    object selectedElement = ObjectValues.getObjectInYPos(caController, cardId, controls.yPos);

                    // Click a checklist point
                    if (response == 1)
                    {
                        if (selectedElement is ChecklistPoint)
                        {
                            ChecklistPoint p = (ChecklistPoint)selectedElement;
                            caController.clickPoint(p.id);
                        }
                    }

                    // Update a description on a card
                    if (response == 2 && controls.yPos == 1)
                    {
                        caController.createDescription(write.createValue("Description"), cardId);

                        if (settings.autoPushToCloud())
                        {
                            Card c = caController.getCards().Find(x => x.id == cardId);
                            pushToCloud(c, "board/updatecard/");
                        }
                    }

                    // Update the name of a card
                    if (response == 2 && controls.yPos == 0)
                    {
                        string newName = write.updateValue(cardName);
                        if (newName.Equals(""))
                        {
                            continue;
                        }

                        caController.updateCard(newName, cardId);

                        if (settings.autoPushToCloud())
                        {
                            Card c = caController.getCards().Find(x => x.id == cardId);
                            pushToCloud(c, "board/updatecard/");
                        }
                    }

                    // If user is updating an element
                    if (response == 2)
                    {
                        updateElement(selectedElement);
                    }

                    // If user is deleting an element
                    if (response == 3)
                    {
                        deleteElement(selectedElement);
                    }

                    // If the user is creating a new checklist
                    if (response == 4)
                    {
                        string ck = write.createValue("Checklist");
                        if (ck.Equals(""))
                        {
                            continue;
                        }

                        caController.createChecklist(ck, cardId);

                        if (settings.autoPushToCloud())
                        {
                            Checklist c = caController.getChecklists(cardId).Last();
                            pushToCloud(c, "board/createchecklist/");
                        }
                    }

                    // If the user is creating a new checklist point
                    if (response == 5)
                    {
                        string p = write.createValue("Point");
                        if (p.Equals(""))
                        {
                            continue;
                        }

                        caController.createChecklistPoint(p, checkId);

                        if (settings.autoPushToCloud())
                        {
                            ChecklistPoint cp = caController.getChecklistPoints().Last();
                            pushToCloud(cp, "board/createpoint/");
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Print out a card and its content
        /// </summary>
        /// <param name="card">The card to print out</param>
        public void writeCard(Card card, CardController controller, int yPos, int yMaxPos)
        {
            string cardName   = card.name;
            int    nameLength = cardName.Length;

            Console.WriteLine();
            EyeCandy.boxTop(nameLength + 4);
            Console.WriteLine(EyeCandy.indent(2));

            int indent = 2;

            if (yPos == 0)
            {
                EyeCandy.cursor();
            }
            else
            {
                indent = 4;
            }

            Console.Write(EyeCandy.indent(indent) + cardName);
            Console.WriteLine();
            EyeCandy.boxBottom(nameLength + 4);
            Console.WriteLine();

            indent = 0;
            if (yPos == 1)
            {
                EyeCandy.cursor();
            }
            else
            {
                indent = 2;
            }

            if (!card.description.Equals(""))
            {
                Console.WriteLine(EyeCandy.indent(indent) + card.description);
            }
            else
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(indent) + "[ No description ]");
                EyeCandy.reset();
            }

            Console.WriteLine();
            Console.WriteLine();

            if (controller.getChecklists(card.id).Count == 0)
            {
                indent = 0;
                if (yPos == 2)
                {
                    EyeCandy.cursor();
                }
                else
                {
                    indent = 2;
                }

                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(indent) + "[ No checklists ]");
                EyeCandy.reset();
            }

            // Checklist section
            int br    = 0;
            int brChk = 1;

            foreach (Checklist checklist in controller.getChecklists(card.id))
            {
                brChk++;


                indent = 0;
                if (yPos == brChk + br)
                {
                    EyeCandy.cursor();
                }
                else
                {
                    indent = 2;
                }

                Console.WriteLine(EyeCandy.indent(indent) + checklist.name);

                if (!controller.getChecklistPoints(checklist.id).Any())
                {
                    EyeCandy.color("yellow");
                    Console.WriteLine(EyeCandy.indent(4) + "[ No checklist points ]");
                    EyeCandy.reset();
                }

                // Checklist points
                foreach (ChecklistPoint point in controller.getChecklistPoints(checklist.id))
                {
                    br++;

                    indent = 0;
                    if (yPos == brChk + br)
                    {
                        EyeCandy.cursor(2);
                    }
                    else
                    {
                        indent = 4;
                    }

                    // Colors, colors everywhere!
                    if (point.isCheck)
                    {
                        EyeCandy.color("green");
                    }

                    Console.WriteLine(EyeCandy.indent(indent) + point.name);
                    EyeCandy.reset();
                }

                Console.WriteLine();
            }

            int ySoFar = brChk + br;

            Console.WriteLine();
            comments(controller.getComments(card.id), ySoFar, yPos);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Print out a card and its content
        /// </summary>
        /// <param name="card">The card to print out</param>
        public void card(Card card, CardController controller)
        {
            cardHeadline(card.name);
            Console.WriteLine();

            if (!card.description.Equals(""))
            {
                Console.WriteLine(EyeCandy.indent(6) + card.description);
            }
            else
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --description to add a description ]");
                EyeCandy.reset();
            }

            Console.WriteLine();
            Console.WriteLine();

            if (controller.getChecklists(card.id).Count == 0)
            {
                EyeCandy.color("yellow");
                Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-check to add a new checklist ]");
                EyeCandy.reset();
            }

            // Checklist section
            int br    = 0;
            int brChk = 0;

            foreach (Checklist checklist in controller.getChecklists(card.id))
            {
                brChk++;
                Console.WriteLine("[" + brChk + "] " + checklist.name);

                if (!controller.getChecklistPoints(checklist.id).Any())
                {
                    EyeCandy.color("yellow");
                    Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-point to add a new checklist point ]");
                    EyeCandy.reset();
                }

                // Checklist points
                foreach (ChecklistPoint point in controller.getChecklistPoints(checklist.id))
                {
                    br++;
                    string outCountP = "[" + br + "] ";

                    // Colors, colors everywhere!
                    if (point.isCheck)
                    {
                        EyeCandy.color("green");
                    }

                    Console.WriteLine(EyeCandy.indent(2) + outCountP + point.name);
                    EyeCandy.reset();
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            comments(controller.getComments(card.id));
        }