예제 #1
0
 public Node(int pIpAddress)
 {
     using (var _db = new Rbr_Db()) {
         nodeRow = _db.NodeCollection.GetByIPAddress(pIpAddress);
     }
     init(nodeRow, pIpAddress);
 }
예제 #2
0
        protected virtual GraphChangeStatus DoSaveNode(GraphNode node)
        {
            GraphChangeStatus result;

            var row = loadNodeRow(node.GDID);

            if (row == null)
            {
                row = new NodeRow(false)
                {
                    GDID          = node.GDID,
                    In_Use        = true,
                    Node_Type     = node.NodeType,
                    G_OriginShard = node.G_OriginShard,
                    G_Origin      = node.G_Origin,
                    Create_Date   = node.TimestampUTC
                };
                result = GraphChangeStatus.Added;
            }
            else
            {
                result = GraphChangeStatus.Updated;
            }

            row.Origin_Name       = node.OriginName;
            row.Friend_Visibility = GSFriendVisibility.ToDomainString(node.DefaultFriendVisibility);

            ForNode(node.GDID).Upsert(row);

            return(result);
        }
예제 #3
0
        internal static NodeDto MapToNode(NodeRow pNodeRow, PlatformDto pPlatform)
        {
            if (pNodeRow == null)
            {
                return(null);
            }

            NodeDto _node = new NodeDto();

            _node.NodeId = pNodeRow.Node_id;
            _node.BillingExportFrequency = pNodeRow.Billing_export_frequency;
            _node.CdrPublishingFrequency = pNodeRow.Cdr_publishing_frequency;
            _node.Description            = pNodeRow.Description;
            _node.IpAddress     = pNodeRow.Ip_address;
            _node.NodeRole      = pNodeRow.NodeRole;
            _node.Password      = pNodeRow.Password;
            _node.Port          = pNodeRow.Port;
            _node.Status        = (Status)pNodeRow.Status;
            _node.TransportType = (TransportType)pNodeRow.Transport_type;
            _node.UserName      = pNodeRow.User_name;

            _node.Platform = pPlatform;

            return(_node);
        }
예제 #4
0
        /// <summary>
        /// Updates a record in the <c>Node</c> table.
        /// </summary>
        /// <param name="value">The <see cref="NodeRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(NodeRow value)
        {
            string sqlStr = "UPDATE [dbo].[Node] SET " +
                            "[platform_id]=" + _db.CreateSqlParameterName("Platform_id") + ", " +
                            "[description]=" + _db.CreateSqlParameterName("Description") + ", " +
                            "[node_config]=" + _db.CreateSqlParameterName("Node_config") + ", " +
                            "[transport_type]=" + _db.CreateSqlParameterName("Transport_type") + ", " +
                            "[user_name]=" + _db.CreateSqlParameterName("User_name") + ", " +
                            "[password]=" + _db.CreateSqlParameterName("Password") + ", " +
                            "[ip_address]=" + _db.CreateSqlParameterName("Ip_address") + ", " +
                            "[port]=" + _db.CreateSqlParameterName("Port") + ", " +
                            "[status]=" + _db.CreateSqlParameterName("Status") + ", " +
                            "[billing_export_frequency]=" + _db.CreateSqlParameterName("Billing_export_frequency") + ", " +
                            "[cdr_publishing_frequency]=" + _db.CreateSqlParameterName("Cdr_publishing_frequency") +
                            " WHERE " +
                            "[node_id]=" + _db.CreateSqlParameterName("Node_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Platform_id", value.Platform_id);
            AddParameter(cmd, "Description", value.Description);
            AddParameter(cmd, "Node_config", value.Node_config);
            AddParameter(cmd, "Transport_type", value.Transport_type);
            AddParameter(cmd, "User_name", value.User_name);
            AddParameter(cmd, "Password", value.Password);
            AddParameter(cmd, "Ip_address", value.Ip_address);
            AddParameter(cmd, "Port", value.Port);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Billing_export_frequency", value.Billing_export_frequency);
            AddParameter(cmd, "Cdr_publishing_frequency", value.Cdr_publishing_frequency);
            AddParameter(cmd, "Node_id", value.Node_id);
            return(0 != cmd.ExecuteNonQuery());
        }
