private void ExtrasViewLoaded(object sender, RoutedEventArgs e)
 {
     var vm = (ExtrasViewModel) DataContext;
     var cvsAvailable = Resources["cvsAvailableExtras"] as CollectionViewSource;
     var c = new CompositeCollection();
     c.Add(new CollectionContainer {Collection = vm.StatusHandlers});
     c.Add(new CollectionContainer {Collection = vm.UrlShorteners});
     cvsAvailable.Source = c;
 }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var compositeCollection = new CompositeCollection();
            foreach (var value in values)
            {
                var enumerable = value as IEnumerable;
                if (enumerable != null)
                {
                    compositeCollection.Add(new CollectionContainer { Collection = enumerable });
                }
                else
                {
                    compositeCollection.Add(value);
                }
            }

            return compositeCollection;
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var res = new CompositeCollection();

            foreach (var item in values)
            {
                if (item is IEnumerable)
                {
                    res.Add(new CollectionContainer()
                    {
                        Collection = item as IEnumerable
                    });
                }
                else
                {
                    res.Add(item);
                }
            }

            return res;
        }
Exemplo n.º 4
0
        public ParameterViewModel()
        {
            coll = new CompositeCollection();
            settings = DataContainer.NeuralNetwork.Settings;
            PropertyInfo[] props = settings.GetType().GetProperties();
            foreach(PropertyInfo prop in props)
            {
                ObservableCollection<dynamic> tempcoll = new ObservableCollection<dynamic>();
                tempcoll.Add(prop.GetValue(settings));
                coll.Add(new CollectionContainer() { Collection = tempcoll });

            }
        }
        private void AccountsView_Loaded(object sender, RoutedEventArgs e)
        {
            var vm = (AccountsViewModel) DataContext;
            var cvsAvailable = Resources["cvsAvailableAccounts"] as CollectionViewSource;
            var c = new CompositeCollection();
            c.Add(new CollectionContainer {Collection = vm.NewMicroblogs});
            cvsAvailable.Source = c;

            var cvsCurrent = Resources["cvsCurrentAccounts"] as CollectionViewSource;
            c = new CompositeCollection();
            c.Add(new CollectionContainer {Collection = vm.PluginRepository.Microblogs});
            cvsCurrent.Source = c;
        }
Exemplo n.º 6
0
        private void DefineCellsPane_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext == null || !(this.DataContext is WorkbookModel)) return;

            var myWorkbookModel = this.DataContext as WorkbookModel;
            var defineCellsCollection = new CompositeCollection();

            #region collection containers
            var inputCellsCContoiner = new CollectionContainer()
            {
                Collection = myWorkbookModel.InputCells
            };
            defineCellsCollection.Add(inputCellsCContoiner);

            var intermediateCellsCContainer = new CollectionContainer()
            {
                Collection = myWorkbookModel.IntermediateCells
            };
            defineCellsCollection.Add(intermediateCellsCContainer);

            var outputCellsCContainer = new CollectionContainer()
            {
                Collection = myWorkbookModel.OutputCells
            };
            defineCellsCollection.Add(outputCellsCContainer);

            #endregion

            var defineCellsBinding = new Binding()
            {
                Source = defineCellsCollection,
                Mode = BindingMode.OneWay
            };

            this.CellDefinitionsList.SetBinding(ListBox.ItemsSourceProperty, defineCellsBinding);
        }
        /// <summary>
        /// Updates the Selector control's <see cref="ItemsControl.ItemsSource"/> to include the
        /// <see cref="NullItem"/> along with the objects in <see cref="ItemsSource"/>.
        /// </summary>
        protected void Adapt()
        {
            if (CollectionView != null)
            {
                CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
                CollectionView = null;
            }
            if (Selector != null && ItemsSource != null)
            {
                CompositeCollection comp = new CompositeCollection();
                comp.Add(NullItem);
                comp.Add(new CollectionContainer { Collection = ItemsSource });

                CollectionView = CollectionViewSource.GetDefaultView(comp);
                if (CollectionView != null) CollectionView.CurrentChanged += CollectionView_CurrentChanged;

                Selector.ItemsSource = comp;
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //var collection = NodeNetwork.Instance.FirstCollection;

            //if (collection == NodeNetwork.CollectionType.Cells)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.Sink)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.Nodes)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.NodeLinks)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            var res = new CompositeCollection();

            foreach (var item in values)
            {
                if (item is IEnumerable)
                {
                    res.Add(new CollectionContainer
                    {
                        Collection = item as IEnumerable
                    });
                }
                else
                {
                    if (item is SinkViewModel)
                        res.Add(item);
                }
            }

            return res;
        }
Exemplo n.º 9
0
        private void ScenarioDetailPane_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext == null || !(this.DataContext is Scenario)) return;

            var myScenario = this.DataContext as Scenario;

            //update bindings
            #region binding definitions
            var titleBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Title"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var authorBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Author"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var creationDateBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("CrationDate"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var ratingBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Rating"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var descriptionBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Description"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            #endregion

            #region set bindings
            //task pane title
            this.PaneTitle.SetBinding(TextBlock.TextProperty, titleBinding);

            //general
            #region general
            //title
            this.TitleTextBox.SetBinding(TextBox.TextProperty, titleBinding);

            //author
            this.AuthorTextbox.SetBinding(TextBox.TextProperty, authorBinding);

            //creation date
            this.CreateDatePicker.SetBinding(DatePicker.SelectedDateProperty, creationDateBinding);

            //rating
            this.RatingTextBox.SetBinding(TextBox.TextProperty, ratingBinding);

            #endregion

            //description
            this.DescriptionTextBox.SetBinding(TextBox.TextProperty, descriptionBinding);
            
            // input, intermediate and result cells data
            ScenarioDataCollection = new CompositeCollection();

            #region collection container
            var inputDataCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Inputs
            };
            ScenarioDataCollection.Add(inputDataCContainer);

            var intermediateCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Intermediates
            };
            ScenarioDataCollection.Add(intermediateCContainer);

            var resultDataCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Results
            };
            ScenarioDataCollection.Add(resultDataCContainer);
            #endregion

            /*this.ScenarioDataView = new ListCollectionView(scenarioDataCollection);
            this.ScenarioDataView.SortDescriptions.Add(new SortDescription("Location", ListSortDirection.Ascending));*/
            this.ScenarioDataListBox.ItemsSource = ScenarioDataCollection;

            #endregion
        }
