public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint)
     : base(designerCanvas)
 {
     this.designerCanvas = designerCanvas;
     this.startPoint = dragStartPoint;
     rubberbandPen = new Pen(Brushes.LightSlateGray, 1);
     rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
 }
 public ConnectorAdorner(DesignerCanvas designer, Connector sourceConnector)
     : base(designer)
 {
     this.designerCanvas = designer;
     this.sourceConnector = sourceConnector;
     drawingPen = new Pen(Brushes.LightSlateGray, 1);
     drawingPen.LineJoin = PenLineJoin.Round;
     this.Cursor = Cursors.Cross;
 }
        public static void GenerateDialPlan(DesignerCanvas d)
        {

            
                StartActivity s = null;
                Connection position = null;
                DialPlanList.Clear();

                IEnumerable<Connection> connections = d.Children.OfType<Connection>();
                IEnumerable<DesignerItem> designerItems = d.Children.OfType<DesignerItem>();

                //Busco Actividad inicial para arrancar por ella
                //Obtengo contexto y DNIS de ella
                foreach (Connection item in connections)
                {
                    if (item.Source.ParentDesignerItem.Activity.AppName == "StartActivity")
                    {
                        position = item;
                        s = (StartActivity)item.Source.ParentDesignerItem.Activity;
                        DNIS = s.exten;
                        Context = s.context;
                        DialPlanList.Add(item.Source.ParentDesignerItem.Activity);
                    }
                }


                BuildPlanLines(position, d);

          
            //pongo used en falso para permitir una nueva recorrida de 0
            foreach (DesignerItem item in designerItems)
            {
                Connection c = new Connection(null,null);

                if (item.GetType() != c.GetType())
                item.Activity.Used = false;
            }

            Dialplan = "";
            foreach (var item in DialPlanList)
            {
                if (item.prio != 0 && item.AppName != "include")
                {
                    Dialplan = Dialplan + "exten=> " + DNIS + "," + item.prio + "," + item.ToString() + "\n";
                }
                else if (item.AppName == "include")
                {
                    Dialplan = Dialplan + item.ToString() + "\n";
                }

            }
         

        }
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            DesignerCanvas canvas = GetDesignerCanvas(this);

            if (canvas != null)
            {
                // position relative to DesignerCanvas
                this.dragStartPoint = new Point?(e.GetPosition(canvas));
                e.Handled           = true;
            }
        }
        private static void BuildPlanLines(Connection position, DesignerCanvas d)
        {
            Connection nextposition;

            if (position != null)
            {
                if (!position.Sink.ParentDesignerItem.Activity.Used)
                {
                    Guid actual = position.Sink.ParentDesignerItem.ID;
                    position.Sink.ParentDesignerItem.Activity.Used = true;


                    DialPlanList.Add(position.Sink.ParentDesignerItem.Activity);
                    position.Sink.ParentDesignerItem.Activity.prio = DialPlanList.Count - 1;


                    //si es una actividad sin condicional
                    if (position.Sink.ParentDesignerItem.Activity.MaxConectors == 1)
                    {
                        nextposition = GetNextDefault(d, actual);
                        BuildPlanLines(nextposition, d);
                    }
                    else
                    {
                        nextposition = GetNextNotDefault(d, actual);
                        if (nextposition != null)
                        {
                            BuildPlanLines(nextposition, d);
                            position.Sink.ParentDesignerItem.Activity.AlternativePath = nextposition.Sink.ParentDesignerItem.Activity.prio;
                        }

                        nextposition = GetNextDefault(d, actual);
                        if (nextposition != null)
                        {
                            BuildPlanLines(nextposition, d);
                            position.Sink.ParentDesignerItem.Activity.DefaultPath = nextposition.Sink.ParentDesignerItem.Activity.prio;
                        }
                    }
                }

                //si ya estaba usada la actividad a la que voy y la actual no es condicional o sea no puede saltar sola
                else if (position.Sink.ParentDesignerItem.Activity.Used && position.Source.ParentDesignerItem.Activity.MaxConectors == 1)
                {
                    Goto g = new Goto();
                    g.prio      = DialPlanList.Count;
                    g.extension = "${EXTEN}";
                    g.context   = Context;
                    g.pri       = position.Sink.ParentDesignerItem.Activity.prio;
                    DialPlanList.Add(g);
                }
            }
        }
