private void Window_Initialized(object sender, EventArgs e)
        {
            var shape = new RadDiagramShape()
            {
                Content = treeRoot.GetType().Name
            };

            Diagram.Items.Add(shape);
            addNodes(treeRoot, shape);
            Diagram.RoutingService.Router = new OrgTreeRouter()
            {
                TreeLayoutType = TreeLayoutType.TreeDown
            };
            Task.Delay(1000).ContinueWith(_ => {
                Dispatcher.Invoke(() => {
                    Diagram.Layout(LayoutType.Tree, new TreeLayoutSettings()
                    {
                        TreeLayoutType       = TreeLayoutType.TreeDown,
                        HorizontalSeparation = 10.0,
                        VerticalSeparation   = 40.0,
                        Roots = { shape },
                        AnimateTransitions = true
                    });
                });
            });
        }
Esempio n. 2
0
        private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
        {
            DiagramListViewVisualItem dragItem   = e.DragInstance as DiagramListViewVisualItem;
            RadDiagramElement         dropTarget = e.HitTarget as RadDiagramElement;

            if (dragItem != null && dropTarget != null && dragItem.Data.Key == "Image")
            {
                e.Handled = true;

                RadDiagramShape shape = dropTarget.Shapes.Last() as RadDiagramShape;
                shape.DiagramShapeElement.Shape = null;
                shape.BackColor = Color.Transparent;


                try
                {
                    OpenFileDialog open = new OpenFileDialog();
                    open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
                    if (open.ShowDialog() == DialogResult.OK)
                    {
                        Bitmap bit = new Bitmap(open.FileName);
                        shape.DiagramShapeElement.Image = bit;
                    }
                }
                catch (Exception)
                {
                    throw new ApplicationException("Failed loading image");
                }


                shape.DiagramShapeElement.ImageLayout = dragItem.ImageLayout;
            }
            ;
        }
Esempio n. 3
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            // the alternative to this code-approach is to set the ContentTemplate in XAML
            // See the documentation on this, http://www.telerik.com/help/wpf/raddiagrams-features-shapes.html
            var calendar = new RadDiagramShape()
            {
                Position = new Point(20, 150),
                Content  = new RadCalendar {
                    SelectedDate = DateTime.Now.AddDays(254), Margin = new Thickness(10)
                },
                Background                 = new SolidColorBrush(Colors.Blue),
                BorderBrush                = new SolidColorBrush(Colors.DarkGray),
                BorderThickness            = new Thickness(1),
                UseGlidingConnector        = true,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment   = VerticalAlignment.Stretch
            };

            this.diagram.AddShape(calendar);

            var con = this.diagram.AddConnection(this.diagram.Shapes[1], this.diagram.Shapes[0]) as RadDiagramConnection;

            con.Content       = "Corresponds to";
            con.SourceCapType = CapType.Arrow6Filled;
            con.TargetCapType = CapType.Arrow2Filled;
        }
