Esempio n. 1
0
        public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape)
        {
            operatorShape.Title     = operatorShapeInfo.Title;
            operatorShape.Subtitle  = operatorShapeInfo.TypeName;
            operatorShape.Color     = operatorShapeInfo.Color;
            operatorShape.LineColor = operatorShapeInfo.LineColor;
            operatorShape.LineWidth = operatorShapeInfo.LineWidth;
            operatorShape.Icon      = operatorShapeInfo.Icon;
            operatorShape.Collapsed = operatorShapeInfo.Collapsed;

            int i = 0;
            int j = 0;
            //remove old connectors and skip correct connectors
            List <string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList();

            while (i < operatorShapeInfo.Connectors.Count() && j < oldConnectorNames.Count)
            {
                if (operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.SuccessorConnector ||
                    operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.PredecessorConnector)
                {
                    i++;
                }
                else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector ||
                         oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector)
                {
                    j++;
                }
                else if (operatorShapeInfo.Connectors.ElementAt(i) != oldConnectorNames[j])
                {
                    operatorShape.RemoveConnector(oldConnectorNames[j]);
                    j++;
                }
                else
                {
                    i++;
                    j++;
                }
            }
            //remove remaining old connectors
            for (; j < oldConnectorNames.Count; j++)
            {
                operatorShape.RemoveConnector(oldConnectorNames[j]);
            }

            //add new connectors except successor and connector
            for (; i < operatorShapeInfo.Connectors.Count(); i++)
            {
                if (operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.SuccessorConnector &&
                    operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.PredecessorConnector)
                {
                    operatorShape.AddConnector(operatorShapeInfo.Connectors.ElementAt(i));
                }
            }

            operatorShape.UpdateLabels(operatorShapeInfo.Labels);
        }
    public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) {
      operatorShape.Title = operatorShapeInfo.Title;
      operatorShape.Subtitle = operatorShapeInfo.TypeName;
      operatorShape.Color = operatorShapeInfo.Color;
      operatorShape.LineColor = operatorShapeInfo.LineColor;
      operatorShape.LineWidth = operatorShapeInfo.LineWidth;
      operatorShape.Icon = operatorShapeInfo.Icon;
      operatorShape.Collapsed = operatorShapeInfo.Collapsed;

      int i = 0;
      int j = 0;
      //remove old connectors and skip correct connectors
      List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList();
      while (i < operatorShapeInfo.Connectors.Count() && j < oldConnectorNames.Count) {
        if (operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.SuccessorConnector ||
          operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.PredecessorConnector)
          i++;
        else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector ||
          oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector)
          j++;
        else if (operatorShapeInfo.Connectors.ElementAt(i) != oldConnectorNames[j]) {
          operatorShape.RemoveConnector(oldConnectorNames[j]);
          j++;
        } else {
          i++;
          j++;
        }
      }
      //remove remaining old connectors
      for (; j < oldConnectorNames.Count; j++)
        operatorShape.RemoveConnector(oldConnectorNames[j]);

      //add new connectors except successor and connector
      for (; i < operatorShapeInfo.Connectors.Count(); i++)
        if (operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.SuccessorConnector &&
          operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.PredecessorConnector)
          operatorShape.AddConnector(operatorShapeInfo.Connectors.ElementAt(i));

      operatorShape.UpdateLabels(operatorShapeInfo.Labels);
    }