Exemplo n.º 1
0
    public static void SetFormViewParameters(IOrderedDictionary parameters, object instance)
    {
        Type ObjType = instance.GetType();
        foreach (DictionaryEntry parameter in parameters)
        {
            PropertyInfo property = ObjType.GetProperty(parameter.Key.ToString());
            if (property != null)
            {
                Type t = property.PropertyType;
                object value = null;
                     switch (t.Name)
                {
                    case "Decimal":
                        if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                            value = Convert.ToDecimal(parameter.Value);
                        else
                            value = Convert.ToDecimal(0.0);
                        break;
                    case "Boolean":
                        value = Convert.ToBoolean(parameter.Value);
                        break;
                    case "DateTime":
                        String DateTimeFormat = "dd/MM/yyyy";
                        DateTimeFormatInfo info = new DateTimeFormatInfo();
                        info.ShortDatePattern = DateTimeFormat;
                        String date = Convert.ToString(parameter.Value);
                        if (!String.IsNullOrEmpty(date) || date == "null")
                            value = Convert.ToDateTime(date,info);
                        break;
                    case "Double":
                        if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                            value = Convert.ToDouble(parameter.Value);
                        else
                            value = 0.0;
                        break;
                    case "Int32":
                        value = Convert.ToInt32(parameter.Value);
                        break;
                    case "Single":
                        value = Convert.ToSingle(parameter.Value);
                        break;
                    case "String":
                        value = Convert.ToString(parameter.Value);
                        break;
                    case "Guid":
                        if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                            value = new Guid("11111111111111111111111111111111");
                        break;
                    default:
                        break;
                }

                property.SetValue(instance, value, null);

            }
        }
        parameters.Clear();
        parameters.Add("Values", instance);
    }
Exemplo n.º 2
0
 public override void Clear()
 {
     propertyIndex.Clear();
 }