Esempio n. 4
0
        private void DiagramLoaded(object sender, RoutedEventArgs e)
        {
            this.diagram.Shapes.ToList().ForEach(x =>
            {
                var connectorUpRight = new RadDiagramConnector()
                {
                    Offset = new Point(1, 0.25), Name = x.Name + "Connector1Right"
                };
                var connectorDownRight = new RadDiagramConnector()
                {
                    Offset = new Point(1, 0.75), Name = x.Name + "Connector2Right"
                };
                var connectorLeftUp = new RadDiagramConnector()
                {
                    Offset = new Point(0, 0.25), Name = x.Name + "Connector3Left"
                };
                var connectorLeftDown = new RadDiagramConnector()
                {
                    Offset = new Point(0, 0.75), Name = x.Name + "Connector4Left"
                };

                x.Connectors.Add(connectorUpRight);
                x.Connectors.Add(connectorDownRight);
                x.Connectors.Add(connectorLeftUp);
                x.Connectors.Add(connectorLeftDown);
            });

            var shape     = new RadDiagramShape();
            var connector = new RadDiagramConnector()
            {
                Offset = new Point(1, 0.5), Name = "CustoMConnector1"
            };

            shape.Connectors.Add(connector);
        }
        public bool MouseDown(PointerArgs e)
        {
            this.areCtrlShiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift &&
                                    (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

            if (this.areCtrlShiftDown)
            {
                RadDiagramShape topShape = this.HitService.GetTopItemNearPoint(e.Point, 0) as RadDiagramShape;
                if (topShape != null)
                {
                    RadDiagramConnector connector = new RadDiagramConnector() { }; 
                    connector.Name = "NewConnector" + connector.GetHashCode().ToString();

                    double xRatio = (e.Point.X - topShape.Bounds.X) / topShape.Width;
                    double yRatio = (e.Point.Y - topShape.Bounds.Y) / topShape.Height;

                    connector.Offset = new Point(xRatio, yRatio);
                    topShape.Connectors.Add(connector);

                    this.lastUsedShape = topShape;
                    return true;
                }
            }
            return false;
        }
        private RadDiagramShape CreatePlayerLabel(ReplayerPlayerViewModel p)
        {
            var label = new RadDiagramShape()
            {
                DataContext      = p,
                Tag              = p,
                Height           = PLAYER_HEIGHT,
                Width            = PLAYER_WIDTH,
                StrokeThickness  = 0,
                BorderThickness  = new Thickness(0),
                IsEnabled        = false,
                IsHitTestVisible = false,
                FontSize         = 13
            };

            BindingOperations.ClearBinding(label, Control.BackgroundProperty);

            Binding myBinding = new Binding(nameof(ReplayerPlayerViewModel.IsFinished))
            {
                Source = p, Mode = BindingMode.TwoWay, Converter = new ReplayerBrushPlayerConverter()
            };

            label.SetBinding(Control.BackgroundProperty, myBinding);

            return(label);
        }
Esempio n. 7
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.SetLayoutRoots();

            RadDiagramShape dummy = new RadDiagramShape();

            this.diagram.Items.Add(dummy);
            List <IConnection> dummyConnections = new List <IConnection>();

            foreach (var item in this.settings.Roots)
            {
                RadDiagramConnection connection = new RadDiagramConnection();
                connection.Source = dummy;
                connection.Target = item;
                this.diagram.Items.Add(connection);
                dummyConnections.Add(connection);
            }
            settings.Roots.Clear();
            settings.Roots.Add(dummy);
            this.diagram.Layout(LayoutType.Tree, settings);

            dummyConnections.ForEach(x => this.diagram.Items.Remove(x));
            this.diagram.Items.Remove(dummy);
            this.diagram.AutoFit();
        }
        public static RadDiagramShape CreateShape(this RadDiagram diagram, string title = null, string name = null)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "Shape";
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "Shape_" + Rand.Next(665686356);
            }
            var shape = new RadDiagramShape
            {
                Width           = 80,
                Height          = 50,
                Name            = name,
                Geometry        = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
                Background      = new SolidColorBrush(Windows8Palette.Palette.AccentColor),
                Content         = title,
                Stroke          = new SolidColorBrush(Colors.DarkGray),
                StrokeThickness = 0,
                Position        = new Point(50 + Rand.Next(800), 50 + Rand.Next(600))
            };

            diagram.AddShape(shape);
            return(shape);
        }
        private RadDiagramShape CreateCardLabel(RadDiagram diagram, ReplayerCardViewModel card)
        {
            var label = new RadDiagramShape()
            {
                Height           = CARD_HEIGHT,
                Width            = CARD_WIDTH,
                MaxHeight        = CARD_HEIGHT,
                MaxWidth         = CARD_WIDTH,
                StrokeThickness  = 0,
                BorderThickness  = new Thickness(0),
                IsEnabled        = false,
                IsHitTestVisible = false,
                DataContext      = card
            };

            try
            {
                BindingOperations.ClearBinding(label, UIElement.VisibilityProperty);
                BindingOperations.ClearBinding(label, Control.BackgroundProperty);

                Binding cardBinding = new Binding(nameof(ReplayerCardViewModel.CardId))
                {
                    Source = card, Mode = BindingMode.TwoWay, Converter = new IntToCardConverter(), ConverterParameter = label
                };
                label.SetBinding(Control.BackgroundProperty, cardBinding);
            }
            catch (Exception ex)
            {
                LogProvider.Log.Error(ex);
            }

            return(label);
        }
