Ejemplo n.º 1
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object originalValue, object newValue, IValueConverter stringConverter)
 {
     _boundPropertyDescriptor = boundPropertyDescriptor;
     _originalValue = originalValue;
     _newValue = newValue;
     _stringConverter = stringConverter;
 }
Ejemplo n.º 2
0
        public void TestInstanceWithLambdas()
        {
            MyClass myClass = new MyClass("myClass", 5);
            BoundPropertyDescriptor test;

            test = new BoundPropertyDescriptor(myClass, () => myClass.Property, "Property", "", "");
            Assert.IsFalse(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals("myClass"));
            test.SetValue(null, "xxx");
            Assert.IsTrue(test.GetValue(null).Equals("xxx"));
            Assert.IsTrue(myClass.Property == "xxx");

            test = new BoundPropertyDescriptor(myClass, () => myClass.ReadOnlyProperty, "ReadOnlyProperty", "", "");
            Assert.IsTrue(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals(5));
            test.SetValue(null, 10);
            Assert.IsTrue(test.GetValue(null).Equals(10));
            Assert.IsTrue(myClass.ReadOnlyProperty == 10);
        }
Ejemplo n.º 3
0
        void IInitializable.Initialize()
        {
            if (m_settingsService != null)
            {
                BoundPropertyDescriptor autoLoadDocuments =
                    new BoundPropertyDescriptor(this, () => AutoLoadDocuments,
                                                "Auto-load Documents".Localize(), null,
                                                "Load previously open documents on application startup".Localize());
                BoundPropertyDescriptor autoNewDocument =
                    new BoundPropertyDescriptor(this, () => AutoNewDocument,
                                                "Auto New Document".Localize("Create a new empty document on application startup"), null,
                                                "Create a new empty document on application startup".Localize());
                BoundPropertyDescriptor autoDocuments =
                    new BoundPropertyDescriptor(this, () => AutoDocuments, "AutoDocuments", null, null);

                m_settingsService.RegisterSettings(this, autoNewDocument, autoLoadDocuments, autoDocuments);

                m_settingsService.RegisterUserSettings("Documents".Localize(), autoNewDocument, autoLoadDocuments);
            }
        }
Ejemplo n.º 4
0
        private void RegisterSettings()
        {
            var resourceRoot =
                new BoundPropertyDescriptor(this, () => ResourceRoot,
                                            "ResourceRoot".Localize("A user preference and the name of the preference in the settings file"),
                                            null,
                                            "Root path for all resources".Localize(),
                                            new FolderNameEditor(), null);

            m_settingsService.RegisterSettings(this, resourceRoot);
            m_settingsService.RegisterUserSettings("Resources".Localize(), resourceRoot);

            var resolveOnLoad =
                new BoundPropertyDescriptor(this, () => ResolveOnLoad,
                                            "Resolve on load".Localize("A user preference and the name of the preference in the settings file"),
                                            null,
                                            "Resolve sub-documents on load".Localize());

            m_settingsService.RegisterSettings("Documents".Localize(), resolveOnLoad);
            m_settingsService.RegisterUserSettings("Documents".Localize(), resolveOnLoad);
        }