Exemplo n.º 10
0
        internal virtual void ShowContextMenu(Card card)
        {
            if (Player.LocalPlayer.Spectator)
                return;
            // Modify selection
            if (card == null || !card.Selected) Selection.Clear();

            var menuItems = new CompositeCollection();            
            ContextGroup = group;
            ContextMenu = new ContextMenu {ItemsSource = menuItems, Tag = card};
            // card has to captured somehow, otherwise it may be overwritten before released in the OnClosed handler, e.g. when rightclicking on a card, then directly right-clicking on another card.
            ContextMenu.Opened += (sender, args) =>
                                      {
                                          ContextGroup.KeepControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.KeepControl();
                                      };
            ContextMenu.Closed += (sender, args) =>
                                      {
                                          ContextGroup.ReleaseControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.ReleaseControl();
                                      };

            ContextCard = card;
            menuItems.Clear();

            if (card != null)
            {
                //var cardMenuItems = await CreateCardMenuItems(card, group.Definition);
                var cardMenuItems = CreateCardMenuItems(card, group.Definition);
                var container = new CollectionContainer { Collection = cardMenuItems };
                menuItems.Add(container);
            }

            if (ShouldShowGroupActions(card))
            {
              var container = new CollectionContainer { Collection = CreateGroupMenuItems(group.Definition) };
              menuItems.Add(container);
            }
            //else // Group is being shuffled
            //    return;

            ContextMenu.IsOpen = false;
            // Required to trigger the ReleaseControl calls if the ContextMenu was already open
            ContextMenu.UpdateLayout(); // Required if the ContextMenu was already open
            ContextMenu.IsOpen = true;
            ContextMenu.FontFamily = groupFont;
            ContextMenu.FontSize = fontsize;
        }
        /// <summary>
        /// Updates the Selector control's <see cref="ItemsControl.ItemsSource"/> to include the
        /// <see cref="NullItem"/> along with the objects in <see cref="ItemsSource"/>.
        /// </summary>
        protected void Adapt()
        {
            //if (CollectionView != null)
            //{
            //    CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
            //    CollectionView = null;
            //}

            if (Selector != null)
            {
                //if (ItemsSource is System.Collections.Specialized.INotifyCollectionChanged)
                //{
                //    var col = ItemsSource as System.Collections.Specialized.INotifyCollectionChanged;
                //    col.CollectionChanged -= ItemsSource_CollectionChanged;
                //    col.CollectionChanged += ItemsSource_CollectionChanged;
                //}

                CompositeCollection comp = new CompositeCollection();
                if (ItemsSource != null)
                {
                    comp.Add(new CollectionContainer { Collection = ItemsSource });
                }

                //comp.Add(new CollectionContainer { Collection = new string[] { "(None)" } });
                if (NullItems != null)
                {
                    foreach (var item in NullItems)
                    {
                        if (IsAddingNullItemsFirst)
                            comp.Insert(0, item);
                        else
                            comp.Add(item);
                    }
                }

                //CollectionView = CollectionViewSource.GetDefaultView(comp);
                //if (CollectionView != null) CollectionView.CurrentChanged += CollectionView_CurrentChanged;

                Selector.ItemsSource = comp;
            }
        }
