コード例 #1
0
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            if (!Directory.Exists(Information.GetSaveFileDirectory()))
            {
                Directory.CreateDirectory(Information.GetSaveFileDirectory());
            }

            var saveData = new SaveData
            {
                HasBreakerTripped = HasBreakerTripped,
                TurbineRot        = new TargetRotation(_targetRotation),
                Health            = LiveMixin.health,
                Charge            = Charge,
                DegPerSec         = GetBiomeData(_currentBiome).Speed,
                Biome             = _currentBiome,
                CurrentSpeed      = _currentSpeed,
                PassedTime        = _passedTime
            };

            var output = JsonConvert.SerializeObject(saveData, Formatting.Indented);

            File.WriteAllText(FilesHelper.GenerateSaveFileString(ID), output);

            LoadItems.CleanOldSaveData();
        }
コード例 #2
0
 public IncrementalLoadingCollection(LoadItems loadItems, IEnumerable <EntityType> collection, uint minItemsLoadCount = 12)
     : base(collection)
 {
     this.loadItems         = loadItems;
     this.minItemsLoadCount = minItemsLoadCount;
     offset = (uint)collection.Count();
 }
コード例 #3
0
        public FlightViewModel(FlightSummary summary, IFlightAcademyClient flightAcademyClient, ContentMatcher matcher)
        {
            this.summary = summary;
            this.matcher = matcher;

            LoadItems = ReactiveCommand.CreateFromObservable(() => Load().ToList());
            LoadItems.ThrownExceptions.Subscribe(x => { });
            items = LoadItems.ToProperty(this, x => x.Items);
        }
コード例 #4
0
        public FlightViewModel(FlightSummary summary, IMediaStore matcher, IViewModelFactory viewModelFactory)
        {
            this.summary = summary;

            LoadItems = ReactiveCommand.CreateFromObservable(() => matcher
                                                             .RecordingsBetween(this.summary.Date.ToInterval(this.summary.TotalRunTime))
                                                             .SelectMany(file => viewModelFactory.CreateFlightContentViewModel(summary.Id, file)).ToList());
            items  = LoadItems.ToProperty(this, x => x.Items);
            isBusy = LoadItems.IsExecuting.ToProperty(this, x => x.IsBusy);
            Play   = ReactiveCommand.CreateFromObservable((FlightContentViewModel e) => e.PlayCommand.Execute());
        }