Esempio n. 10
0
 private void addNodes(SyntaxNode node, RadDiagramShape parentShape)
 {
     if (node.Child == null)
     {
         return;
     }
     foreach (var syntaxNode in node.Child)
     {
         string content = "";
         if (syntaxNode is TerminalNode tn)
         {
             content = tn.Lex.StringValue;
         }
         else
         {
             content = syntaxNode.GetType().Name;
         }
         var shape = new RadDiagramShape()
         {
             Content = content
         };
         shape.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape);
         var connection = new RadDiagramConnection()
         {
             Source = parentShape,
             Target = shape,
             SourceConnectorPosition = ConnectorPosition.Bottom,
             TargetConnectorPosition = ConnectorPosition.Left
         };
         Diagram.Items.Add(shape);
         Diagram.Items.Add(connection);
         addNodes(syntaxNode, shape);
     }
 }
        private RadDiagramShape AddActiveIndicator(RadDiagramShape player, TableRingItem tableItem)
        {
            RadDiagramShape indicator = new RadDiagramShape()
            {
                DataContext                  = tableItem,
                Height                       = ACTIVE_INDICATOR_HEIGHT,
                Width                        = ACTIVE_INDICATOR_WIDTH,
                StrokeThickness              = 0,
                BorderThickness              = new Thickness(0),
                IsResizingEnabled            = false,
                IsRotationEnabled            = false,
                IsDraggingEnabled            = false,
                IsManipulationEnabled        = false,
                IsManipulationAdornerVisible = false,
                IsHitTestVisible             = true,
                FontSize                     = 13,
                X = player.X + activeIndicatorRelativePosition.X,
                Y = player.Y + activeIndicatorRelativePosition.Y
            };

            BindingOperations.ClearBinding(indicator, RadDiagramShape.BackgroundProperty);
            Binding backgroundBinding = new Binding()
            {
                Path = new PropertyPath(ReflectionHelper.GetPath <TableRingItem>(o => o.IsChecked)), Mode = BindingMode.TwoWay, Converter = new FilterTableRingBooleanToBrushConverter()
            };

            indicator.SetBinding(RadDiagramShape.BackgroundProperty, backgroundBinding);

            return(indicator);
        }
Esempio n. 12
0
        /// <summary>
        /// Adds new shape for <see cref="HudBaseToolViewModel"/> to shapes
        /// </summary>
        /// <param name="toolViewModel">ViewModel of tool to add</param>
        private void AddTool(HudBaseToolViewModel toolViewModel)
        {
            var shape = new RadDiagramShape()
            {
                DataContext                     = toolViewModel,
                StrokeThickness                 = 0,
                BorderThickness                 = new Thickness(0),
                IsEnabled                       = true,
                Background                      = null,
                IsRotationEnabled               = false,
                Padding                         = new Thickness(0),
                IsManipulationEnabled           = false,
                IsDraggingEnabled               = true,
                IsConnectorsManipulationEnabled = false,
                ZIndex = ToolElementZIndex
            };

            AttachToolBar(shape, toolViewModel as IHudToolBar);

            SetReadOnly(shape, IsReadOnly, toolViewModel);

            SetWidthBinding(shape, toolViewModel);
            SetHeightBinding(shape, toolViewModel);
            SetPositionBinding(shape, toolViewModel);
            SetIsSelectedBinding(shape, toolViewModel);
            SetIsVisibleBinding(shape, toolViewModel);

            AssociatedObject.AddShape(shape);
            RemovableShapes.Add(shape);
        }
Esempio n. 13
0
 //Sets the Layout roots in the Layout Settings.
 private void SetLayoutRoots()
 {
     foreach (var item in this.viewModel.HierarchicalDataSource)
     {
         RadDiagramShape shape = this.diagram.ContainerGenerator.ContainerFromItem(item) as RadDiagramShape;
         this.viewModel.ChildTreeLayoutViewModel.CurrentLayoutSettings.Roots.Add(shape);
     }
 }
		public RadDiagramShape CreateShape()
		{
			var shape = new RadDiagramShape
				{
					Geometry = this.Geometry,
					BorderThickness = new Thickness(0.7)
				};
			return shape;
		}
Esempio n. 15
0
        private bool AreValidShapes(RadDiagramShape source, RadDiagramShape target)
        {
            if (source == target)
            {
                return(false);
            }

            return(!this.Graph.GetConnectionsForShape(source).Intersect(this.Graph.GetConnectionsForShape(target)).Any());
        }