Exemplo n.º 12
0
        internal virtual void ShowContextMenu(Card card, bool showGroupActions = true)
        {
            // Modify selection
            if (card == null || !card.Selected) Selection.Clear();

            var menuItems = new CompositeCollection();            
            ContextGroup = group;
            ContextMenu = new ContextMenu {ItemsSource = menuItems, Tag = card};
            // card has to captured somehow, otherwise it may be overwritten before released in the OnClosed handler, e.g. when rightclicking on a card, then directly right-clicking on another card.
            ContextMenu.Opened += (sender, args) =>
                                      {
                                          ContextGroup.KeepControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.KeepControl();
                                      };
            ContextMenu.Closed += (sender, args) =>
                                      {
                                          ContextGroup.ReleaseControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.ReleaseControl();
                                      };

            ContextCard = card;
            menuItems.Clear();

            if (group.CanManipulate())
            {
                if (card != null)
                {
                    if (card.CanManipulate())
                    {
                        if (_cardHeader != null)
                        {
                            _cardHeader.Header = card.Name;
                            _cardHeader.Background = card.Controller.TransparentBrush;
                            menuItems.Add(_cardMenu);
                        }
                    }
                    else
                    {
                        var item = new MenuItem {Header = card.Name, Background = card.Controller.TransparentBrush};
                        item.SetResourceReference(StyleProperty, "MenuHeader");
                        menuItems.Add(item);

                        item = new MenuItem {Header = "Take control"};
                        item.Click += delegate { card.TakeControl(); };
                        menuItems.Add(item);
                    }

                    if (!card.FaceUp)
                    {
                        var peekItem = new MenuItem {Header = "Peek", InputGestureText = "Ctrl+P"};
                        peekItem.Click += delegate { ContextCard.Peek(); };
                        if (menuItems.Count == 0)
                        {
                            var item = new MenuItem {Header = card.Name, Background = card.Owner.TransparentBrush};
                            item.SetResourceReference(StyleProperty, "MenuHeader");
                            menuItems.Add(item);
                        }
                        menuItems.Add(peekItem);
                    }
                }

                if (showGroupActions)
                    menuItems.Add(_groupMenu);
            }
            else// if (!group.WantToShuffle)
            {
                menuItems.Add(CreateGroupHeader());

                var item = new MenuItem {Header = "Take control"};
                item.Click += delegate { group.TakeControl(); };
                menuItems.Add(item);

                menuItems.Add(new Separator());
                item = CreateLookAtCardsMenuItem();
                if (item != null) menuItems.Add(item);
            }
            //else // Group is being shuffled
            //    return;

            ContextMenu.IsOpen = false;
            // Required to trigger the ReleaseControl calls if the ContextMenu was already open
            ContextMenu.UpdateLayout(); // Required if the ContextMenu was already open
            ContextMenu.IsOpen = true;
            ContextMenu.FontFamily = groupFont;
            ContextMenu.FontSize = fontsize;
        }
