public CreateRobotTemplate()
        {
            InitializeComponent();
            Entities        = new EntityDefaults(this.Connstr);
            RTemplate       = new RobotTemplatesTable(this.Connstr);
            BotTemplate     = new RobotTemplate();
            HeadSlotList    = new CompositeCollection();
            ChassisSlotList = new CompositeCollection();
            LegSlotList     = new CompositeCollection();

            BotsList      = Entities.GetEntitiesByCategory(Types.CategoryFlags.cf_robots);
            HeadsList     = Entities.GetEntitiesByCategory(Types.CategoryFlags.cf_robot_head);
            ChassisList   = Entities.GetEntitiesByCategory(Types.CategoryFlags.cf_robot_chassis);
            LegsList      = Entities.GetEntitiesByCategory(Types.CategoryFlags.cf_robot_leg);
            InventoryList = Entities.GetEntitiesByCategory(Types.CategoryFlags.cf_robot_inventory);
            // oh dear god. Shitshow ahead!
            Mods = Entities.GetAllEntities();


            this.DataContext = this;
        }
Exemplo n.º 2
0
        public SuplexMru()
        {
            RecentFiles     = new ObservableCollection <string>();
            RecentServices  = new ObservableCollection <string>();
            RecentDatabases = new ObservableCollection <DatabaseConnectionData>();

            CollectionContainer rsc = new CollectionContainer()
            {
                Collection = RecentServices
            };
            CollectionContainer rdc = new CollectionContainer()
            {
                Collection = RecentDatabases
            };

            RecentRemoteConnections = new CompositeCollection
            {
                rsc,
                rdc
            };
        }
Exemplo n.º 3
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            CompositeCollection CollectionOfItems = parameter as CompositeCollection;

            if (values != null && values.Length > 2 && (values[0] is int) && (values[1] is bool) && (values[2] is int))
            {
                int Level = (int)values[0];
                bool IsRootAlwaysExpanded = (bool)values[1];
                int ChildCount = (int)values[2];

                //Debug.Print("Level: " + Level);

                if (Level == 0 && IsRootAlwaysExpanded)
                    return CollectionOfItems[0];

                else if (ChildCount == 0)
                    return CollectionOfItems[1];
            }

            return CollectionOfItems[2];
        }
        private void PopulateComboboxPetugas()
        {
            _itemRepo = new ItemServices();
            var Data = AutoMapper.Mapper.Map <List <MasterPetugasDto> >(_pekerjaRepo.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataPetugas = CollectionViewSource.GetDefaultView(Data);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataPetugas
            });

            NamaPetugas.ItemsSource   = TransportCompositeCollection;
            NamaPetugas.SelectedIndex = 0;
        }
        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);
        }
        private void PopulateComboboxNamaPengirim()
        {
            _supplierServices = new SupplierServices();
            var Data = AutoMapper.Mapper.Map <List <MasterSupplierDto> >(_supplierServices.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataSupplier = CollectionViewSource.GetDefaultView(Data);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataSupplier
            });

            NamaPengirim.ItemsSource   = TransportCompositeCollection;
            NamaPengirim.SelectedIndex = 0;
        }
        private void PopulateComboboxNoPolisi()
        {
            _transportServices = new TransportServices();
            var Data = AutoMapper.Mapper.Map <List <MasterTransportDto> >(_transportServices.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataTransport = CollectionViewSource.GetDefaultView(Data);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataTransport
            });

            NoPolisi.ItemsSource   = TransportCompositeCollection;
            NoPolisi.SelectedIndex = 0;
        }
Exemplo n.º 8
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool BooleanValue;

            if (value is bool)
            {
                BooleanValue = (bool)value;
            }
            else if (value is bool?)
            {
                BooleanValue = ((bool?)value).HasValue ? ((bool?)value).Value : false;
            }
            else
            {
                BooleanValue = false;
            }

            CompositeCollection CollectionOfItems = parameter as CompositeCollection;

            return(BooleanValue ? CollectionOfItems[1] : CollectionOfItems[0]);
        }
