public TypeViewModel(ICrestType type)
 {
     Type = type;
     Visibility = type?.Icon64X64Url != null ? Visibility.Visible : Visibility.Hidden;
     Tooltip = type?.Name;
     Icon = Type?.Icon64X64Url;
 }
 public Skill(ICrestType type, int groupId, int categoryId,  SkillLevel skillLevel = SkillLevel.V)
     : base(type, groupId, categoryId)
 {
     AddAttributeRange(
                       new IAttribute[]
                       {
                           new ConstantAttribute(this, 280, "skillLevel", (int) skillLevel),
                           new Attribute(this, 276, "skillPoints", true, true, 0)
                       });
 }
        private void InitViewModel(ICrestType shipType, ICrestKillmail killMail)
        {
            _fittingViewModel = new FittingViewModel();
            _fittingViewModel.Ship = new TypeViewModel(killMail.Victim.ShipType)
                                     {
                                         Icon = $"https://image.eveonline.com/Render/{shipType.Id}_{256}.png"
                                     };

            DataContext = _fittingViewModel;

            var priceModel = new PriceViewModel();
            Prices.DataContext = priceModel;

            Task.Factory.StartNew(
                                  () =>
                                  {
                                      Parallel.ForEach(killMail.Victim.Items, AssignToSlot);
                                      var fittingModel = Fitting.FromCrestKillmail("", "", killMail);

                                      Task.Factory.StartNew(
                                                            () =>
                                                            {
                                                                try
                                                                {
                                                                    var market = new Market(App.CREST);

                                                                    var jitaPrices = market.GetPricesForTypeIdsInSystem(
                                                                                                                        EveConstants.THE_FORGE_ID,
                                                                                                                        "Jita IV",
                                                                                                                        fittingModel);

                                                                    var slots = _fittingViewModel.HighSlots.Slots.Concat(_fittingViewModel.MediumSlots.Slots)
                                                                        .Concat(_fittingViewModel.LowSlots.Slots)
                                                                        .Concat(_fittingViewModel.RigSlots.Slots)
                                                                        .Concat(_fittingViewModel.SubSystemSlots.Slots)
                                                                        .Concat(new[] { _fittingViewModel.Ship })
                                                                        .Where(x => x?.Type != null)
                                                                        .ToArray();

                                                                    foreach (var curModel in slots)
                                                                    {
                                                                        double curPrice;
                                                                        curModel.Price =
                                                                            (jitaPrices.TryGetValue(curModel.Type.Id, out curPrice) ? curPrice : 0.0)
                                                                                .ToStringInIskFormat();
                                                                    }

                                                                    priceModel.JitaPrice = GetPriceInSystem(slots, jitaPrices);

                                                                    var amarrPrices = market.GetPricesForTypeIdsInSystem(
                                                                                                                         EveConstants.DOMAIN_ID,
                                                                                                                         "Amarr",
                                                                                                                         fittingModel);
                                                                    priceModel.AmarrPrice = GetPriceInSystem(slots, amarrPrices);

                                                                    var dodixiePrices = market.GetPricesForTypeIdsInSystem(
                                                                                                                           EveConstants.SINQ_LAISON_ID,
                                                                                                                           "Dodixie",
                                                                                                                           fittingModel);
                                                                    priceModel.DodixiePrice = GetPriceInSystem(slots, dodixiePrices);

                                                                    var hekPrices = market.GetPricesForTypeIdsInSystem(
                                                                                                                    EveConstants.METROPOLIS_ID,
                                                                                                                    "Hek",
                                                                                                                    fittingModel);
                                                                    priceModel.HekPrice = GetPriceInSystem(slots, hekPrices);

                                                                    var rensPrices = market.GetPricesForTypeIdsInSystem(
                                                                                                                        EveConstants.HEIMATAR_ID,
                                                                                                                        "Rens",
                                                                                                                        fittingModel);
                                                                    priceModel.RensPrice = GetPriceInSystem(slots, rensPrices);

                                                                }
                                                                catch (Exception e)
                                                                {
                                                                    Log.Logger.Warning(e, "Error in loading market data");
                                          //TODO messagebox? statusline?
                                      }
                                                            },
                                                            TaskCreationOptions.LongRunning)
                                          .ConfigureAwait(false);

                                      Task.Factory.StartNew(
                                                            async () =>
                                                            {
                                                                try
                                                                {
                                                                    CharacterDisplay.SetFitting(fittingModel);

                                                                    var shipContext = await App.FittingService.CreatContextFromFittingAsync(fittingModel);

                                                                    Application.Current.Dispatcher.Invoke(() => FittingDisplay.ShowShip(shipContext));
                                                                }
                                                                catch (Exception e)
                                                                {
                                                                    Log.Logger.Warning(e, "Error in loading of fit");

                                          //TODO sollte hier ne messagebox aufgehen?
                                      }
                                                            },
                                                            TaskCreationOptions.LongRunning)
                                          .ConfigureAwait(false);
                                  });

            
        }
 public IEnumerable<IMarketItem> GetSellItems(int solarSystemId, ICrestType type)
 {
     return new PagedEnumerable<IMarketItem>($"{Crest.Settings.PublicEndpointUri}market/{solarSystemId}/orders/sell/?type={type.Href}");
 }