Exemple #1
0
        private void LoadData(MessagesModel model)
        {
            var(location, size) = WindowPosition.Normalize(this, model.FormLocation, model.FormSize);

            Location         = location;
            LocationChanged += (s, e) => model.FormLocation = WindowState == FormWindowState.Normal ? Location : RestoreBounds.Location;
            Size             = size;
            SizeChanged     += (s, e) => model.FormSize = WindowState == FormWindowState.Normal ? Size : RestoreBounds.Size;

            UpdateMessages(model.Messages.ToArray());
            _presenter.Model.Messages.ListChanged += OnMessagesListChanged;
        }
Exemple #2
0
        private void LoadData(MainModel model)
        {
            // keep the model value synchronized with the form
            Resize += (s, e) => model.WindowState = WindowState;
            DataBindings.Add(nameof(ShowInTaskbar), model, nameof(MainModel.ShowInTaskbar), false, DataSourceUpdateMode.OnPropertyChanged);

            var(location, size) = WindowPosition.Normalize(this, model.FormLocation, model.FormSize);

            Location         = location;
            LocationChanged += (s, e) => model.FormLocation = WindowState == FormWindowState.Normal ? Location : RestoreBounds.Location;

            if (size.Width != 0 && size.Height != 0)
            {
                if (!model.FormLogWindowVisible)
                {
                    size = new Size(size.Width, size.Height + model.FormLogWindowHeight);
                }
                Size         = size;
                SizeChanged += (s, e) => model.FormSize = WindowState == FormWindowState.Normal ? Size : RestoreBounds.Size;

                // make sure split location is at least the minimum panel size
                if (model.FormSplitterLocation < splitContainer1.Panel2MinSize)
                {
                    model.FormSplitterLocation = splitContainer1.Panel2MinSize;
                }
                splitContainer1.SplitterDistance = model.FormSplitterLocation;
                splitContainer1.SplitterMoved   += (s, e) => model.FormSplitterLocation = splitContainer1.SplitterDistance;
            }

            if (!model.FormLogWindowVisible)
            {
                ShowHideLogWindow(false);
            }
            if (!model.QueueWindowVisible)
            {
                ShowHideQueue(false);
            }

            ViewToggleFollowLogFileMenuItem.BindChecked(model, nameof(MainModel.FollowLog));
            clientDetailsStatusLabel.BindText(model, nameof(MainModel.ClientDetails));
            workingSlotsStatusLabel.BindText(model, nameof(MainModel.WorkingSlotsText));
            totalProductionStatusLabel.BindText(model, nameof(MainModel.TotalProductionText));
            txtLogFile.DataBindings.Add(nameof(txtLogFile.ColorLogFile), model, nameof(MainModel.ColorLogFile), false, DataSourceUpdateMode.OnPropertyChanged);

            model.PropertyChanged += ModelPropertyChanged;

            RestoreFormColumns(model.FormColumns);
        }
        private void LoadData(BenchmarksModel model)
        {
            var(location, size) = WindowPosition.Normalize(this, model.FormLocation, model.FormSize);

            Location         = location;
            LocationChanged += (s, e) => model.FormLocation = WindowState == FormWindowState.Normal ? Location : RestoreBounds.Location;
            Size             = size;
            SizeChanged     += (s, e) => model.FormSize = WindowState == FormWindowState.Normal ? Size : RestoreBounds.Size;

            cboClients.BindSelectedValue(model, nameof(BenchmarksModel.SelectedSlotIdentifier));
            cboClients.DataSource    = model.SlotIdentifiers;
            cboClients.DisplayMember = nameof(ListItem.DisplayMember);
            cboClients.ValueMember   = nameof(ListItem.ValueMember);

            picDeleteClient.BindVisible(model, nameof(BenchmarksModel.SelectedSlotDeleteEnabled));

            ProjectIDTextBox.BindText(model, nameof(BenchmarksModel.WorkUnitName));
            CreditTextBox.BindText(model, nameof(BenchmarksModel.Credit));
            KFactorTextBox.BindText(model, nameof(BenchmarksModel.KFactor));
            FramesTextBox.BindText(model, nameof(BenchmarksModel.Frames));
            AtomsTextBox.BindText(model, nameof(BenchmarksModel.NumberOfAtoms));
            CoreTextBox.BindText(model, nameof(BenchmarksModel.Core));
            DescriptionLinkLabel.Text = "Click to view online";
            DescriptionLinkLabel.DataBindings.Add(nameof(Tag), model, nameof(BenchmarksModel.DescriptionUrl), false, DataSourceUpdateMode.OnPropertyChanged);
            TimeoutTextBox.BindText(model, nameof(BenchmarksModel.PreferredDays));
            ExpirationTextBox.BindText(model, nameof(BenchmarksModel.MaximumDays));
            ContactTextBox.BindText(model, nameof(BenchmarksModel.Contact));
            WorkServerTextBox.BindText(model, nameof(BenchmarksModel.ServerIP));

            model.PropertyChanged += (s, e) => ModelPropertyChanged((BenchmarksModel)s, e);
            model.SelectedSlotProjectListItems = new ListBoxSelectedListItemCollection(projectsListBox);
            projectsListBox.DataSource         = model.SlotProjects;
            projectsListBox.DisplayMember      = nameof(ListItem.DisplayMember);
            projectsListBox.ValueMember        = nameof(ListItem.ValueMember);
            model.SetDefaultSlotProject();

            lstColors.DataSource    = model.GraphColors;
            lstColors.DisplayMember = nameof(ListItem.DisplayMember);
            lstColors.ValueMember   = nameof(ListItem.ValueMember);
            lstColors.BindSelectedValue(model, nameof(BenchmarksModel.SelectedGraphColorItem));

            colorPreviewPictureBox.DataBindings.Add(nameof(PictureBox.BackColor), model, nameof(BenchmarksModel.SelectedGraphColor), false, DataSourceUpdateMode.OnPropertyChanged);
        }