Example #1
0
        void DrawConnections(ConnectionStyle style)
        {
            var drawer = ConnectionStyleDrawers[style];

            foreach (GraphNode parent in AllNodes)
            {
                foreach (Connection child in parent.connectedTo)
                {
                    ConnectionDrawInfo info;
                    parent.GetConnectionDrawData(child, out info);
                    {
                        LastConnectionData.from       = info.@from + PannedOffset;
                        LastConnectionData.fromOrigin = new Vector2((parent.DrawRect.center + PannedOffset).x, LastConnectionData.from.y);
                        LastConnectionData.to         = info.to + PannedOffset;
                        LastConnectionData.toOrigin   = new Vector2((child.Target.Owner.DrawRect.center + PannedOffset).x, LastConnectionData.to.y);
                        LastConnectionData.color      = info.color;

                        drawer(LastConnectionData);
                    }
                }
            }
        }
Example #2
0
        public void Draw(
            EditorWindow editor, Rect viewRect,
            ConnectionStyle style = ConnectionStyle.Smooth
            )
        {
            DrawRect            = viewRect;
            ConnectionLineStyle = style;

            EditorAreaUtils.BeginZoomArea(ZoomLevel, viewRect);
            {
                try
                {
                    DrawWindows(editor);
                    DrawConnections(style);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
            EditorAreaUtils.EndZoomArea();
        }
        void DrawConnections(ConnectionStyle style)
        {
            var drawer = ConnectionStyleDrawers[style];

            foreach (GraphNode parent in AllNodes)
            {
                foreach (GraphNode.ConnectionInfo child in parent.connectedTo)
                {
                    ChildNodePositionsBuffer.Clear();
                    parent.GetChildConnectPositions(child.Node, ChildNodePositionsBuffer);
                    foreach (Vector2 position in ChildNodePositionsBuffer)
                    {
                        LastConnectionData.fromOrigin = parent.Position + PannedOffset;
                        LastConnectionData.from       = position + PannedOffset;
                        LastConnectionData.toOrigin   = child.Node.Position + PannedOffset;
                        LastConnectionData.to         = child.Node.GetParentConnectPosition(child.Node) + PannedOffset;
                        LastConnectionData.color      = child.Node.GetParentConnectColor(parent);

                        drawer(LastConnectionData);
                    }
                }
            }
        }
Example #4
0
            public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle)
            {
                Source = source;
                Target = target;
                VisualCompassPoint = visualCompassPoint;
                Conditional = connectionStyle == ConnectionStyle.Dashed;

                assignPrimaryPriority();
                assignSecondaryDirection(connectionText);
                if (SecondaryDirection != null)
                  PrimaryDirection = (AutomapDirection)SecondaryDirection;
                else
                  assignPrimaryDirection();
            }
Example #5
0
        /*
        public Connection(SqlServerType server_type,
            string strConnectionString)
        {
            this.SqlServerType = server_type;
            if (server_type == rms.SqlServerType.MsSqlServer)
                this.m_connection = new SqlConnection(strConnectionString);
            else if (server_type == rms.SqlServerType.SQLite)
                this.m_connection = new SQLiteConnection(strConnectionString);
            else
            {
                throw new Exception("不支持的类型 " + server_type.ToString());
            }
        }
         * */

        public Connection(SqlDatabase database,
            string strConnectionString,
            ConnectionStyle style = ConnectionStyle.None)
        {
            this.SqlDatabase = database;
            this.SqlServerType = database.container.SqlServerType;

            if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut)
                this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut;

            if (this.SqlServerType == rms.SqlServerType.MsSqlServer)
                this.m_connection = new SqlConnection(strConnectionString);
            else if (this.SqlServerType == rms.SqlServerType.SQLite)
            {
#if NO
                // SQLite 专用, 快速的, 全局共用的
                if ((style & ConnectionStyle.Global) == ConnectionStyle.Global)
                {
                    Debug.Assert(this.SqlDatabase.SQLiteInfo != null, "");

                    lock (this.SqlDatabase.SQLiteInfo)
                    {
                        if (this.SqlDatabase.SQLiteInfo.FastMode == false)
                        {
                            this.m_connection = new SQLiteConnection(strConnectionString);
                            return;
                        }

                        if (this.SqlDatabase.SQLiteInfo.m_connection == null)
                        {
                            this.m_connection = new SQLiteConnection(strConnectionString);
                            this.m_bGlobal = true;
                            this.SqlDatabase.SQLiteInfo.m_connection = this;
                        }
                        else
                        {
                            // 复制成员
                            this.Clone(this.SqlDatabase.SQLiteInfo.m_connection);
                            if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut)
                                this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut;
                        }
                    }
                    return;
                }
#endif
                if ((style & ConnectionStyle.Global) == ConnectionStyle.Global)
                {
                    this.m_bGlobal = true;
                }
                this.m_connection = new SQLiteConnection(strConnectionString);
            }
            else if (this.SqlServerType == rms.SqlServerType.MySql)
                this.m_connection = new MySqlConnection(strConnectionString);
            else if (this.SqlServerType == rms.SqlServerType.Oracle)
                this.m_connection = new OracleConnection(strConnectionString);
            else
            {
                throw new Exception("不支持的类型 " + this.SqlServerType.ToString());
            }
        }
