Beispiel #1
0
        public static void LoadAddicionalProperties(UcmlObject objUCML, Canvas myCanvas, String template)
        {
            // Goes through canvas's list of children looking for a object as the same type and
            // set all new properties it's has to the new object
            var obj = getObjectByType(myCanvas, objUCML.TemplateName);

            if (obj.listNewProp.Count > 0)
            {
                foreach (var p in obj.listNewProp)
                {
                    var prop1 = new AdditionalProperty {
                        name = p.name, value = ""
                    };
                    objUCML.listNewProp.Add(prop1);
                }
            }
            else if (!template.Equals(""))
            {
                var list = getListPropertiestFromTemplate(char.ToLower(objUCML.TemplateName[0]) + objUCML.TemplateName.Substring(1), template);
                foreach (var p in list)
                {
                    var prop1 = new AdditionalProperty {
                        name = p.name, value = ""
                    };
                    objUCML.listNewProp.Add(prop1);
                }
            }
        }
Beispiel #2
0
        public LoopQuantityCircle Clone(UcmlObject obj)
        {
            var newObj = new LoopQuantityCircle();
            var aux    = (LoopQuantityCircle)obj;

            newObj.Id                  = aux.Id;
            newObj.UcmlName            = aux.UcmlName;
            newObj.Color               = aux.Color;
            newObj.PosTopX             = aux.PosTopX;
            newObj.PosTopY             = aux.PosTopY;
            newObj.Description         = aux.Description;
            newObj.TemplateName        = aux.TemplateName;
            newObj.listNewProp         = aux.listNewProp;
            newObj.UcmlWidth           = aux.UcmlWidth;
            newObj.UcmlHeight          = aux.UcmlHeight;
            newObj.myPathOrigem        = aux.myPathOrigem;
            newObj.myPathDestino       = aux.myPathDestino;
            newObj.myColor             = aux.myColor;
            newObj.Percentage          = aux.Percentage;
            newObj.StartLine           = aux.StartLine;
            newObj.IsSelected          = aux.IsSelected;
            newObj.IdObjectStarLine    = aux.IdObjectStarLine;
            newObj.isAbleUserSelection = aux.isAbleUserSelection;
            newObj.UsedAtDestination   = aux.UsedAtDestination;

            return(newObj);
        }
Beispiel #3
0
        public ExitPath Clone(UcmlObject obj)
        {
            var newObj = new ExitPath();
            var aux    = (ExitPath)obj;

            newObj.Id                  = aux.Id;
            newObj.UcmlName            = aux.UcmlName;
            newObj.Color               = aux.Color;
            newObj.PosTopX             = aux.PosTopX;
            newObj.PosTopY             = aux.PosTopY;
            newObj.Description         = aux.Description;
            newObj.TemplateName        = aux.TemplateName;
            newObj.listNewProp         = aux.listNewProp;
            newObj.UcmlWidth           = aux.UcmlWidth;
            newObj.UcmlHeight          = aux.UcmlHeight;
            newObj.myColor             = aux.myColor;
            newObj.Percentage          = aux.Percentage;
            newObj.StartLine           = aux.StartLine;
            newObj.EndLine             = aux.EndLine;
            newObj.IdObjectStartLine   = aux.IdObjectStartLine;
            newObj.IdObjectEndLine     = aux.IdObjectEndLine;
            newObj.isAbleUserSelection = aux.isAbleUserSelection;

            return(newObj);
        }
Beispiel #4
0
        public DescriptionLineActivityType Clone(UcmlObject obj)
        {
            var newObj = new DescriptionLineActivityType();
            var aux    = (DescriptionLineActivityType)obj;

            newObj.Id                  = aux.Id;
            newObj.UcmlName            = aux.UcmlName;
            newObj.Color               = aux.Color;
            newObj.PosTopX             = aux.PosTopX;
            newObj.PosTopY             = aux.PosTopY;
            newObj.Description         = aux.Description;
            newObj.TemplateName        = aux.TemplateName;
            newObj.listNewProp         = aux.listNewProp;
            newObj.UcmlWidth           = aux.UcmlWidth;
            newObj.UcmlHeight          = aux.UcmlHeight;
            newObj.myPathOrigem        = aux.myPathOrigem;
            newObj.myPathDestino       = aux.myPathDestino;
            newObj.myColor             = aux.myColor;
            newObj.Percentage          = aux.Percentage;
            newObj.StartLine           = aux.StartLine;
            newObj.EndLine             = aux.EndLine;
            newObj.IdObjectStarLine    = aux.IdObjectStarLine;
            newObj.IdObjectEndLine     = aux.IdObjectEndLine;
            newObj.isAbleUserSelection = aux.isAbleUserSelection;

            return(newObj);
        }