Esempio n. 16
0
        private void InitializeGraph()
        {
            var stateToShape = new Dictionary <AnalyzerState, RadDiagramShape>();

            foreach (var state in slr1Table.States.Values)
            {
                var shape = new RadDiagramShape()
                {
                    Content = String.Join("\n", from item in state.ItemSet select item.ToString())
                };
                shape.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape);
                ItemSetGraph.Items.Add(shape);
                stateToShape.Add(state, shape);
            }

            foreach (var state in slr1Table.States.Values)
            {
                foreach (var kv in state.Action)
                {
                    if (kv.Value is ShiftOperation so)
                    {
                        var connection = new RadDiagramConnection()
                        {
                            Source  = stateToShape[state],
                            Target  = stateToShape[so.NextState],
                            Content = new TextBlock()
                            {
                                Text = kv.Key.Name
                            }
                        };
                        ItemSetGraph.Items.Add(connection);
                    }
                }

                foreach (var kv in state.GotoTable)
                {
                    var connection = new RadDiagramConnection()
                    {
                        Source  = stateToShape[state],
                        Target  = stateToShape[kv.Value],
                        Content = new TextBlock()
                        {
                            Text = kv.Key.ToString()
                        }
                    };
                    ItemSetGraph.Items.Add(connection);
                }
            }
            ItemSetGraph.AutoLayout = true;
            ItemSetGraph.Layout(LayoutType.Sugiyama, new SugiyamaSettings()
            {
                HorizontalDistance = 10,
                VerticalDistance   = 10,
                Orientation        = Telerik.Windows.Diagrams.Core.Orientation.Horizontal,
            });
        }
Esempio n. 17
0
        private void btnNew_Click_1(object sender, RoutedEventArgs e)
        {
            RadDiagramShape shape = new RadDiagramShape();

            shape.Tag      = new Epizode();
            shape.Position = new Point {
                X = this.diagram.Viewport.Left, Y = this.diagram.Viewport.Top
            };
            //shape.
            diagram.AddShape(shape);
        }
Esempio n. 18
0
        /// <summary>
        /// Makes shape with tool read only
        /// </summary>
        /// <param name="shape">Shape</param>
        /// <param name="isReadOnly"></param>
        private void SetReadOnly(RadDiagramShape shape, bool isReadOnly, HudBaseToolViewModel toolViewModel)
        {
            if (shape == null || toolViewModel == null)
            {
                return;
            }

            shape.IsEditable        = !isReadOnly;
            shape.IsResizingEnabled = toolViewModel.IsResizable && !isReadOnly;
            shape.IsDraggingEnabled = !isReadOnly;
        }
Esempio n. 19
0
        private ObservableCollection <RadDiagramShape> GetTeamMembers(XContainer element, OrgContainerShape team)
        {
            var members = new ObservableCollection <RadDiagramShape>();

            foreach (var xmlNodeMember in element.Elements("Child"))
            {
                RadDiagramShape member = this.CreateMemberShape(team, xmlNodeMember);
                members.Add(member);
            }

            return(members);
        }
Esempio n. 20
0
 private bool IsActiveConnectorUnderPoint(RadDiagramShape shape, Point point)
 {
     foreach (var conn in shape.Connectors.Where(x => x.IsActive == true))
     {
         var distance = conn.AbsolutePosition.Distance(point);
         if (distance < DiagramConstants.ConnectorHitTestRadius)
         {
             return(true);
         }
     }
     return(false);
 }
 private bool IsActiveConnectorUnderPoint(RadDiagramShape shape, Point point)
 {
     foreach (var conn in shape.Connectors.Where(x => x.IsActive == true))
     {
         var distance = conn.AbsolutePosition.Distance(point);
         if (distance < DiagramConstants.ConnectorHitTestRadius)
         {
             return true;
         }            
     }
     return false;
 }
Esempio n. 22
0
        private static RadDiagramShape CreateTableRadDiagramShape()
        {
            var table = new RadDiagramShape()
            {
                Height              = HudDefaultSettings.TableHeight,
                Width               = HudDefaultSettings.TableWidth,
                StrokeThickness     = 0,
                IsEnabled           = false,
                SnapsToDevicePixels = true
            };

            return(table);
        }
Esempio n. 23
0
        public MainWindow()
        {
            InitializeComponent();

            MainViewModel mvm = new MainViewModel();
            var           x   = mvm.Items[0].Shapes[0];
            var           c   = new RadDiagramShape();

            c.Width       = 30;
            c.Height      = 30;
            c.DataContext = x;
            this.xsp.Children.Add(c);
        }
