示例#1
0
        public void TestExecuteWithNonWindowParameter()
        {
            CloseWindowCommand changeFocusCommand = new CloseWindowCommand();
            var exception = Assert.ThrowsException <ArgumentException>(() => changeFocusCommand.Execute(null));

            Assert.AreEqual("parameter is not Window", exception.Message);
        }
        public CloseWindowBox()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            MessageTextBlock  = this.FindControl <TextBlock>("MessageTextBox");
            CloseWindowButton = this.FindControl <Button>("CloseWindowButton");

            this.WhenActivated(disposableRegistration =>
            {
                this.OneWayBind(
                    ViewModel,
                    viewModel => viewModel.Message,
                    view => view.MessageTextBlock.Text)
                .DisposeWith(disposableRegistration);

                this.BindCommand(
                    ViewModel,
                    viewModel => viewModel.CloseWindowCommand,
                    view => view.CloseWindowButton)
                .DisposeWith(disposableRegistration);

                ViewModel !.CloseWindowCommand.Subscribe(_ => Close()).DisposeWith(disposableRegistration);
            });
        }
        public MissingInvoicesViewModel(DocumentHandlerViewModel documentHandlerViewModel)
        {
            docHandler      = new DocHandler();
            MissingInvoices = docHandler.GetPurchaseDocumentsAs_SupplierPurchaseInvoicesGrouping(
                documentHandlerViewModel.InvoiceContent.Where(d => d.FileWasMoved == false).ToList());

            CloseWindowCommand     = new CloseWindowCommand(this);
            CopyToClipboardCommand = new CopyToClipboardCommand(this);
        }
示例#4
0
        public MainWindowCommands(MainWindowViewModel viewModel)
        {
            this.viewModel = viewModel;

            LoadFractalCommand    = new LoadFractalCommand(viewModel);
            SaveImageCommand      = new SaveImageCommand(viewModel);
            CloseWindowCommand    = new CloseWindowCommand(viewModel);
            MinimizeWindowCommand = new MinimizeWindowCommand(viewModel);
        }
示例#5
0
        public void TestExecuteSuccess()
        {
            CloseWindowCommand changeFocusCommand = new CloseWindowCommand();
            Window             window             = new Window();
            bool windowClosed = false;

            window.Closed += (sender, e) => { windowClosed = true; };
            changeFocusCommand.Execute(window);

            Assert.IsTrue(windowClosed);
        }
示例#6
0
        /// <summary>
        /// Вызывает окно редактирования данных пользователя
        /// </summary>
        /// <param name="parameter"></param>
        private void ShowReaderUserWindow(object parameter)
        {
            CloseWindowCommand.Execute(null);

            var updateWindow = new RegistrationWindow(UserList, User);
            var viewUpdater  = new UpdateViewUpdater(updateWindow);

            viewUpdater.Update();

            updateWindow.ShowDialog();
        }
示例#7
0
 public new void Close()
 {
     if (CloseWindowCommand != null)
     {
         CloseWindowCommand?.Execute(this);
     }
     else
     {
         base.Close();
     }
 }
示例#8
0
 public MainViewModel()
 {
     DatagridPreviewCommand           = new DatagridPreviewCommand(this);
     PartitionsDatagridPreviewCommand = new PartitionsDatagridPreviewCommand(this);
     OpenCommand           = new OpenCommand(this);
     ExportCommand         = new ExportCommand(this);
     OpenHelpCommand       = new OpenHelpCommand();
     OpenAboutCommand      = new OpenAboutCommand();
     CloseWindowCommand    = new CloseWindowCommand();
     PartitionsViewCommand = new PartitionsViewCommand(this);
 }
示例#9
0
        public LogWindowViewModel()
        {
            #region Commands

            CloseCommand    = new CloseWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();

            #endregion

            Logs = new ObservableCollection <Log>();
        }
        public SettingsWindowViewModel(
            IDispatcherMessenger messenger,
            SaveSettingsCommand saveCommand,
            CloseWindowCommand cancelCommand)
        {
            if (messenger == null) throw new ArgumentNullException("messenger");
            if (saveCommand == null) throw new ArgumentNullException("saveCommand");
            if (cancelCommand == null) throw new ArgumentNullException("cancelCommand");
            SaveCommand = saveCommand;
            CloseCommand = cancelCommand;

            messenger.Register<ConfigSavedEvent>(this, _ => Close = true);
        }
