Beispiel #1
0
        internal OAProperties(NodeProperties target)
        {
            System.Diagnostics.Debug.Assert(target != null);

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }
Beispiel #2
0
    protected override void OnPointerUp()
    {
        base.OnPointerUp();

        NodeProperties nodeBehaviour = this.GetComponent <NodeProperties>();

        if (nodeBehaviour.m_nodeType == NodeProperties.NodeType.Simple)
        {
            if (m_attachedAnchor == null)
            {
                if (m_snappedAnchor != null)
                {
                    m_attachedAnchor = m_snappedAnchor;
                    m_snappedAnchor.Spread();
                    Destroy(nodeBehaviour.m_deactivatedGUIItem);
                }
                else
                {
                    Destroy(this.gameObject);
                    nodeBehaviour.m_deactivatedGUIItem.SetActive(true);
                }
            }
        }
        else if (nodeBehaviour.m_nodeType == NodeProperties.NodeType.TargetIndicator)
        {
            if (m_snappedAnchor != null)
            {
                this.m_parentNode.GetComponent <NodeMovement>().MoveParentNodeToAnchor(m_snappedAnchor);
            }
            Destroy(this.gameObject);                                                        //destroy the target indicator node
            Destroy(m_parentNode.GetComponent <NodeTouchHandler>().m_targetIndicatorBridge); //destroy the target indicator node
        }
    }
 void IConfigDialogView.UpdateNodePropertiesControls(NodeProperties props)
 {
     descriptionLabel.Text = props?.Description ?? "";
     updateLocked          = true;
     if ((colorComboBox.Enabled = props != null && props.Color != null) == true)
     {
         if (colorComboBox.Items.Count == 0)
         {
             colorComboBox.Items.AddRange(props.Palette.Select(c => (object)c).ToArray());
         }
         colorComboBox.SelectedIndex = props.Palette.IndexOf(c => c.Argb == props.Color.Value.Argb).GetValueOrDefault(-1);
     }
     if ((markerComboBox.Enabled = props != null && props.Marker != null) == true)
     {
         if (markerComboBox.Items.Count == 0)
         {
             markerComboBox.Items.AddRange(typeof(MarkerType).GetEnumValues().OfType <object>().ToArray());
         }
         markerComboBox.SelectedIndex = typeof(MarkerType).GetEnumValues().OfType <MarkerType>().IndexOf(c => c == props.Marker.Value).GetValueOrDefault(-1);
     }
     if ((drawLineCheckBox.Enabled = props?.DrawLine != null) == true)
     {
         drawLineCheckBox.Checked = props.DrawLine.Value;
     }
     else
     {
         drawLineCheckBox.Checked = true;
     }
     updateLocked = false;
 }
Beispiel #4
0
        public OAProperties(NodeProperties target)
        {
            Utilities.ArgumentNotNull("target", target);

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }
 private void NodeUpdatedCB(Node obj, NodeProperties prop)
 {
     if (prop == NodeProperties.POINT)
     {
         EdgeUpdated?.Invoke(this);
     }
 }
Beispiel #6
0
        public void SetupProperties()
        {
            if (_scene != null)
            {
                NodeProperties nodeProperties = new NodeProperties();
                nodeProperties.Name                 = _name;
                nodeProperties.BaseEntity           = this;
                nodeProperties.Scene                = _scene;
                nodeProperties.Enabled              = true;
                nodeProperties.Node                 = _node;
                nodeProperties.Position             = _position;
                nodeProperties.PulsarApplication    = _scene.MainApplication;
                nodeProperties.Rotation             = new Quaternion(_rotation.X, _rotation.Y, _rotation.Z);
                nodeProperties.Scale                = _scale;
                nodeProperties.InCreation           = false;
                nodeProperties.PulsarComponentClass = PulsarComponent.ComponentClass.Properties;
                nodeProperties.PulsarComponentType  = PulsarComponent.ComponentType.NodeProperties;

                if (_componentProperties != null)
                {
                    Debug.Print("BaseEntity.SetupBaseNodeProperties - Added nodeProperties to _componentProperties");
                    _componentProperties.Add(nodeProperties);
                }

                ProcessExtendedProperties();
            }
        }