Esempio n. 24
0
        private void diagram_ShapeDoubleClicked_1(object sender, ShapeRoutedEventArgs e)
        {
            RadDiagramShape   shape = (RadDiagramShape)e.Shape;
            Epizode           Ep    = (Epizode)shape.Tag;
            EpizodeProperties win   = new EpizodeProperties(Ep);
            var result = win.ShowDialog();

            if (result == true)
            {
                shape.Tag       = Ep;
                e.Shape.Content = ((Epizode)shape.Tag).EpizodeNumber;
            }
        }
        private void CreatePlayerLabels(RadDiagram diagram, FilterStandardViewModel viewModel)
        {
            var positions = predefinedPlayerPositions[seats];

            IList <TableRingItem> collection;

            switch ((EnumTableType)seats)
            {
            case EnumTableType.Six:
                collection = viewModel.FilterModel.ActiveTable6MaxCollection;
                break;

            default:
                collection = viewModel.FilterModel.ActiveTableFullRingCollection;
                break;
            }

            for (int i = 0; i < seats && i < collection.Count; i++)
            {
                var tableItem = collection[i];

                RadDiagramShape player = new RadDiagramShape()
                {
                    DataContext                  = tableItem,
                    Background                   = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), BackgroundPlayerImage))),
                    Height                       = PLAYER_HEIGHT,
                    Width                        = PLAYER_WIDTH,
                    StrokeThickness              = 0,
                    BorderThickness              = new Thickness(0),
                    IsResizingEnabled            = false,
                    IsRotationEnabled            = false,
                    IsDraggingEnabled            = false,
                    IsManipulationEnabled        = false,
                    IsManipulationAdornerVisible = false,
                    IsHitTestVisible             = true,
                    FontSize                     = 13,
                };

                player.X = positions[tableItem.Seat - 1, 0];
                player.Y = positions[tableItem.Seat - 1, 1];

                var indicator = AddActiveIndicator(player, tableItem);

                player.MouseLeftButtonUp    += PlayerControl_MouseLeftButtonUp;
                indicator.MouseLeftButtonUp += PlayerControl_MouseLeftButtonUp;

                diagram.AddShape(player);
                diagram.AddShape(indicator);
            }
        }
Esempio n. 26
0
        void timer_TickGap(object sender, EventArgs e)
        {
            RadDiagramShape connection1 = (RadDiagramShape)this.radDiagram1.Shapes[4];
            RadDiagramShape connection2 = (RadDiagramShape)this.radDiagram1.Shapes[5];

            connection1.Position = new Telerik.Windows.Diagrams.Core.Point(connection1.Position.X - step, connection1.Position.Y);
            connection2.Position = new Telerik.Windows.Diagrams.Core.Point(connection2.Position.X - step, connection2.Position.Y);


            if (connection1.Position.X < 250 || connection1.Position.X > 440)
            {
                step = -step;
            }
        }
        private void PlaceCardLabels(RadDiagram diagram, RadDiagramShape playerLabel, int cardsCount = 2)
        {
            var player = playerLabel.DataContext as ReplayerPlayerViewModel;

            if (player == null)
            {
                throw new ArgumentNullException("playerLabel", "Cannot place card labels for player because player is null");
            }

            Binding myBinding = new Binding(nameof(ReplayerPlayerViewModel.IsFinished))
            {
                Source = player, Mode = BindingMode.TwoWay, Converter = new BoolToVisibilityConverter(), ConverterParameter = "Inverse"
            };

            for (int i = 0; i < cardsCount; i++)
            {
                var card = CreateCardLabel(diagram, player.Cards[i]);
                card.SetBinding(UIElement.VisibilityProperty, myBinding);

                if (cardsCount == 4)
                {
                    double offset = card.Width / 4;
                    var    start  = playerLabel.X - offset + 2;
                    var    width  = playerLabel.Width + offset;
                    card.X = start + i * width / 5;
                }
                else if (cardsCount == 2)
                {
                    card.X = playerLabel.X + 5 + i * (playerLabel.Width - 10 - card.Width);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("cardsCount", "Supported cardsCount values are 2 and 4");
                }

                card.Y = playerLabel.Y - 60;

                diagram.AddShape(card);
            }

            if (player.IsDealer)
            {
                var button = CreateDealerLabel(diagram, player);
                button.X = playerLabel.X - BUTTON_WIDTH - 5;
                button.Y = playerLabel.Y + playerLabel.Height / 2 - BUTTON_HEIGHT / 2;

                diagram.AddShape(button);
            }
        }