コード例 #5
0
        public CatalogItemListViewModel(
            string categoryId,
            ICatalogItemRepoFactory itemRepoFactory = null,
            IViewStackService viewStackService      = null)
        {
            itemRepoFactory  = itemRepoFactory ?? Locator.Current.GetService <ICatalogItemRepoFactory>();
            viewStackService = viewStackService ?? Locator.Current.GetService <IViewStackService>();

            var itemRepo = itemRepoFactory.Create(categoryId);

            LoadItems = ReactiveCommand.CreateFromObservable(
                () =>
            {
                return(itemRepo
                       .GetItems()
                       .SelectMany(x => x)
                       .Select(x => new CatalogItemCellViewModel(x, itemRepo))
                       .ToList()
                       .Select(x => x as IReadOnlyList <ICatalogItemCellViewModel>));
            });

            _items = LoadItems.ToProperty(this, x => x.Items);

            var firebaseStorageService = Locator.Current.GetService <GameCtor.FirebaseStorage.DotNet.IFirebaseStorageService>();

            DownloadImages = ReactiveCommand.CreateFromObservable(
                () =>
            {
                return(Items
                       .ToObservable()
                       .SelectMany(
                           itemCell =>
                {
                    return firebaseStorageService
                    .GetDownloadUrl("catalogPhotos/" + itemCell.Id + ".jpg")
                    .Catch <string, Exception>(ex => Observable.Return <string>(null))
                    .Where(x => x != null)
                    .Do(imageUrl => itemCell.ImageUrl = imageUrl)
                    .Select(_ => itemCell);
                })
                       .SelectMany(
                           itemCell =>
                {
                    return itemRepo
                    .Upsert(itemCell.Model);
                }));
            });
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: cyberwyvern/radio-catalog
        public MainForm()
        {
            InitializeComponent();

            OpenToolStripMenuItem.Click   += OpenFile;
            CreateToolStripMenuItem.Click += CreateFile;
            SaveAsToolStripMenuItem.Click += SaveFileAs;

            CategoryList.SelectedIndexChanged += ChooseCategory;
            DataGrid.SelectionChanged         += ChooseItem;

            DataGrid.DoubleClick += delegate(object sender, EventArgs e)
            {
                LoadItems?.Invoke(this, EventArgs.Empty);
            };
        }
コード例 #7
0
        public PricelistsViewModel()
        {
            ServicesViewModel = new PricelistServicesViewModel();
            Items.ShapeView().OrderBy(p => p.Caption).Apply();

            EditorViewModel = new PricelistEditorViewModel();
            EditorViewModel.Save.InvokeCommand(LoadItems);
            GroupEditorViewModel = new PricelistGroupEditorViewModel();
            GroupEditorViewModel.Save.Select(p => 0).InvokeCommand(LoadItems);

            Copy = ReactiveCommand.Create(() =>
            {
                var id = EntityManagerService.DefaultPricelistManager.Copy(SelectedItem);
                LoadItems.Execute(id).Subscribe();
            }, canEdit);
            EditGroup = ReactiveCommand.Create(() =>
            {
                List <Pricelist> items;
                if (IsMultiSelect == false)
                {
                    items = Items.Where(p => p.ID == SelectedItem.ID).ToList();
                }
                else
                {
                    items = Items.OnlySelected().ToList();
                }
                GroupEditorViewModel.Init(items);
            }, canMultiEdit);
            Print = ReactiveCommand.Create(() =>
            {
                var report = new PricelistReport("Reports/ReportResources/Pricelist.frx");
                report.ShowReport(SelectedItem.ID);
            }, canEdit);

            this.WhenAnyValue(p => p.SelectedItem)
            .Where(p => p != null)
            .Subscribe(p =>
            {
                ServicesViewModel.Init(0, SelectedItem);
            });
        }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: cyberwyvern/radio-catalog
        private void ChooseCategory(object sender, EventArgs e)
        {
            if (CategoryList.SelectedIndices.Count > 0)
            {
                SelectedCategoryName = CategoryList.SelectedItems[0].Text;
                SelectedCategoryId   = CategoryList.SelectedItems[0].ImageIndex;

                ItemsHeading.Text = SelectedCategoryName;

                EditCategoryBtn.Enabled   = true;
                RemoveCategoryBtn.Enabled = true;
                AddItemBtn.Enabled        = true;

                LoadItems?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                SelectedCategoryName      = null;
                EditCategoryBtn.Enabled   = false;
                RemoveCategoryBtn.Enabled = false;
                AddItemBtn.Enabled        = false;
            }
        }
コード例 #9
0
        /// <summary>
        /// Metodo que carga el datagrid con las columnas predefinidas en NumColumns
        /// </summary>
        private void loadDataGrid()
        {
            List <object> listAux = LoadItems.OfType <object>().ToList();

            var s = LoadItems.OfType <object>().ToList().ElementAt(107);

            // Creamos la columnas con su binding
            for (int i = 0; i < _numberColumns; i++)
            {
                actIndText(ref _letter);

                ///Generamos el DatagridColumn con las propiedades
                column = new DataGridTextColumn();
                Binding binding = new Binding(_letter);
                binding.Mode      = BindingMode.TwoWay;
                column.Binding    = binding;
                column.IsReadOnly = true;

                dg.Columns.Add(column);
            }

            //Generamos el objeto con sus propiedades
            while (listAux.Count > 0)
            {
                int _numColumnsAux = _numberColumns;
                if (listAux.Count < _numberColumns)
                {
                    _numColumnsAux = listAux.Count;
                }

                ConvertExpandObject(listAux.Take(_numColumnsAux));
                listAux.RemoveRange(0, _numColumnsAux);

                _listItemSource.Add(_obj);
            }
            dg.ItemsSource = _listItemSource;
        }
コード例 #10
0
        public DiscountlistsViewModel()
        {
            ServicesViewModel = new DiscountlistServicesViewModel();
            Items.ShapeView().OrderBy(p => p.Caption).Apply();

            EditorViewModel = new DiscountlistEditorViewModel();
            EditorViewModel.Save.InvokeCommand(LoadItems);
            GroupEditorViewModel = new DiscountlistGroupEditorViewModel();
            GroupEditorViewModel.Save.Select(p => 0).InvokeCommand(LoadItems);


            Copy = ReactiveCommand.Create(() =>
            {
                var id = EntityManagerService.DefaultDiscountlistManager.Copy(SelectedItem);
                LoadItems.Execute(id).Subscribe();
            }, canEdit);

            this.WhenAnyValue(p => p.SelectedItem)
            .Where(p => p != null)
            .Subscribe(p =>
            {
                ServicesViewModel.Init(0, SelectedItem);
            });
        }
コード例 #11
0
 public IncrementalLoadingCollection(LoadItems loadItems, uint minItemsLoadCount = 12)
 {
     this.loadItems         = loadItems;
     this.minItemsLoadCount = minItemsLoadCount;
 }
コード例 #12
0
        public OrdersViewModel()
        {
            PeriodFilter = new PeriodFilter();
            PeriodFilter.Periods.ForEach(p => p.IsActive = true);
            PeriodFilter.PeriodChanged.Select(p => 0).InvokeCommand(LoadItems);

            Items.ShapeView().OrderBy(p => p.InTime).Apply();
            Items.ShapeView().GroupBy(p => p.InTime.Date).Apply();

            EditorViewModel = new OrderEditorViewModel();
            EditorViewModel.Save.Subscribe(id =>
            {
                if (EditorViewModel.EditingItem.InDate < PeriodFilter.StartDate ||
                    EditorViewModel.EditingItem.InDate > PeriodFilter.EndDate)
                {
                    PeriodFilter.SetManualDate(EditorViewModel.EditingItem.InTime.Date);
                }

                LoadItems.Execute(id).Subscribe();
            });

            SetReady = ReactiveCommand.Create(() =>
            {
                using (var db = DbService.GetDb())
                {
                    var manager = new OrderManager(db);
                    if (IsMultiSelect == false)
                    {
                        manager.ValidateAndSetReadiness(SelectedItem, true);
                    }
                    else
                    {
                        db.BeginTransaction();
                        manager.SetReadiness(Items.OnlySelected(), true);
                        db.CommitTransaction();
                    }
                }
            }, canMultiEdit);
            SetReady.Select(p => 0).InvokeCommand(LoadItems);
            SetReady.ThrownExceptions.Subscribe(async ex => await Interactions.ShowError(ex.Message));
            SetUnready = ReactiveCommand.Create(() =>
            {
                using (var db = DbService.GetDb())
                {
                    var manager = new OrderManager(db);
                    if (IsMultiSelect == false)
                    {
                        manager.ValidateAndSetReadiness(SelectedItem, false);
                    }
                    else
                    {
                        db.BeginTransaction();
                        manager.SetReadiness(Items.OnlySelected(), false);
                        db.CommitTransaction();
                    }
                }
            }, canMultiEdit);
            SetUnready.Select(p => 0).InvokeCommand(LoadItems);
            SwitchReadiness = ReactiveCommand.Create(() =>
            {
                EntityManagerService.DefaultOrderManager.ValidateAndSetReadiness(SelectedItem, !SelectedItem.IsClosed);
            }, canEdit);
            SwitchReadiness.Select(p => 0).InvokeCommand(LoadItems);
            SwitchReadiness.ThrownExceptions.Subscribe(async ex => await Interactions.ShowError(ex.Message));

            DaySummaryViewModel = new DaySummaryViewModel();
            ShowDaySummary      = ReactiveCommand.Create <DateTime>((day) =>
            {
                DaySummaryViewModel.Init(day);
            });

            Print = ReactiveCommand.CreateFromTask(async() =>
            {
                if (SelectedItem.IsClosed == false)
                {
                    await Interactions.ShowError("Заезд не закрыт!");
                    return;
                }
                var report = new OrderForClientReport("Reports/ReportResources/OrderForClient.frx");
                report.ShowReport(SelectedItem.ID);
            }, canEdit);
        }
コード例 #13
0
 public virtual void Init(int id)
 {
     LoadItems.Execute(id).Subscribe();
 }