Example #6
0
        public void SetConnectionStyle(ConnectionStyle style)
        {
            var controller = new CanvasController();

            controller.SetConnectionStyle(style);
        }
Example #7
0
            public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle)
            {
                Source             = source;
                Target             = target;
                VisualCompassPoint = visualCompassPoint;
                Conditional        = connectionStyle == ConnectionStyle.Dashed;

                assignPrimaryPriority();
                assignSecondaryDirection(connectionText);
                if (SecondaryDirection != null)
                {
                    PrimaryDirection = (AutomapDirection)SecondaryDirection;
                }
                else
                {
                    assignPrimaryDirection();
                }
            }
Example #8
0
        void DrawConnections(ConnectionStyle style)
        {
            switch (style)
            {
            case ConnectionStyle.Line:
                foreach (GraphNode parent in nodes)
                {
                    foreach (GraphNode.ConnectionInfo child in parent.connectedTo)
                    {
                        DrawNodeConnectionLine(
                            parent.GetChildConnectPosition(child.Node),
                            child.Node.GetParentConnectPosition(parent),
                            child.Node.GetParentConnectColor(parent)
                            );
                    }
                }
                break;

            case ConnectionStyle.BezierHorizontal:
                foreach (GraphNode parent in nodes)
                {
                    foreach (GraphNode.ConnectionInfo child in parent.connectedTo)
                    {
                        DrawNodeConnectionBezierHorizontal(
                            parent.GetChildConnectPosition(child.Node),
                            child.Node.GetParentConnectPosition(child.Node),
                            child.Node.GetParentConnectColor(parent)
                            );
                    }
                }
                break;

            case ConnectionStyle.BezierVertical:
                foreach (GraphNode parent in nodes)
                {
                    foreach (GraphNode.ConnectionInfo child in parent.connectedTo)
                    {
                        DrawNodeConnectionBezierVertical(
                            parent.GetChildConnectPosition(child.Node),
                            child.Node.GetParentConnectPosition(child.Node),
                            child.Node.GetParentConnectColor(parent)
                            );
                    }
                }
                break;
            }

            bool goodEvent = Event.current.type == EventType.Repaint || Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag;

            if (goodEvent && IsConnecting && GraphNode.selected != null)
            {
                switch (style)
                {
                case ConnectionStyle.Line:
                    DrawNodeConnectionLine(CurrentConnectionStart, Event.current.mousePosition, Color.cyan);
                    break;

                case ConnectionStyle.BezierHorizontal:
                    DrawNodeConnectionBezierHorizontal(CurrentConnectionStart, Event.current.mousePosition, Color.cyan);
                    break;

                case ConnectionStyle.BezierVertical:
                    DrawNodeConnectionBezierVertical(CurrentConnectionStart, Event.current.mousePosition, Color.cyan);
                    break;
                }

                if (Event.current.type != EventType.Repaint)
                {
                    Event.current.Use();
                }

                GUI.color = Color.white;
            }
        }