Esempio n. 28
0
        private void AttachToolBar(RadDiagramShape shape, IHudToolBar toolBar)
        {
            if (toolBar == null || shape == null)
            {
                return;
            }

            var toolbarShape = new RadDiagramShape()
            {
                DataContext                     = toolBar,
                Height                          = double.NaN,
                Width                           = double.NaN,
                StrokeThickness                 = 0,
                IsEnabled                       = true,
                IsEditable                      = false,
                IsManipulationEnabled           = false,
                IsResizingEnabled               = false,
                IsRotationEnabled               = false,
                IsDraggingEnabled               = false,
                IsConnectorsManipulationEnabled = false,
                IsManipulationAdornerVisible    = false,
                IsSelected                      = false,
                IsInEditMode                    = false,
                SnapsToDevicePixels             = true,
                Template                        = ToolbarTemplate,
                Background                      = new SolidColorBrush(Colors.Transparent),
                ZIndex                          = ToolBarZIndex
            };

            var disposable = Observable.FromEventPattern <PropertyEventArgs>(
                h => shape.PropertyChanged += h,
                h => shape.PropertyChanged -= h).Subscribe(x =>
            {
                if (x.EventArgs.PropertyName == nameof(RadDiagramShape.Bounds))
                {
                    toolbarShape.X = shape.X + shape.ActualWidth - toolbarShape.ActualWidth;
                    toolbarShape.Y = shape.Y + shape.ActualHeight + 1;
                }
                else if (x.EventArgs.PropertyName == nameof(RadDiagramShape.IsSelected))
                {
                    toolbarShape.ZIndex = shape.IsSelected ? ToolElementZIndex : ToolBarZIndex;
                }
            });

            AssociatedObject.AddShape(toolbarShape);
            RemovableShapes.Add(toolbarShape);

            Disposables.Add(disposable);
        }
Esempio n. 29
0
        private static void ExportShape(RadDiagramShape shape, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height);

            var pathGeometry   = shape.Geometry as PathGeometry;
            var transformGroup = new TransformGroup();

#if WPF
            if (pathGeometry == null)
            {
                var streamGeometry = shape.Geometry as StreamGeometry;
                if (streamGeometry != null)
                {
                    pathGeometry = streamGeometry.AsPathGeometry();
                }
            }
#endif

            var geometrySize = shape.Geometry.Bounds.ToSize();
            if (IsValidSize(geometrySize) && (geometrySize.Width != bounds.Width || geometrySize.Width != bounds.Width))
            {
                transformGroup.Children.Add(new ScaleTransform()
                {
                    ScaleX = bounds.Width / geometrySize.Width, ScaleY = bounds.Height / geometrySize.Height
                });
            }
            transformGroup.Children.Add(new RotateTransform()
            {
                Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2
            });
            transformGroup.Children.Add(new TranslateTransform()
            {
                X = bounds.X, Y = bounds.Y
            });

            var position = new MatrixPosition(transformGroup.Value);

            EditorInfo         info         = new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle);
            FixedContentEditor editor       = CreateEditor(info, false);
            FixedContentEditor filledEditor = CreateEditor(info, true);

            ExportGeometry(editor, filledEditor, pathGeometry);

            if (shape.Content != null)
            {
                var center = bounds.Center();
                ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return(new Point(center.X - s.Width / 2, center.Y - s.Height / 2)); });
            }
        }
Esempio n. 30
0
        internal ReplayerChipsContainer()
        {
            Chips = new ObservableCollection <ChipModel>();

            ChipsShape = new RadDiagramShape()
            {
                Height          = CHIP_VIEW_HEIGHT,
                Width           = CHIP_VIEW_WIDTH,
                StrokeThickness = 0,
                BorderThickness = new Thickness(0),
                Tag             = "ChipsInfo",
                Visibility      = Visibility.Visible,
                Background      = new SolidColorBrush(Colors.Transparent)
            };
        }
Esempio n. 31
0
        private ObservableCollection <RadDiagramShape> GetTeamMembers(XContainer element, OrgContainerShape team)
        {
            //XElement data = XElement.Load(@"C:\Temp\Hersan.xml");
            XElement data = XElement.Load(Directory.GetCurrentDirectory() + "\\Hersan.xml");

            var members = new ObservableCollection <RadDiagramShape>();

            foreach (var xmlNodeMember in data.Elements("Element"))
            {
                RadDiagramShape member = this.CreateMemberShape(team, Nombre);
                members.Add(member);
            }

            return(members);
        }
Esempio n. 32
0
        void timer_Tick(object sender, EventArgs e)
        {
            RadDiagramShape shape  = (RadDiagramShape)this.radDiagram1.Shapes[3];
            RadDiagramShape shape1 = (RadDiagramShape)this.radDiagram1.Shapes[4];

            shape.Position  = new Telerik.Windows.Diagrams.Core.Point(shape.Position.X - step, shape.Position.Y);
            shape1.Position = new Telerik.Windows.Diagrams.Core.Point(shape1.Position.X - step1, shape1.Position.Y);
            if (shape.Position.X < 380 || shape.Position.X > 620)
            {
                step = -step;
            }
            if (shape1.Position.X < 380 || shape1.Position.X > 620)
            {
                step1 = -step1;
            }
        }
