示例#1
0
        public void TestInitialize()
        {
            ProductViewModel product1 = new ProductViewModel(new Model.Product());
            ProductViewModel product2 = new ProductViewModel(new Model.Product());
            ModuleViewModel  module   = new ModuleViewModel(new Model.Module());

            module.Add(product1);
            module.Add(product2);

            HierarchyDataGrid hierarchyDataGrid = new HierarchyDataGrid(new ObservableCollection <ItemViewModel>());

            hierarchyDataGrid.Add(module);
            _dataGridItemModule = hierarchyDataGrid.DataGridItems[0];
            hierarchyDataGrid.Remove(module);

            BlockViewModel block = new BlockViewModel(new Model.Block());

            block.Add(module);
            hierarchyDataGrid.Add(block);

            _dataGridItemBlock = hierarchyDataGrid.DataGridItems[0];
        }
示例#2
0
        private void UpdateParams(object sender, BlockViewModel model)
        {
            TabControl.SelectedIndex = 1;
            var displayNameBind = new Binding
            {
                Source = model,
                Path   = new PropertyPath("BlockModel.Name"),
                Mode   = BindingMode.TwoWay
            };

            var versionBind = new Binding
            {
                Source = model,
                Path   = new PropertyPath("BlockModel.Version"),
                Mode   = BindingMode.OneWay
            };

            ParamDisplayName.SetBinding(TextBox.TextProperty, displayNameBind);
            ParamModelVersion.SetBinding(ContentProperty, versionBind);

            ParamList.ItemsSource = model.BlockModel.Parameters;
            IOList.ItemsSource    = model.BlockModel.Connectors;
        }
示例#3
0
        public IActionResult BlockPeriod(DateTime startDate, DateTime endDate, TimeSpan startTime, TimeSpan endTime, string description, string customerMessage)
        {
            if (!sessMan.IsAdmin())
            {
                return(RedirectToAction("Main", "Page"));
            }

            DateTime start = startDate.Date + startTime;
            DateTime end   = endDate.Date + endTime;

            BlockViewModel pageVM = new BlockViewModel {
                Pages       = PModel.GetMenu(),
                CurrentPage = new Page {
                    InternalName = "BlockPeriod",
                    DisplayName  = "Periode Blokkeren"
                },
                Dynamic = false,
                Today   = timeManager.Today().Date
            };

            if (!RModel.IsChronological(start, end))
            {
                pageVM.Error = 2;
                return(View(pageVM));
            }
            else if (RModel.DoesPeriodContainReservations(start, end))
            {
                pageVM.Error = 1;
                return(View(pageVM));
            }
            else
            {
                BlockedPeriod blockedPeriod = RModel.MakeBlockedPeriod(start, end, description, customerMessage);
                RModel.AddBlockedPeriod(blockedPeriod);
                return(RedirectToAction("BlockedOverview", "Reservation"));
            }
        }
        private void timelineBlock_QueryCursor(object sender, QueryCursorEventArgs e)
        {
            FrameworkElement control = (FrameworkElement)sender;
            BlockViewModel   block   = (BlockViewModel)control.DataContext;

            if (sequencer.IsPipetteActive)
            {
                HandlePipetteQueryCursor(block, e);
                return;
            }

            switch (dragMode)
            {
            case BlockDragMode.Block:
                e.Cursor = Cursors.SizeAll;
                break;

            case BlockDragMode.Start:
            case BlockDragMode.End:
                e.Cursor = Cursors.SizeWE;
                break;

            case BlockDragMode.None:
                FrameworkElement controlBlock = (FrameworkElement)VisualTreeHelper.GetChild(control, 0);
                var localMouse = e.GetPosition(controlBlock);


                // if the block start/end is already being dragged or if the mouse is at the left or right edge
                if (localMouse.X < DRAG_START_END_PIXEL_WINDOW ||
                    (localMouse.X > controlBlock.ActualWidth - DRAG_START_END_PIXEL_WINDOW && localMouse.X < controlBlock.ActualWidth + DRAG_START_END_PIXEL_WINDOW))
                {
                    e.Cursor = Cursors.SizeWE;
                }

                break;
            }
        }