Exemplo n.º 13
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var sourceClass = value as TagClass;
            if (sourceClass == null)
                return null;

            //hax 2 tha max
            var nullTag = new TagEntry(null, null, "(null)");

            var tagList = new CompositeCollection();
            tagList.Add(nullTag);

            var mainTagListContainer = new CollectionContainer();
            mainTagListContainer.Collection = sourceClass.Children;

            tagList.Add(mainTagListContainer);

            return tagList;
        }
        public NetworkDrawingViewModel()
        {
            rendercoll = new CompositeCollection();
            tracklines = new ObservableCollection<Track>();
            OCPcollection = new ObservableCollection<OCP>();
            switchcollection = new ObservableCollection<Switch>();
            penscale = 1;
            for(int i = 0; i < DataContainer.model.infrastructure.tracks.Count; i++)
            {
                Track temptrack = new Track();
                eTrack track = DataContainer.model.infrastructure.tracks[i];
                if (track.trackTopology.trackEnd.geoCoord.coord.Count != 0 && track.trackTopology.trackBegin.geoCoord.coord.Count != 0)
                {

                    temptrack.track = track;
                    temptrack.index = i;
                    temptrack.X1 = track.trackTopology.trackBegin.geoCoord.coord[0];
                    temptrack.X2 = track.trackTopology.trackEnd.geoCoord.coord[0];
                    temptrack.Y1 = track.trackTopology.trackBegin.geoCoord.coord[1];
                    temptrack.Y2 = track.trackTopology.trackEnd.geoCoord.coord[1];

                    temptrack.points.Add(new Point(track.trackTopology.trackBegin.geoCoord.coord[0],track.trackTopology.trackBegin.geoCoord.coord[1]));

                    foreach(tPlacedElement point in track.trackElements.geoMappings)
                    {
                        temptrack.points.Add(new Point(point.geoCoord.coord[0], point.geoCoord.coord[1]));
                    }
                    temptrack.points.Add(new Point(track.trackTopology.trackEnd.geoCoord.coord[0], track.trackTopology.trackEnd.geoCoord.coord[1]));

                    tracklines.Add(temptrack);

                    foreach(tCommonSwitchAndCrossingData connection in track.trackTopology.connections)
                    {
                        if (connection.geoCoord.coord.Count == 2)
                        {
                            Switch sw = new Switch();
                            sw.element = connection;
                            sw.X = connection.geoCoord.coord[0];
                            sw.Y = connection.geoCoord.coord[1];
                            switchcollection.Add(sw);
                        }
                    }

                }

            }

            foreach(eOcp ocp in DataContainer.model.infrastructure.operationControlPoints)
            {
                OCP tempocp = new OCP();
                tempocp.ocp = ocp;
                if (ocp.geoCoord.coord.Count == 2)
                {
                    tempocp.X = ocp.geoCoord.coord[0] - tempocp.diameter / 2;
                    tempocp.Y = ocp.geoCoord.coord[1] - tempocp.diameter / 2;
                    OCPcollection.Add(tempocp);
                }
            }
            rendercoll.Add(new CollectionContainer(){Collection = tracklines});
            rendercoll.Add(new CollectionContainer() { Collection = OCPcollection });
            rendercoll.Add(new CollectionContainer() {Collection = switchcollection});
        }
        public SurfaceWindow1ViewModel()
        {
            _allObjectsCollection = new CompositeCollection();

            _chromosomeBarViewModel = new ChromosomeBarViewModel(_genBankProvider, this);
            _chromosomeBarViewModel.NewGeneSelected += new GeneSelectedHandler((gene) => OnPropertyChanged("SelectedGene"));

            _testSVIViewModel = new TestSVIViewModel();
            _extendedDesktopViewModel = new ExtendedDesktopViewModel(this);
            _primerDesignerViewModel = new PrimerDesignerViewModel(this);

            _allObjectsCollection.Add(_chromosomeBarViewModel);
            //_allObjectsCollection.Add(_testSVIViewModel);
            _allObjectsCollection.Add(_extendedDesktopViewModel);
            _allObjectsCollection.Add(PersistentSearchMenu);
        }
        public RoutineBuilder(Routine routine)
        {
            //View initialization
            InitializeComponent();
            LivePreview = false;
            //Initialize Routine
            _routine = routine;
            _routine.RoutineBuilder = this;
            tbxRoutineName.Text = _routine.Name;
            this.Title = _routine.Name;
            //Build Canvas toolbar - drawing shapes icons
            toolbarButtons = new List<ToggleButton>();
            toolbarButtons.Add(btnToolbarMove);
            toolbarButtons.Add(btnToolbarArc);
            toolbarButtons.Add(btnToolbarCircle);
            toolbarButtons.Add(btnToolbarDot);
            toolbarButtons.Add(btnToolbarLine);
            toolbarButtons.Add(btnToolbarPolyline);
            toolbarButtons.Add(btnToolbarRectangle);
            toolbarButtons.Add(btnToolbarReferencePoint);
            toolbarButtons.Add(btnToolbarAttrPoint);
            _activeTool = null;
            _drawing = false;
            _movingShape = false;
            _movingReferencePoint = false;
            _movingAttributePoint = false;
            _makingPath = false;
            _makingPathStep2 = false;
            attributePointPopup = new AttributePointPopup();
            //Build "Add Fixture" popup
            addFixturePop = new AddFixturePopup();
            addFixturePop.AddSelectedClick += new RoutedEventHandler(SubroutineBuilder_AddSelectedClick);

            //Initialize Timeline
            CollectionContainer items = new CollectionContainer();
            items.Collection = _routine.RoutineFixtures;
            CollectionContainer newFixtureLineCollection = new CollectionContainer();
            BindingList<string> newFixtureLine = new BindingList<string>();
            newFixtureLine.Add("Click here to add a fixture...");
            newFixtureLineCollection.Collection = newFixtureLine;

            CompositeCollection cmpc = new CompositeCollection();
            cmpc.Add(items);
            cmpc.Add(newFixtureLineCollection);

            lbxTimeline.ItemsSource = cmpc;
            //lbxTimeline.ItemsSource = _routine.RoutineFixtures;
            _lastSelectedFixture = null;

            //Step items list. necessary?
            lbxSteps.ItemsSource = null;

            //Reference Point list.
            lbxReferencePoints.ItemsSource = null;
        }