Beispiel #5
0
        /*
         * This method validate connection between two ucml objects.
         * Get the origin and destination objects, validate the start point and end point for each object.
         * Parameters are type of each object, the line that will be connected and the two ucml objects.
         * */
        public static bool ValidaConexao(string tipoObjetoOrigem,
                                         string tipoObjetoDestino,
                                         Connection link,
                                         UcmlObject origem,
                                         UcmlObject destino,
                                         bool YesNoLine,
                                         Dictionary <object, int> Users
                                         )
        {
            if (destino.GetType() == typeof(DescriptionLineUser))
            {
                MessageBox.Show("DescriptionLineUser dont receive connection!");
                return(false);
            }
            else if (origem == destino)
            {
                MessageBox.Show("Destiny and origin can't be the same element!");
                return(false);
            }


            // Get the color from origin object
            SolidColorBrush color = origem.myColor;

            if (origem.GetType() == typeof(SyncPoint) || origem.GetType() == typeof(Branch) || origem.GetType() == typeof(Condition))
            {
                destino.isAbleUserSelection = true;
            }

            // Validate origin object
            # region Valida Objetos de Origem

            // Check each type of object and validate each one in particular
            switch (tipoObjetoOrigem)
Beispiel #6
0
 private static void LoadMyUsers(UcmlObject ucmlObject, Canvas myCanvas)
 {
     foreach (var item in ucmlObject.tempUsers.Keys)
     {
         UcmlObject obj = GetObjectByName(myCanvas, item);
         if (obj != null)
         {
             ucmlObject.myUsers.Add(obj, ucmlObject.tempUsers[item]);
         }
     }
 }
Beispiel #7
0
 private static void LoadMyUsers(Connection connection, Canvas myCanvas)
 {
     foreach (var item in connection.tempUsers.Keys)
     {
         UcmlObject obj = GetObjectByName(myCanvas, item);
         if (obj != null)
         {
             connection.myUsers.Add(obj, connection.tempUsers[item]);
         }
     }
 }
Beispiel #8
0
 public static SolidColorBrush getColorFromSelectedUser(List <object> users)
 {
     foreach (var item in users)
     {
         UcmlObject ucml = item as UcmlObject;
         if (ucml.IsSelected)
         {
             return(ucml.myColor);
         }
     }
     return(null);
 }
Beispiel #9
0
        public static void setPercentage(UcmlObject currentObject)
        {
            double percentage = 0.0;

            foreach (UcmlObject item in currentObject.myUsers.Keys)
            {
                if (item.IsSelected)
                {
                    percentage += item.Percentage;
                }
            }
        }
Beispiel #10
0
 public static bool HasPercentageProperty(UcmlObject selectedObjUCML)
 {
     if (selectedObjUCML.TemplateName.Equals(EnumTemplates.TempQuantityCircle) ||
         selectedObjUCML.TemplateName.Equals(EnumTemplates.TempExitPath) ||
         selectedObjUCML.TemplateName.Equals(EnumTemplates.TempLoop) ||
         selectedObjUCML.TemplateName.Equals(EnumTemplates.TempDescriptionLineActivity) ||
         selectedObjUCML.TemplateName.Equals(EnumTemplates.TempDescriptionLineUser))
     {
         return(true);
     }
     return(false);
 }
Beispiel #11
0
        public static void ClearLinesFromObject(UcmlObject currentObject)
        {
            #region Valida Objetos de Destino

            // Check each type of object and validate each one in particular
            switch (currentObject.GetType().Name)
            {
            case EnumTemplates.TempQuantityCircle:

                break;

            case EnumTemplates.TempBranch:
                Branch auxBranch = currentObject as Branch;

                foreach (Connection item in auxBranch.StartLines)
                {
                }

                break;

            case EnumTemplates.TempCondition:

                break;

            case EnumTemplates.TempDescriptionLineActivity:

                break;

            case EnumTemplates.TempExitPath:

                break;

            case EnumTemplates.TempMerge:

                break;

            case EnumTemplates.TempOptionBox:

                break;

            case EnumTemplates.TempSyncPoint:

                break;
            }
            #endregion
        }
Beispiel #12
0
        private static void SortByType(UcmlObject ucmlObj)
        {
            switch (ucmlObj.TemplateName)
            {
            case EnumTemplates.TempBranch:
                listBranch.Add(ucmlObj as Branch);
                break;

            case EnumTemplates.TempCondition:
                listCondition.Add(ucmlObj as Condition);
                break;

            case EnumTemplates.TempDescriptionLineActivity:
                listDescriptionLineActivity.Add(ucmlObj as DescriptionLineActivity);
                break;

            case EnumTemplates.TempDescriptionLineUser:
                listDescriptionLineUser.Add(ucmlObj as DescriptionLineUser);
                break;

            case EnumTemplates.TempExitPath:
                listExitPath.Add(ucmlObj as ExitPath);
                break;

            case EnumTemplates.TempMerge:
                listMerge.Add(ucmlObj as Merge);
                break;

            case EnumTemplates.TempOptionBox:
                listOptionBox.Add(ucmlObj as OptionBox);
                break;

            case EnumTemplates.TempQuantityCircle:
                listQuantityCircle.Add(ucmlObj as QuantityCircle);
                break;

            case EnumTemplates.TempSyncPoint:
                listSyncPoint.Add(ucmlObj as SyncPoint);
                break;

            case EnumTemplates.TempLoop:
                listLoop.Add(ucmlObj as Loop);
                break;
            }
        }
Beispiel #13
0
        private static Point GetEndPointToConnection(UcmlObject obj)
        {
            var point = new Point();

            switch (obj.TemplateName)
            {
            case EnumTemplates.TempDescriptionLineActivity:
                var dlAux = obj as DescriptionLineActivity;
                point = new Point(Canvas.GetLeft(dlAux) + 2,
                                  Canvas.GetTop(dlAux) + dlAux.UcmlHeight - 1);
                break;

            case EnumTemplates.TempOptionBox:
                var obAux = obj as OptionBox;
                point = new Point(Canvas.GetLeft(obAux),
                                  Canvas.GetTop(obAux));
                break;
            }
            return(point);
        }
Beispiel #14
0
        public Loop Clone(UcmlObject obj)
        {
            var newObj = new Loop();
            var aux    = (Loop)obj;

            newObj.Id           = aux.Id;
            newObj.UcmlName     = aux.UcmlName;
            newObj.Color        = aux.Color;
            newObj.PosTopX      = aux.PosTopX;
            newObj.PosTopY      = aux.PosTopY;
            newObj.Description  = aux.Description;
            newObj.TemplateName = aux.TemplateName;
            newObj.listNewProp  = aux.listNewProp;
            newObj.UcmlWidth    = aux.UcmlWidth;
            newObj.UcmlHeight   = aux.UcmlHeight;
            newObj.myColor      = aux.myColor;
            newObj.Percentage   = 0;

            return(newObj);
        }
Beispiel #15
0
        /*
         * This method validate connection between two ucml objects.
         * Get the origin and destination objects, validate the start point and end point for each object.
         * Parameters are type of each object, the line that will be connected and the two ucml objects.
         * */
        public static bool ValidaConexao(string tipoObjetoOrigem,
                                         string tipoObjetoDestino,
                                         LineGeometry link,
                                         UcmlObject origem,
                                         UcmlObject destino,
                                         bool YesNoLine,
                                         List <object> Users
                                         )
        {
            // Get the color from origin object
            SolidColorBrush color = origem.myColor;

            if (origem.GetType() == typeof(SyncPoint) || origem.GetType() == typeof(Branch) || origem.GetType() == typeof(Condition))
            {
                destino.isAbleUserSelection = true;
            }

            // Validate origin object
            # region Valida Objetos de Origem

            // Check each type of object and validate each one in particular
            switch (tipoObjetoOrigem)
Beispiel #16
0
        public void ChangeColor(SolidColorBrush color, UcmlObject selectedObj)
        {
            UcmlObject selectedObjUCML;
            Border     border;
            TextBlock  percentage;

            if (selectedObj == null)
            {
                selectedObjUCML = this;
            }
            else
            {
                selectedObjUCML = selectedObj;
            }

            border                = (Border)selectedObjUCML.Template.FindName("circle", selectedObjUCML);
            border.BorderBrush    = color;
            percentage            = (TextBlock)selectedObjUCML.Template.FindName("Percentage", selectedObjUCML);
            percentage.Foreground = color;

            System.Windows.Shapes.Path ph = new System.Windows.Shapes.Path();
            PathFigure   pf = new PathFigure();
            PathGeometry pg = new PathGeometry();

            border                = (Border)selectedObjUCML.Template.FindName("circle", selectedObjUCML);
            border.BorderBrush    = color;
            percentage            = (TextBlock)selectedObjUCML.Template.FindName("Percentage", selectedObjUCML);
            percentage.Foreground = color;

            QuantityCircle lqc = selectedObjUCML as QuantityCircle;

            lqc.myColor = color;
            lqc.LoopReference.bezierCurve.Stroke = color;
            lqc.LoopReference.myColor            = color;
            lqc.LoopReference.myArrow.Stroke     = color;
            lqc.LoopReference.myArrow.Fill       = color;
            lqc.LoopReference.myColor            = color;
        }
Beispiel #17
0
        private static void SetPathLines(UcmlObject obj, Connection connection, bool isEndLine = false, bool isConnectionNo = false)
        {
            switch (obj.TemplateName)
            {
            case EnumTemplates.TempBranch:
                if (isEndLine)
                {
                    (obj as Branch).EndLine = connection;
                }
                else
                {
                    (obj as Branch).StartLines.Add(connection);
                }
                break;

            case EnumTemplates.TempCondition:
                if (isEndLine)
                {
                    (obj as Condition).EndLine = connection;
                }
                else
                {
                    if (isConnectionNo)
                    {
                        (obj as Condition).StartLineNo = connection;
                    }
                    else
                    {
                        (obj as Condition).StartLineYes = connection;
                    }
                }
                break;

            case EnumTemplates.TempDescriptionLineActivity:
                if (isEndLine)
                {
                    (obj as DescriptionLineActivity).EndLine = connection;
                }
                else
                {
                    (obj as DescriptionLineActivity).StartLine = connection;
                }
                break;

            case EnumTemplates.TempDescriptionLineUser:
                (obj as DescriptionLineUser).StartLine = connection;
                break;

            case EnumTemplates.TempExitPath:
                if (isEndLine)
                {
                    (obj as ExitPath).EndLine = connection;
                }
                else
                {
                    (obj as ExitPath).StartLine = connection;
                }
                break;

            case EnumTemplates.TempMerge:
                if (isEndLine)
                {
                    (obj as Merge).EndLines.Add(connection);
                }
                else
                {
                    (obj as Merge).StartLine = connection;
                }
                break;

            case EnumTemplates.TempOptionBox:
                if (isEndLine)
                {
                    (obj as OptionBox).EndLine = connection;
                }
                else
                {
                    (obj as OptionBox).StartLine = connection;
                }
                break;

            case EnumTemplates.TempSyncPoint:
                if (isEndLine)
                {
                    (obj as SyncPoint).EndLines.Add(connection);
                }
                else
                {
                    (obj as SyncPoint).StartLines.Add(connection);
                }
                break;
            }
        }
Beispiel #18
0
        private static Point GetPointToConnection(UcmlObject obj, bool isConnectionNo = false)
        {
            var point = new Point();

            switch (obj.TemplateName)
            {
            case EnumTemplates.TempBranch:
                var branchAux = obj as Branch;
                point = new Point(Canvas.GetLeft(branchAux) + branchAux.ActualWidth / 2, Canvas.GetTop(branchAux) + branchAux.ActualHeight / 2);
                break;

            case EnumTemplates.TempCondition:
                var conditionAux = obj as Condition;
                if (!isConnectionNo)
                {
                    point = new Point((Canvas.GetLeft(conditionAux) + conditionAux.UcmlWidth / 2) + 21,
                                      (Canvas.GetTop(conditionAux) + conditionAux.UcmlHeight / 2) + 1);
                }
                else if (isConnectionNo)
                {
                    point = new Point((Canvas.GetLeft(conditionAux) + conditionAux.UcmlWidth / 2) - 6,
                                      (Canvas.GetTop(conditionAux) + conditionAux.UcmlHeight / 2) + 28);
                }
                break;

            case EnumTemplates.TempDescriptionLineActivity:
                var dlAux = obj as DescriptionLineActivity;
                point = new Point((Canvas.GetLeft(dlAux) + dlAux.UcmlWidth),
                                  Canvas.GetTop(dlAux) + dlAux.UcmlHeight);
                break;

            case EnumTemplates.TempDescriptionLineUser:
                var dlU = obj as DescriptionLineUser;
                point = new Point((Canvas.GetLeft(dlU) + dlU.UcmlWidth) - 1,
                                  Canvas.GetTop(dlU) + dlU.UcmlHeight / 1.4 - 1);
                break;

            case EnumTemplates.TempExitPath:
                var epAux = obj as ExitPath;
                point = new Point(Canvas.GetLeft(epAux) + 8,
                                  Canvas.GetTop(epAux));
                break;

            case EnumTemplates.TempMerge:
                var mergeAux = obj as Merge;
                point = new Point(Canvas.GetLeft(mergeAux) + mergeAux.ActualWidth / 2, Canvas.GetTop(mergeAux) + mergeAux.ActualHeight / 2);
                break;

            case EnumTemplates.TempOptionBox:
                var obAux = obj as OptionBox;
                point = new Point((Canvas.GetLeft(obAux) + obAux.ActualWidth) - 2,
                                  Canvas.GetTop(obAux));
                break;

            case EnumTemplates.TempSyncPoint:
                var spAux = obj as SyncPoint;
                point = new Point(Canvas.GetLeft(spAux) + spAux.ActualWidth / 2, Canvas.GetTop(spAux) + spAux.ActualHeight / 2);
                break;
            }
            return(point);
        }
Beispiel #19
0
        private static void ImportConnections(ref Canvas myCanvas, XmlNodeList listConnections, Canvas canvas)
        {
            connectionLineList = new List <Connection>();
            foreach (XmlNode connectItem in listConnections)
            {
                Connection connect = new Connection().ImportToXml(connectItem);
                if (connect.elementoDestId != 0 && (connect.elementoOrigId != 0 || connect.elementoOrigId != 0))
                {
                    var startObj       = new UcmlObject();
                    var endObj         = new UcmlObject();
                    var isConnectionNo = false;

                    if (connect.elementoOrigId != 0)
                    {
                        startObj       = FindObjectById(ref myCanvas, connect.elementoOrigId);
                        isConnectionNo = true;
                    }
                    else
                    {
                        startObj = FindObjectById(ref myCanvas, connect.elementoOrigId);
                    }
                    endObj = FindObjectById(ref myCanvas, connect.elementoDestId);

                    var y = new Point();
                    var x = new Point();


                    if (startObj.GetType() == typeof(Condition))
                    {
                        if ((startObj as Condition).IdObjectStarLineYes == connect.elementoDestId)
                        {
                            x = GetPointToConnection(startObj, false);
                        }
                        else
                        {
                            x = GetPointToConnection(startObj, true);
                        }
                    }
                    else
                    {
                        x = GetPointToConnection(startObj, isConnectionNo);
                    }

                    if (endObj.TemplateName.Equals(EnumTemplates.TempDescriptionLineActivity) || endObj.TemplateName.Equals(EnumTemplates.TempOptionBox))
                    {
                        y = GetEndPointToConnection(endObj);
                    }
                    else
                    {
                        y = GetPointToConnection(endObj);
                    }

                    var link = new Connection(x, y, null);

                    Connection connection = new Connection(link.initialPoint, link.endPoint, (SolidColorBrush)connect.Stroke);


                    if (startObj.GetType() == typeof(Condition))
                    {
                        if (endObj.Id == (startObj as Condition).IdObjectStarLineYes)
                        {
                            (startObj as Condition).StartLineYes = connection;
                            SetPathLines(endObj, connection, true, isConnectionNo);
                        }
                        else if (endObj.Id == (startObj as Condition).IdObjectStarLineNo)
                        {
                            (startObj as Condition).StartLineNo = connection;
                            SetPathLines(endObj, connection, true, isConnectionNo);
                        }
                        else
                        {
                            if (endObj.GetType() == typeof(Condition))
                            {
                                (endObj as Condition).EndLine = connection;
                                SetPathLines(startObj, connection, false, isConnectionNo);
                            }
                        }
                    }
                    else
                    {
                        SetPathLines(startObj, connection, false, isConnectionNo);
                        SetPathLines(endObj, connection, true, isConnectionNo);
                    }


                    connection.tempUsers = connect.tempUsers;

                    connection.elementoOrigId = startObj.Id;
                    connection.elementoDestId = endObj.Id;
                    myCanvas.Children.Add(connection);

                    //Load users
                    LoadMyUsers(connection, myCanvas);

                    connectionLineList.Add(connection);
                }
            }
        }