Esempio n. 33
0
        private void DiagramLoaded(object sender, RoutedEventArgs e)
        {
            this.diagram.Shapes.ToList().ForEach(x =>
            {
                var connectorUpRight = new RadDiagramConnector() { Offset = new Point(1, 0.25), Name = x.Name + "Connector1" };
                var connectorDownRight = new RadDiagramConnector() { Offset = new Point(1, 0.75), Name = x.Name + "Connector2" };
                var connectorLeftUp = new RadDiagramConnector() { Offset = new Point(0, 0.25), Name = x.Name + "Connector3" };
                var connectorLeftDown = new RadDiagramConnector() { Offset = new Point(0, 0.75), Name = x.Name + "Connector4" };

                x.Connectors.Add(connectorUpRight);
                x.Connectors.Add(connectorDownRight);
                x.Connectors.Add(connectorLeftUp);
                x.Connectors.Add(connectorLeftDown);
            });

            var shape = new RadDiagramShape();
            var connector = new RadDiagramConnector() { Offset = new Point(1, 0.5), Name = "CustoMConnector1" };
            shape.Connectors.Add(connector);
        }
Esempio n. 34
0
		private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
		{
			// the alternative to this code-approach is to set the ContentTemplate in XAML
			// See the documentation on this, http://www.telerik.com/help/wpf/raddiagrams-features-shapes.html
			var calendar = new RadDiagramShape()
			{
				Position = new Point(20, 150),
				Content = new RadCalendar { SelectedDate = DateTime.Now.AddDays(254), Margin = new Thickness(10) },
				Background = new SolidColorBrush(Colors.Blue),
				BorderBrush = new SolidColorBrush(Colors.DarkGray),
				BorderThickness = new Thickness(1),
				UseGlidingConnector = true,
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				VerticalContentAlignment = VerticalAlignment.Stretch
			};
			this.diagram.AddShape(calendar);

			var con = this.diagram.AddConnection(this.diagram.Shapes[1], this.diagram.Shapes[0]) as RadDiagramConnection;
			con.Content = "Corresponds to";
			con.SourceCapType = CapType.Arrow6Filled;
			con.TargetCapType = CapType.Arrow2Filled;
		}
Esempio n. 35
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.SetLayoutRoots();

            RadDiagramShape dummy = new RadDiagramShape();
            this.diagram.Items.Add(dummy);
            List<IConnection> dummyConnections = new List<IConnection>();

            foreach (var item in this.settings.Roots)
            {
                RadDiagramConnection connection = new RadDiagramConnection();
                connection.Source = dummy;
                connection.Target = item;
                this.diagram.Items.Add(connection);
                dummyConnections.Add(connection);
            }
            settings.Roots.Clear();
            settings.Roots.Add(dummy);
            this.diagram.Layout(LayoutType.Tree, settings);

            dummyConnections.ForEach(x => this.diagram.Items.Remove(x));
            this.diagram.Items.Remove(dummy);
            this.diagram.AutoFit();
        }
Esempio n. 36
0
 private void btnNew_Click_1(object sender, RoutedEventArgs e)
 {
     RadDiagramShape shape = new RadDiagramShape();
     shape.Tag = new Epizode();
     shape.Position = new Point { X = this.diagram.Viewport.Left, Y = this.diagram.Viewport.Top };
     //shape.
     diagram.AddShape(shape);
 }
