コード例 #1
0
        public BindingSource <TSource, TTarget> AddFuncBinding(Expression <Func <TSource, object> > sourceGetter, Expression <Func <TTarget, object> > targetProperty)
        {
            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new FuncBindingBridge <TSource>(this, sourceGetter, targetInfo));

            return(this);
        }
コード例 #2
0
 public void AddBridge(List <string> gates, List <string> regions)
 {
     if (gates.Count == 0 || regions.Count == 0)
     {
         throw new InvalidCastException("未找到有效的关联项。");
     }
     lock (Bridges)
     {
         foreach (var gate in gates)
         {
             var g = Bridges.FirstOrDefault(_ => _.ID == gate);
             if (g == null)
             {
                 g = new Bridge()
                 {
                     ID = gate, Links = new List <string>()
                 };
                 Bridges.Add(g);
             }
             else
             {
                 g.UpdateTime = DateTime.Now;
             }
             foreach (var reg in regions)
             {
                 if (g.Links.All(_ => _ != reg))
                 {
                     g.Links.Add(reg);
                 }
             }
             g.Links = g.Links.OrderBy(_ => _).ToList();
         }
     }
 }
コード例 #3
0
        public BindingSource <TSource, TTarget> AddBinding(Expression <Func <TSource, object> > sourceProperty, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter, object converterParameter, System.Globalization.CultureInfo converterCulture)
        {
            PropertyInfo sourceInfo = PropertyUtil.GetPropertyInfo(sourceProperty);

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter, converterParameter, converterCulture));

            return(this);
        }
コード例 #4
0
        public BindingSource <TSource, TTarget> AddBinding(Expression <Func <TSource, object> > sourceProperty, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter)
        {
            PropertyInfo sourceInfo = PropertyUtil.GetPropertyInfo(sourceProperty);

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter));

            return(this);
        }
コード例 #5
0
ファイル: World.cs プロジェクト: ktj007/mmo
        private void Generate()
        {
            var random = new Random();

            Width  = random.Next(1000) + 4000;
            Height = random.Next(1000) + 3000;

            RegionInterval = (int)Math.Sqrt(Width * Height / (double)(random.Next(100) + 200));
            XCount         = Width / RegionInterval;
            YCount         = Height / RegionInterval;
            Width          = XCount * RegionInterval;
            Height         = YCount * RegionInterval;

            var margin       = RegionInterval / 8;
            var realInterval = RegionInterval - margin * 2;

            for (var x = 0; x < XCount; x++)
            {
                for (var y = 0; y < YCount; y++)
                {
                    var cityX = x * RegionInterval + random.Next(realInterval) + margin;
                    var cityY = y * RegionInterval + random.Next(realInterval) + margin;
                    Cities.Add(new City(cityX, cityY));
                }
            }

            var isolatedCities = new HashSet <City>(Cities);

            while (isolatedCities.Count > 0)
            {
                foreach (var fromCity in Cities)
                {
                    if (!isolatedCities.Contains(fromCity))
                    {
                        continue;
                    }

                    var cityBridges = random.Next((int)Math.Pow(2, 8));
                    for (var bridgeType = 0; bridgeType < 8; bridgeType++)
                    {
                        if ((cityBridges & (1 << bridgeType)) != 0)
                        {
                            var toCityIndex = GetAdjancyCity(Cities.IndexOf(fromCity), bridgeType);
                            if (toCityIndex > 0)
                            {
                                var toCity = Cities[toCityIndex];
                                Bridges.Add(new Bridge(fromCity, toCity));

                                isolatedCities.Remove(fromCity);
                                isolatedCities.Remove(toCity);
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        public BindingObjectSource <TTarget> AddBinding(string sourcePropertyName, Expression <Func <TTarget, object> > targetProperty)
        {
            PropertyInfo sourceInfo = DataSourceObject.GetType().GetProperty(sourcePropertyName);

            if (sourceInfo == null)
            {
                throw new ArgumentException(String.Format("Property {0} not found.", sourcePropertyName));
            }
            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo));

            return(this);
        }
コード例 #7
0
        public BindingObjectSource <TTarget> AddBinding(string sourcePropertyName, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter, object converterParameter, System.Globalization.CultureInfo converterCulture)
        {
            PropertyInfo sourceInfo = DataSourceObject.GetType().GetProperty(sourcePropertyName);

            if (sourceInfo == null)
            {
                throw new ArgumentException(String.Format("Property {0} not found.", sourcePropertyName));
            }

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter, converterParameter, converterCulture));

            return(this);
        }
コード例 #8
0
        protected async void ExecuteScanBridgesAsync()
        {
            IsScanningBridges = true;
            ScanBridgesCommand.RaiseCanExecuteChanged();

            var rv = await _bridgeFinder.GetBridgesAsync(_connection);

            Bridges.Clear();
            _firstBridgeViewModel = null;
            if (!rv.IsError())
            {
                foreach (Bridge bridge in ((HueObjectCollectionBase <Bridge>)rv).Dictionary.Values)
                {
                    SettingsInitialiser.InitialiseScenes(_settings, bridge);
                    var bridgeViewModel = new BridgeViewModel(bridge, _settings, _commandFactory, _messageHandler);

                    if (_firstBridgeViewModel == null)
                    {
                        _firstBridgeViewModel = new ConnectedBridgeViewModel(bridge, _settings, _commandFactory, _messageHandler);
                        RaisePropertyChanged("FirstBridge");
                    }

                    Bridges.Add(bridgeViewModel);

                    if (_settings.Bridge.Value != null && _settings.Bridge.Value == bridge.InternalIPAddress)
                    {
                        SelectedBridge = bridgeViewModel;
                        //SelectedBridge.ConnectAsync().ContinueWith(o => RaisePropertyChanged("SelectedBridge"));
                    }
                }
            }
            else
            {
                Bridges = new ObservableCollection <BridgeViewModel>();
            }

            IsScanningBridges = false;
            ScanBridgesCommand.RaiseCanExecuteChanged();
        }
コード例 #9
0
        private static void BuildBridges(int value, List <Component> remainingList, List <Component> existingList)
        {
            if (existingList == null)
            {
                existingList = new List <Component>();
            }

            var listToLoop = remainingList.Where(x => x.Contains(value));

            if (listToLoop.Count() == 0)
            {
                Bridges.Add(existingList);
            }

            foreach (var item in listToLoop)
            {
                var newList = new List <Component>(remainingList.Where(x => x != item));

                var sendList = new List <Component>(existingList);
                sendList.Add(item);

                BuildBridges(item.Next(value), newList, sendList);
            }
        }