//selects a command (updates the UI)
        private void SelectMessageCommand(SelectionCommand command)
        {
            ResetCommandSelections();

            switch (command)
            {
            case SelectionCommand.TXT:
                TXT_Selected = true;
                break;

            case SelectionCommand.LED:
                LED_Selected = true;
                break;

            case SelectionCommand.IR:
                IR_Selected = true;
                break;

            case SelectionCommand.SPD:
                SPD_Selected = true;
                break;
            }

            UI_UpdateSelectionState();
        }
예제 #2
0
        /// <summary>
        /// 選択肢ビューを追加する
        /// </summary>
        /// <param name="command"></param>
        public void AddSelection(SelectionCommand command)
        {
            // 表示最大数に達していたら追加しない
            if (_viewList.Count == _maxSelectionNum)
            {
                return;
            }

            var view = Instantiate(selectionPrefab, transform)
                       .GetComponent <ScenarioSelectionView>();

            view.Initialize(command.SelectionText, command.LabelName, OnClick);
            _viewList.Add(view);

            // 座標を設定
            var viewRect = view.GetComponent <RectTransform>();
            var pos      = viewRect.localPosition;

            pos.y -= _viewList.Count * (viewRect.sizeDelta.y + MarginY);
            viewRect.localPosition = pos;

            // クリック時のコールバック
            // ビューから渡されるラベル名を通知する
            void OnClick(string labelName)
            {
                onSelect.OnNext(labelName);
            }

            AdjustPosition();
        }
예제 #3
0
 public static void Shift(User user, string directionAndAmount = "1")
 {
     try
     {
         SelectionCommand command = SelectionCommand.ShiftCommand(user, directionAndAmount);
         if (command.Invoke())
         {
             user.Player.MsgLoc($"Shifted selection {command.amount} {command.direction}");
         }
     }
     catch (WorldEditCommandException e)
     {
         user.Player.ErrorLocStr(e.Message);
     }
     catch (Exception e)
     {
         Log.WriteError(Localizer.Do($"{e}"));
     }
 }
예제 #4
0
 private void InkCanvas_SelectionChanged(object sender, EventArgs e)
 {
     if (fireCommand)
     {
         IEnumerable <object> items = GetSelectedElements()
                                      .Select(i => (i is FrameworkElement fe) ? fe.DataContext : null)
                                      .Where(i => i != null);
         if (SelectionCommand != null && SelectionCommand.CanExecute(items))
         {
             SelectionCommand.Execute(items);
         }
         fireCommand = false;
         Select(Array.Empty <UIElement>());
     }
     else
     {
         fireCommand = true;
     }
 }
예제 #5
0
 public Infrastructure Create(ModelEntities entity, string function)
 {
     if (function == "item")
     {
         ItemViews         _view             = new ItemViews();
         SelectionCommand  selectionCommand  = new SelectionCommand(_view);
         UpdateItemCommand updateItemCommand = new UpdateItemCommand(_view);
         AddItemCommand    addItemCommand    = new AddItemCommand(_view);
         ViewModel         _viewModel        = new ViewModel(entity, selectionCommand.Command, updateItemCommand.Command, addItemCommand.Command);
         selectionCommand.ViewModel  = _viewModel;
         updateItemCommand.ViewModel = _viewModel;
         addItemCommand.ViewModel    = _viewModel;
         return(new Infrastructure(_view, _viewModel, entity));
     }
     else
     {
         return(null);
     }
 }
예제 #6
0
        public SelectManyDemoVm()
        {
            Items       = new ObservableCollection <ItemVm>().AllDisposedBy(this);
            SelectedIds = new ObservableCollection <string>  {
                "2", "5", "8", "1111", "11115", "22229", "StamItem"
            };
            Initialize();
            SelectionCommand  = MvvmRx.CreateCommand <IEnumerable <String> >(this);
            RandomFiveCommand = MvvmRx.CreateCommand(this);
            RemoveSelected    = MvvmRx.CreateCommand <IEnumerable>(this);
            ResetCommand      = MvvmRx.CreateCommand(this);
            ClearCommand      = MvvmRx.CreateCommand(this);

            SelectionCommand.Select(ienum => ienum.ToObservableCollection()).ApplyOnProperty(this, x => x.SelectedIds);
            RandomFiveCommand.Subscribe(_ =>
            {
                var rnd   = new Random();
                var items = Enumerable.Range(0, 5).Select(__ => Items[rnd.Next(Items.Count)].Uid);
                SelectedIds.AddRange(items);
            }).DisposedBy(this);

            RemoveSelected.Subscribe(x =>
            {
                foreach (var item in x.OfType <string>().ToArray())
                {
                    SelectedIds.Remove(item);
                }
            }).DisposedBy(this);

            ResetCommand.Subscribe(_ =>
            {
                var rnd     = new Random();
                var ids     = Items.Select(x => x.Uid).Where(x => rnd.Next(40) < 2).ToObservableCollection();
                SelectedIds = ids;
            }).DisposedBy(this);

            ClearCommand.Subscribe(_ =>
            {
                Items.Clear();
            }).DisposedBy(this);
        }
 public void ApplySelectionCommand(SelectionCommand selectionCommand)
 {
     ControlSettings.SelectionCommand = selectionCommand;
     UpdateTipMessage(ControlSettings.SelectionCommand);
     // Setup the PlateControl selection mode accordingly
     switch (ControlSettings.SelectionCommand)
     {
         case SelectionCommand.Fill:
             _plateControl.SelectionMode = PlateControl2DSilverlight.Enumerations.SelectingMode.FirstAndLast;
             _plateControl.PosMouseCursor = Cursors.Hand;
             break;
         case SelectionCommand.Erase:
             _plateControl.SelectionMode = PlateControl2DSilverlight.Enumerations.SelectingMode.None;
             _plateControl.PosMouseCursor = Cursors.Eraser;
             break;
         case SelectionCommand.Flag:
             _plateControl.SelectionMode = PlateControl2DSilverlight.Enumerations.SelectingMode.Single;
             _plateControl.PosMouseCursor = Cursors.Arrow;
             break;
     }
 }
 private void UpdateTipMessage(SelectionCommand selectionCommand)
 {
     switch (selectionCommand)
     {
         case SelectionCommand.Erase:
             UpdateTipMessage("Select the sample groups to remove, i.e. those that were not read.");
             break;
         case SelectionCommand.Fill:
             UpdateTipMessage("Select a single position or drag the mouse to fill multiple positions.");
             break;
         case SelectionCommand.Flag:
             UpdateTipMessage("Click a position to flag it.");
             break;
     }
 }