示例#11
0
        public AdminWindowViewModel()
        {
            RunList = new ObservableCollection <Run>();

            IsTaskReadOnly   = true;
            IsUserReadOnly   = true;
            IsMarketReadOnly = true;

            SaveTaskCommand   = new SaveTaskCommand(this);
            SaveMarketCommand = new SaveMarketCommand(this);

            ChangeTaskCommand       = new ChangeTaskCommand(this);
            CancelSaveTaskCommand   = new CancelSaveTaskCommand(this);
            ContactDeveloperCommand = new ContactDeveloperCommand(this);
            ResetTaskCommand        = new ResetTaskCommand(this);

            CreateReportCommand = new CreateReportCommand(this);

            CloseCommand    = new CloseWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();

            CreateUserCommand = new CreateUserCommand(this);
            ChangeUserCommand = new ChangeUserCommand(this);
            SaveUserCommand   = new SaveUserCommand(this);
            CancelUserCommand = new CancelUserCommand(this);
            RemoveUserCommand = new RemoveUserCommand(this);

            TaskIndex   = 0;
            UserIndex   = 0;
            MarketIndex = 0;

            DevList = new List <User>(UserManager.GetUserByGroup(UserGroup.Dev, RunTimeContext.Context.DatabaseContext));

            MarketList = new ObservableCollection <Market>(MarketManager.GetAllMarkets(RunTimeContext.Context.DatabaseContext));
            TaskList   = new ObservableCollection <Task>(TaskManager.GetAllTasks(RunTimeContext.Context.DatabaseContext));
            SetUserList();

            SelectedTask   = TaskList.FirstOrDefault();
            SelectedUser   = UserList.FirstOrDefault();
            SelectedMarket = MarketList.FirstOrDefault();

            StartDate = DateTime.Now.AddMonths(-1);
            EndDate   = DateTime.Now;

            TaskFilter   = TaskList.FirstOrDefault();
            MarketFilter = MarketList.FirstOrDefault();
            DevFilter    = DevList.FirstOrDefault();
        }
        public QuickEditHarmonicKeyViewModel(
            Track track, 
            SaveHarmonicKeyCommand saveBpmCommand, 
            CloseWindowCommand closeCommand)
        {
            if (track == null) throw new ArgumentNullException("track");
            if (saveBpmCommand == null) throw new ArgumentNullException("saveBpmCommand");
            if (closeCommand == null) throw new ArgumentNullException("closeCommand");

            AllHarmonicKeys = HarmonicKey.AllKeys;

            Track = track;
            SaveBpmCommand = saveBpmCommand;
            CloseCommand = closeCommand;

            harmonicKey = track.OriginalKey;
        }
示例#13
0
        public MainWindowViewModel(
            DragWindowCommand dragWindowCommand,
            MinimizeWindowCommand minimizeWindowCommand,
            MaximizeWindowCommand maximizeWindowCommand,
            FullScreenCommand fullScreenCommand,
            CloseWindowCommand closeWindowCommand,
            NoDistractionsCommand noDistractionsCommand)
        {
            _dragWindowCommand     = dragWindowCommand;
            _minimizeWindowCommand = minimizeWindowCommand;
            _maximizeWindowCommand = maximizeWindowCommand;
            _fullScreenCommand     = fullScreenCommand;
            _closeWindowCommand    = closeWindowCommand;
            _noDistractionsCommand = noDistractionsCommand;

            NavigationEventHub.Navigated += OnNavigated;
        }
        public QuickEditBpmViewModel(
            Track track, 
            SaveBpmCommand saveBpmCommand, 
            CloseWindowCommand closeCommand)
        {
            if (track == null) throw new ArgumentNullException("track");
            if (saveBpmCommand == null) throw new ArgumentNullException("saveBpmCommand");
            if (closeCommand == null) throw new ArgumentNullException("closeCommand");

            Validator.AddRule(() => Bpm, ValidateBpm);

            Track = track;
            SaveBpmCommand = saveBpmCommand;
            CloseCommand = closeCommand;

            if (!Double.IsNaN(track.OriginalBpm))
                bpm = track.OriginalBpm.ToString();
        }