Exemplo n.º 9
0
        public void TestCompositeCollectionEnumrator()
        {
            List <int> list1 = Enumerable.Range(0, 10).ToList();
            List <int> list2 = Enumerable.Range(10, 10).ToList();
            CompositeCollection <int> comp = new CompositeCollection <int>(list1, list2);
            int i = 0;

            foreach (var item in comp)
            {
                Assert.Equal(item, i);
                i++;
            }
            Assert.Equal(i, 20);
            int[] array = new int[25];
            comp.CopyTo(array, 1);
            Assert.Equal(0, array[0]);
            for (int j = 1; j < 21; j++)
            {
                Assert.Equal(j - 1, array[j]);
            }
        }
        public void SortInsertOnRightSpot()
        {
            CompositeCollection <int> collection = new CompositeCollection <int>(true);


            ViewModelCollection <int> a = new ViewModelCollection <int>(new List <int>());
            ViewModelCollection <int> b = new ViewModelCollection <int>(new List <int>());

            collection.Add(a);
            collection.Add(b);

            Random r = new Random();

            for (int i = 0; i < 200; i++)
            {
                if ((i % 2) == 1)
                {
                    a.Add(r.Next());
                }
                else
                {
                    b.Add(r.Next());
                }
            }

            int prv = collection[0];

            for (int i = 1; i < collection.Count; i++)
            {
                if (collection[i] < prv)
                {
                    throw new Exception($"{i}");
                }
                else
                {
                    prv = collection[i];
                }
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Contract.Requires(values != null);
            var collection = new CompositeCollection();

            foreach (object item in values)
            {
                if (item is IEnumerable ienum)
                {
                    collection.Add(new CollectionContainer()
                    {
                        Collection = ienum
                    });
                }
                else
                {
                    collection.Add(item);
                }
            }

            return(collection);
        }
Exemplo n.º 12
0
        public override void Perform()
        {
            ICollectionView collectionView = null;

            if (ItemsControl.ItemsSource is CompositeCollection)
            {
                CompositeCollection compositeCollection = ItemsControl.ItemsSource as CompositeCollection;
                if (compositeCollection != null)
                {
                    if (compositeCollection.Count > 0)
                    {
                        Index %= compositeCollection.Count;
                        CollectionContainer container = ((CollectionContainer)compositeCollection[Index]);
                        if (container != null && container.Collection != null)
                        {
                            collectionView = CollectionViewSource.GetDefaultView(container.Collection);
                        }
                    }
                }
            }
            else
            {
                collectionView = ItemsControl.Items;
            }

            if (collectionView != null)
            {
                Index %= BindingInfo.SortDescriptions.Length;
                SortDescriptionCollection sortDescriptionCollection = BindingInfo.SortDescriptions[Index];
                using (collectionView.DeferRefresh())
                {
                    collectionView.SortDescriptions.Clear();
                    foreach (SortDescription sortDescription in sortDescriptionCollection)
                    {
                        collectionView.SortDescriptions.Add(sortDescription);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var sourceGroup = value as TagGroup;

            if (sourceGroup == null)
            {
                return(null);
            }

            var tagList = new CompositeCollection();

            tagList.Add(sourceGroup.NullTag);

            var mainTagListContainer = new CollectionContainer();

            mainTagListContainer.Collection = sourceGroup.Children;

            tagList.Add(mainTagListContainer);


            return(tagList);
        }
Exemplo n.º 14
0
        private CompositeCollection CreateSearchList(string filterText)
        {
            //todo: make parallel

            CompositeCollection cc = new CompositeCollection();

            cc.Add(AddSearchItems());

            double t = 0;

            if (double.TryParse(filterText, out t))
            {
                AddTransaction(cc, filterText);
            }

            GetPatients(cc, filterText);
            GetDoctors(cc, filterText);

            AddInventory(cc, filterText);

            return(cc);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        private void btnSetWorkbook_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = false;
            ofd.ValidateNames    = true;
            ofd.DereferenceLinks = false; // Will return .lnk in shortcuts.
            ofd.Filter           = "Excel |*.xlsx";

            if ((bool)ofd.ShowDialog())
            {
                lbCurrentWorkbook.Content = ofd.FileName;

                using (berkeleyEntities dataContext = new berkeleyEntities())
                {
                    _workbook = new ExcelWorkbook(ofd.FileName);

                    CompositeCollection composite = new CompositeCollection();

                    foreach (var marketplace in dataContext.EbayMarketplaces)
                    {
                        composite.Add(new EbayPublisherViewModel(_workbook, marketplace.Code));
                    }

                    foreach (var marketplace in dataContext.AmznMarketplaces)
                    {
                        composite.Add(new AmznPublisherViewModel(_workbook, marketplace.Code));
                    }

                    foreach (var marketplace in dataContext.BonanzaMarketplaces)
                    {
                        composite.Add(new BonanzaPublisherViewModel(_workbook, marketplace.Code));
                    }

                    tcSheets.ItemsSource = composite;
                }
            }
        }
Exemplo n.º 17
0
        public void TestCompositeCollectionOperations()
        {
            var collection = new CompositeCollection <Order>();
            var list1      = new List <Order>();

            list1.Fill(x => new Order {
                Id = x
            });
            var list2 = new List <Order>();

            list2.Fill(x => new Order {
                Id = x
            }, 100);
            var list3 = new List <Order>();

            list3.Fill(x => new Order {
                Id = x
            }, 5);
            collection.AddAll(list1);
            collection.AddAll(list2);
            collection.AddAll(list3);
            collection.CollectionOperations <Order>(1105);
        }
Exemplo n.º 18
0
        public MainWindow()
        {
            DataContext = this;

            MapObjects  = new CompositeCollection();
            MapHexagons = new ObservableCollection <MapHexagon>();
            MapRivers   = new ObservableCollection <MapRiver>();
            MapObjects.Add(new CollectionContainer()
            {
                Collection = MapHexagons
            });
            MapObjects.Add(new CollectionContainer()
            {
                Collection = MapRivers
            });

            GenerateNewWorld(MaxX, MaxY);
            Scale = DEFAULT_SCALE;

            InitializeComponent();

            DrawHexMap(_world.Map, _world.Map.BaseColorAt);
        }
        protected void Adapt()
        {
            if (CollectionView != null)
            {
                CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
                CollectionView = null;
            }
            if (Selector != null && ItemsSource != null)
            {
                CompositeCollection comp = new CompositeCollection();
                comp.Add(new CollectionContainer {
                    Collection = ItemsSource
                });

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

                Selector.ItemsSource = comp;
            }
        }
 public StateJointCollectionViewModel(
     TreeViewViewModel treeParent,
     CompoundObjectViewModel parentVm,
     MainViewModel mainVm,
     bool enabled = true) :
     base(treeParent, parentVm, mainVm, enabled)
 {
     _joints = new CompositeCollection()
     {
         new CollectionContainer {
             Collection = new ObservableCollection <WeldJointViewModel>()
         },
         new CollectionContainer {
             Collection = new ObservableCollection <RevoluteJointViewModel>()
         },
         new CollectionContainer {
             Collection = new ObservableCollection <PrismaticJointViewModel>()
         },
         new CollectionContainer {
             Collection = new ObservableCollection <RopeViewModel>()
         },
     };
 }
Exemplo n.º 21
0
 protected void Adapt()
 {
     if (CollectionView != null)
     {
         CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
         CollectionView = null;
     }
     if (ComboBox != null && ItemsSource != null)
     {
         CompositeCollection comp = new CompositeCollection();
         //If AllowNull == true, add a "NullItem" as the first item in the ComboBox.
         if (AllowNull)
         {
             comp.Add(NullItem);
         }
         //Now Add the ItemsSource.
         comp.Add(new CollectionContainer {
             Collection = ItemsSource
         });
         //Lastly, If Selected item is not null and does not already exist in the ItemsSource,
         //Add it as the last item in the ComboBox
         if (SelectedItem != null)
         {
             List <object> items = ItemsSource.Cast <object>().ToList();
             if (!items.Contains(SelectedItem))
             {
                 comp.Add(SelectedItem);
             }
         }
         CollectionView = CollectionViewSource.GetDefaultView(comp);
         if (CollectionView != null)
         {
             CollectionView.CurrentChanged += CollectionView_CurrentChanged;
         }
         ComboBox.ItemsSource = comp;
     }
 }
Exemplo n.º 22
0
        private void AddInventory(CompositeCollection cc, string filterText)
        {
            try
            {
                //todo: make parallel
                using (var ctx = new RMSModel())
                {
                    var itms = ctx.Item.OfType <Medicine>().Where(x => x.ItemName.Contains(filterText) &&
                                                                  x.QBItemListID != null
                                                                  &&
                                                                  (x.Inactive == null ||
                                                                   (x.Inactive != null &&
                                                                    x.Inactive == _showInactiveItems))).Take(listCount)
                               .AsEnumerable()
                               .OrderBy(x => x.DisplayName).ToList();

                    foreach (var itm in itms)
                    {
                        cc.Add(itm);
                    }
                }

                using (var ctx = new RMSModel())
                {
                    foreach (
                        var itm in ctx.Item.OfType <StockItem>().Where(x => x.ItemName.Contains(filterText)).Take(listCount))
                    {
                        cc.Add(itm);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 23
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var compositeCollection = new CompositeCollection();

            foreach (object value in values)
            {
                if (value is IEnumerable enumerable)
                {
                    var binding = new Binding {
                        Source = enumerable
                    };
                    var collectionContainer = new CollectionContainer();
                    BindingOperations.SetBinding(collectionContainer, CollectionContainer.CollectionProperty, binding);

                    compositeCollection.Add(collectionContainer);
                }
                else
                {
                    compositeCollection.Add(value);
                }
            }

            return(compositeCollection);
        }
Exemplo n.º 24
0
        private void AddSearchItems(CompositeCollection cc)
        {
            SearchItem b = new SearchItem();

            b.SearchObject   = new RMSDataAccessLayer.Transactionlist();
            b.SearchCriteria = "Transaction History";
            b.DisplayName    = "Transaction History";
            cc.Add(b);

            if (ApplicationMode == SalesRegion.ApplicationMode.Pharmacy)
            {
                SearchItem p = new SearchItem();
                p.SearchObject   = null;
                p.SearchCriteria = "Add Patient";
                p.DisplayName    = "Add Patient";
                cc.Add(p);

                SearchItem d = new SearchItem();
                d.SearchObject   = null;
                d.SearchCriteria = "Add Doctor";
                d.DisplayName    = "Add Doctor";
                cc.Add(d);
            }
        }
Exemplo n.º 25
0
        private void ContextMenu_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem mi = new MenuItem();

            mi.Header  = "Export to CSV";
            mi.Command = _exportCommand;

            if (this.ContextMenu.ItemsSource != null)
            {
                CompositeCollection cc = new CompositeCollection();

                CollectionContainer boundCollection = new CollectionContainer();
                boundCollection.Collection = this.ContextMenu.ItemsSource;
                cc.Add(boundCollection);

                CollectionContainer exportCollection = new CollectionContainer();
                List <Control>      exportMenuItems  = new List <Control>(2);
                exportMenuItems.Add(new Separator());
                exportMenuItems.Add(mi);
                exportCollection.Collection = exportMenuItems;
                cc.Add(exportCollection);

                this.ContextMenu.ItemsSource = cc;
            }
            else
            {
                if (this.ContextMenu.HasItems)
                {
                    this.ContextMenu.Items.Add(new Separator());
                }

                this.ContextMenu.Items.Add(mi);
            }

            this.ContextMenu.Loaded -= ContextMenu_Loaded;
        }
        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
                {
                    if (value != null)
                    {
                        compositeCollection.Add(value);
                    }
                }
            }

            return(compositeCollection);
        }
Exemplo n.º 27
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.º 28
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainWindowViewModel(IOpenDDSharpService dds, IViewService view, IConfigurationService config)
        {
            _dds = dds;
            _dds.SquareUpdated   += DdsSquareUpdated;
            _dds.CircleUpdated   += DdsCircleUpdated;
            _dds.TriangleUpdated += DdsTriangleUpdated;

            _view   = view;
            _config = config;

            _publishedSquares    = new ObservableCollection <SquareType>();
            _publishedCircles    = new ObservableCollection <CircleType>();
            _publishedTriangles  = new ObservableCollection <TriangleType>();
            _subscribedSquares   = new ObservableCollection <SquareType>();
            _subscribedCircles   = new ObservableCollection <CircleType>();
            _subscribedTriangles = new ObservableCollection <TriangleType>();

            Shapes = new CompositeCollection
            {
                new CollectionContainer()
                {
                    Collection = _publishedSquares
                },
                new CollectionContainer()
                {
                    Collection = _publishedCircles
                },
                new CollectionContainer()
                {
                    Collection = _publishedTriangles
                },
                new CollectionContainer()
                {
                    Collection = _subscribedSquares
                },
                new CollectionContainer()
                {
                    Collection = _subscribedCircles
                },
                new CollectionContainer()
                {
                    Collection = _subscribedTriangles
                }
            };

            PublishShapeCommand   = new RelayCommand(PublishShape, () => true);
            WriterQosCommand      = new RelayCommand(WriterQos, () => true);
            ReaderQosCommand      = new RelayCommand(ReaderQos, () => true);
            ReaderFilterCommand   = new RelayCommand(ReaderFilter, () => true);
            SubscribeShapeCommand = new RelayCommand(SubscribeShape, () => true);

            _rect   = new Rect(0, 0, 321, 361);
            _random = new Random();
            _selectedSubscriberShape = ShapeKind.Circle;
            _selectedPublisherShape  = ShapeKind.Circle;
            _selectedColor           = ShapeColor.Green;
            _selectedSize            = 45;
            _selectedSpeed           = 45;

            BindingOperations.EnableCollectionSynchronization(_publishedSquares, _lockPublishedSquares);
            BindingOperations.EnableCollectionSynchronization(_publishedCircles, _lockPublishedCircles);
            BindingOperations.EnableCollectionSynchronization(_publishedTriangles, _lockPublishedTriangles);
            BindingOperations.EnableCollectionSynchronization(_subscribedSquares, _lockSubscribedSquares);
            BindingOperations.EnableCollectionSynchronization(_subscribedCircles, _lockSubscribedCircles);
            BindingOperations.EnableCollectionSynchronization(_subscribedTriangles, _lockSubscribedTriangles);

            Messenger.Default.Register <FilterConfigMessage>(this, OnFilterConfigMessage);
        }
Exemplo n.º 29
0
        public void Initialize(Controller.Controller controller, PSMClass psmClass, PSMAttribute initialSelectedAttribute = null)
        {
            this.controller = controller;
            this.psmClass   = psmClass;

            this.Title = string.Format("PSM class: {0}", psmClass);

            tbName.Text = psmClass.Name;

            #region attributes

            typeColumn.ItemsSource = psmClass.PSMSchema.GetAvailablePSMTypes();

            PSMClass nearestInterpretedClass = psmClass.NearestInterpretedClass();

            if (nearestInterpretedClass != null)
            {
                CompositeCollection coll = new CompositeCollection();
                //coll.Add("(None)");
                coll.Add(new CollectionContainer {
                    Collection = ((PIMClass)nearestInterpretedClass.Interpretation).PIMAttributes
                });
                interpretationColumn.ItemsSource = coll;
            }

            ObservableCollection <FakePSMAttribute> fakeAttributesList = new ObservableCollection <FakePSMAttribute>();

            TypeFinder tf = TryFindSuitablePIMType;
            fakeAttributes = new FakeAttributeCollection(fakeAttributesList, psmClass, tf);
            fakeAttributesList.CollectionChanged += delegate { UpdateApplyEnabled(); };
            gridAttributes.ItemsSource            = fakeAttributesList;

            #endregion

            #region associatiosn

            if (nearestInterpretedClass != null)
            {
                CompositeCollection coll = new CompositeCollection();
                //coll.Add("(None)");
                coll.Add(new CollectionContainer {
                    Collection = ((PIMClass)nearestInterpretedClass.Interpretation).PIMAssociationEnds.Select(e => e.PIMAssociation)
                });
                interpretationAssociation.ItemsSource = coll;
            }

            ObservableCollection <FakePSMAssociation> fakeAssociationsList = new ObservableCollection <FakePSMAssociation>();

            fakeAssociations = new FakeAssociationCollection(fakeAssociationsList, psmClass);
            fakeAssociationsList.CollectionChanged += delegate { UpdateApplyEnabled(); };
            gridAssociations.ItemsSource            = fakeAssociationsList;

            #endregion

            if (initialSelectedAttribute != null)
            {
                gridAttributes.SelectedItem = fakeAttributesList.SingleOrDefault(fa => fa.SourceAttribute == initialSelectedAttribute);
            }

            dialogReady = true;
        }
Exemplo n.º 30
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;
        }