예제 #5
0
파일: GraphNode.cs 프로젝트: saleyn/agni
        /// <summary>
        /// Creates a new GraphNode with new GDID
        /// </summary>
        public static GraphNode MakeNew(string nodeType, GDID gOrigShard, GDID gOrig, string origName, byte[] origData, FriendVisibility defaultFriendVisibility)
        {
            var gdid   = NodeRow.GenerateNewNodeRowGDID();
            var utcNow = App.TimeSource.UTCNow;

            return(new GraphNode(nodeType, gdid, gOrigShard, gOrig, origName, origData, utcNow, defaultFriendVisibility));
        }
예제 #6
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="NodeRow"/> objects.</returns>
        protected virtual NodeRow[] MapRecords(IDataReader reader,
                                               int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int node_idColumnIndex                  = reader.GetOrdinal("node_id");
            int platform_idColumnIndex              = reader.GetOrdinal("platform_id");
            int descriptionColumnIndex              = reader.GetOrdinal("description");
            int node_configColumnIndex              = reader.GetOrdinal("node_config");
            int transport_typeColumnIndex           = reader.GetOrdinal("transport_type");
            int user_nameColumnIndex                = reader.GetOrdinal("user_name");
            int passwordColumnIndex                 = reader.GetOrdinal("password");
            int ip_addressColumnIndex               = reader.GetOrdinal("ip_address");
            int portColumnIndex                     = reader.GetOrdinal("port");
            int statusColumnIndex                   = reader.GetOrdinal("status");
            int billing_export_frequencyColumnIndex = reader.GetOrdinal("billing_export_frequency");
            int cdr_publishing_frequencyColumnIndex = reader.GetOrdinal("cdr_publishing_frequency");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    NodeRow record = new NodeRow();
                    recordList.Add(record);

                    record.Node_id                  = Convert.ToInt16(reader.GetValue(node_idColumnIndex));
                    record.Platform_id              = Convert.ToInt16(reader.GetValue(platform_idColumnIndex));
                    record.Description              = Convert.ToString(reader.GetValue(descriptionColumnIndex));
                    record.Node_config              = Convert.ToInt32(reader.GetValue(node_configColumnIndex));
                    record.Transport_type           = Convert.ToByte(reader.GetValue(transport_typeColumnIndex));
                    record.User_name                = Convert.ToString(reader.GetValue(user_nameColumnIndex));
                    record.Password                 = Convert.ToString(reader.GetValue(passwordColumnIndex));
                    record.Ip_address               = Convert.ToInt32(reader.GetValue(ip_addressColumnIndex));
                    record.Port                     = Convert.ToInt32(reader.GetValue(portColumnIndex));
                    record.Status                   = Convert.ToByte(reader.GetValue(statusColumnIndex));
                    record.Billing_export_frequency = Convert.ToInt32(reader.GetValue(billing_export_frequencyColumnIndex));
                    record.Cdr_publishing_frequency = Convert.ToInt32(reader.GetValue(cdr_publishing_frequencyColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((NodeRow[])(recordList.ToArray(typeof(NodeRow))));
        }
    void AddNodeRow(List <IdentifiableNode> nodes)
    {
        NodeRow nr = new NodeRow(rowIndex + 1);

        nr.nodesInRow = new List <IdentifiableNode>(nodes);
        nr.Initialize();
        Rows.Add(nr);
    }
예제 #8
0
 private void GenerateNodeNetwork()
 {
     for (int i = 0; i < nodeRows.Count - 1; i++)
     {
         NodeRow nextRow = nodeRows[i + 1];
         nodeRows[i].GenerateNodeConnections(nextRow);
     }
 }
예제 #9
0
 public void CopyArray(StageData src)
 {
     _Rows = new NodeRow[src.Rows.Count];
     for (int i = 0; i < src.Rows.Count; i++)
     {
         _Rows[i] = new NodeRow();
         _Rows[i].CopyFrom(src.Rows[i]);
     }
 }
예제 #10
0
 //NOTE: !!! Manual Replication required !!!
 internal static void Delete(Rbr_Db pDb, NodeRow pNodeRow)
 {
     if (pNodeRow.DottedIPAddress == Configuration.Instance.Main.HostIP)
     {
         return;
     }
     LoadBalancingMapManager.Delete(pDb, pNodeRow);
     pDb.NodeCollection.Delete(pNodeRow);
 }
예제 #11
0
 public void CreateGrid(int rows, int columns, NodeType type)
 {
     _Rows = new NodeRow[rows];
     for (int i = 0; i < rows; i++)
     {
         _Rows[i] = new NodeRow(
             Enumerable.Repeat <NodeType>(type, columns).ToArray()
             );
     }
 }
예제 #12
0
        static NodeDto getNodeInfo(Rbr_Db_Base pDb, NodeRow pNodeRow)
        {
            if (pNodeRow == null)
            {
                return(null);
            }

            var _platform = MapToPlatform(pDb.PlatformCollection.GetByPrimaryKey(pNodeRow.Platform_id));

            return(MapToNode(pNodeRow, _platform));
        }
예제 #13
0
        private NodeRow ParseRow()
        {
            tempRow = new List <Token>();
            Match(TokenType.RowBegin);
            NodeRow r = new NodeRow {
                FieldList = ParseFieldList()
            };

            Match(TokenType.RowEnd);
            tempTable.Add(tempRow);
            return(r);
        }
예제 #14
0
    public void GenerateNodeMap()
    {
        nodeRows.Clear();

        for (int i = 0; i < NUM_NODE_ROWS; i++)
        {
            int     numOfNodes = UnityEngine.Random.Range(MIN_NODES_PER_ROW, MAX_NODES_PER_ROW + 1);
            NodeRow newRow     = new NodeRow(i, numOfNodes);
            nodeRows.Add(newRow);
        }
        GenerateNodeNetwork();
    }
 void AddNode(IdentifiableNode id, bool withRow)
 {
     if (Rows.ValidList())
     {
         if (withRow)
         {
             int     n  = rowIndex + 1;
             NodeRow nr = new NodeRow(n);
             Rows.Add(nr);
         }
         Rows[rowIndex].Add(id);
     }
 }
예제 #16
0
 static void validateRole(Rbr_Db_Base pDb, NodeRow pNodeRow)
 {
     if (pNodeRow.NodeRole == NodeRole.Admin)
     {
         var _siteNodes = pDb.NodeCollection.GetByPlatform_id(pNodeRow.Platform_id);
         foreach (var _node in _siteNodes)
         {
             if (_node.NodeRole == NodeRole.Admin)
             {
                 throw new ApplicationException("Error: Only one node per Platform can have role: Admin");
             }
         }
     }
 }
예제 #17
0
        private SubscriberVolumeRow createVolume()
        {
            var gVol   = NodeRow.GenerateNewNodeRowGDID(); // NOTICE: Volume uses Node Row GDID (Briefcase key)
            var result = new SubscriberVolumeRow()
            {
                G_Owner            = G_Owner,
                G_SubscriberVolume = gVol,
                Create_Date        = App.TimeSource.UTCNow,
                Count = 0
            };

            ForNode(G_Owner).Insert(result);
            return(result);
        }
예제 #18
0
        //------------------------------- Private ----------------------------------------------
        void init(NodeRow pNodeRow, int pIPAddress)
        {
            if (pNodeRow == null)
            {
                throw new Exception("Node: " + IPUtil.ToString(pIPAddress) + " NOT FOUND");
            }
            nodeRow = pNodeRow;

            //-- get site
            using (var _db = new Rbr_Db()) {
                platformRow = _db.PlatformCollection.GetByPrimaryKey(nodeRow.Platform_id);
            }
            if (platformRow == null)
            {
                throw new Exception("Site: " + nodeRow.Platform_id + " NOT FOUND");
            }
        }
예제 #19
0
        /// <summary>
        /// Adds a new record into the <c>Node</c> table.
        /// </summary>
        /// <param name="value">The <see cref="NodeRow"/> object to be inserted.</param>
        public virtual void Insert(NodeRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[Node] (" +
                            "[node_id], " +
                            "[platform_id], " +
                            "[description], " +
                            "[node_config], " +
                            "[transport_type], " +
                            "[user_name], " +
                            "[password], " +
                            "[ip_address], " +
                            "[port], " +
                            "[status], " +
                            "[billing_export_frequency], " +
                            "[cdr_publishing_frequency]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Node_id") + ", " +
                            _db.CreateSqlParameterName("Platform_id") + ", " +
                            _db.CreateSqlParameterName("Description") + ", " +
                            _db.CreateSqlParameterName("Node_config") + ", " +
                            _db.CreateSqlParameterName("Transport_type") + ", " +
                            _db.CreateSqlParameterName("User_name") + ", " +
                            _db.CreateSqlParameterName("Password") + ", " +
                            _db.CreateSqlParameterName("Ip_address") + ", " +
                            _db.CreateSqlParameterName("Port") + ", " +
                            _db.CreateSqlParameterName("Status") + ", " +
                            _db.CreateSqlParameterName("Billing_export_frequency") + ", " +
                            _db.CreateSqlParameterName("Cdr_publishing_frequency") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Node_id", value.Node_id);
            AddParameter(cmd, "Platform_id", value.Platform_id);
            AddParameter(cmd, "Description", value.Description);
            AddParameter(cmd, "Node_config", value.Node_config);
            AddParameter(cmd, "Transport_type", value.Transport_type);
            AddParameter(cmd, "User_name", value.User_name);
            AddParameter(cmd, "Password", value.Password);
            AddParameter(cmd, "Ip_address", value.Ip_address);
            AddParameter(cmd, "Port", value.Port);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Billing_export_frequency", value.Billing_export_frequency);
            AddParameter(cmd, "Cdr_publishing_frequency", value.Cdr_publishing_frequency);
            cmd.ExecuteNonQuery();
        }
예제 #20
0
            public NodeRow AddNodeRow(string ID, string Flag, string Radius, string Entity, string Team, string Group, string Connection1, string Connection2, string Connection3, string Connection4)
            {
                NodeRow rowNodeRow = ((NodeRow)(this.NewRow()));

                rowNodeRow.ItemArray = new object[] {
                    ID,
                    Flag,
                    Radius,
                    Entity,
                    Team,
                    Group,
                    Connection1,
                    Connection2,
                    Connection3,
                    Connection4
                };
                this.Rows.Add(rowNodeRow);
                return(rowNodeRow);
            }
예제 #21
0
        /// <summary>
        /// Get existing not full Comment Volume or create a new one
        /// </summary>
        /// <param name="ctxNode">TargetNode context</param>
        /// <param name="gTargetNode">TargetNode GDID</param>
        /// <param name="dimension">Scope of comment</param>
        /// <returns>Existing or new volume</returns>
        private CommentVolumeRow getEmptyVolume(GDID gTargetNode, string dimension, CRUDOperations?ctxNode = null)
        {
            var ctx       = ctxNode ?? ForNode(gTargetNode);
            var qryVolume = Queries.FindEmptyCommentVolume <CommentVolumeRow>(gTargetNode, dimension, MaxSizeCommentVolume);
            var volume    = ctxNode.LoadRow(qryVolume);

            if (volume == null)
            {
                volume = new CommentVolumeRow
                {
                    G_Owner         = gTargetNode,
                    G_CommentVolume = NodeRow.GenerateNewNodeRowGDID(),
                    Dimension       = dimension,
                    Count           = 0,
                    Create_Date     = App.TimeSource.UTCNow
                };
                ctx.Insert(volume);
            }
            return(volume);
        }
예제 #22
0
            internal static void CreateCurrentNode(Rbr_Db pDb, short pPlatformId)
            {
                //add DEFAULT NODE  - GuiHost and SoftSwitch
                var _nodeRow = new NodeRow
                {
                    Platform_id = pPlatformId,
                    NodeRole    = NodeRole.H323
                };

                _nodeRow.Description              = _nodeRow.NodeRole.ToString();
                _nodeRow.Transport_type           = (byte)TransportType.Ftp;
                _nodeRow.User_name                = Configuration.Instance.Main.HostName;
                _nodeRow.Password                 = Configuration.Instance.Main.HostIP;
                _nodeRow.Ip_address               = IPUtil.ToInt32(Configuration.Instance.Main.HostIP);
                _nodeRow.Port                     = 21;
                _nodeRow.Status                   = (byte)Status.Active;
                _nodeRow.Billing_export_frequency = 0;
                _nodeRow.Cdr_publishing_frequency = 0;

                pDb.NodeCollection.Insert(_nodeRow);
            }
예제 #23
0
            public NodeRow AddNodeRow(string ID, string Flag, string Radius, string Entity, string Team, string Group, string Connection1, string Connection2, string Connection3, string Connection4, string PositionX, string PositionY, string PositionZ)
            {
                NodeRow rowNodeRow = ((NodeRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    ID,
                    Flag,
                    Radius,
                    Entity,
                    Team,
                    Group,
                    Connection1,
                    Connection2,
                    Connection3,
                    Connection4,
                    PositionX,
                    PositionY,
                    PositionZ
                };
                rowNodeRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowNodeRow);
                return(rowNodeRow);
            }
예제 #24
0
 public void AddNodeRow(NodeRow row)
 {
     this.Rows.Add(row);
 }
예제 #25
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="NodeRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="NodeRow"/> object.</returns>
        protected virtual NodeRow MapRow(DataRow row)
        {
            NodeRow    mappedObject = new NodeRow();
            DataTable  dataTable    = row.Table;
            DataColumn dataColumn;

            // Column "Node_id"
            dataColumn = dataTable.Columns["Node_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Node_id = (short)row[dataColumn];
            }
            // Column "Platform_id"
            dataColumn = dataTable.Columns["Platform_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Platform_id = (short)row[dataColumn];
            }
            // Column "Description"
            dataColumn = dataTable.Columns["Description"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Description = (string)row[dataColumn];
            }
            // Column "Node_config"
            dataColumn = dataTable.Columns["Node_config"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Node_config = (int)row[dataColumn];
            }
            // Column "Transport_type"
            dataColumn = dataTable.Columns["Transport_type"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Transport_type = (byte)row[dataColumn];
            }
            // Column "User_name"
            dataColumn = dataTable.Columns["User_name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.User_name = (string)row[dataColumn];
            }
            // Column "Password"
            dataColumn = dataTable.Columns["Password"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Password = (string)row[dataColumn];
            }
            // Column "Ip_address"
            dataColumn = dataTable.Columns["Ip_address"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Ip_address = (int)row[dataColumn];
            }
            // Column "Port"
            dataColumn = dataTable.Columns["Port"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Port = (int)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (byte)row[dataColumn];
            }
            // Column "Billing_export_frequency"
            dataColumn = dataTable.Columns["Billing_export_frequency"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Billing_export_frequency = (int)row[dataColumn];
            }
            // Column "Cdr_publishing_frequency"
            dataColumn = dataTable.Columns["Cdr_publishing_frequency"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Cdr_publishing_frequency = (int)row[dataColumn];
            }
            return(mappedObject);
        }
예제 #26
0
파일: Nodes.cs 프로젝트: fishxz/omni-bot
 public NodeRowChangeEvent(NodeRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
예제 #27
0
 /// <summary>
 /// Deletes the specified object from the <c>Node</c> table.
 /// </summary>
 /// <param name="value">The <see cref="NodeRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(NodeRow value)
 {
     return(DeleteByPrimaryKey(value.Node_id));
 }
예제 #28
0
        public RollNodeView(Row row)
        {
            this.row = row;
            nodeData = row.Components.Get <NodeRow>();
            label    = new ThemedSimpleText {
                ForceUncutText = false,
                VAlignment     = VAlignment.Center,
                OverflowMode   = TextOverflowMode.Ellipsis,
                LayoutCell     = new LayoutCell(Alignment.LeftCenter, float.MaxValue)
            };
            editBoxContainer = new Widget {
                Visible    = false,
                Layout     = new HBoxLayout(),
                LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue),
            };
            nodeIcon = new Image(NodeIconPool.GetTexture(nodeData.Node.GetType()))
            {
                HitTestTarget = true,
                MinMaxSize    = new Vector2(21, 16),
                Padding       = new Thickness {
                    Left = 5
                }
            };
            expandButton = CreateExpandButton();
            var expandButtonContainer = new Widget {
                Layout = new StackLayout {
                    IgnoreHidden = false
                },
                LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0),
                Nodes      = { expandButton }
            };

            expandButtonContainer.CompoundPresenter.Add(new SyncDelegatePresenter <Widget>(widget => {
                widget.PrepareRendererState();
                var a          = new Vector2(0, -4);
                var b          = widget.Size + new Vector2(0, 3);
                int colorIndex = nodeData.Node.EditorState().ColorIndex;
                Renderer.DrawRect(a, b, ColorMarks[colorIndex]);
                if (colorIndex != 0)
                {
                    Renderer.DrawRectOutline(a, b, ColorTheme.Current.TimelineRoll.Lines);
                }
            }));
            expandButtonContainer.Updating += delta => {
                bool visible = false;
                foreach (var a in nodeData.Node.Animators)
                {
                    if (!a.IsZombie && a.AnimationId == Document.Current.AnimationId)
                    {
                        visible = true;
                        break;
                    }
                }
                expandButton.Visible = visible;
            };
            enterButton         = NodeCompositionValidator.CanHaveChildren(nodeData.Node.GetType()) ? CreateEnterButton() : null;
            eyeButton           = CreateEyeButton();
            lockButton          = CreateLockButton();
            lockAnimationButton = CreateLockAnimationButton();
            widget = new Widget {
                HitTestTarget = true,
                Padding       = new Thickness {
                    Right = 2
                },
                MinHeight = TimelineMetrics.DefaultRowHeight,
                Layout    = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center)
                },
                Nodes =
                {
                    expandButtonContainer,
                    (indentSpacer = new Widget()),
                    nodeIcon,
                    Spacer.HSpacer(3),
                    label,
                    editBoxContainer,
                    linkIndicatorButtonContainer,
                    (Widget)enterButton ?? (Widget)Spacer.HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X),
                    lockAnimationButton,
                    eyeButton,
                    lockButton,
                },
            };
            widget.Components.Add(new AwakeBehavior());
            label.AddChangeWatcher(() => nodeData.Node.Id, s => RefreshLabel());
            label.AddChangeWatcher(() => IsGrayedLabel(nodeData.Node), s => RefreshLabel());
            label.AddChangeWatcher(() => nodeData.Node.ContentsPath, s => RefreshLabel());
            widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground));
            nodeIdEditor        = new ObjectIdInplaceEditor(row, nodeData.Node, label, editBoxContainer);
            label.HitTestTarget = true;
            label.Gestures.Add(new DoubleClickGesture(() => {
                Document.Current.History.DoTransaction(() => {
                    if (NodeData.Node.EditorState().Locked)
                    {
                        return;
                    }
                    var labelExtent = label.MeasureUncutText();
                    if (label.LocalMousePosition().X < labelExtent.X)
                    {
                        nodeIdEditor.Rename();
                    }
                    else
                    {
                        EnterNode.Perform(nodeData.Node);
                    }
                });
            }));
            widget.Gestures.Add(new ClickGesture(1, ShowContextMenu));
        }