示例#15
0
        /// <summary>
        /// Удаляет выбранного пользователя
        /// </summary>
        private void ShowAsseccQuestionWindow(object parameter)
        {
            if (MessageBox.Show(@"Вы действительно хотите удалить данных данного пользователя ?",
                                @"Подтверждение", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }

            CloseWindowCommand.Execute(null);

            using (var dataBase = new UserService())
            {
                dataBase.DeleteUser(User.Id);
            }

            var removedElement = UserList.FirstOrDefault(x => x.Id == User.Id);

            UserList.Remove(removedElement);
        }
示例#16
0
        public CustomerDetailsViewModel()
        {
            if (IsInDesignMode)
            {
                m_currentCustomer = new Customer
                {
                    FirstName = "Frank",
                    LastName  = "Spolsky",
                    Age       = 12,
                    Address   = "BamBam !"
                };
            }
            else
            {
                m_currentCustomer = new Customer();
            }

            CloseWindowCommandCommand = new CloseWindowCommand();
        }
示例#17
0
        public DatabaseViewModel()
        {
            #region Commands

            CloseCommand    = new CloseWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();

            #endregion

            AvailableTables = new List <string>
            {
                "Stamp Duty",
                "Trading News Expire Date",
                "Trading News Exl Name"
            };

            SelectedTable = AvailableTables.FirstOrDefault();
        }
        public DeveloperWindowViewModel()
        {
            MarketList = new ObservableCollection <Market>(MarketManager.GetAllMarkets(RunTimeContext.Context.DatabaseContext));
            SetTaskList();

            IsReadOnly = true;

            SelectedTask = TaskList.FirstOrDefault();

            ChangeTaskCommand     = new ChangeTaskCommand(this);
            SaveTaskCommand       = new SaveTaskCommand(this);
            CancelSaveTaskCommand = new CancelTaskCommand(this);

            CreateTaskCommand = new CreateTaskCommand(this);
            LaunchTaskCommand = new LaunchTaskCommand(this);

            CloseCommand    = new CloseWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();
        }
示例#19
0
 public WMIEventListener(Window window)
 {
     try
     {
         //lanches the listener and specifies its process scope
         scope = new ManagementScope(String.Format("\\\\{0}\\root\\CIMV2", computerName), null);
         scope.Connect();
         wmiQuery = "Select * From __InstanceCreationEvent Within 1 " +
                    "Where TargetInstance ISA 'Win32_Process' ";
         watcher = new ManagementEventWatcher(scope, new EventQuery(wmiQuery));
         //this event fires every time new window process is lanched
         watcher.EventArrived += watcher_EventArrived;
         this.window           = window;
         closeWindow           = new CloseWindowCommand();
     }
     catch (Exception)
     {
         MessageBox.Show("An error monitoring processes");
     }
 }
示例#20
0
        public MainWindowViewModel(List <Task> tasks, UserGroup group)
        {
            GridWidth = false;

            // Set the current user
            CurrentUser = RunTimeContext.Context.CurrentUser;

            #region Lists

            // The list of scheduled tasks (bind to the Schedule list in UI)
            ScheduledList = new ObservableCollection <Schedule>(ScheduleManager.GetScheduledTask(RunTimeContext.Context.CurrentUser,
                                                                                                 RunTimeContext.Context.DatabaseContext));

            // Result list (bind to the result panel in UI)
            ResultList = new ObservableCollection <ResultTask>();

            // Property list, to use with FileLib, /!\ not implemented now :(
            Props = new ObservableCollection <Dictionary <string, string> >();

            // Task list, with all the task, given by the loading screen as constructor parameter
            TaskList = tasks == null ? new ObservableCollection <Task>() : new ObservableCollection <Task>(tasks);

            // The list of queued tasks (bind to the queue panel in UI)
            QueueList = new ObservableCollection <Task>();

            // The list of markets (Bind to the combobox with the list of markets in UI)
            MarketList = new ObservableCollection <Market>(MarketManager.GetAllMarkets(RunTimeContext.Context.DatabaseContext));

            #endregion

            #region Selected

            // Set the market to the main market of the user
            SelectedMarket = CurrentUser.MainMarket;

            // Set the selected task to the first one of the list
            SelectedTask = FilteredTasks.FirstOrDefault();

            #endregion

            #region User right

            // Those three properties are used to be bind with some UI elements like menu
            // If you bind the IsVisibility property of a control with one of those, only the group of person with the appropriate
            // rights will be able to see it
            // eg : Visibility="{Binding IsAdmin}" <-- only Admin level people will see

            // Do the user have Admin Access ?
            IsAdmin = (@group == UserGroup.Dev || @group == UserGroup.Admin) ? Visibility.Visible : Visibility.Collapsed;

            // Manager ?
            IsManager = @group == UserGroup.Manager ? Visibility.Visible : Visibility.Collapsed;

            // Or maybe a Developer ?
            IsDev = @group == UserGroup.Dev ? Visibility.Visible : Visibility.Collapsed;

            #endregion

            #region Commands

            OpenConfigCommand   = new OpenConfigCommand(this);
            OpenScheduleCommand = new OpenScheduleCommand(this);

            OpenFileCommand   = new OpenFileCommand(this);
            OpenFolderCommand = new OpenFolderCommand(this);

            OpenLogCommand = new OpenLogCommand(this);

            RunCommand      = new RunTaskCommand(this);
            QueueCommand    = new QueueTaskCommand(this);
            RemoveCommand   = new RemoveTaskCommand(this);
            CloseCommand    = new CloseWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            LogoutCommand   = new LogoutCommand();

            ClearQueueCommand    = new ClearQueueCommand(this);
            MoveDownQueueCommand = new MoveDownQueueCommand(this);
            MoveUpQueueCommand   = new MoveUpQueueCommand(this);

            StartQueueCommand     = new StartQueueCommand(this);
            AddScheduleCommand    = new AddScheduleCommand(this);
            RemoveScheduleCommand = new RemoveScheduleCommand(this);
            ChangeScheduleCommand = new ChangeScheduleCommand(this);
            ShowAllTaskCommand    = new ShowAllTaskCommand(this);
            ShowMarketTaskCommand = new ShowMarketTaskCommand(this);

            ShowInfoCommand  = new ShowInfoCommand(this);
            ShowQueueCommand = new ShowQueueCommand(this);

            FilterResultCommand = new FilterResultCommand(this);

            ReportDevCommand = new ReportDevCommand(this);

            #endregion

            // Number of time in a row a task failed
            // if 3 the error window will appear automatically
            FailedInARow = 0;

            #region Hide other regions

            GridWidth = true;
            //CollapseQueue();
            //CollapseGrid();

            #endregion

            // A simple bool to see if a task is running at the moment or not
            TaskRunning = false;

            // The result filter, chaging it will change automatically the task list
            ResultFilter = "";

            // The log List
            Log = new ObservableCollection <Log>();

            // The list of currently scheduled tasks, use for rerun if failed and keep track of current running status
            CurrentlyScheduledTasks = new Dictionary <int, ScheduledTaskInfo>();

            #region Timer

            // Create new DispatcherTimer and attach event handler to it
            var launchScheduleTimer = new DispatcherTimer();
            launchScheduleTimer.Tick    += LaunchScheduleTimer_Tick;
            launchScheduleTimer.Interval = new TimeSpan(0, 1, 0);
            launchScheduleTimer.Start();

            #endregion
        }
        private ICommand CreateCloseWindowCommand()
        {
            var command = new CloseWindowCommand();

            return(command);
        }
示例#22
0
 public LogPickerDialogViewModel()
 {
     CloseWindowCommand    = new CloseWindowCommand();
     PickLogCommand        = new PickLogCommand(this);
     SaveLogToGroupCommand = new SaveLogToGroupCommand(this);
 }
示例#23
0
 public async Task <IActionResult> SendWindowManagerCloseWindowCommand([FromBody] CloseWindowCommand command)
 {
     return(Ok(await _commandBus.SendAsync(command)));
 }
示例#24
0
 public SummaryPageViewModel(AccountModel accountModel, Mediator mediator)
 {
     Done             = new CloseWindowCommand();
     GoToPreviousPage = new RelayCommand <object>(arg => mediator.Invoke("OnGoToPreviousPage"));
     AccountModel     = accountModel;
 }
示例#25
0
 public CloseWindowViewModel()
 {
     this.closewindowcommand = new CloseWindowCommand(this);
 }
示例#26
0
 public StudentDetailsViewModel()
 {
     _currentStudent = new Student();
     _closeCommand   = new CloseWindowCommand();
 }
示例#27
0
 public WorkerDetailsViewModel()
 {
     _currentWorker = new Worker();
     _closeCommand  = new CloseWindowCommand();
 }
示例#28
0
 public Task <CommandCorrelationId> CloseWindow(CloseWindowCommand command)
 {
     return(_apiClient.Post <CloseWindowCommand, CommandCorrelationId>("Devices/window-manager/commands/close-window", command));
 }
 protected virtual void OnCloseWindow(EventArgs e)
 {
     CloseWindowCommand?.Invoke(this, e);
 }