示例#5
0
        public PdfCreator(BlockViewModel data)
        {
            InitializeComponent();

            _data            = data;
            this.DataContext = data;
            List <BlockAttribute> combolist = new List <BlockAttribute>();

            Dictionary <string, string> attrList = new Dictionary <string, string>();
            Transaction tr = Active.Database.TransactionManager.StartTransaction();

            var names = Utils.GetAttrList(tr, attrList);

            attrList   = names.Item2;
            _blockName = names.Item1;

            foreach (KeyValuePair <string, string> entry in attrList)
            {
                combolist.Add(new BlockAttribute(entry.Key, entry.Value));
            }

            ComboObjectNameEn.ItemsSource = combolist;
            NameBlock.Text = _blockName;
        }
示例#6
0
        public MainWindow(BlockViewModel data)
        {
            InitializeComponent();

            _data            = data;
            this.DataContext = data;
            List <BlockAttribute> combolist = new List <BlockAttribute>();

            Dictionary <string, string> attrList = new Dictionary <string, string>();
            Transaction tr = Active.Database.TransactionManager.StartTransaction();

            var names = Utils.GetAttrList(tr, attrList);

            tr?.Dispose();
            attrList   = names.Item2;
            _blockName = names.Item1;

            foreach (KeyValuePair <string, string> entry in attrList)
            {
                combolist.Add(new BlockAttribute(entry.Key, entry.Value));
            }

            ComboObjectNameEn.ItemsSource = combolist;
            ComboObjectNameRu.ItemsSource = combolist;

            ComboBoxPosition.ItemsSource   = combolist;
            ComboBoxNomination.ItemsSource = combolist;
            ComboBoxComment.ItemsSource    = combolist;

            ComboBoxTrItem.ItemsSource       = combolist;
            ComboBoxTrDocNumber.ItemsSource  = combolist;
            ComboBoxTrDocTitleEn.ItemsSource = combolist;
            ComboBoxTrDocTitleRu.ItemsSource = combolist;

            NameBlock.Text = _blockName;
        }
 public void Dependencies_Should_Be_Set_Correctly(IWebsiteDependencies dependencies)
 {
     baseViewModel = new BlockViewModel <RichTextBlock>(dummyBlock, dependencies, DisplayOptionEnum.Full);
     baseViewModel.WebsiteDependencies.Should().NotBeNull();
 }
示例#8
0
 private void RemoveModel(object sender, BlockViewModel model)
 {
     DiagramCanvas.Remove(model);
 }
        public async Task <BlockViewModel> CreateTopic(CreateTopic newTopic)
        {
            try
            {
                if (newTopic == null || newTopic.BlockNumber == -1)
                {
                    throw new ApplicationException("Topic is not null");
                }
                if (
                    string.IsNullOrEmpty(newTopic.CountryName) ||
                    string.IsNullOrEmpty(newTopic.Description) ||
                    string.IsNullOrEmpty(newTopic.CountryName))
                {
                    throw new ApplicationException("Topic detail is not completed to save");
                }

                //Make sure only 1 topic per block
                var alreadyHasTopic = _blockRepository.Get(x => x.BlockNumber == newTopic.BlockNumber).Any();

                if (alreadyHasTopic)
                {
                    throw new ApplicationException("This block number already has topic");
                }

                // Find the block this new topic will belong too.
                var owningCountry = _countryRepository
                                    .GetQueryable()
                                    .Single(x => x.Blocks.Any(y => y.BlockNumber == newTopic.BlockNumber));
                var countryBlock = owningCountry.Blocks.Single(y => y.BlockNumber == newTopic.BlockNumber);

                var objectId = countryBlock.Id;
                var UId      = countryBlock.UId;

                // TODO: Consider refactor for BlockDetail and BlockViewModel for interacting with BlockService.
                var blockObj = new BlockDetail
                {
                    UId            = UId,
                    Id             = objectId,
                    Name           = newTopic.Name,
                    Description    = newTopic.Description,
                    BlockAxis      = newTopic.BlockAxis,
                    BlockYxis      = newTopic.BlockYxis,
                    BlockNumber    = newTopic.BlockNumber,
                    CreatedOn      = DateTime.UtcNow,
                    CreatedBy      = newTopic.UserUId,
                    CountryId      = newTopic.CountryId,
                    OwnerId        = newTopic.OwnerId,
                    TotalResidents = 1,
                    IsDeleted      = false,
                };

                await _blockRepository.Add(blockObj);

                var blockViewModel = new BlockViewModel
                {
                    Id             = blockObj.Id,
                    Name           = blockObj.Name,
                    Description    = blockObj.Description,
                    BlockAxis      = blockObj.BlockAxis,
                    BlockYxis      = blockObj.BlockYxis,
                    CreatedOn      = blockObj.CreatedOn,
                    CreatedBy      = blockObj.CreatedBy,
                    Owner          = null,
                    TotalResidents = blockObj.TotalResidents,
                };

                return(blockViewModel);
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Create topic error " + e.Message);
            }
        }