Beispiel #7
0
        public OAProperties(NodeProperties target)
        {
            System.Diagnostics.Debug.Assert(target != null);

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }
Beispiel #8
0
        public void SetupProperties()
        {
            if (_scene != null)
            {
                NodeProperties nodeProperties = new NodeProperties
                {
                    Name                 = _name,
                    BaseEntity           = this,
                    Scene                = _scene,
                    Enabled              = true,
                    Node                 = _node,
                    Position             = _position,
                    PulsarApplication    = _scene.MainApplication,
                    Rotation             = new Quaternion(_rotation.X, _rotation.Y, _rotation.Z),
                    Scale                = _scale,
                    InCreation           = false,
                    PulsarComponentClass = PulsarComponent.ComponentClass.Properties,
                    PulsarComponentType  = PulsarComponent.ComponentType.NodeProperties
                };

                if (_componentProperties != null)
                {
                    _componentProperties.Add(nodeProperties);
                }

                ProcessExtendedProperties();
            }
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Message" /> class.
 /// </summary>
 /// <param name="sender">The sender of this message.</param>
 /// <param name="data">The data contained in this message.</param>
 /// <param name="messageId">The id of this message.</param>
 /// <param name="awaitingResponse">
 /// A value indicating whether the sender is awaiting a response.
 /// </param>
 /// <param name="inResponseToMessage">
 /// A value indicating whether this message is in response to another.
 /// </param>
 internal Message(NodeProperties sender, string data, uint messageId, bool awaitingResponse, bool inResponseToMessage)
 {
     _sender = sender;
     _data = data;
     _messageId = messageId;
     _awaitingResponse = awaitingResponse;
     _inResponseToMessage = inResponseToMessage;
 }
Beispiel #10
0
 public NodeProperties[] GetNodes()
 {
     NodeProperties[] outputArray = new NodeProperties[node.Count];
     for (int i = 0; i < outputArray.Length; i++)
     {
         outputArray[i] = node[i]._nodeProp;
     }
     return(outputArray);
 }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnaryOperatorNode"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="argument">The argument.</param>
        protected UnaryOperatorNode(NodeTypes type, Node argument)
            : base(type)
        {
            Argument = argument.ThrowIfNull(nameof(argument));

            if ((Argument.Properties & NodeProperties.Constant) != 0)
            {
                Properties = NodeProperties.Constant;
            }
        }
Beispiel #12
0
        internal void FireEvent(MapNode node, NodeProperties property, object oldValue)
        {
            var args = new NodePropertyChangedEventArgs()
            {
                ChangedProperty = property,
                OldValue        = oldValue
            };

            NodePropertyChanged(node, args);
        }
        public OAProperties(NodeProperties target)
        {
            System.Diagnostics.Debug.Assert(target != null);

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }
        public OAProperties(NodeProperties target)
        {
            System.Diagnostics.Debug.Assert(target != null);

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }
Beispiel #15
0
        void IConfigDialogView.UpdateNodePropertiesControls(NodeProperties props)
        {
            nodeDescriptionTextView.Value = props?.Description ?? "";

            if (colorPopup.Menu.Count == 0 && props != null)
            {
                foreach (var c in props.Palette)
                {
                    colorPopup.Menu.AddItem(colorItems[c.Argb] = CreateGraphicsMenuItem((g, r) =>
                    {
                        using (var b = new Brush(c.ToColor()))
                            g.FillRectangle(b, r);
                    }, () => evts.OnColorChanged(c)));
                }
            }
            if (markerPopup.Menu.Count == 0 && props != null)
            {
                foreach (var m in Enum.GetValues(typeof(MarkerType)))
                {
                    markerPopup.Menu.AddItem(markerItems[(MarkerType)m] = CreateGraphicsMenuItem((g, r) =>
                    {
                        Drawing.DrawLegendSample(g, resources,
                                                 new ModelColor(0xff, 0, 0, 0), (MarkerType)m, r);
                    }, () => evts.OnMarkerChanged((MarkerType)m)));
                }
            }

            if ((colorPopup.Enabled = (props != null && props.Color != null)) == true)
            {
                colorPopup.SelectItem(colorItems[props.Color.Value.Argb]);
            }
            else
            {
                colorPopup.SelectItem((NSMenuItem)null);
            }
            if ((markerPopup.Enabled = (props != null && props.Marker != null)) == true)
            {
                markerPopup.SelectItem(markerItems[props.Marker.Value]);
            }
            else
            {
                markerPopup.SelectItem((NSMenuItem)null);
            }

            if ((drawLineCheckbox.Enabled = (props != null && props.DrawLine != null)) == true)
            {
                drawLineCheckbox.State = props.DrawLine.Value ? NSCellStateValue.On : NSCellStateValue.Off;
            }
            else
            {
                drawLineCheckbox.State = NSCellStateValue.On;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BinaryOperatorNode"/> class.
        /// </summary>
        /// <param name="type">The node type.</param>
        /// <param name="left">The left argument.</param>
        /// <param name="right">The right argument.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="left"/> or <paramref name="right"/> is <c>null</c>.</exception>
        protected BinaryOperatorNode(NodeTypes type, Node left, Node right)
            : base(type)
        {
            Left  = left.ThrowIfNull(nameof(left));
            Right = right.ThrowIfNull(nameof(right));

            // If both are constant, the result is also constant
            if ((Left.Properties & NodeProperties.Constant) != 0 && (Right.Properties & NodeProperties.Constant) != 0)
            {
                Properties |= NodeProperties.Constant;
            }
        }
Beispiel #17
0
        public OAProperties(NodeProperties target)
        {
            Debug.Assert(target != null);

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            Target = target;
            AddPropertiesFromType(target.GetType());
        }
Beispiel #18
0
        public async Task <bool> HashesMatch(DbConnection con, string tableName, TypeMap typeMap)
        {
            const string HASH_COLUMN = "Hash";

            string getHashRecord = $"select {HASH_COLUMN} from AnalyzedModelHashes where TableName='{tableName}'";

            string existingHash = await con.RunCommandGetString(getHashRecord, HASH_COLUMN);

            string newHash = typeMap.EncodeToBase64();

            if (existingHash == newHash)
            {
                return(true);
            }

            if (existingHash == string.Empty)
            {
                await CreateTableFromTypeMap(con, tableName, typeMap);

                return(false);
            }

            TypeMap existing = TypeMap.DecodeFromBase64(existingHash);

            TypeMapDifferences differences = existing.GetDifferences(typeMap);

            foreach (TypeMapDifference difference in differences)
            {
                if (difference.DifferenceType == DifferenceType.DataTypeChange)
                {
                    throw new Exception($"Difference types {nameof(DifferenceType.DataTypeChange)}, " +
                                        $" not supported. \n" +
                                        $"Column:  {difference.ColumnKey}");
                }

                if (difference.DifferenceType == DifferenceType.ChangedColumnOrder)
                {
                    //TODO: Better handling.
                    //ignore for now
                }

                if (difference.DifferenceType == DifferenceType.AddedColumn)
                {
                    NodeProperties node = typeMap[difference.ColumnKey];

                    string alterState = $"ALTER TABLE {typeMap.Name} ADD COLUMN {difference.ColumnKey} {SqlTranslator.SqlTypeFromInternalType(node.InternalType, this).SqlType};";

                    await con.RunCommandAsync(alterState);
                }
            }
            return(false);
        }
Beispiel #19
0
        private Node ParseNode(Lexer lexer)
        {
            Node result = null;

            if (lexer.Peek().Type == LexemeType.Semicolon)
            {
                lexer.Read();
                NodeProperties properties = ParseNodeProperties(lexer);
                result = new Node(properties);
            }

            return(result);
        }
Beispiel #20
0
        private NodeProperties ParseNodeProperties(Lexer lexer)
        {
            NodeProperties result   = new NodeProperties();
            NodeProperty   property = ParseNodeProperty(lexer);

            while (property != null)
            {
                result.Add(property);
                property = ParseNodeProperty(lexer);
            }

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TernaryOperatorNode"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="condition">The condition.</param>
        /// <param name="ifTrue">If true.</param>
        /// <param name="ifFalse">If false.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="condition"/>, <paramref name="ifTrue"/> or <paramref name="ifFalse"/> is <c>null</c>.</exception>
        protected TernaryOperatorNode(NodeTypes type, Node condition, Node ifTrue, Node ifFalse)
            : base(type)
        {
            Condition = condition.ThrowIfNull(nameof(condition));
            IfTrue    = ifTrue.ThrowIfNull(nameof(ifTrue));
            IfFalse   = ifFalse.ThrowIfNull(nameof(ifFalse));

            if (((Condition.Properties & NodeProperties.Constant) != 0) &&
                ((IfTrue.Properties & NodeProperties.Constant) != 0) &&
                ((IfFalse.Properties & NodeProperties.Constant) != 0))
            {
                Properties = NodeProperties.Constant;
            }
        }
Beispiel #22
0
    string BuildInfoString()
    {
        NodeProperties np   = this.GetComponent <NodeProperties>();
        string         info = "<b>" + np.LongName + "</b>\n\n";

        info += "Layer: " + np.Layer + "\n";
        info += "Critically: " + np.Critically + "\n";
        info += "Desirability: " + np.Desirability + "\n";
        info += "Business Area: " + np.BusinessArea + "\n";
        info += "Business Function: " + np.BusinessFunction + "\n";
        info += "IsMarkets: " + np.IsMarkets.ToString();

        return(info);
    }
        public static NodeProperties FromString(string s)
        {
            NodeProperties props = new NodeProperties();
            Dictionary <string, string> pairs = new Dictionary <string, string>();

            foreach (string segment in s.Split('&'))
            {
                var segArr = segment.Split('=');
                pairs.Add(segArr[0], segArr[1]);
            }
            props.InternalType = new InternalType(pairs[SQLTYPEKEY]);
            props.NodeName     = pairs[NODENAMEKEY] != "NULL"? pairs["node_name"] : null;
            props.ServiceName  = pairs[SERVICENAMEKEY] != "NULL"? pairs[SERVICENAMEKEY] : null;
            props.Unique       = bool.Parse(pairs[UNIQUEKEY]);
            return(props);
        }
        private void _populateTypeMaps(NodeProperties props, string key, bool overwrite = false)
        {
            if (key.Length > KeyLengthLimit)
            {
                KeyLengthLimitSurpassed = true;
            }

            if (!TypeMap.ContainsKey(key))
            {
                props.Name   = key;
                TypeMap[key] = props;
                return;
            }

            TypeMap[key].Update(props);
        }
Beispiel #25
0
 public bool this[NodeProperties p]
 {
     get
     {
         return(Properties.HasFlag(p));
     }
     set
     {
         if (value)
         {
             Properties |= p;
         }
         else
         {
             Properties &= ~p;
         }
     }
 }
Beispiel #26
0
 private void NodeUpdatedCB(Node n, NodeProperties prop)
 {
     if (prop == NodeProperties.HIGHLIGHT)
     {
         if (n.Highlight)
         {
             nodeEllipse.Fill = Brushes.YellowGreen;
         }
         else
         {
             nodeEllipse.Fill = selected ? Brushes.Green :
                                visited ? Brushes.Blue:
                                Brushes.White;
         }
     }
     else if (prop == NodeProperties.VIZUALIZED)
     {
         if (n.Visualized)
         {
             nodeEllipse.Fill = Brushes.Red;
         }
         else
         {
             nodeEllipse.Fill = selected ? Brushes.Green :
                                visited ? Brushes.Blue :
                                Brushes.White;
         }
     }
     else if (prop == NodeProperties.VISITED)
     {
         Visited = n.Visited;
     }
     else if (prop == NodeProperties.SHORTESTDISTANCE)
     {
         if (n.ShortestDistance == int.MaxValue)
         {
             ShortestDistanceText = "";
         }
         else
         {
             ShortestDistanceText = n.ShortestDistance.ToString();
         }
     }
 }
Beispiel #27
0
    /**
     * Drag a playable item onto the scene by destroying the GUI item itself and creating a game object
     * **/
    public void DragOntoScene()
    {
        //create a cloned game object
        Vector2 guiNodePosition    = this.GetComponent <RectTransform>().anchoredPosition;
        Vector3 clonedNodePosition = CoordinatesUtils.SharedInstance.GetScreenCoordinatesInWorldPoint(guiNodePosition);

        clonedNodePosition.z = NodeProperties.NODE_Z_VALUE;
        GameObject     clonedNode          = (GameObject)Instantiate(m_simpleNodePrefab, clonedNodePosition, Quaternion.identity);
        NodeProperties clonedNodeBehaviour = clonedNode.GetComponent <NodeProperties>();

        clonedNodeBehaviour.m_nodeType = NodeProperties.NodeType.Simple;
        NodeMovement clonedNodeMovement = clonedNode.GetComponent <NodeMovement>();

        clonedNodeMovement.m_movementPoints = this.GetComponent <NodeMovement>().m_movementPoints;

        //deactivate the gui element
        this.gameObject.SetActive(false);
        clonedNodeBehaviour.m_deactivatedGUIItem = this.gameObject;
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="FunctionNode"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="arguments">The arguments.</param>
        protected FunctionNode(string name, IReadOnlyList <Node> arguments)
            : base(NodeTypes.Function)
        {
            Name      = name.ThrowIfNull(nameof(name));
            Arguments = arguments.ThrowIfNull(nameof(arguments));

            // Check for constant arguments
            var isConstant = true;

            foreach (var arg in arguments)
            {
                arg.ThrowIfNull(nameof(arg));
                if ((arg.Properties & NodeProperties.Constant) == 0)
                {
                    isConstant = false;
                    break;
                }
            }
            Properties = isConstant ? NodeProperties.Constant : NodeProperties.None;
        }
        private static Dictionary <string, PropertyInfo> GetNodeProperties <TNode>() where TNode : IGraphElement
        {
            var nodeType = typeof(TNode).Name;

            lock (NodeProperties)
            {
                if (NodeProperties.TryGetValue(nodeType, out Dictionary <string, PropertyInfo> result))
                {
                    return(result);
                }
                var nodePropsDic = typeof(TNode)
                                   .GetProperties()
                                   .Where(x => x.CanRead && x.CanWrite)
                                   .Where(x => x.MemberType == MemberTypes.Property && x.PropertyType.IsPublic)
                                   .Where(x => !x.PropertyType.IsSubclassOf(typeof(IEnumerable)))
                                   .Where(x => x.GetSetMethod() != null && (x.GetSetMethod().Attributes & MethodAttributes.Static) == 0)
                                   .ToDictionary(x => x.Name, x => x);
                NodeProperties[nodeType] = nodePropsDic;
                return(nodePropsDic);
            }
        }
Beispiel #30
0
    public void UpdateNearestNodeToCylinderCenter(int lineIndex)
    {
        float          beta, deltaR;
        NodeProperties nodeA      = node[line[lineIndex]._lineProp.node1]._nodeProp;
        NodeProperties nodeB      = node[line[lineIndex]._lineProp.node2]._nodeProp;
        float          lineLength = Vector3.Magnitude(nodeB.position - nodeA.position);

        activeLineLength = lineLength;
        float smallestNodeRadius, largestNodeRadius;

        if (nodeA.maxRadius > nodeB.maxRadius)
        {
            smallestNodeRadius = nodeB.maxRadius;
            largestNodeRadius  = nodeA.maxRadius;
        }
        else if (nodeA.maxRadius == nodeB.maxRadius)
        {
            beta       = 0;
            activeBeta = beta;

            line[lineIndex]._lineProp.AC = 0;
            line[lineIndex]._lineProp.BD = 0;

            return;
        }
        else
        {
            smallestNodeRadius = nodeA.maxRadius;
            largestNodeRadius  = nodeB.maxRadius;
        }

        deltaR     = largestNodeRadius - smallestNodeRadius;
        beta       = Mathf.Asin((deltaR) / lineLength);
        activeBeta = beta * Mathf.Rad2Deg;

        line[lineIndex]._lineProp.AC = smallestNodeRadius * deltaR / lineLength;
        line[lineIndex]._lineProp.BD = largestNodeRadius * deltaR / lineLength;
        line[lineIndex]._lineProp.CE = Mathf.Sqrt(Mathf.Pow(smallestNodeRadius, 2) - Mathf.Pow(line[lineIndex]._lineProp.AC, 2));
        line[lineIndex]._lineProp.DF = Mathf.Sqrt(Mathf.Pow(largestNodeRadius, 2) - Mathf.Pow(line[lineIndex]._lineProp.BD, 2));
    }
Beispiel #31
0
    //Updates the bottom UI component to reflect target node properties
    public void UpdateNodePopUp(NodeProperties nProp)
    {
        string output = "";

        switch (nProp.NodeEvent)
        {
        case (NodeProperties.EventType.COMBAT):
            output += "There are enemies near this location. Brace for combat!";
            break;

        case (NodeProperties.EventType.NARRATIVECORE):
            output += "Continue your story upon venturing here.";
            output += ResourceModToString(nProp.ResourceMod);
            break;

        case (NodeProperties.EventType.NARRATIVE):
            output += "There seems to be something interesting happening here.";
            output += ResourceModToString(nProp.ResourceMod);
            break;
        }
        ChangePopUp.GetComponent <Text>().text = output;
    }
Beispiel #32
0
    void DrawNodes()
    {
        for (int i = 0; i < _nodeProps.Count; i++)
        {
            NodeProperties node                 = _nodeProps[i];
            Vector3        position             = new Vector3(node.X, node.Y, node.Z) * radius;
            Vector3        sphericalCoordinates = GetSphericalCoordinates(position);

            _nodeProps[i].X = sphericalCoordinates.x;
            _nodeProps[i].Y = sphericalCoordinates.y;
            _nodeProps[i].Z = sphericalCoordinates.z;

            GameObject nodeObj = Instantiate(_nodePrefab, sphericalCoordinates, Quaternion.identity, transform);
            nodeObj.name = node.No;
            nodeObj.tag  = "Node";

            Node n = nodeObj.GetComponent <Node>();
            n.pos = new Vector3(sphericalCoordinates.x, sphericalCoordinates.y, sphericalCoordinates.z);
            n.num = node.No;

            _nodes.Add(n);
        }
    }
 /// <summary>
 /// Initializes new instance of OANestedProjectProperties object based on specified ProjectNode.
 /// </summary>
 /// <param name="project">The Project Node.</param>
 internal OANestedProjectProperties(NodeProperties nodeProperties)
     : base(nodeProperties)
 {
     this.AddProperties();
 }
 protected override NodeProperties CreatePropertiesObject()
 {
     return(_nodeproperties = new SQFileNodeProperties(this));
 }
Beispiel #35
0
        internal void FireEvent(MapNode node, NodeProperties property, object oldValue)
        {
            var args = new NodePropertyChangedEventArgs()
            {
                ChangedProperty = property,
                OldValue = oldValue
            };

            NodePropertyChanged(node, args);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApprovedNodeDetails"/> structure.
 /// </summary>
 /// <param name="node">The node that needs to be acted on.</param>
 /// <param name="approvalGranted">A value indicating whether approval was granted or received.</param>
 public ApprovedNodeDetails(NodeProperties node, bool approvalGranted)
 {
     _node = node;
     _approvalGranted = approvalGranted;
 }
Beispiel #37
0
        public OAProperties(NodeProperties target) {
            Utilities.ArgumentNotNull("target", target);

            this.target = target;
            this.AddPropertiesFromType(target.GetType());
        }