Пример #1
0
        public async Task <IActionResult> ExecuteAsync(int menuId, SaveMenuItem saveMenuItem, CancellationToken cancellationToken)
        {
            var menu = await _menuItemRepository.GetMenuId(menuId, cancellationToken);

            if (menu == null)
            {
                return(new NoContentResult());
            }
            saveMenuItem.MenuId = menuId;
            var menuItem = _saveMenuItemToMenuItemMapper.Map(saveMenuItem);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();

            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub").Value;
            //menuItem.CreatedBy = userId;
            //menuItem.ModifiedBy = userId;

            menuItem = await _menuItemRepository.Add(menuItem, cancellationToken);

            var menuItemViewModel = _menuItemToMenuItemMapper.Map(menuItem);

            return(new CreatedAtRouteResult(MenuItemsControllerRoute.GetMenuItem,
                                            new { id = menuItemViewModel.Id },
                                            menuItemViewModel));
        }
Пример #2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData.HasFlag(Keys.Control))
            {
                if (keyData.HasFlag(Keys.O))
                {
                    OpenMenuItem.PerformClick();
                    return(true);
                }
                if (keyData.HasFlag(Keys.Alt) && keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveDecryptedMenuItem.PerformClick();
                    return(true);
                }
                if (keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveEncryptedMenuItem.PerformClick();
                    return(true);
                }
                if (keyData.HasFlag(Keys.S))
                {
                    SaveMenuItem.PerformClick();
                    return(true);
                }
                if (keyData.HasFlag(Keys.U))
                {
                    FirmwareUpdaterMenuItem.PerformClick();
                    return(true);
                }
            }

            return(m_tabPages.Any(tabPage => tabPage.OnHotkey(keyData)) || base.ProcessCmdKey(ref msg, keyData));
        }
Пример #3
0
 // Because the viewModel needs time to be created,
 // this method is called from two points
 private void ConfigureOptionMenu()
 {
     if (ViewModel != null && SaveMenuItem != null)
     {
         SaveMenuItem.SetVisible(ViewModel.IsManual);
     }
 }
Пример #4
0
        public async Task <IActionResult> ExecuteAsync(int menuItemId, SaveMenuItem saveMenuItem, CancellationToken cancellationToken)
        {
            var menuItem = await _menuItemRepository.Get(menuItemId, cancellationToken);

            if (menuItem == null)
            {
                return(new NotFoundResult());
            }
            _saveMenuItemToMenuItemMapper.Map(saveMenuItem, menuItem);

            var listMenuItemId = await getListMenuItemId(new List <int>(), menuItem.Id, cancellationToken);

            var menuItems = await _menuItemRepository.GetMenuItemsByListId(listMenuItemId, cancellationToken);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub").Value;

            foreach (var item in menuItems)
            {
                item.Active = saveMenuItem.Active;
                //item.ModifiedBy = userId;
                await _menuItemRepository.Update(item, cancellationToken);
            }
            var menuItemViewModel = _menuItemToMenuItemMapper.Map(menuItem);

            return(new OkObjectResult(menuItemViewModel));
        }
Пример #5
0
        /// <summary>
        /// Called upon loading of the form.
        /// This method initializes the graph and the input mode.
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);
            // initialize the graph
            Graph.SetUndoEngineEnabled(true);
            graphControl.FileOperationsEnabled = true;
            ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
            ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
            FitContentButton.SetCommand(Commands.FitContent, graphControl);

            SaveMenuItem.SetCommand(Commands.SaveAs, graphControl);
            OpenMenuItem.SetCommand(Commands.Open, graphControl);
            sampleFilesComboBox.SelectedIndex = 0;
        }
Пример #6
0
        public MainWindowViewModel()
        {
            OpenFiles = new ObservableCollection <OpenFileViewModel>();

            OpenDirectoryMenuItem          = new OpenDirectoryMenuItem(this);
            SaveDirectoryAsMenuItem        = new SaveDirectoryAsMenuItem(this);
            SaveMenuItem                   = new SaveMenuItem(this);
            RunAutomationScriptMenuItem    = new ApplyModMenuItem(this);
            CreateAutomationScriptMenuItem = new CreateAutomationScriptMenuItem(this);
            CreateModpackMenuItem          = new CreateModpackMenuItem(this);

            // Start out with a tutorial for the most common functions
            var intro = new IntroViewModel(this);

            OpenFiles.Add(intro);
            CurrentFile = intro;
        }
