Exemple #1
0
        public NewDefaultDocumentDialog(IServiceProvider serviceProvider, DefaultDocumentFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                var name    = txtName.Text.Trim();
                var invalid = "*".ToCharArray();
                foreach (var ch in invalid)
                {
                    if (name.Contains(ch))
                    {
                        MessageBox.Show($"The specific default document contains the following invalid character: {ch}.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                foreach (var item in feature.Items)
                {
                    if (string.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase))
                    {
                        MessageBox.Show("The specific default document already exists in the default documents list.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                Item         = new DocumentItem(null);
                Item.Name    = name;
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                .Sample(TimeSpan.FromSeconds(1))
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text);
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
        protected override void Initialize(object navigationData)
        {
            base.Initialize(navigationData);
            var service = (IConfigurationService)GetService(typeof(IConfigurationService));

            pictureBox1.Image = service.Scope.GetImage();

            _feature = new DefaultDocumentFeature(Module);
            _feature.DefaultDocumentSettingsUpdated = InitializeListPage;
            _feature.Load();
        }
 public FeatureTaskList(DefaultDocumentFeature owner)
 {
     _owner = owner;
 }