Exemple #6
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;

            if (dragObject != null && !String.IsNullOrEmpty(dragObject.Xaml))
            {
                DesignerItem newItem = null;
                Image        content = (Image)XamlReader.Load(XmlReader.Create(new StringReader(dragObject.Xaml)));

                if (content != null)
                {
                    newItem         = new DesignerItem();
                    newItem.Content = content;

                    Assembly  a   = Assembly.GetAssembly(typeof(IActivity));
                    Type      t   = a.GetType("IntegraDesigner." + content.Tag);
                    IActivity act = (IActivity)Activator.CreateInstance(t);
                    act.AppName      = content.Tag.ToString();
                    newItem.Activity = act;
                    ToolTipService.SetToolTip(newItem, act.AppName + ": " + act.Description);


                    Point position = e.GetPosition(this);

                    if (dragObject.DesiredSize.HasValue)
                    {
                        Size desiredSize = dragObject.DesiredSize.Value;
                        newItem.Width  = desiredSize.Width;
                        newItem.Height = desiredSize.Height;

                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
                    }
                    else
                    {
                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y));
                    }

                    Canvas.SetZIndex(newItem, this.Children.Count);
                    this.Children.Add(newItem);
                    SetConnectorDecoratorTemplate(newItem);

                    //update selection
                    this.SelectionService.SelectItem(newItem);
                    newItem.Focus();
                }

                e.Handled = true;
            }
        }
        public static void GenerateDialPlan(DesignerCanvas d)
        {
            StartActivity s        = null;
            Connection    position = null;

            DialPlanList.Clear();

            IEnumerable <Connection>   connections   = d.Children.OfType <Connection>();
            IEnumerable <DesignerItem> designerItems = d.Children.OfType <DesignerItem>();

            //Busco Actividad inicial para arrancar por ella
            //Obtengo contexto y DNIS de ella
            foreach (Connection item in connections)
            {
                if (item.Source.ParentDesignerItem.Activity.AppName == "StartActivity")
                {
                    position = item;
                    s        = (StartActivity)item.Source.ParentDesignerItem.Activity;
                    DNIS     = s.exten;
                    Context  = s.context;
                    DialPlanList.Add(item.Source.ParentDesignerItem.Activity);
                }
            }


            BuildPlanLines(position, d);


            //pongo used en falso para permitir una nueva recorrida de 0
            foreach (DesignerItem item in designerItems)
            {
                Connection c = new Connection(null, null);

                if (item.GetType() != c.GetType())
                {
                    item.Activity.Used = false;
                }
            }

            Dialplan = "";
            foreach (var item in DialPlanList)
            {
                if (item.prio != 0 && item.AppName != "include")
                {
                    Dialplan = Dialplan + "exten=> " + DNIS + "," + item.prio + "," + item.ToString() + "\n";
                }
                else if (item.AppName == "include")
                {
                    Dialplan = Dialplan + item.ToString() + "\n";
                }
            }
        }
        private static Connection GetNextNotDefault(DesignerCanvas d, Guid actual)
        {
            IEnumerable <Connection> connections = d.Children.OfType <Connection>();

            foreach (Connection item in connections)
            {
                if (item.Source.ParentDesignerItem.ID == actual && !item.DefaultPath)
                {
                    return(item);
                }
            }

            return(null);
        }
        private void ShowAdorner()
        {
            // the ConnectionAdorner is created once for each Connection
            if (this.connectionAdorner == null)
            {
                DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas;

                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
                if (adornerLayer != null)
                {
                    this.connectionAdorner = new ConnectionAdorner(designer, this);
                    adornerLayer.Add(this.connectionAdorner);
                }
            }
        }