Example #9
0
        public void SetConnectionStyle(ConnectionStyle style)
        {
            var elements = canvas.SelectedConnections;

            setConnectionStyle(elements, style);
        }
Example #10
0
 private void setConnectionStyle(List <Connection> connections, ConnectionStyle style)
 {
     connections.ForEach(p => p.Style = style);
     canvas.NewConnectionStyle        = style;
 }
            public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle)
            {
                Source             = source;
                Target             = target;
                VisualCompassPoint = visualCompassPoint;
                Conditional        = connectionStyle == ConnectionStyle.Dashed;

                AssignPrimaryPriority();
                AssignPrimaryDirection();
                AssignSecondaryDirection(connectionText);
            }
Example #12
0
        /*
         * public Connection(SqlServerType server_type,
         *  string strConnectionString)
         * {
         *  this.SqlServerType = server_type;
         *  if (server_type == rms.SqlServerType.MsSqlServer)
         *      this.m_connection = new SqlConnection(strConnectionString);
         *  else if (server_type == rms.SqlServerType.SQLite)
         *      this.m_connection = new SQLiteConnection(strConnectionString);
         *  else
         *  {
         *      throw new Exception("不支持的类型 " + server_type.ToString());
         *  }
         * }
         * */

        public Connection(SqlDatabase database,
                          string strConnectionString,
                          ConnectionStyle style = ConnectionStyle.None)
        {
            this.SqlDatabase   = database;
            this.SqlServerType = database.container.SqlServerType;

            if (this._nLockTimeout < this.SqlDatabase.m_nTimeOut)
            {
                this._nLockTimeout = this.SqlDatabase.m_nTimeOut;
            }

            if (this.SqlServerType == rms.SqlServerType.MsSqlServer)
            {
                this._connection = new SqlConnection(strConnectionString);
            }
            else if (this.SqlServerType == rms.SqlServerType.SQLite)
            {
#if NO
                // SQLite 专用, 快速的, 全局共用的
                if ((style & ConnectionStyle.Global) == ConnectionStyle.Global)
                {
                    Debug.Assert(this.SqlDatabase.SQLiteInfo != null, "");

                    lock (this.SqlDatabase.SQLiteInfo)
                    {
                        if (this.SqlDatabase.SQLiteInfo.FastMode == false)
                        {
                            this.m_connection = new SQLiteConnection(strConnectionString);
                            return;
                        }

                        if (this.SqlDatabase.SQLiteInfo.m_connection == null)
                        {
                            this.m_connection = new SQLiteConnection(strConnectionString);
                            this.m_bGlobal    = true;
                            this.SqlDatabase.SQLiteInfo.m_connection = this;
                        }
                        else
                        {
                            // 复制成员
                            this.Clone(this.SqlDatabase.SQLiteInfo.m_connection);
                            if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut)
                            {
                                this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut;
                            }
                        }
                    }
                    return;
                }
#endif
                if ((style & ConnectionStyle.Global) == ConnectionStyle.Global)
                {
                    this._bGlobal = true;
                }
                this._connection = new SQLiteConnection(strConnectionString);
            }
            else if (this.SqlServerType == rms.SqlServerType.MySql)
            {
                this._connection = new MySqlConnection(strConnectionString);
            }
            else if (this.SqlServerType == rms.SqlServerType.Oracle)
            {
                this._connection = new OracleConnection(strConnectionString);
            }
            else
            {
                throw new Exception("不支持的类型 " + this.SqlServerType.ToString());
            }
        }
Example #13
0
            public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle)
            {
                Source = source;
                Target = target;
                VisualCompassPoint = visualCompassPoint;
                Conditional = connectionStyle == ConnectionStyle.Dashed;

                AssignPrimaryPriority();
                AssignPrimaryDirection();
                AssignSecondaryDirection(connectionText);
            }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="nodeEditor">Node editor to work on</param>
 /// <param name="priority">When this mode should be processed relative
 /// to other input modes. Lower number == processed first</param>
 public ConnectNodeInputMode(NodeEditor nodeEditor, int priority = 0)
     : base(nodeEditor, priority)
 {
     ConnectionLogic = ConnectionStyle.MULTIPLE;
 }