public NavigationPageDialog(PrototypeElement _instance, SessionManager _sessionManager, string _gesture, Label _behaviorLabel) { InitializeComponent(); gesture = _gesture; const string gestureContent = "Use {0} to navigate to page:"; Title.Content = String.Format(gestureContent, gesture); sessionManager = _sessionManager; instance = _instance; PagesListBox.SetBinding(SurfaceListBox.ItemsSourceProperty, new Binding() { Source = _sessionManager.CurrentProject.PageDictionary.ValueObservableCollection }); behaviorLabel = _behaviorLabel; }
public void BindScatterViewItemAndElement(ScatterViewItem svi, PrototypeElement element) { svi.Tag = element; PrototypeElement _element = new PrototypeElement() { Width = element.Width, Height = element.Height, Center = element.Center, Orientation = element.Orientation}; Binding elementBindings = new Binding(); elementBindings.Mode = BindingMode.OneWayToSource; elementBindings.Source = element; elementBindings.Path = new PropertyPath("Width"); svi.SetBinding(ScatterViewItem.WidthProperty, elementBindings); elementBindings = new Binding(); elementBindings.Mode = BindingMode.OneWayToSource; elementBindings.Source = element; elementBindings.Path = new PropertyPath("Height"); svi.SetBinding(ScatterViewItem.HeightProperty, elementBindings); elementBindings = new Binding(); elementBindings.Mode = BindingMode.OneWayToSource; elementBindings.Source = element; elementBindings.Path = new PropertyPath("Center"); svi.SetBinding(ScatterViewItem.CenterProperty, elementBindings); elementBindings = new Binding(); elementBindings.Mode = BindingMode.OneWayToSource; elementBindings.Source = element; elementBindings.Path = new PropertyPath("Orientation"); svi.SetBinding(ScatterViewItem.OrientationProperty, elementBindings); if (element != null) { svi.Width = _element.Width; svi.Center = _element.Center; svi.Height = _element.Height; svi.Orientation = _element.Orientation; } }
private ScatterViewItem getItemByElement(PrototypeElement element) { ScatterView previewContainer = this.previewContainer; foreach (var item in previewContainer.Items) { if (item is ScatterViewItem) if ((item as ScatterViewItem).Tag is PrototypeElement) if (((item as ScatterViewItem).Tag as PrototypeElement).UniqueId == element.UniqueId) return item as ScatterViewItem; } return null; }
/* * PREPARE EVENTS PANEL TO BE USED WITH A PROTOTYPE ELEMENT */ public void SetupEventsPanel(PrototypeElement instance = null) { this.TriggersGrid.IsEnabled = (instance != null); this.TriggersGrid.Items.Clear(); ScatterViewItem svi = asg.Container.ItemContainerGenerator.ContainerFromItem(this) as ScatterViewItem; if (svi == null) return; const string behaviorLabelFormatBase = "Navigate, Page {0}"; LookForNewGestures(); foreach (var item in asg.ActiveSessionManager.CommonGestureManager.GestureList) { //SurfaceListBoxItem listItem = new SurfaceListBoxItem(); DockPanel panel = new DockPanel(); Border borderLeft = new Border { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(5), Background = Brushes.White }; Label gestureLabel = new Label { Content = item.DisplayName, Width = svi.Width /4, FontSize=20 }; borderLeft.Child = gestureLabel; panel.Children.Add(borderLeft); Border borderRight = new Border { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(5), Background = Brushes.White }; DockPanel rightDockPanel = new DockPanel { LastChildFill = true }; borderRight.Child = rightDockPanel; String behaviorLabelText = String.Empty; if (instance != null) { if (instance.GestureTargetPageMap.ContainsKey(item.Identifier) && asg.ActiveSessionManager.CurrentProject.PageDictionary.ContainsKey(instance.GestureTargetPageMap[item.Identifier])) behaviorLabelText = String.Format(behaviorLabelFormatBase, asg.ActiveSessionManager.CurrentProject.PageDictionary[instance.GestureTargetPageMap[item.Identifier]].PageNumber); } Label behaviorLabel = new Label { Content = behaviorLabelText, Width = svi.Width/2.2, FontSize=20 }; SurfaceButton setValueButton = new SurfaceButton { Content = "+", FontSize=25, FontWeight = FontWeights.Bold, Width = 40, Height=40, Foreground = new SolidColorBrush(Colors.White), Background = new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString("#282828")), BorderThickness = new Thickness(0, 0, 0, 0), Tag = item }; SurfaceButton removeValueButton = new SurfaceButton { Content = "-", FontSize = 25, Height=40, Foreground = new SolidColorBrush(Colors.White), FontWeight = FontWeights.Bold, Width = 45, Background = new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString("#282828")), BorderThickness = new Thickness(0, 0, 0, 0), Tag = item }; setValueButton.Click += new RoutedEventHandler(delegate(object sender, RoutedEventArgs args) { if (instance == null) return; if (asg.Container.Items.Contains(choose)) { asg.Container.Items.Remove(choose); } String selectedGestureId = (setValueButton.Tag as Gesture).Identifier; choose = new NavigationPageDialog(instance, asg.ActiveSessionManager, selectedGestureId, behaviorLabel); asg.Container.Items.Add(choose); ScatterViewItem newItem = asg.Container.ItemContainerGenerator.ContainerFromItem(choose) as ScatterViewItem; newItem.Orientation = 0; newItem.Height = asg.Height / 2; newItem.Width = asg.Width / 1.3; newItem.Center = asg.CanvasItem.ActualCenter; }); removeValueButton.Click += new RoutedEventHandler(delegate(object sender, RoutedEventArgs args) { String selectedGestureId = (setValueButton.Tag as Gesture).Identifier; if (instance.GestureTargetPageMap.ContainsKey(selectedGestureId)) { instance.GestureTargetPageMap.Remove(selectedGestureId); behaviorLabel.Content = ""; } }); DockPanel.SetDock(setValueButton, Dock.Right); DockPanel.SetDock(removeValueButton, Dock.Right); rightDockPanel.Children.Add(removeValueButton); rightDockPanel.Children.Add(setValueButton); rightDockPanel.Children.Add(behaviorLabel); panel.Children.Add(borderRight); this.TriggersGrid.Items.Add(panel); } }
private void ObjectsTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { selectedElement = e.NewValue as PrototypeElement; }
public void RemovePrototypeElementFromPage(PrototypeElement element) { CurrentPage.PrototypeElementDictionary.Remove(element.UniqueId); NotifyPropertyChanged("PrototypeElementDictionary.Values"); }
public void AddPrototypeElementToPage(ASGPage page, PrototypeElement element) { element.UniqueId = CurrentProject.GetNextUniqueId(); page.PrototypeElementDictionary.Add(element.UniqueId, element); NotifyPropertyChanged("PrototypeElementDictionary.Values"); }
private void CreateGestureArea() { Rect b = selectedStrokes.GetBounds(); PrototypeElement element = new PrototypeElement { Orientation = defaultOrientation, Width = b.Width, Height = b.Height, Center = new Point(b.Location.X + b.Width / 2, b.Location.Y + b.Height / 2) }; addThisElementToCanvas(ActiveSessionManager.CurrentPage, element, element.Orientation); ScatterViewItem svi = Container.ItemContainerGenerator.ContainerFromItem(events) as ScatterViewItem; if (svi == null) { Container.Items.Add(events); svi = Container.ItemContainerGenerator.ContainerFromItem(events) as ScatterViewItem; defaultOrientation = 0; svi.BorderThickness = new Thickness(10, 10, 10, 10); svi.Orientation = 0; svi.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; svi.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; svi.Height = this.Height / 1.5; svi.Width = this.Width / 2; svi.Visibility = System.Windows.Visibility.Hidden; // CanvasItem.ActualCenter; } svi.Center = new Point(this.Width / 2, this.Height / 2); svi.IsTopmostOnActivation = true; svi.Visibility = System.Windows.Visibility.Visible; events.SetupEventsPanel(element); }
/* * ADDS AN ELEMENT TO CANVAS (GESTURE AREA) * ADDS IT TO CONTAINER AND ACTIVESESSIONMANAGER * AND BINDS IT TO A PROTOTYPE ELEMENT */ public void addThisElementToCanvas(ASGPage page, PrototypeElement _element, double _orientation, System.Windows.Visibility _visibility = System.Windows.Visibility.Visible) { ScatterViewItem svi = new ScatterViewItem(); PrototypeElement element; Container.Items.Add(svi); svi.Visibility = _visibility; svi.BorderThickness = new Thickness(20, 20, 20, 20); svi.Background = new SolidColorBrush(Colors.Transparent); svi.ContainerManipulationCompleted += ScatterViewItem_ScatterManipulationCompleted; if (_element == null) element = new PrototypeElement { ElementType = ElementTypes.None, Orientation = _orientation, Center = svi.ActualCenter }; else { element = new PrototypeElement { ElementType = _element.ElementType, Orientation = _element.Orientation, Center = _element.Center, Width = _element.Width, Height = _element.Height, Content = _element.Content, GestureTargetPageMap = _element.GestureTargetPageMap }; } canvasHelper.BindScatterViewItemAndElement(svi, element); ActiveSessionManager.AddPrototypeElementToPage(page, element); }