示例#10
0
 private void AddModel(object sender, BlockViewModel model)
 {
     DiagramCanvas.Add(model);
 }
示例#11
0
        public override void SetViewModel(BlockViewModel blockViewModel)
        {
            viewModel = (SleepBlockViewModel)blockViewModel;

            sleepLabel.Text = viewModel.Milliseconds;
        }
示例#12
0
 /// <summary>
 /// Adds the element on top of existing elements.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public void Add(BlockViewModel element)
 {
     Add(element, Children.Count);
 }
示例#13
0
 public bool IsEaten(BlockViewModel block)
 => block.X + block.Size > X && block.X <X && block.Y + block.Size> Y && block.Y < Y;
        private void timelineBlock_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton != MouseButton.Left && e.ChangedButton != MouseButton.Right)
            {
                return;
            }

            FrameworkElement control = (FrameworkElement)sender;
            // Get to the actual list item, because for some reason capturing the mouse on the ContentPresenter
            // wrapper (ItemContainer) messes up the reported coordinates during MouseMove.
            FrameworkElement controlBlock = (FrameworkElement)VisualTreeHelper.GetChild(control, 0);
            BlockViewModel   block        = (control.DataContext as BlockViewModel);

            if (sequencer.IsPipetteActive)
            {
                HandlePipetteClick(block, controlBlock, e);
                return;
            }

            var localMouse = e.GetPosition(controlBlock);

            BlockDragMode mode;

            if (e.RightButton == MouseButtonState.Pressed)
            {
                mode = BlockDragMode.Block;
            }
            else if (localMouse.X > controlBlock.ActualWidth - DRAG_START_END_PIXEL_WINDOW && localMouse.X < controlBlock.ActualWidth + DRAG_START_END_PIXEL_WINDOW)
            {
                mode = BlockDragMode.End;
            }
            else if (localMouse.X < DRAG_START_END_PIXEL_WINDOW)
            {
                mode = BlockDragMode.Start;
            }
            else
            {
                mode = BlockDragMode.None;
            }


            if (mode == BlockDragMode.None)
            {
                IEnumerable <BlockViewModel> toSelect;
                if (e.ClickCount == 2 && block is ColorBlockViewModel)
                {
                    toSelect = sequencer.AllBlocks.OfType <ColorBlockViewModel>().Where(other => other.Color == ((ColorBlockViewModel)block).Color);
                }
                else if (e.ClickCount == 2 && block is RampBlockViewModel)
                {
                    toSelect = sequencer.AllBlocks.OfType <RampBlockViewModel>().Where(other => other.StartColor == ((RampBlockViewModel)block).StartColor &&
                                                                                       other.EndColor == ((RampBlockViewModel)block).EndColor);
                }
                else
                {
                    toSelect = Enumerable.Repeat(block, 1);
                }

                sequencer.SelectBlocks(toSelect, CompositionModeFromKeyboard());
            }
            else
            {
                // Make sure the clicked block is always selected before dragging.
                if (!block.IsSelected)
                {
                    var compositionMode = CompositionModeFromKeyboard();
                    if (compositionMode == CompositionMode.Subtractive)
                    {
                        compositionMode = CompositionMode.None;
                    }
                    sequencer.SelectBlock(block, compositionMode);
                }

                // record initial information
                dragMode  = mode;
                dragStart = e.GetPosition(timeline); // always relative to timeline
                dragNeedsToOvercomeThreshold = true;
                dragTrackBaseline            = GetTrackIndexFromOffset(dragStart.Y);
                draggedBlocks = sequencer.SelectedBlocks.Select(b => new DraggedBlockData {
                    block = b, initialDuration = b.Duration, initialStartTime = b.StartTime
                }).ToList();

                controlBlock.CaptureMouse();
                e.Handled = true;
            }

            //control.Focus();
        }
 public abstract void SetViewModel(BlockViewModel blockViewModel);