예제 #29
0
        public void GenerateNodeConnections(NodeRow nextRow)
        {
            //[Mandatory Links]
            //Top to Top
            nodes[0].AddExitLink(0);

            //Bottom to Bottom
            nodes[nodes.Count - 1].AddExitLink(nextRow.Nodes.Count - 1);

            if (nodes.Count == 3)
            {
                //3:2 middle requires exit
                if (nextRow.Nodes.Count == 2)
                {
                    int chosen_exit = UnityEngine.Random.Range(0, 2);
                    nodes[1].AddExitLink(chosen_exit);
                }
                //3:3 middle requires exit
                else if (nextRow.Nodes.Count == 3)
                {
                    int chosen_exit = UnityEngine.Random.Range(0, 3);
                    nodes[1].AddExitLink(chosen_exit);

                    //3:3 middle requires path (but no crossing)
                    if (chosen_exit == 0)
                    {
                        nodes[2].AddExitLink(1);
                    }
                    else if (chosen_exit == 2)
                    {
                        nodes[0].AddExitLink(1);
                    }
                }
            }
            else if (nodes.Count == 2)
            {
                //2:3 middle requires path
                if (nextRow.Nodes.Count == 3)
                {
                    int chosen_node = UnityEngine.Random.Range(0, 2);
                    nodes[chosen_node].AddExitLink(1);
                }
            }

            //[Optional Links]
            if (nodes.Count == 2)
            {
                //2:2 Chance for one path
                if (nextRow.Nodes.Count == 2)
                {
                    if (UnityEngine.Random.Range(0, 100) < EXTRA_NODE_EXIT_CHANCE)
                    {
                        int chosen_node = UnityEngine.Random.Range(0, 2);
                        nodes[chosen_node].AddExitLink(UnityEngine.Random.Range(0, 2));
                    }
                }
                //2:3 Chance for one/two path
                else if (nextRow.Nodes.Count == 3)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (UnityEngine.Random.Range(0, 100) < EXTRA_NODE_EXIT_CHANCE)
                        {
                            nodes[i].AddExitLink(1);
                        }
                    }
                }
            }
            else if (nodes.Count == 3)
            {
                if (nextRow.Nodes.Count == 2)
                {
                    //3:2 Chance for second path from middle
                    if (UnityEngine.Random.Range(0, 100) < EXTRA_NODE_EXIT_CHANCE)
                    {
                        if (nodes[1].ExitLinks.Count == 1)
                        {
                            nodes[1].AddExitLink(nodes[1].ExitLinks[0] == 0 ? 1 : 0);
                        }
                    }
                }
                else if (nextRow.Nodes.Count == 3)
                {
                    //3:3 Chance for extra paths from each node (no crossing)
                    List <int> drawOrder = new List <int> {
                        0, 1, 2
                    };
                    while (drawOrder.Count > 0)
                    {
                        int randomDraw = UnityEngine.Random.Range(0, drawOrder.Count);
                        if (drawOrder[randomDraw] == 0)
                        {
                            DrawOptionalFromTop();
                        }
                        else if (drawOrder[randomDraw] == 1)
                        {
                            DrawOptionalFromMiddle();
                        }
                        else if (drawOrder[randomDraw] == 2)
                        {
                            DrawOptionalFromBottom();
                        }
                        drawOrder.Remove(drawOrder[randomDraw]);
                    }
                }
            }
        }
예제 #30
0
파일: Nodes.cs 프로젝트: fishxz/omni-bot
 public void RemoveNodeRow(NodeRow row)
 {
     this.Rows.Remove(row);
 }
예제 #31
0
 public void RemoveNodeRow(NodeRow row)
 {
     this.Rows.Remove(row);
 }
예제 #32
0
 public NodeRowChangeEvent(NodeRow row, DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
예제 #33
0
파일: Nodes.cs 프로젝트: fishxz/omni-bot
 public void AddNodeRow(NodeRow row)
 {
     this.Rows.Add(row);
 }