Пример #7
0
        private void Initialize()
        {
            FormBorderStyle = FormBorderStyle.Sizable;

            var saveToolStripMenuItem  = new SaveMenuItem();
            var singleObjectControlTab = this.DockPanel.ActiveDocument as RDMPSingleControlTab;

            if (singleObjectControlTab == null)
            {
                saveToolStripMenuItem.Saveable = null;
                return;
            }

            var saveable = singleObjectControlTab.Control as ISaveableUI;

            saveToolStripMenuItem.Saveable = saveable;
        }
Пример #8
0
        private bool askToSave()
        {
            if (!isSaved)
            {
                DialogResult result = MessageBox.Show("Do you want to save changes before closing this file?", "Save changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    SaveMenuItem.PerformClick();
                }
                else if (result == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #9
0
        public void SetWindowManager(WindowManager windowManager)
        {
            SetItemActivator(windowManager.ActivateItems);

            _windowManager          = windowManager;
            _atomicCommandUIFactory = new AtomicCommandUIFactory(Activator);


            //top menu strip setup / adjustment
            LocationsMenu.DropDownItems.Add(new DataExportMenu(Activator));
            _saveToolStripMenuItem = new SaveMenuItem
            {
                Enabled = false,
                Name    = "saveToolStripMenuItem",
                Size    = new System.Drawing.Size(214, 22)
            };
            fileToolStripMenuItem.DropDownItems.Insert(3, _saveToolStripMenuItem);

            _windowManager.TabChanged         += WindowFactory_TabChanged;
            _windowManager.Navigation.Changed += (s, e) => UpdateForwardBackEnabled();

            var tracker = new TutorialTracker(Activator);

            foreach (Tutorial t in tracker.TutorialsAvailable)
            {
                tutorialsToolStripMenuItem.DropDownItems.Add(new LaunchTutorialMenuItem(tutorialsToolStripMenuItem, Activator, t, tracker));
            }

            tutorialsToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());

            tutorialsToolStripMenuItem.DropDownItems.Add(new DisableTutorialsMenuItem(tutorialsToolStripMenuItem, tracker));
            tutorialsToolStripMenuItem.DropDownItems.Add(new ResetTutorialsMenuItem(tutorialsToolStripMenuItem, tracker));

            closeToolStripMenuItem.Enabled = false;

            rdmpTaskBar1.SetWindowManager(_windowManager);

            // Location menu
            LocationsMenu.DropDownItems.Add(_atomicCommandUIFactory.CreateMenuItem(new ExecuteCommandChoosePlatformDatabase(Activator.RepositoryLocator)));

            Activator.Theme.ApplyTo(menuStrip1);
        }
Пример #10
0
        public void SetWindowManager(WindowManager windowManager)
        {
            SetItemActivator(windowManager.ActivateItems);

            _windowManager          = windowManager;
            _atomicCommandUIFactory = new AtomicCommandUIFactory(Activator);


            //top menu strip setup / adjustment
            LocationsMenu.DropDownItems.Add(new DataExportMenu(Activator));
            _saveToolStripMenuItem = new SaveMenuItem
            {
                Enabled = false,
                Name    = "saveToolStripMenuItem",
                Size    = new System.Drawing.Size(214, 22)
            };
            fileToolStripMenuItem.DropDownItems.Insert(3, _saveToolStripMenuItem);

            _windowManager.TabChanged         += WindowFactory_TabChanged;
            _windowManager.Navigation.Changed += (s, e) => UpdateForwardBackEnabled();

            var tracker = new TutorialTracker(Activator);

            foreach (Tutorial t in tracker.TutorialsAvailable)
            {
                tutorialsToolStripMenuItem.DropDownItems.Add(new LaunchTutorialMenuItem(tutorialsToolStripMenuItem, Activator, t, tracker));
            }

            tutorialsToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());

            tutorialsToolStripMenuItem.DropDownItems.Add(new DisableTutorialsMenuItem(tutorialsToolStripMenuItem, tracker));
            tutorialsToolStripMenuItem.DropDownItems.Add(new ResetTutorialsMenuItem(tutorialsToolStripMenuItem, tracker));

            closeToolStripMenuItem.Enabled = false;

            rdmpTaskBar1.SetWindowManager(_windowManager);

            // Location menu
            instancesToolStripMenuItem.DropDownItems.Add(_atomicCommandUIFactory.CreateMenuItem(
                                                             new ExecuteCommandChoosePlatformDatabase(Activator.RepositoryLocator)
            {
                OverrideCommandName = "Change Default Instance"
            }));

            Activator.Theme.ApplyTo(menuStrip1);

            try
            {
                BuildSwitchInstanceMenuItems();
            }
            catch (Exception ex)
            {
                Activator.GlobalErrorCheckNotifier.OnCheckPerformed(
                    new CheckEventArgs("Failed to BuildSwitchInstanceMenuItems", CheckResult.Fail, ex));
            }

            launchAnotherInstanceToolStripMenuItem.ToolTipText = "Start another copy of the RDMP process targetting the same (or another) RDMP platform database";

            if (switchToInstanceToolStripMenuItem.DropDownItems.Count > 1)
            {
                switchToInstanceToolStripMenuItem.Enabled     = true;
                switchToInstanceToolStripMenuItem.ToolTipText = "Close the application and start another copy of the RDMP process targetting another RDMP platform database";
            }
            else
            {
                switchToInstanceToolStripMenuItem.Enabled     = false;
                switchToInstanceToolStripMenuItem.ToolTipText = "There are no other RDMP platform databases configured, create a .yaml file with connection strings to enable this feature";
            }
        }
Пример #11
0
        public async override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ViewModel = await EditTimeEntryViewModel.Init(TimeEntryId);

            // TODO: in theory, this event could be binded but
            // the event "CheckedChange" isn't found when
            // the app is compiled for release. Investigate!
            BillableCheckBox.CheckedChange += (sender, e) => {
                ViewModel.IsBillable = BillableCheckBox.Checked;
            };

            DurationTextView.Click += (sender, e) =>
                                      ChangeTimeEntryDurationDialogFragment.NewInstance(ViewModel.StopDate, ViewModel.StartDate)
                                      .SetChangeDurationHandler(this)
                                      .Show(FragmentManager, "duration_dialog");

            StartTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStartTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StartDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "start_time_dialog");
            };

            StopTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStopTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StopDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "stop_time_dialog");
            };

            ProjectField.TextField.Click += (sender, e) => OpenProjectListActivity();
            ProjectField.Click           += (sender, e) => OpenProjectListActivity();
            TagsField.OnPressTagField    += OnTagsEditTextClick;

            durationBinding  = this.SetBinding(() => ViewModel.Duration, () => DurationTextView.Text);
            startTimeBinding = this.SetBinding(() => ViewModel.StartDate, () => StartTimeEditText.Text)
                               .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            stopTimeBinding = this.SetBinding(() => ViewModel.StopDate, () => StopTimeEditText.Text)
                              .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            projectBinding = this.SetBinding(() => ViewModel.ProjectName, () => ProjectField.TextField.Text);
            clientBinding  = this.SetBinding(() => ViewModel.ClientName, () => ProjectField.AssistViewTitle);
            tagBinding     = this.SetBinding(() => ViewModel.TagList, () => TagsField.TagNames)
                             .ConvertSourceToTarget(tagList => tagList.Select(tag => tag.Name).ToList());
            descriptionBinding = this.SetBinding(() => ViewModel.Description, () => DescriptionField.TextField.Text, BindingMode.TwoWay);
            isPremiumBinding   = this.SetBinding(() => ViewModel.IsPremium, () => BillableCheckBox.Visibility)
                                 .ConvertSourceToTarget(isVisible => isVisible ? ViewStates.Visible : ViewStates.Gone);
            isRunningBinding = this.SetBinding(() => ViewModel.IsRunning).WhenSourceChanges(() => {
                StopTimeEditText.Visibility  = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
                stopTimeEditLabel.Visibility = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
            });
            isBillableBinding = this.SetBinding(() => ViewModel.IsBillable, () => BillableCheckBox.Checked);
            billableBinding   = this.SetBinding(() => ViewModel.IsBillable)
                                .WhenSourceChanges(() => {
                var label             = ViewModel.IsBillable ? GetString(Resource.String.CurrentTimeEntryEditBillableChecked) : GetString(Resource.String.CurrentTimeEntryEditBillableUnchecked);
                BillableCheckBox.Text = label;
            });
            saveMenuBinding = this.SetBinding(() => ViewModel.IsManual)
                              .WhenSourceChanges(() => {
                if (SaveMenuItem != null)
                {
                    SaveMenuItem.SetVisible(ViewModel.IsManual);
                }
            });

            // Configure option menu.
            ConfigureOptionMenu();

            // If project list needs to be opened?
            var settingsStore = ServiceContainer.Resolve <SettingsStore> ();

            if (settingsStore.ChooseProjectForNew && LogTimeEntriesListFragment.NewTimeEntryStartedByFAB)
            {
                LogTimeEntriesListFragment.NewTimeEntryStartedByFAB = false;
                OpenProjectListActivity();
            }
        }
 public Task <IActionResult> Put(
     [FromServices] IPutMenuItemCommand command,
     int id,
     [FromBody] SaveMenuItem saveMenuItem,
     CancellationToken cancellationToken) => command.ExecuteAsync(id, saveMenuItem);