示例#16
0
 public BlockView() : base(false)
 {
     InitializeComponent();
     ViewModel        = IocContainer.Resolve <BlockViewModel>();
     base.DataContext = ViewModel;
 }
 public KeycheckBlockSettingsViewerViewModel(BlockViewModel block) : base(block)
 {
 }
示例#18
0
 /// <summary>
 /// Changes the position of the view
 /// </summary>
 /// <param name="element"></param>
 public static void UpdatePosition(BlockViewModel element)
 {
     SetLeft(element, element.BlockModel.Position.X);
     SetTop(element, element.BlockModel.Position.Y);
 }
示例#19
0
 public void Remove(BlockViewModel element)
 {
     Children.Remove(element);
 }
        private void HandleDrag(BlockViewModel principal, Vector delta)
        {
            float deltaT = (float)(delta.X / sequencer.TimePixelScale);

            DraggedBlockData principalData = draggedBlocks.Single(db => db.block == principal);

            // adjust delta according to constraints
            // - grid snapping on the principal
            // - respect min duration on all blocks
            // - non-negative start time on the earliest block
            float minDurationDelta, minStartTime, snappedStartTime;

            switch (dragMode)
            {
            case BlockDragMode.Start:
                snappedStartTime = SnapValue(principalData.initialStartTime + deltaT);
                deltaT           = snappedStartTime - principalData.initialStartTime;

                minDurationDelta = -draggedBlocks.Min(b => b.initialDuration - b.block.GetModel().GetMinDuration());
                if (-deltaT < minDurationDelta)
                {
                    deltaT = -minDurationDelta;
                }

                minStartTime = draggedBlocks.Min(b => b.initialStartTime);
                if (deltaT < -minStartTime)
                {
                    deltaT = -minStartTime;
                }
                break;

            case BlockDragMode.End:
                float snappedEndTime = SnapValue(principalData.initialStartTime + principalData.initialDuration + deltaT);
                deltaT = snappedEndTime - principalData.initialStartTime - principalData.initialDuration;

                minDurationDelta = -draggedBlocks.Min(b => b.initialDuration - b.block.GetModel().GetMinDuration());
                if (deltaT < minDurationDelta)
                {
                    deltaT = minDurationDelta;
                }
                break;

            case BlockDragMode.Block:
                // adjust back to zero if in orthogonal drag mode
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) /* && dragTrackBaseline != GetTrackIndexFromOffset(dragStart.Y)*/)
                {
                    deltaT = 0;
                }
                else
                {
                    snappedStartTime = SnapValue(principalData.initialStartTime + deltaT);
                    deltaT           = snappedStartTime - principalData.initialStartTime;

                    minStartTime = draggedBlocks.Min(b => b.initialStartTime);
                    if (deltaT < -minStartTime)
                    {
                        deltaT = -minStartTime;
                    }
                }
                break;
            }

            if (dragNeedsToOvercomeThreshold)
            {
                if (Math.Abs(delta.X) < DRAG_INITIAL_THRESHOLD)
                {
                    // Note that the transaction below will still be created despite the reset,
                    // but it will be empty as no values are actually changed.
                    deltaT = 0;
                }
                else
                {
                    dragNeedsToOvercomeThreshold = false;
                }
            }

            using (sequencer.ActionManager.CreateTransaction())
            {
                // apply delta to all dragged blocks
                switch (dragMode)
                {
                case BlockDragMode.Start:
                    foreach (var b in draggedBlocks)
                    {
                        b.block.StartTime = b.initialStartTime + deltaT;
                        b.block.Duration  = b.initialDuration - deltaT;
                    }
                    break;

                case BlockDragMode.End:
                    foreach (var b in draggedBlocks)
                    {
                        b.block.Duration = b.initialDuration + deltaT;
                    }
                    break;

                case BlockDragMode.Block:
                    foreach (var b in draggedBlocks)
                    {
                        b.block.StartTime = b.initialStartTime + deltaT;
                    }
                    break;
                }
            }


            // vertical drag
            int currentTrackIndex = GetTrackIndexFromOffset(dragStart.Y + delta.Y);

            if (dragMode == BlockDragMode.Block && currentTrackIndex != dragTrackBaseline)
            {
                int trackDelta = currentTrackIndex - dragTrackBaseline;

                int rangeMin = draggedBlocks.Min(b => b.block.GetModel().Tracks.Min(t => t.GetIndex()));
                int rangeMax = draggedBlocks.Max(b => b.block.GetModel().Tracks.Max(t => t.GetIndex()));
                Debug.WriteLine("clamping {0} to {1}", -rangeMin, sequencer.Tracks.Count - rangeMax - 1);
                trackDelta = MathUtil.Clamp(trackDelta, -rangeMin, sequencer.Tracks.Count - rangeMax - 1);

                if (trackDelta != 0)
                {
                    using (sequencer.ActionManager.CreateTransaction(false))
                    {
                        foreach (var b in draggedBlocks)
                        {
                            b.block.GetModel().ShiftTracks(trackDelta, sequencer.ActionManager);
                        }
                    }

                    // set current index as the new baseline
                    dragTrackBaseline = currentTrackIndex;
                }
            }
        }
        private void InitializeViewModels()
        {
            WarehouseRootViewModel = new WarehouseRootViewModel(CMContext);
            foreach (var warehouse in CMContext.Warehouse.Local)
            {
                WarehouseViewModel bufferWarehouseViewModel = new WarehouseViewModel(CMContext);
                bufferWarehouseViewModel.Warehouse = warehouse;
                foreach (var plane in warehouse.Planes)
                {
                    PlaneViewModel bufferPlaneViewModel = new PlaneViewModel(CMContext);
                    bufferPlaneViewModel.Plane = plane;
                    foreach (var block in plane.Blocks)
                    {
                        BlockViewModel bufferBlockViewModel = new BlockViewModel(CMContext);
                        bufferBlockViewModel.Block = block;
                        foreach (var cargoCollection in block.CargoCollections)
                        {
                            CargoCollectionViewModel bufferCargoCollectionViewModel = new CargoCollectionViewModel(CMContext)
                            {
                                CargoCollectionViewModels = CargoCollectionViewModels
                            };
                            bufferCargoCollectionViewModel.CargoCollection           = cargoCollection;
                            bufferCargoCollectionViewModel.BlockViewModel            = bufferBlockViewModel;
                            bufferCargoCollectionViewModel.SelectedPurchasePrizeDic  = bufferCargoCollectionViewModel.CargoCollection.PurchasePrizeDics[0];
                            bufferCargoCollectionViewModel.CargoCollectionViewModels = CargoCollectionViewModels;

                            bufferBlockViewModel.CargoCollectionViewModels.Add(bufferCargoCollectionViewModel);
                            CargoCollectionViewModels.Add(bufferCargoCollectionViewModel);
                        }
                        bufferBlockViewModel.PlaneViewModel = bufferPlaneViewModel;
                        bufferPlaneViewModel.BlockViewModels.Add(bufferBlockViewModel);
                    }
                    bufferPlaneViewModel.WarehouseViewModel = bufferWarehouseViewModel;
                    bufferWarehouseViewModel.PlaneViewModels.Add(bufferPlaneViewModel);
                }
                bufferWarehouseViewModel.WarehouseRootViewModel = WarehouseRootViewModel;
                WarehouseRootViewModel.WarehouseViewModels.Add(bufferWarehouseViewModel);
            }
            foreach (var cargo in CMContext.Cargo.Local)
            {
                CargoViewModel bufferCargoViewModel = new CargoViewModel(CMContext);
                bufferCargoViewModel.Cargo                     = cargo;
                bufferCargoViewModel.CargoViewModels           = CargoViewModels;
                bufferCargoViewModel.CargoCollectionViewModels = CargoCollectionViewModels;
                CargoViewModels.Add(bufferCargoViewModel);
            }
            PurchaseOrderCollectionViewModels = new ObservableCollection <PurchaseOrderCollectionViewModel>();
            foreach (var purchaseOrderCollection in CMContext.PurchaseOrderCollection.Local)
            {
                PurchaseOrderCollectionViewModel pocvm = new PurchaseOrderCollectionViewModel(CMContext)
                {
                    PurchaseOrderCollection = purchaseOrderCollection, PurchaseOrderCollectionViewModels = PurchaseOrderCollectionViewModels
                };
                foreach (var purchaseOrder in purchaseOrderCollection.PurchaseOrders)
                {
                    PurchaseOrderViewModel povm = new PurchaseOrderViewModel(CMContext)
                    {
                        PurchaseOrder = purchaseOrder, PurchaseOrderCollectionViewModel = pocvm
                    };
                    pocvm.PurchaseOrderViewModels.Add(povm);
                }
                PurchaseOrderCollectionViewModels.Add(pocvm);
            }
            SellOrderCollectionViewModels = new ObservableCollection <SellOrderCollectionViewModel>();
            foreach (var sellOrderCollection in CMContext.SellOrderCollection.Local)
            {
                SellOrderCollectionViewModel socvm = new SellOrderCollectionViewModel(CMContext)
                {
                    SellOrderCollection = sellOrderCollection, SellOrderCollectionViewModels = SellOrderCollectionViewModels
                };
                foreach (var sellOrder in sellOrderCollection.SellOrders)
                {
                    SellOrderViewModel sovm = new SellOrderViewModel(CMContext, new CargoCollectionViewModel())
                    {
                        SellOrder = sellOrder
                    };
                    socvm.SellOrderViewModels.Add(sovm);
                }
                SellOrderCollectionViewModels.Add(socvm);
            }
        }
示例#22
0
        private void OnBlockSymbolsInsertAtEventHandler(int insertAt, BlockSymbol newBlockSymbol)
        {
            var block = new BlockViewModel(newBlockSymbol, _client, _inspectorTool);

            SymbolVms.Insert(insertAt, block);
        }
示例#23
0
        public void postFunction([FromBody] BlockViewModel blockModel)
        {
            var model = blockModel;

            _tinyChain.generateNextBlock(model.data);
        }
示例#24
0
 public void DisplayParameters(BlockViewModel model)
 {
     OnViewModelParameters(this, model);
 }
 public override void SetViewModel(BlockViewModel blockViewModel)
 {
     viewModel = (MoveBlockViewModel)blockViewModel;
     UpdateView();
 }