Esempio n. 37
0
 public static RadDiagramShape CreateShape(this RadDiagram diagram, string title = null, string name = null)
 {
     if (string.IsNullOrEmpty(title)) title = "Shape";
     if (string.IsNullOrEmpty(name)) name = "Shape_" + Rand.Next(665686356);
     var shape = new RadDiagramShape
     {
         Width = 80,
         Height = 50,
         Name = name,
         Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
         Background = new SolidColorBrush(Windows8Palette.Palette.AccentColor),
         Content = title,
         Stroke = new SolidColorBrush(Colors.DarkGray),
         StrokeThickness = 0,
         Position = new Point(50 + Rand.Next(800), 50 + Rand.Next(600))
     };
     diagram.AddShape(shape);
     return shape;
 }
		private void ImportImageButtonClick(object sender, RoutedEventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
#if WPF
			openFileDialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
#else
			openFileDialog.Filter = "Image Files (*.png, *.jpg)|*.png;*.jpg";
#endif
			bool? dialogResult = openFileDialog.ShowDialog();
			if (dialogResult.HasValue && dialogResult.Value == true)
			{
				Image image = new Image();
#if WPF
				image.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
#else
					using (var fileOpenRead = openFileDialog.File.OpenRead())
					{
						BitmapImage bitmap = new BitmapImage();
						bitmap.SetSource(fileOpenRead);
						image.Source = bitmap;
					}
#endif
				Viewbox viewBox = new Viewbox() { Stretch = Stretch.Fill, Margin = new Thickness(-4) };
				viewBox.Child = image;
				RadDiagramShape imageShape = new RadDiagramShape()
				{
					Content = viewBox
				};
				this.diagram.Items.Add(imageShape);
			}
		}
		private void LayoutShape(RadDiagramShape node, Point point)
		{
			if (!node.HasChildren())
			{
				node.Position = new Point(point.X, point.Y);
			}
			else
			{
				double x, y;
				Point selfLocation;
				var boundingBox = this.sizeCache[node.Id];
				selfLocation = new Point(point.X + ((boundingBox.Width - node.ActualBounds.Width) / 2), point.Y);
				node.Position = selfLocation;

				if (Math.Abs(selfLocation.X - point.X) < Telerik.Windows.Diagrams.Core.Utils.Epsilon)
				{
					x = point.X + ((node.ActualBounds.Width - boundingBox.Width) / 2);
				}
				else
				{
					x = point.X;
				}

				var children = GetChildren(node);

				foreach (var childNode in children)
				{
					y = selfLocation.Y + this.VerticalLevelSeparation + node.ActualBounds.Height;
					var childPoint = new Point(x, y);
					this.LayoutShape(childNode, childPoint);
					var size = this.sizeCache[childNode.Id];
					x += size.Width + this.HorizontalLevelSeparation;
				}
			}
		}
		private static IEnumerable<RadDiagramShape> GetChildren(RadDiagramShape node)
		{
			return node.OutgoingLinks.Select(child => child.Target as RadDiagramShape);
		}
		private Size CalculateBoundingBoxes(RadDiagramShape node)
		{
			if (!node.HasChildren())
			{
				var size = new Size(node.ActualBounds.Width, node.ActualBounds.Height);
				this.sizeCache.Add(node.Id, size);
				return size;
			}

			double width = 0;
			double height = 0;

			Size shapeBox;

			var children = GetChildren(node);

			foreach (var child in children)
			{
				shapeBox = this.CalculateBoundingBoxes(child);
				width += shapeBox.Width;
				height = Math.Max(height, shapeBox.Height);
			}

			width += (children.Count() - 1) * this.HorizontalLevelSeparation;
			height += this.HorizontalLevelSeparation + node.ActualBounds.Height;

			shapeBox = new Size(width, height);

			this.sizeCache.Add(node.Id, shapeBox);

			return shapeBox;
		}
Esempio n. 42
0
        private bool AreValidShapes(RadDiagramShape source, RadDiagramShape target)
        {
            if (source == target) return false;

            return !this.Graph.GetConnectionsForShape(source).Intersect(this.Graph.GetConnectionsForShape(target)).Any();
        }
Esempio n. 43
0
        private static void ExportShape(RadDiagramShape shape, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height);

            var pathGeometry = shape.Geometry as PathGeometry;
            var transformGroup = new TransformGroup();
#if WPF
            if (pathGeometry == null)
            {
                var streamGeometry = shape.Geometry as StreamGeometry;
                if (streamGeometry != null)
                    pathGeometry = streamGeometry.AsPathGeometry();
            }
#endif

            var geometrySize = shape.Geometry.Bounds.ToSize();
            if (IsValidSize(geometrySize) && (geometrySize.Width != bounds.Width || geometrySize.Width != bounds.Width))
                transformGroup.Children.Add(new ScaleTransform() { ScaleX = bounds.Width / geometrySize.Width, ScaleY = bounds.Height / geometrySize.Height });
            transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 });
            transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y });

            var position = new MatrixPosition(transformGroup.Value);

            EditorInfo info = new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle);
            FixedContentEditor editor = CreateEditor(info, false);
            FixedContentEditor filledEditor = CreateEditor(info, true);

            ExportGeometry(editor, filledEditor, pathGeometry);

            if (shape.Content != null)
            {
                var center = bounds.Center();
                ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return new Point(center.X - s.Width / 2, center.Y - s.Height / 2); });
            }
        }
		public GalleryItem(string header, RadDiagramShape shape)
			: this(header, shape, string.Empty)
		{ }
		public GalleryItem(string header, RadDiagramShape shape, string type)
		{
			this.Header = header;
			this.Shape = shape;
			this.ItemType = type;
		}