/// <summary> /// Creates a random connected graph and displayes a (non-unique) spanning tree using Prim's algorithm. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> private void Prims(RadDiagram diagram, GraphGenerationSpecifications specs) { diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; var randomConnectedGraph = GraphExtensions.CreateRandomConnectedGraph(10); var root = randomConnectedGraph.FindTreeRoot(); var g = diagram.CreateDiagram(randomConnectedGraph, out nodeMap, out edgeMap, GraphExtensions.CreateShape, specs.RandomShapeSize); // making it undirected will reach all the nodes since the random graph is connected g.IsDirected = false; var tree = g.PrimsSpanningTree(root); if (tree != null) { this.Highlight(tree, nodeMap, edgeMap, this.HighlighBrush); } var settings = new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.TreeDown, VerticalSeparation = 50d, HorizontalSeparation = 80d, }; diagram.Layout(LayoutType.Tree, settings); }
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); }
/// <summary> /// Creates a specific graph to show the shortest path between two nodes. /// </summary> /// <param name="obj">The diagram.</param> /// <param name="specs">The specs.</param> private void ShortestPath(RadDiagram obj, GraphGenerationSpecifications specs) { this.diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; var g = this.diagram.CreateDiagram(new List <string> { "1,2", "2,3", "1,4", "4,5", "5,3", "1,6", "6,7", "7,8", "8,3", "3,9", "9,10", "10,11" }, out nodeMap, out edgeMap, GraphExtensions.CreateShape, this.RandomSizeCheck.IsChecked.HasValue && this.RandomSizeCheck.IsChecked.Value); // Dijkstra's algorithm will give you the shortest path var path = g.DijkstraShortestPath(1, 11); if (path != null) { this.Highlight(path, nodeMap, edgeMap, this.HighlighBrush); } // the node map gives us the shape from a node and we want to have the "1" node at the root of the tree var nodeOne = g.FindNode(1); var shapeOne = nodeMap[nodeOne]; var settings = new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.TreeDown, VerticalSeparation = 50d, HorizontalSeparation = 80d, }; // specifying the root (or roots if we have a forest) can be done using the Roots property like so settings.Roots.Add(shapeOne); diagram.Layout(LayoutType.Tree, settings); }
/// <summary> /// Creates a forest of unbalanced trees and applies a radial layout. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> private void RandomRadialForest(RadDiagram diagram, GraphGenerationSpecifications specs) { this.diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; var g = this.diagram.CreateDiagram(GraphExtensions.CreateRandomGraph(250, 4, true), out nodeMap, out edgeMap, GraphExtensions.CreateShape, this.RandomSizeCheck.IsChecked.HasValue && this.RandomSizeCheck.IsChecked.Value); var settings = new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.RadialTree, HorizontalSeparation = this.HorizontalSeparationSlider.Value, VerticalSeparation = this.VerticalSeparationSlider.Value, UnderneathHorizontalOffset = this.UnderneathHorizontalOffsetSlider.Value, UnderneathVerticalSeparation = this.UnderneathVerticalOffsetSlider.Value, KeepComponentsInOneRadialLayout = true, RadialSeparation = 45d }; var center = g.FindNode(0); settings.Roots.Add(nodeMap[center]); var layout = new TreeLayout(); layout.Layout(this.diagram, settings); this.diagram.AutoFit(); //Colorize(g, nodeMap, center); }
private void CreatePlayersLayout(RadDiagram diagram, HudDragCanvas dgCanvas, ReplayerViewModel viewModel) { var seats = (int)CurrentCapacity; var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(ReplayerPokerSite.ToString()); var labelPositions = positionProvider.Positions[seats]; var hasHoleCards = viewModel.CurrentGame.Players.Any(x => x.hasHoleCards); var cardsCount = hasHoleCards ? viewModel.CurrentGame.Players.Where(x => x.hasHoleCards).Max(x => x.HoleCards.Count) : 2; for (var i = 0; i < seats; i++) { var player = viewModel.PlayersCollection[i]; var label = CreatePlayerLabel(player); label.X = labelPositions[i, 0]; label.Y = labelPositions[i, 1]; PlaceCardLabels(diagram, label, cardsCount); player.ChipsContainer.ChipsShape.X = predefinedChipsPositions[seats][i, 0]; player.ChipsContainer.ChipsShape.Y = predefinedChipsPositions[seats][i, 1]; AddPotPlayerLabel(diagram, viewModel.PlayersCollection[i], predefinedChipsPositions[seats][i, 0], predefinedChipsPositions[seats][i, 1]); diagram.AddShape(label); diagram.AddShape(player.ChipsContainer.ChipsShape); } }
/// <summary> /// Creates a tree which grows symmetrically. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> private void BalancedRadialTree(RadDiagram diagram, GraphGenerationSpecifications specs) { this.diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; // the algorithm to create a balanced tree is quite straighforward var g = this.diagram.CreateDiagram(GraphExtensions.CreateBalancedTree(), out nodeMap, out edgeMap, GraphExtensions.CreateShape, this.RandomSizeCheck.IsChecked.HasValue && this.RandomSizeCheck.IsChecked.Value); // the result is best displayed with the radial tree layout var settings = new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.RadialTree, HorizontalSeparation = this.HorizontalSeparationSlider.Value, VerticalSeparation = this.VerticalSeparationSlider.Value, UnderneathHorizontalOffset = this.UnderneathHorizontalOffsetSlider.Value, UnderneathVerticalSeparation = this.UnderneathVerticalOffsetSlider.Value, StartRadialAngle = Math.PI, // use a specific angle rather than the full 360° to show one of the layout's (hidden) gem EndRadialAngle = 3.47 * Math.PI / 2 }; var center = g.FindNode(-1); settings.Roots.Add(nodeMap[center]); var layout = new TreeLayout(); layout.Layout(this.diagram, settings); // center and size autimagically this.diagram.AutoFit(); // you can colorize the shapes, if you wish // this.Colorize(g, nodeMap, center); }
public Form1() { StyleManager.ApplicationTheme = new Office_SilverTheme(); InitializeComponent(); diagram = new RadDiagram() { Background = System.Windows.Media.Brushes.White, IsBackgroundSurfaceVisible = false }; elementHost1.Child = diagram; var s1 = diagram.AddShape(new RadDiagramShape { Position = new System.Windows.Point(120, 50) }); var s2 = diagram.AddShape(new RadDiagramShape { Position = new System.Windows.Point(320, 50) }); var con = diagram.AddConnection(s1, s2) as RadDiagramConnection; con.Content = "Connected"; con.Stroke = System.Windows.Media.Brushes.OrangeRed; var info = diagram.AddShape( "This is not a XAML form, but a Windows Form hosting RadDiagram.", ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape), new System.Windows.Point(280, 150)) as RadDiagramShape; info.Background = System.Windows.Media.Brushes.Transparent; info.Stroke = System.Windows.Media.Brushes.Silver; }
private static ScrollingDirection GetScrollingDirection(RadDiagram diagram, Point currentPosition) { var diagramPosition = diagram.GetTransformedPoint(currentPosition); if (diagramPosition.Y <= diagram.Viewport.Top) { return(ScrollingDirection.Up); } else if (diagramPosition.Y >= diagram.Viewport.Bottom) { return(ScrollingDirection.Down); } else if (diagramPosition.X <= diagram.Viewport.Left) { return(ScrollingDirection.Left); } else if (diagramPosition.X >= diagram.Viewport.Right) { return(ScrollingDirection.Right); } else { return(ScrollingDirection.None); } }
/// <summary> /// Creates a specific graph which has some obvious cycles and lets the graph analysis highlight them, thus confirming the cycles /// which can be easily found manually. The analysis goes of course beyond what the human eye can see and would find cycles in an arbitrary graph. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> private void Cycles(RadDiagram diagram, GraphGenerationSpecifications specs) { diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; var g = diagram.CreateDiagram(new List <string> { "1,2", "3,1", "2,4", "4,3", "4,5", "10,11", "11,12", "12,10" }, out nodeMap, out edgeMap, specs.CreateShape, specs.RandomShapeSize); var cycles = g.FindCycles(); if (cycles.Count > 0) { foreach (var cycle in cycles) { var path = new GraphPath <Node, Edge>(); cycle.ToList().ForEach(path.AddNode); this.Highlight(path, nodeMap, edgeMap, specs.HighlightBrush); } } diagram.Layout(LayoutType.Tree, new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.TreeRight, VerticalSeparation = 50d, HorizontalSeparation = 80d }); }
public static IContainerShape CreateContainerShape(this RadDiagram diagram, string title = null, string name = null) { if (string.IsNullOrEmpty(title)) { title = "Container"; } if (string.IsNullOrEmpty(name)) { name = "Container_" + Rand.Next(665686356); } var shape = new RadDiagramContainerShape { Width = 250, Height = 150, Name = name, Content = title, //Stroke = Brushes.DimGray, IsCollapsible = true, StrokeThickness = 1, CollapsedContent = null, }; diagram.AddShape(shape); return(shape); }
private static void AddAssosiation(RadDiagram diagram) { if (!diagramInfos.ContainsKey(diagram)) { diagramInfos[diagram] = CreateDiagramInfo(diagram); } }
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); }
public PageManager(RadDiagram diagram) { this.diagram = diagram; this.fileManager = new FileManager(diagram); this.Pages = new ObservableCollection<Page>(); this.HyperLinks = new ObservableCollection<LogicalLink>(); }
public static List <RadDiagramShape> CreateDivisionBranch(this RadDiagram diagram, string name) { var shapes = new List <RadDiagramShape>(); var director = diagram.CreateShape(name + " director"); shapes.Add(director); var manCount = Rand.Next(2, 4); for (var j = 0; j < manCount; j++) { var man = diagram.CreateShape(name + " manager"); shapes.Add(man); man.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape); man.Background = new SolidColorBrush(Colors.Brown); var devCount = Rand.Next(3, 6); diagram.AddConnection(director, man, ConnectorPosition.Bottom, ConnectorPosition.Top); for (var k = 0; k < devCount; k++) { var dev = diagram.CreateShape("Dev " + k); shapes.Add(dev); dev.Background = new SolidColorBrush(Colors.LightGray); diagram.Connect(man, dev); } } return(shapes); }
/// <summary> /// Creates a specific diagram and highlight the longest path found through the graph analysis. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> private void LongestPath(RadDiagram diagram, GraphGenerationSpecifications specs) { diagram.Clear(); Dictionary <Node, RadDiagramShape> nodeMap; Dictionary <Edge, RadDiagramConnection> edgeMap; // this creates the specific graph var g = this.diagram.CreateDiagram(new List <string> { "1,2", "2,3", "2,4", "3,5", "4,5", "5,6", "2,7", "7,8", "8,9", "9,10", "10,6", "20,21", "21,22", "20,25" }, out nodeMap, out edgeMap, GraphExtensions.CreateShape, this.RandomSizeCheck.IsChecked.HasValue && this.RandomSizeCheck.IsChecked.Value); // note that this works on disconnected graphs as well as on connected ones var path = g.FindLongestPath(); // highlight the longest path if one is found if (path != null) { this.Highlight(path, nodeMap, edgeMap, this.HighlighBrush); } // use a layout which displays the result best diagram.Layout(LayoutType.Tree, new TreeLayoutSettings { TreeLayoutType = TreeLayoutType.TreeUp, VerticalSeparation = 80d, HorizontalSeparation = 50d }); }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; System.Windows.Application.LoadComponent(this, new System.Uri("/Procbel.Apps.Silverlight.Modules.Inicio;component/Views/InicioView.xaml", System.UriKind.Relative)); this.diagram = ((RadDiagram)(this.FindName("diagram"))); }
private static void DetachHandlers(RadDiagram diagram) { if (diagramInfos.Keys.Contains(diagram) && (diagramInfos[diagram].ScrollingTimer != null)) { diagramInfos[diagram].ScrollingTimer.Tick -= ScrollingTimer_Tick; } diagram.PreviewMouseMove -= diagram_PreviewMouseMove; }
public MyDragging(RadDiagram graph) : base(graph as IGraphInternal) { this.DragAllowedArea = Rect.Empty; this.diagram = graph; this.IsOn = true; this.UseRotaitonBounds = true; }
protected void ConnectDiagramShapes(string startShapeID, string endShapeID, RadDiagram diagram) { var connection = new DiagramConnection(); connection.FromSettings.ShapeId = startShapeID; connection.ToSettings.ShapeId = endShapeID; diagram.ConnectionsCollection.Add(connection); }
private void Initialize(RadDiagram diagram, ItemInformationAdorner informationAdorner, Popup rootPopup) { this.diagram = diagram; this.informationAdorner = informationAdorner; this.informationAdorner.IsAdditionalContentVisibleChanged += this.InformationAdorner_IsAdditionalContentVisibleChanged; this.rootPopup = rootPopup; this.dataProvider = new SettingsPaneDataProvider(this.diagram); this.dataProvider.BoundsChanged += (_, __) => this.PlacePopup(); }
/// <summary> /// Initializes a new instance of the <see cref="FileManager"/> class. /// </summary> /// <param name="diagram">The diagram.</param> public FileManager(RadDiagram diagram) { this.CurrentFile = string.Empty; if (diagram == null) { throw new ArgumentNullException("diagram"); } this.diagram = diagram; }
public static IConnection Connect(this RadDiagram diagram, IShape a, IShape b, string name = null) { var c = diagram.AddConnection(a, b); if (!string.IsNullOrEmpty(name)) { c.Name = name; } return(c); }
public static IEnumerable<SampleItem> GetSamples(RadDiagram diagram = null) { return new[] { new SampleItem { Title = "Sample: Simple Diagram", Description = "A basic diagram of geometric shapes.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/flow.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = SimpleDiagramSample, RunCommand = new DelegateCommand((x) => SimpleDiagramSample(diagram)) }, new SampleItem { Title = "Sample: Cycle Diagram", Description = "Example of a cycle process aka methodology.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/circle.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = CycleSample, RunCommand = new DelegateCommand((x) => CycleSample(diagram)) }, new SampleItem { Title = "Sample: Stakeholders Diagram", Description = "Sample demonstrating a stakeholder diagram.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/stakeholder.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = StakeholderSample, RunCommand = new DelegateCommand((x) => StakeholderSample(diagram)) }, new SampleItem { Title = "Sample: Linear Process Diagram", Description = "Linear sequence of dependence.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/rolls.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = SequenceSample, RunCommand = new DelegateCommand((x) => SequenceSample(diagram)) }, new SampleItem { Title = "Sample: Floor plan", Description = "Sample which demonstrates the possibility to use RadDiagram to create floor plans.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/floorplan.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = FloorPlanSample, RunCommand = new DelegateCommand((x) => FloorPlanSample(diagram)) }, new SampleItem { Title = "Sample: Decision Flowchart", Description = "A typical flowchart using RadDiagram.", Icon = FeatureUtilities.GetBitmap(new Uri("/Images/simpleflow.jpg", UriKind.RelativeOrAbsolute), "Telerik.Windows.Diagrams.Features"), Run = DecisionSample, RunCommand = new DelegateCommand((x) => DecisionSample(diagram)) } }; }
/// <summary> /// Initializes a new instance of the <see cref="FileManager"/> class. /// </summary> /// <param name="diagram">The diagram.</param> public FileManager(RadDiagram diagram) { this.CurrentFile = string.Empty; if (diagram == null) throw new ArgumentNullException("diagram"); this.diagram = diagram; #if WPF tempPath = Path.GetTempPath(); #else #endif }
private void Save(RadDiagram diagram, string Path) { var xml = diagram.Save(); using (var stream = System.IO.File.OpenWrite(Path)) { using (var Writer = new System.IO.StreamWriter(stream)) { Writer.Write(xml); } } }
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); } }
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); } }
private static BitmapSource CreateDiagramImage(RadDiagram diagram, Rect enclosingBounds, Size returnImageSize, Brush backgroundBrush, Thickness margin, double dpi) { var virtualizationService = diagram.ServiceLocator.GetService <IVirtualizationService>() as VirtualizationService; virtualizationService.ForceRealization(); diagram.UpdateLayout(); var itemsHost = diagram.FindChildByType <DiagramSurface>(); BitmapSource image = CreateWriteableBitmap(itemsHost, enclosingBounds, returnImageSize, backgroundBrush, margin, dpi); virtualizationService.Virtualize(); diagram.UpdateLayout(); return(image); }
/// <summary> /// Gets the samples. /// </summary> /// <param name="diagram">The diagram.</param> /// <returns></returns> public static IEnumerable<SampleItem> GetSamples(RadDiagram diagram = null) { return new[] { new SampleItem { Title = "Simple Diagram", Description = "A basic diagram of geometric shapes.", Icon = "../Images/flow.jpg", Run = SimpleDiagramSample }, new SampleItem { Title = "Cycle Diagram", Description = "Example of a cycle process aka methodology.", Icon = "../Images/circle.jpg", Run = CycleSample }, new SampleItem { Title = "Bezier Diagram", Description = "Sample demonstrating a stakeholder diagram.", Icon = "../Images/bezier.jpg", Run = BezierSample }, new SampleItem { Title = "Linear Process Diagram", Description = "Linear sequence of dependence.", Icon = "../Images/rolls.jpg", Run = SequenceSample }, new SampleItem { Title = "Floor plan", Description = "Sample which demonstrates the possibility to use RadDiagram to create floor plans.", Icon = "../Images/floorplan.jpg", Run = FloorPlanSample }, new SampleItem { Title = "Decision Flowchart", Description = "A typical flowchart using RadDiagram.", Icon = "../Images/simpleflow.jpg", Run = SimpleFlowSample } }; }
/// <summary> /// Gets the samples. /// </summary> /// <param name="diagram">The diagram.</param> /// <returns></returns> public static IEnumerable <SampleItem> GetSamples(RadDiagram diagram = null) { return(new[] { new SampleItem { Title = "Simple Diagram", Description = "A basic diagram of geometric shapes.", Icon = "Images/flow.jpg", Run = SimpleDiagramSample }, new SampleItem { Title = "Cycle Diagram", Description = "Example of a cycle process aka methodology.", Icon = "Images/circle.jpg", Run = CycleSample }, new SampleItem { Title = "Bezier Diagram", Description = "Sample demonstrating a stakeholder diagram.", Icon = "Images/bezier.jpg", Run = BezierSample }, new SampleItem { Title = "Linear Process Diagram", Description = "Linear sequence of dependence.", Icon = "Images/rolls.jpg", Run = SequenceSample }, new SampleItem { Title = "Floor plan", Description = "Sample which demonstrates the possibility to use RadDiagram to create floor plans.", Icon = "Images/floorplan.jpg", Run = FloorPlanSample }, new SampleItem { Title = "Decision Flowchart", Description = "A typical flowchart using RadDiagram.", Icon = "Images/simpleflow.jpg", Run = SimpleFlowSample } }); }
/// <summary> /// Layouts all the shapes of a diagram in organizational manner. /// </summary> /// <param name="diagram">The diagram.</param> public void Layout(RadDiagram diagram) { if (diagram == null) { return; } var root = diagram.Shapes.FirstOrDefault(shape => !(shape as RadDiagramShape).HasParents()) as RadDiagramShape; if (root != null) { this.sizeCache.Clear(); this.CalculateBoundingBoxes(root); this.LayoutShape(root, new Point(0, 0)); } }
private static DiagramScrollingInfo CreateDiagramInfo(RadDiagram diagram) { var toolService = diagram.ServiceLocator.GetService <IToolService>() as ToolService; var diagramInfo = new DiagramScrollingInfo() { ConnectionTool = (ConnectionTool)toolService.FindTool(ConnectionTool.ToolName), ConnectionManipulationTool = (ConnectionManipulationTool)toolService.FindTool(ConnectionManipulationTool.ToolName), ScrollingTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1) }, DraggingService = (DraggingService)diagram.ServiceLocator.GetService <IDraggingService>(), }; return(diagramInfo); }
private static void LoadSample(RadDiagram diagram, string name) { diagram.Clear(); using (var stream = ExtensionUtilities.GetStream(string.Format("/Common/SampleDiagrams/{0}.xml", name))) { using (var reader = new StreamReader(stream)) { var xml = reader.ReadToEnd(); if (!string.IsNullOrEmpty(xml)) { diagram.Load(xml); } } } diagram.Dispatcher.BeginInvoke(new Action(() => diagram.AutoFit()), System.Windows.Threading.DispatcherPriority.Loaded); }
private void CreateCurrentPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel) { System.Windows.Controls.Label lbl = new System.Windows.Controls.Label(); Binding myBinding = new Binding(nameof(ReplayerViewModel.CurrentPotValue)) { Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "Pot {0:C2}" }; lbl.SetBinding(ContentControl.ContentProperty, myBinding); lbl.Background = Brushes.LightGray; lbl.Foreground = Brushes.Black; lbl.BorderBrush = Brushes.Black; lbl.BorderThickness = new Thickness(1); lbl.Padding = new Thickness(3, 3, 3, 3); lbl.Margin = new Thickness(480, 315, 100, 100); diagram.AddShape(lbl); }
public static void CreateGraph(this RadDiagram diagram, GraphGenerationSpecifications specs, CreateShapeDelegate createShape) { diagram.Clear(); if (specs.Connections) { var g = specs.Connected ? GraphExtensions.CreateRandomConnectedGraph(specs.NodeCount, 4, specs.TreeGraph) : GraphExtensions.CreateRandomGraph(specs.NodeCount, 4, specs.TreeGraph); diagram.CreateDiagram(g, GraphExtensions.CreateShape, specs.RandomShapeSize); } else { for (var i = 0; i < specs.NodeCount; i++) { var shape = createShape(new Node(i, false), specs.RandomShapeSize); diagram.AddShape(shape); } } }
public static RadFixedPage ExportDiagram(RadDiagram diagram, Rect pageSize) { RadFixedPage page = new RadFixedPage(); page.Size = pageSize.ToSize(); var orderedContainers = diagram.Items.Select(i => diagram.ContainerGenerator.ContainerFromItem(i)).OrderBy(c => c.ZIndex); foreach (var container in orderedContainers) { if (container.Visibility != Visibility.Visible) { continue; } var shape = container as RadDiagramShape; if (shape != null) { ExportShape(shape, pageSize, page); continue; } var textShape = container as RadDiagramTextShape; if (textShape != null) { ExportTextShape(textShape, pageSize, page); continue; } var containerShape = container as RadDiagramContainerShape; if (containerShape != null) { ExportContainerShape(containerShape, pageSize, page); continue; } var connection = container as RadDiagramConnection; if (connection != null) { ExportConnection(connection, pageSize, page); continue; } } return(page); }
private void Open(RadDiagram diagram, string Path) { if (diagram.GraphSource == null) { diagram.Clear(); } using (var stream = System.IO.File.OpenRead(Path)) { using (var reader = new System.IO.StreamReader(stream)) { var xml = reader.ReadToEnd(); if (!string.IsNullOrEmpty(xml)) { diagram.Load(xml); } } } }
private void CreateTotalPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel) { System.Windows.Controls.Label lbl = new System.Windows.Controls.Label(); Binding myBinding = new Binding(nameof(ReplayerViewModel.TotalPotValue)) { Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "{0:C2}" }; lbl.SetBinding(ContentControl.ContentProperty, myBinding); lbl.Foreground = Brushes.White; lbl.Margin = new Thickness(480, 100, 100, 100); diagram.AddShape(lbl); viewModel.TotalPotChipsContainer.ChipsShape.X = TotalPotChipsPosition.X; viewModel.TotalPotChipsContainer.ChipsShape.Y = TotalPotChipsPosition.Y; diagram.AddShape(viewModel.TotalPotChipsContainer.ChipsShape); }
public static RadFixedPage ExportDiagram(RadDiagram diagram, Rect pageSize) { RadFixedPage page = new RadFixedPage(); page.Size = pageSize.ToSize(); var orderedContainers = diagram.Items.Select(i => diagram.ContainerGenerator.ContainerFromItem(i)).OrderBy(c => c.ZIndex); foreach (var container in orderedContainers) { if (container.Visibility != Visibility.Visible) continue; var shape = container as RadDiagramShape; if (shape != null) { ExportShape(shape, pageSize, page); continue; } var textShape = container as RadDiagramTextShape; if (textShape != null) { ExportTextShape(textShape, pageSize, page); continue; } var containerShape = container as RadDiagramContainerShape; if (containerShape != null) { ExportContainerShape(containerShape, pageSize, page); continue; } var connection = container as RadDiagramConnection; if (connection != null) { ExportConnection(connection, pageSize, page); continue; } } return page; }
public static void LoadDiagram(RadDiagram diagram, string name) { diagram.Clear(); using (var stream = ExtensionUtilities.GetStream(string.Format("{0}.xml", name), "Procbel.Apps.Silverlight.Modules.Inicio")) { using (var reader = new StreamReader(stream)) { var xml = reader.ReadToEnd(); if (!string.IsNullOrEmpty(xml)) { diagram.Load(xml); } } } #if WPF diagram.Dispatcher.BeginInvoke(new Action(() => diagram.AutoFit()), System.Windows.Threading.DispatcherPriority.Loaded); #else diagram.Dispatcher.BeginInvoke(new Action(() => diagram.AutoFit())); #endif }
/// <summary> /// Loads the cycle sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void CycleSample(RadDiagram diagram) { LoadSample(diagram, "Cycle3"); }
/// <summary> /// Loads the decision sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void SimpleFlowSample(RadDiagram diagram) { LoadSample(diagram, "SimpleFlow"); }
/// <summary> /// Loads the floor plan sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void FloorPlanSample(RadDiagram diagram) { LoadSample(diagram, "FloorPlan"); }
public MyResizing(RadDiagram owner) : base(owner as IGraphInternal) { this.CanResizeWidth = true; this.CanResizeHeight = true; }
/// <summary> /// Loads the stakeholders sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void StakeholderSample(RadDiagram diagram) { LoadSample(diagram, "Stakeholder"); }
private static void LoadSample(RadDiagram diagram, string name) { diagram.Clear(); using (var stream = ExtensionUtilities.GetStream(string.Format("/Common/SampleDiagrams/{0}.xml", name))) { using (var reader = new StreamReader(stream)) { var xml = reader.ReadToEnd(); if (!string.IsNullOrEmpty(xml)) { diagram.Load(xml); } } } diagram.Dispatcher.BeginInvoke(new Action(() => diagram.AutoFit())); }
/// <summary> /// Loads the cycle sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void BezierSample(RadDiagram diagram) { LoadSample(diagram, "Supply"); }
/// <summary> /// Loads the sequence sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void SequenceSample(RadDiagram diagram) { LoadSample(diagram, "Rolls"); }
public SamplesViewModel(RadDiagram diagram) { this.diagram = diagram; this.Samples = SamplesFactory.GetSamples(diagram); this.SelectedSample = this.Samples.Last(); }
private static void ScrollDiagram(DiagramScrollingInfo diagramInfo, RadDiagram diagram) { switch (diagramInfo.AutoScrollingDirection) { case ScrollingDirection.Up: diagram.Scroll(0, ConnectionManipulationAutoScrollBehavior.ScrollingStep); break; case ScrollingDirection.Down: diagram.Scroll(0, -ConnectionManipulationAutoScrollBehavior.ScrollingStep); break; case ScrollingDirection.Right: diagram.Scroll(-ConnectionManipulationAutoScrollBehavior.ScrollingStep, 0); break; case ScrollingDirection.Left: diagram.Scroll(ConnectionManipulationAutoScrollBehavior.ScrollingStep, 0); break; } }
public static void CreateHTMLFile(RadDiagram diagram, string jsRadSVGFilePath = RadSVGFilePath, string jsRadDiagramFilePath = RadDiagramFilePath) { string htmlContent = string.Empty; htmlContent += HTMLExportHelper.DocumentStart; htmlContent += HTMLExportHelper.HeadStart; htmlContent += LoadStringFromFile(jsRadSVGFilePath); htmlContent += LoadStringFromFile(jsRadDiagramFilePath); var serialization = diagram.Serialize(); htmlContent += "var diagramXML = '" + serialization.ToString().Replace(System.Environment.NewLine, " ") + "'; \n"; htmlContent += LoadStringFromFile(JSInteractionsFilePath); htmlContent += HTMLExportHelper.ScriptEnd; htmlContent += LoadStringFromFile(ExportStyleFilePath); htmlContent += HTMLExportHelper.HeadEnd; htmlContent += HTMLExportHelper.Body; htmlContent += HTMLExportHelper.DocumentEnd; try { var saveFileDialog = new SaveFileDialog() { Filter = "HTML (.html;*.htm)|*.html;*.htm|All Files (*.*)|*.*" }; var result = saveFileDialog.ShowDialog(); if (result == true) { using (var fileStream = saveFileDialog.OpenFile()) { using (var writer = new StreamWriter(fileStream)) { writer.Write(htmlContent); } } #if WPF Process.Start(saveFileDialog.FileName); #endif } } catch (Exception exc) { #if WPF if (exc is Win32Exception) { // error finding the file } else #endif if (exc is ObjectDisposedException || exc is FileNotFoundException) { //failed to start the default browser or HTML viewer } else throw; } }
private static void RemoveAssosiation(RadDiagram diagram) { diagramInfos.Remove(diagram); }
//private bool isFirstResize; public CustomResizingService(RadDiagram diagram) : base(diagram) { }
/// <summary> /// Loads the simple diagram sample. /// </summary> /// <param name="diagram">The diagram.</param> public static void SimpleDiagramSample(RadDiagram diagram) { LoadSample(diagram, "Flow2"); }
private static ScrollingDirection GetScrollingDirection(RadDiagram diagram, Point currentPosition) { var diagramPosition = diagram.GetTransformedPoint(currentPosition); if (diagramPosition.Y <= diagram.Viewport.Top) { return ScrollingDirection.Up; } else if (diagramPosition.Y >= diagram.Viewport.Bottom) { return ScrollingDirection.Down; } else if (diagramPosition.X <= diagram.Viewport.Left) { return ScrollingDirection.Left; } else if (diagramPosition.X >= diagram.Viewport.Right) { return ScrollingDirection.Right; } else { return ScrollingDirection.None; } }
private static DiagramScrollingInfo CreateDiagramInfo(RadDiagram diagram) { var toolService = diagram.ServiceLocator.GetService<IToolService>() as ToolService; var diagramInfo = new DiagramScrollingInfo() { ConnectionTool = (ConnectionTool)toolService.FindTool(ConnectionTool.ToolName), ConnectionManipulationTool = (ConnectionManipulationTool)toolService.FindTool(ConnectionManipulationTool.ToolName), ScrollingTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1) }, DraggingService = (DraggingService)diagram.ServiceLocator.GetService<IDraggingService>(), }; return diagramInfo; }