示例#1
0
        private void HilightInputAnchorOffByName(string name)
        {
            var anchor = GetElementByName(name);

            if (anchor == null)
            {
                return;
            }

            var inputColor = ConnectionsFrom.SingleOrDefault(c => c.RightAnchorName == name)?.Left?.CustomColor ?? InputBackground;

            // set anchor color
            (anchor as Rectangle).Fill = new SolidColorBrush(inputColor);

            var label = GetElementByName((anchor as Rectangle).Name.Replace(InputAnchorPrefix, LabelPrefix)) as Label;

            if (label != null)
            {
                label.Foreground = new SolidColorBrush(TextForeground);
            }

            // set connection color
            var connection = ConnectionsFrom.SingleOrDefault(c => c.RightAnchorName == name);

            if (connection != null)
            {
                connection.Hilight(inputColor);
            }

            Cursor = Cursors.Arrow;
        }
示例#2
0
        /// <summary>
        /// resets input anchor background color based on connection
        /// </summary>
        /// <param name="name"></param>
        public void ResetInputAnchorColor(string name)
        {
            var anchor = GetElementByName(name);

            if (anchor == null)
            {
                return;
            }

            var inputColor = ConnectionsFrom.SingleOrDefault(c => c.RightAnchorName == name)?.Left?.CustomColor ?? InputBackground;

            // set anchor color
            (anchor as Rectangle).Fill = new SolidColorBrush(inputColor);
        }
示例#3
0
        protected void HilightInputAnchorOn(object sender, MouseEventArgs e)
        {
            var anchorName = (sender as FrameworkElement).Name;
            var connection = ConnectionsFrom.SingleOrDefault(c => c.RightAnchorName == anchorName);

            // allow hilight only if connection is in progress and rightAnchor is valid, or if no connection is in progress and right anchor is not empty
            if ((Workspace.NewConnection != null && Workspace.CheckConnectionInProgress(this, anchorName)) || Workspace.NewConnection == null && connection != null)
            {
                (sender as Rectangle).Fill = new SolidColorBrush(Colors.White);

                var label = GetElementByName((sender as Rectangle).Name.Replace(InputAnchorPrefix, LabelPrefix)) as Label;
                if (label != null)
                {
                    label.Foreground = new SolidColorBrush(Colors.White);
                }

                if (connection != null)
                {
                    connection.Hilight(Colors.White);
                }

                Cursor = Cursors.Hand;
            }
        }