Ejemplo n.º 5
0
        void IInitializable.Initialize()
        {
            m_listbox                       = new CommandList();
            m_listbox.DrawMode              = DrawMode.OwnerDrawFixed;
            m_listbox.BorderStyle           = BorderStyle.None;
            m_listbox.SelectedIndexChanged += (sender, e) =>
            {
                try
                {
                    m_undoingOrRedoing = true;
                    int indexLastDone = m_commandHistory.Current - 1;
                    int cmdIndex      = m_listbox.SelectedIndex + m_startIndex;
                    if (cmdIndex < indexLastDone)
                    {
                        while (cmdIndex < indexLastDone)
                        {
                            m_historyContext.Undo();
                            indexLastDone = m_commandHistory.Current - 1;
                        }
                    }
                    else
                    {
                        while (cmdIndex >= m_commandHistory.Current)
                        {
                            m_historyContext.Redo();
                        }
                    }
                }
                finally
                {
                    m_undoingOrRedoing = false;
                }
            };


            m_listbox.DrawItem2 += (sender, e) =>
            {
                if (e.Index < 0)
                {
                    return;
                }
                int     cmdIndex = e.Index + m_startIndex;
                Command cmd      = (Command)m_listbox.Items[e.Index];
                if (cmdIndex >= m_commandHistory.Current)
                {
                    m_textBrush.Color = m_redoForeColor;
                    m_fillBrush.Color = m_redoBackColor;
                }
                else
                {
                    m_textBrush.Color = m_undoForeColor;
                    m_fillBrush.Color = m_undoBackColor;
                }

                if (e.State == DrawItemState.Selected)
                {
                    e.DrawBackground();
                    e.DrawFocusRectangle();
                }
                else
                {
                    e.Graphics.FillRectangle(m_fillBrush, e.Bounds);
                }

                e.Graphics.DrawString(cmd.Description, e.Font, m_textBrush,
                                      e.Bounds, StringFormat.GenericDefault);
            };

            ControlInfo cinfo = new ControlInfo("History", "Undo/Redo stack", StandardControlGroup.Right);

            m_controlHostService.RegisterControl(m_listbox, cinfo, null);
            m_documentRegistry.ActiveDocumentChanged += m_documentRegistry_ActiveDocumentChanged;

            m_listbox.BackColorChanged += (sender, e) => ComputeColors();
            m_listbox.ForeColorChanged += (sender, e) => ComputeColors();

            if (m_settingsService != null)
            {
                var descriptor = new BoundPropertyDescriptor(
                    this,
                    () => MaxCommandCount,
                    "Max Visual Command History Count".Localize(),
                    null,
                    "Maximum number of commands in the visual command history".Localize());

                m_settingsService.RegisterSettings(this, descriptor);
                m_settingsService.RegisterUserSettings("Application", descriptor);
            }
            ComputeColors();
        }
Ejemplo n.º 6
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object originalValue, object newValue)
 {
     _boundPropertyDescriptor = boundPropertyDescriptor;
     _originalValue           = originalValue;
     _newValue = newValue;
 }
Ejemplo n.º 7
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object newValue) :
     this(boundPropertyDescriptor, boundPropertyDescriptor.Value, newValue)
 {
 }
Ejemplo n.º 8
0
 public ResetObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object originalValue, IValueConverter stringConverter)
 {
     mBoundPropertyDescriptor = boundPropertyDescriptor;
     mOriginalValue           = originalValue;
     mStringConverter         = stringConverter;
 }
Ejemplo n.º 9
0
 public ResetObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, IValueConverter stringConverter) :
     this(boundPropertyDescriptor, boundPropertyDescriptor.Value, stringConverter)
 {
 }
Ejemplo n.º 10
0
 public ResetObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, IValueConverter stringConverter)
     : this(boundPropertyDescriptor, boundPropertyDescriptor.Value, stringConverter)
 {
 }
Ejemplo n.º 11
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object originalValue, object newValue)
 {
     _boundPropertyDescriptor = boundPropertyDescriptor;
     _originalValue = originalValue;
     _newValue = newValue;
 }
Ejemplo n.º 12
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object newValue)
     : this(boundPropertyDescriptor, boundPropertyDescriptor.Value, newValue)
 {
 }
Ejemplo n.º 13
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object newValue, IValueConverter stringConverter) :
     this(boundPropertyDescriptor, boundPropertyDescriptor.Value, newValue, stringConverter)
 {
 }
Ejemplo n.º 14
0
 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object newValue, IValueConverter stringConverter)
     : this(boundPropertyDescriptor, boundPropertyDescriptor.Value, newValue, stringConverter)
 {
 }