Exemplo n.º 3
0
    public static void SetFormViewParameters(IOrderedDictionary parameters, object instance)
    {
        Type ObjType = instance.GetType();

        foreach (DictionaryEntry parameter in parameters)
        {
            PropertyInfo property = ObjType.GetProperty(parameter.Key.ToString());
            if (property != null)
            {
                Type   t     = property.PropertyType;
                object value = null;
                switch (t.Name)
                {
                case "Decimal":
                    if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                    {
                        value = Convert.ToDecimal(parameter.Value);
                    }
                    else
                    {
                        value = Convert.ToDecimal(0.0);
                    }
                    break;

                case "Boolean":
                    value = Convert.ToBoolean(parameter.Value);
                    break;

                case "DateTime":
                    String             DateTimeFormat = "dd/MM/yyyy";
                    DateTimeFormatInfo info           = new DateTimeFormatInfo();
                    info.ShortDatePattern = DateTimeFormat;
                    String date = Convert.ToString(parameter.Value);
                    if (!String.IsNullOrEmpty(date) || date == "null")
                    {
                        value = Convert.ToDateTime(date, info);
                    }
                    break;

                case "Double":
                    if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                    {
                        value = Convert.ToDouble(parameter.Value);
                    }
                    else
                    {
                        value = 0.0;
                    }
                    break;

                case "Int32":
                    value = Convert.ToInt32(parameter.Value);
                    break;

                case "Single":
                    value = Convert.ToSingle(parameter.Value);
                    break;

                case "String":
                    value = Convert.ToString(parameter.Value);
                    break;

                case "Guid":
                    if (!string.IsNullOrEmpty(parameter.Value.ToString()))
                    {
                        value = new Guid("11111111111111111111111111111111");
                    }
                    break;

                default:
                    break;
                }

                property.SetValue(instance, value, null);
            }
        }
        parameters.Clear();
        parameters.Add("Values", instance);
    }
        private void BuildShapeLists(IOrderedDictionary shapeList, IOrderedDictionary constraintList, int mousePointIndex)
        {
            if (mousePointIndex == 0)
            {
                return;
            }
            var  root         = _document.Root;
            var  dci          = root.Get <DocumentContextInterpreter>();
            var  shapeGraph   = dci.ShapesGraph;
            var  relatedNodes = new List <int>();
            bool expanding;

            do
            {
                var shapeNodes           = GetUnusedNodes(shapeList);
                var shapeNodesCount      = shapeNodes.Count;
                var referrencedByNodes   = GetReferrencedByNodes(shapeNodes, shapeGraph);
                var referingNodes        = GetReferingNodes(shapeNodes, shapeGraph);
                var constraintNodes      = GetUnusedNodes(constraintList);
                var constraintNodesCount = constraintNodes.Count;
                expanding = shapeNodesCount != 0 || constraintNodesCount != 0;
                var toMap = GetReferingNodes(constraintNodes, shapeGraph);

                ExpandDictionaryWithItems(shapeList, constraintList, referrencedByNodes);
                ExpandDictionaryWithItems(shapeList, constraintList, referingNodes);
                ExpandDictionaryWithItems(shapeList, constraintList, toMap);
            } while (expanding);

            if (relatedNodes.Count == 0)
            {
                relatedNodes = GetRelatedNodes(new [] { mousePointIndex }, shapeGraph);
            }

            _freePointsCount = relatedNodes.Count * 2;

            // exclude mouse position for closed shapes (e.g. rectangle)
            if (relatedNodes.Contains(mousePointIndex))
            {
                _freePointsCount -= 2;
            }

            var orderedList = relatedNodes.ToDictionary(node => node, node => true);

            foreach (var shape in shapeList.Keys)
            {
                if (!orderedList.ContainsKey((int)shape))
                {
                    orderedList.Add((int)shape, true);
                }
            }
            var newShapeList = new List <int>();

            // shapeList will contain all the points, ordered on levels from the mouse point, the mouse point
            // and after that all the constraints
            foreach (var value in orderedList.Keys)
            {
                if (NodeIsPoint(value))
                {
                    if (!newShapeList.Contains(value))
                    {
                        newShapeList.Add(value);
                    }
                }
                if (NodeIsCircle(value))
                {
                    var circleNode  = new NodeBuilder(_document.Root[value]);
                    var circleIndex = circleNode.Dependency[0].ReferenceBuilder.Node.Index;
                    if (newShapeList.Contains(circleIndex))
                    {
                        int i = 0;
                        for (i = 0; i < newShapeList.Count - 1; i++)
                        {
                            if (newShapeList[i] == circleIndex)
                            {
                                break;
                            }
                            i++;
                        }
                        if (i < newShapeList.Count - 1)
                        {
                            newShapeList.Insert(i + 1, value);
                        }
                        else
                        {
                            newShapeList.Add(value);
                        }
                    }
                    else
                    {
                        newShapeList.Add(circleIndex);
                        newShapeList.Add(value);
                    }
                }
            }

            // move mouse point at the end of the points list
            if (newShapeList.Contains(mousePointIndex))
            {
                newShapeList.Remove(mousePointIndex);
                newShapeList.Add(mousePointIndex);
                foreach (var item in newShapeList)
                {
                    var nb = new NodeBuilder(_document.Root[item]);
                    if (nb.FunctionName == FunctionNames.Circle)
                    {
                        if (nb.Dependency[0].ReferenceBuilder.Node.Index == mousePointIndex)
                        {
                            newShapeList.Remove(item);
                            newShapeList.Add(item);
                            break;
                        }
                    }
                }
            }

            newShapeList.AddRange(orderedList.Keys.Where(value => !NodeIsPointOrCircle(value)));

            foreach (var constr in constraintList.Keys)
            {
                var nb = new NodeBuilder(_document.Root[(int)constr]);
                if (nb.FunctionName == Constraint2DNames.LineLengthFunction)
                {
                    _freePointsCount += 2;
                }
            }
            shapeList.Clear();
            foreach (var element in newShapeList)
            {
                shapeList.Add(element, true);
            }
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     Log.Debug("Destroying scheduling service");
     _handleSetMap.Clear();
     _timeHandleMap.Clear();
 }