예제 #1
0
        public void ObjectDeselected(object obj)
        {
            try
            {
                ObjectValues objval = obj as ObjectValues;

                foreach (TabItem currentTab in TabValues)
                {
                    if (currentTab.Tag.ToString() == objval.UniqueId)
                    {
                        TabValues.Remove(currentTab);
                        break;
                    }
                }

                if (TabValues.Count == 0)
                {
                    GridWidth = new GridLength(0);
                    TitleSpan = 1;
                }
            }
            catch (Exception GeneralException)
            {
            }
        }
        public List <ElementValuesCollection> SplitForCorrectGrpcMessageSize()
        {
            if (DoubleValues.Count < MaxArrayLength && UintValues.Count < MaxArrayLength && ObjectValues.Length < MaxByteStringLength)
            {
                return(new List <ElementValuesCollection> {
                    this
                });
            }

            var result = new List <ElementValuesCollection>();

            int doubleIndex     = 0;
            int uintIndex       = 0;
            int objectIndex     = 0;
            int objectByteIndex = 0;
            ElementValuesCollection?prevElementValuesCollection = null;

            while (doubleIndex < DoubleAliases.Count ||
                   uintIndex < UintAliases.Count ||
                   objectIndex < ObjectAliases.Count ||
                   objectByteIndex < ObjectValues.Length)
            {
                var elementValuesCollection = new ElementValuesCollection();
                if (prevElementValuesCollection is not null)
                {
                    string guid = System.Guid.NewGuid().ToString();
                    prevElementValuesCollection.NextCollectionGuid = guid;
                    elementValuesCollection.Guid = guid;
                }

                elementValuesCollection.DoubleAliases.AddRange(DoubleAliases.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleValueStatusCodes.AddRange(DoubleValueStatusCodes.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleTimestamps.AddRange(DoubleTimestamps.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleValues.AddRange(DoubleValues.Skip(doubleIndex).Take(MaxArrayLength));

                elementValuesCollection.UintAliases.AddRange(UintAliases.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintValueStatusCodes.AddRange(UintValueStatusCodes.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintTimestamps.AddRange(UintTimestamps.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintValues.AddRange(UintValues.Skip(uintIndex).Take(MaxArrayLength));

                elementValuesCollection.ObjectAliases.AddRange(ObjectAliases.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectValueStatusCodes.AddRange(ObjectValueStatusCodes.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectTimestamps.AddRange(ObjectTimestamps.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectValues = Google.Protobuf.ByteString.CopyFrom(
                    ObjectValues.Skip(objectByteIndex).Take(MaxByteStringLength).ToArray());

                result.Add(elementValuesCollection);
                doubleIndex                += MaxArrayLength;
                uintIndex                  += MaxArrayLength;
                objectIndex                += MaxArrayLength;
                objectByteIndex            += MaxByteStringLength;
                prevElementValuesCollection = elementValuesCollection;
            }

            return(result);
        }
예제 #3
0
        private IObjectValues ConvertObject(AttributeValuesMap values)
        {
            var dov = new ObjectValues(_returnArraySize);

            for (var i = 0; i < _returnArraySize; i++)
            {
                var queryFieldAction = _queryFieldActions[i];
                ((AbstractQueryFieldAction)queryFieldAction).Execute(values.GetObjectInfoHeader().GetOid(), values);

                SetValue(i, dov, queryFieldAction);
            }
            return(dov);
        }
예제 #4
0
        private void SetValue(int i, ObjectValues dov, IQueryFieldAction queryFieldAction)
        {
            var value = queryFieldAction.GetValue();

            // When Values queries return objects, they actually return the oid of the object
            // So we must load it here
            if (value is OID)
            {
                var oid = (ObjectOID)value;
                value = _engine.GetObjectFromOid(oid);
            }

            dov.Set(i, queryFieldAction.GetAlias(), value);
        }
예제 #5
0
        public Value GetNewOrExistingValue(string memberName, ValueContainer scopes)
        {
            if (ObjectValues == null)
            {
                return(null);
            }

            if (!ObjectValues.ContainsKey(memberName))
            {
                this[memberName] = scopes?.NewValue() ?? new Value();
            }

            return(this[memberName]);
        }
        private ObjectValues Build(IParsingContext context, Object current, ClassInfo type, Object[] values, IDictionary<Int32, ObjectValues> cache)
        {
            // Check (and return) cached values early so we don't enter an infinite
            // loop while resolving references to ourself.
            var hasObjectId = current as ISerializedObject;
            if (hasObjectId != null && cache.ContainsKey(hasObjectId.ObjectId)) {
                return cache[hasObjectId.ObjectId];
            }

            String libraryName = null;
            var hasLibraryId = current as IHasLibraryId;
            if (hasLibraryId != null) {
                var library = context.GetLibrary(hasLibraryId.LibraryId);
                libraryName = library.LibraryName;
            }

            var target = new ObjectValues(libraryName, type.Name);
            if (hasObjectId != null) {
                // Store the item in the cache early to avoid infinite loops if
                // we have a reference to ourself.
                cache[hasObjectId.ObjectId] = target;
            }

            for(var i = 0; i < values.Length; ++i){
                var memberName = type.Members[i];
                var value = values[i];

                while(value is IValueHolder) {
                    value = ((IValueHolder)value).GetValue(context);
                }

                var nestedTypeHolder = value as ITypeHolder;
                if (nestedTypeHolder != null) {
                    var nestedType = nestedTypeHolder.GetClassInfo(context);
                    var nestedValues = ((ClassRecordBase)value).Values;

                    Object result;
                    if (TryBuildSystemType(context, nestedType, nestedValues, out result))
                        target[memberName] = result;
                    else
                        target[memberName] = Build(context, value, nestedType, nestedValues, cache);
                } else {
                    target[memberName] = value;
                }
            }

            return target;
        }
예제 #7
0
        public void ObjectSelected(object obj)
        {
            try
            {
                if (GridWidth == new GridLength(0))
                {
                    GridWidth = new GridLength(500);
                    TitleSpan = 2;
                }

                ObjectValues objval = obj as ObjectValues;

                if (TabValues.Count < MaxTags)
                {
                    TabItem temptab = new TabItem();
                    temptab.Header             = objval.ObjectName;
                    temptab.Tag                = objval.UniqueId;
                    temptab.MouseLeftButtonUp += new MouseButtonEventHandler(temptab_MouseLeftButtonUp);
                    temptab.Unloaded          += new RoutedEventHandler(temptab_Unloaded);
                    TabValues.Add(temptab);

                    if (isFirstSelected)
                    {
                        temptab_MouseLeftButtonUp(temptab, null);
                        isFirstSelected = false;
                    }
                }
                else
                {
                    Views.MessageBox msgbox;
                    ViewModels.MessageBoxViewModel mboxvmodel;
                    msgbox             = new Views.MessageBox();
                    mboxvmodel         = new MessageBoxViewModel("Information", "Maximum number of tabs Exceeded. Please Deselect some objects to add more.", msgbox, "MainWindow", Settings.GetInstance().Theme);
                    msgbox.DataContext = mboxvmodel;
                    msgbox.ShowDialog();
                    objval.isGridChecked = false;
                }
            }
            catch (Exception GeneralException)
            {
            }
        }
예제 #8
0
 public Value this[string index]
 {
     get
     {
         if (Values.ContainsKey(index))
         {
             return(Values[index]);
         }
         return(null);
     }
     set
     {
         if (this[index] != null)
         {
             ObjectValues[index] = value;
         }
         else
         {
             ObjectValues.Add(index, value);
         }
     }
 }
        public void CombineWith(ElementValuesCollection nextElementValuesCollection)
        {
            Guid = nextElementValuesCollection.Guid;
            NextCollectionGuid = nextElementValuesCollection.NextCollectionGuid;

            DoubleAliases.Add(nextElementValuesCollection.DoubleAliases);
            DoubleValueStatusCodes.Add(nextElementValuesCollection.DoubleValueStatusCodes);
            DoubleTimestamps.Add(nextElementValuesCollection.DoubleTimestamps);
            DoubleValues.Add(nextElementValuesCollection.DoubleValues);

            UintAliases.Add(nextElementValuesCollection.UintAliases);
            UintValueStatusCodes.Add(nextElementValuesCollection.UintValueStatusCodes);
            UintTimestamps.Add(nextElementValuesCollection.UintTimestamps);
            UintValues.Add(nextElementValuesCollection.UintValues);

            ObjectAliases.Add(nextElementValuesCollection.ObjectAliases);
            ObjectValueStatusCodes.Add(nextElementValuesCollection.ObjectValueStatusCodes);
            ObjectTimestamps.Add(nextElementValuesCollection.ObjectTimestamps);
            ObjectValues = Google.Protobuf.ByteString.CopyFrom(
                ObjectValues.Concat(nextElementValuesCollection.ObjectValues).ToArray()
                );
        }
예제 #10
0
        public void End()
        {
            ObjectValues dov = null;

            if (!_query.IsMultiRow())
            {
                dov = new ObjectValues(_returnArraySize);
            }

            for (var i = 0; i < _returnArraySize; i++)
            {
                var queryFieldAction = _queryFieldActions[i];
                queryFieldAction.End();

                if (!_query.IsMultiRow())
                {
                    SetValue(i, dov, queryFieldAction);
                }
            }
            if (!_query.IsMultiRow())
            {
                _result.Add(dov);
            }
        }
예제 #11
0
        /// <summary>
        /// Encapsulates the elements of a matrix.
        /// </summary>
        /// <param name="Elements">Matrix elements.</param>
        /// <param name="Rows">Rows</param>
        /// <param name="Columns">Columns</param>
        /// <param name="Node">Script node from where the encapsulation is done.</param>
        /// <returns>Encapsulated matrix.</returns>
        public static IMatrix Encapsulate(ICollection <IElement> Elements, int Rows, int Columns, ScriptNode Node)
        {
            IElement SuperSetExample = null;
            IElement Element2;
            ISet     CommonSuperSet = null;
            ISet     Set;
            bool     Upgraded = false;

            foreach (IElement Element in Elements)
            {
                if (CommonSuperSet == null)
                {
                    SuperSetExample = Element;

                    if (Element == null)
                    {
                        CommonSuperSet = new ObjectValues();
                    }
                    else
                    {
                        CommonSuperSet = Element.AssociatedSet;
                    }
                }
                else
                {
                    if (Element == null)
                    {
                        Set = new ObjectValues();
                    }
                    else
                    {
                        Set = Element.AssociatedSet;
                    }

                    if (!Set.Equals(CommonSuperSet))
                    {
                        Element2 = Element;
                        if (!Expression.Upgrade(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node))
                        {
                            CommonSuperSet = null;
                            break;
                        }
                        else
                        {
                            Upgraded = true;
                        }
                    }
                }
            }

            if (CommonSuperSet != null)
            {
                if (Upgraded)
                {
                    LinkedList <IElement> SuperElements = new LinkedList <IElement>();

                    foreach (IElement Element in Elements)
                    {
                        if (Element == null)
                        {
                            Set = new ObjectValues();
                        }
                        else
                        {
                            Set = Element.AssociatedSet;
                        }

                        if (Set.Equals(CommonSuperSet))
                        {
                            SuperElements.AddLast(Element);
                        }
                        else
                        {
                            Element2 = Element;
                            if (Expression.Upgrade(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node) && Element2 is IVectorSpaceElement)
                            {
                                SuperElements.AddLast(Element2);
                            }
                            else
                            {
                                SuperElements  = null;
                                CommonSuperSet = null;
                                break;
                            }
                        }
                    }

                    if (SuperElements != null)
                    {
                        Elements = SuperElements;
                    }
                }

                if (CommonSuperSet != null)
                {
                    if (CommonSuperSet is DoubleNumbers)
                    {
                        return(new DoubleMatrix(Rows, Columns, Elements));
                    }
                    else if (CommonSuperSet is ComplexNumbers)
                    {
                        return(new ComplexMatrix(Rows, Columns, Elements));
                    }
                    else if (CommonSuperSet is BooleanValues)
                    {
                        return(new BooleanMatrix(Rows, Columns, Elements));
                    }
                }
            }

            return(new ObjectMatrix(Rows, Columns, Elements));
        }
예제 #12
0
        /// <summary>
        /// Encapsulates the elements of a matrix.
        /// </summary>
        /// <param name="Elements">Matrix elements.</param>
        /// <param name="Rows">Rows</param>
        /// <param name="Columns">Columns</param>
        /// <param name="Node">Script node from where the encapsulation is done.</param>
        /// <returns>Encapsulated matrix.</returns>
        public static IMatrix Encapsulate(ICollection <IElement> Elements, int Rows, int Columns, ScriptNode Node)
        {
            IElement SuperSetExample = null;
            IElement Element2;
            ISet     CommonSuperSet = null;
            ISet     Set;
            bool     Upgraded = false;

            if (Elements.Count == Rows && Columns > 1)
            {
                List <IElement> Temp = new List <IElement>();

                foreach (IElement E in Elements)
                {
                    if (E is IVector V)
                    {
                        Temp.AddRange(V.VectorElements);
                    }
                    else
                    {
                        throw new ScriptRuntimeException("Invalid number of elements.", Node);
                    }
                }

                Elements = Temp;
            }

            foreach (IElement Element in Elements)
            {
                if (CommonSuperSet is null)
                {
                    SuperSetExample = Element;

                    if (Element is null)
                    {
                        CommonSuperSet = new ObjectValues();
                    }
                    else
                    {
                        CommonSuperSet = Element.AssociatedSet;
                    }
                }
                else
                {
                    if (Element is null)
                    {
                        Set = new ObjectValues();
                    }
                    else
                    {
                        Set = Element.AssociatedSet;
                    }

                    if (!Set.Equals(CommonSuperSet))
                    {
                        Element2 = Element;
                        if (!Expression.UpgradeField(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node))
                        {
                            CommonSuperSet = null;
                            break;
                        }
                        else
                        {
                            Upgraded = true;
                        }
                    }
                }
            }

            if (!(CommonSuperSet is null))
            {
                if (Upgraded)
                {
                    LinkedList <IElement> SuperElements = new LinkedList <IElement>();

                    foreach (IElement Element in Elements)
                    {
                        if (Element is null)
                        {
                            Set = new ObjectValues();
                        }
                        else
                        {
                            Set = Element.AssociatedSet;
                        }

                        if (Set.Equals(CommonSuperSet))
                        {
                            SuperElements.AddLast(Element);
                        }
                        else
                        {
                            Element2 = Element;
                            if (Expression.UpgradeField(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node) && Element2 is IVectorSpaceElement)
                            {
                                SuperElements.AddLast(Element2);
                            }
                            else
                            {
                                SuperElements  = null;
                                CommonSuperSet = null;
                                break;
                            }
                        }
                    }

                    if (!(SuperElements is null))
                    {
                        Elements = SuperElements;
                    }
                }

                if (!(CommonSuperSet is null))
                {
                    if (CommonSuperSet is DoubleNumbers)
                    {
                        return(new DoubleMatrix(Rows, Columns, Elements));
                    }
                    else if (CommonSuperSet is ComplexNumbers)
                    {
                        return(new ComplexMatrix(Rows, Columns, Elements));
                    }
                    else if (CommonSuperSet is BooleanValues)
                    {
                        return(new BooleanMatrix(Rows, Columns, Elements));
                    }
                }
            }

            return(new ObjectMatrix(Rows, Columns, Elements));
        }
예제 #13
0
        /// <summary>
        /// Encapsulates the elements of a vector.
        /// </summary>
        /// <param name="Elements">Vector elements.</param>
        /// <param name="CanEncapsulateAsMatrix">If the method can encapsulate the contents as a matrix.</param>
        /// <param name="Node">Script node from where the encapsulation is done.</param>
        /// <returns>Encapsulated vector.</returns>
        public static IElement Encapsulate(ICollection <IElement> Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
        {
            IElement            SuperSetExample = null;
            IElement            Element2;
            ISet                CommonSuperSet = null;
            IVectorSpaceElement Vector;
            ISet                Set;
            int? Columns        = null;
            bool Upgraded       = false;
            bool SameDimensions = true;

            foreach (IElement Element in Elements)
            {
                if (CanEncapsulateAsMatrix && SameDimensions)
                {
                    Vector = Element as IVectorSpaceElement;
                    if (Vector is null)
                    {
                        SameDimensions = false;
                    }
                    else
                    {
                        if (!Columns.HasValue)
                        {
                            Columns = Vector.Dimension;
                        }
                        else if (Columns.Value != Vector.Dimension)
                        {
                            SameDimensions = false;
                        }
                    }
                }

                if (CommonSuperSet is null)
                {
                    SuperSetExample = Element;

                    if (Element is null)
                    {
                        CommonSuperSet = new ObjectValues();
                    }
                    else
                    {
                        CommonSuperSet = Element.AssociatedSet;
                    }
                }
                else
                {
                    if (Element is null)
                    {
                        Set = new ObjectValues();
                    }
                    else
                    {
                        Set = Element.AssociatedSet;
                    }

                    if (!Set.Equals(CommonSuperSet))
                    {
                        Element2 = Element;
                        if (!Expression.UpgradeField(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node))
                        {
                            CommonSuperSet = null;
                            break;
                        }
                        else
                        {
                            Upgraded = true;
                        }
                    }
                }
            }

            if (CanEncapsulateAsMatrix && SameDimensions && Columns.HasValue)
            {
                return(Operators.Matrices.MatrixDefinition.Encapsulate(Elements, Node));
            }

            if (!(CommonSuperSet is null))
            {
                if (Upgraded)
                {
                    LinkedList <IElement> SuperElements = new LinkedList <IElement>();

                    foreach (IElement Element in Elements)
                    {
                        if (Element is null)
                        {
                            Set = new ObjectValues();
                        }
                        else
                        {
                            Set = Element.AssociatedSet;
                        }

                        if (Set.Equals(CommonSuperSet))
                        {
                            SuperElements.AddLast(Element);
                        }
                        else
                        {
                            Element2 = Element;
                            if (Expression.UpgradeField(ref Element2, ref Set, ref SuperSetExample, ref CommonSuperSet, Node))
                            {
                                SuperElements.AddLast(Element2);
                            }
                            else
                            {
                                SuperElements  = null;
                                CommonSuperSet = null;
                                break;
                            }
                        }
                    }

                    if (!(SuperElements is null))
                    {
                        Elements = SuperElements;
                    }
                }

                if (!(CommonSuperSet is null))
                {
                    if (CommonSuperSet is DoubleNumbers)
                    {
                        return(new DoubleVector(Elements));
                    }
                    else if (CommonSuperSet is ComplexNumbers)
                    {
                        return(new ComplexVector(Elements));
                    }
                    else if (CommonSuperSet is BooleanValues)
                    {
                        return(new BooleanVector(Elements));
                    }
                    else if (CommonSuperSet is DateTimeValues)
                    {
                        return(new DateTimeVector(Elements));
                    }
                }
            }

            return(new ObjectVector(Elements));
        }
예제 #14
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/");
                        }
                    }
                }
            }
        }
예제 #15
0
 public string ToStringLight()
 {
     return((ObjectValues?.Any() ?? false) ? $"[{string.Join(",", ObjectValues.Keys)}]" : "[]");
 }
예제 #16
0
 public void Delete(string key)
 {
     ObjectValues.Remove(key);
 }