Exemple #10
0
        public ConnectionAdorner(DesignerCanvas designer, Connection connection)
            : base(designer)
        {
            this.designerCanvas = designer;
            adornerCanvas       = new Canvas();
            this.visualChildren = new VisualCollection(this);
            this.visualChildren.Add(adornerCanvas);

            this.connection = connection;
            this.connection.PropertyChanged += new PropertyChangedEventHandler(AnchorPositionChanged);

            InitializeDragThumbs();

            drawingPen          = new Pen(Brushes.LightSlateGray, 1);
            drawingPen.LineJoin = PenLineJoin.Round;

            base.Unloaded += new RoutedEventHandler(ConnectionAdorner_Unloaded);
        }
        public ConnectionAdorner(DesignerCanvas designer, Connection connection)
            : base(designer)
        {
            this.designerCanvas = designer;
            adornerCanvas = new Canvas();
            this.visualChildren = new VisualCollection(this);
            this.visualChildren.Add(adornerCanvas);

            this.connection = connection;
            this.connection.PropertyChanged += new PropertyChangedEventHandler(AnchorPositionChanged);

            InitializeDragThumbs();

            drawingPen = new Pen(Brushes.LightSlateGray, 1);
            drawingPen.LineJoin = PenLineJoin.Round;

            base.Unloaded += new RoutedEventHandler(ConnectionAdorner_Unloaded);


        }
        void Connection_Unloaded(object sender, RoutedEventArgs e)
        {
            // do some housekeeping when Connection is unloaded

            // remove event handler
            this.Source = null;
            this.Sink   = null;

            // remove adorner
            if (this.connectionAdorner != null)
            {
                DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas;

                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
                if (adornerLayer != null)
                {
                    adornerLayer.Remove(this.connectionAdorner);
                    this.connectionAdorner = null;
                }
            }
        }
        protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);

            // usual selection business
            DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas;

            if (designer != null)
            {
                if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
                {
                    if (this.IsSelected)
                    {
                        designer.SelectionService.RemoveFromSelection(this);
                    }
                    else
                    {
                        designer.SelectionService.AddToSelection(this);
                    }
                }
                if (!this.IsSelected)
                {
                    designer.SelectionService.SelectItem(this);
                }
                else
                {
                    designer.SelectionService.RemoveFromSelection(this);
                }



                Focus();
            }

            e.Handled = false;
        }
Exemple #14
0
 public SelectionService(DesignerCanvas canvas)
 {
     this.designerCanvas = canvas;
 }
        private static Connection GetNextNotDefault(DesignerCanvas d, Guid actual)
        {
            IEnumerable<Connection> connections = d.Children.OfType<Connection>();

            foreach (Connection item in connections)
            {
                if (item.Source.ParentDesignerItem.ID == actual && !item.DefaultPath)
                    return item;
            }

            return null;
        }
        private static void BuildPlanLines(Connection position, DesignerCanvas d)
        {

            Connection nextposition;

            if (position != null)
            {
                if (!position.Sink.ParentDesignerItem.Activity.Used)
                {

                    Guid actual = position.Sink.ParentDesignerItem.ID;
                    position.Sink.ParentDesignerItem.Activity.Used = true;


                    DialPlanList.Add(position.Sink.ParentDesignerItem.Activity);
                    position.Sink.ParentDesignerItem.Activity.prio = DialPlanList.Count - 1;


                    //si es una actividad sin condicional
                    if (position.Sink.ParentDesignerItem.Activity.MaxConectors == 1)
                    {

                        nextposition = GetNextDefault(d, actual);
                        BuildPlanLines(nextposition, d);
                    }
                    else
                    {



                        nextposition = GetNextNotDefault(d, actual);
                        if (nextposition != null)
                        {
                            BuildPlanLines(nextposition, d);
                            position.Sink.ParentDesignerItem.Activity.AlternativePath = nextposition.Sink.ParentDesignerItem.Activity.prio;
                        }

                        nextposition = GetNextDefault(d, actual);
                        if (nextposition != null)
                        {
                            BuildPlanLines(nextposition, d);
                            position.Sink.ParentDesignerItem.Activity.DefaultPath = nextposition.Sink.ParentDesignerItem.Activity.prio;
                        }


                    }
                }
                
                //si ya estaba usada la actividad a la que voy y la actual no es condicional o sea no puede saltar sola
                else if (position.Sink.ParentDesignerItem.Activity.Used && position.Source.ParentDesignerItem.Activity.MaxConectors == 1)
                {

                    Goto g = new Goto();
                    g.prio = DialPlanList.Count;
                    g.extension = "${EXTEN}";
                    g.context = Context;
                    g.pri = position.Sink.ParentDesignerItem.Activity.prio;
                    DialPlanList.Add(g);

                }
            }

        }
 public SelectionService(DesignerCanvas canvas)
 {
     this.designerCanvas = canvas;
 }