Esempio n. 1
0
        public SledSyntaxCheckerService(ISettingsService settingsService)
        {
            Enabled = true;
            Verbosity = SledSyntaxCheckerVerbosity.Overall;

            var enabledProp =
                new BoundPropertyDescriptor(
                    this,
                    () => Enabled,
                    "Enabled",
                    null,
                    "Enable or disable the syntax checker");

            var verboseProp =
                new BoundPropertyDescriptor(
                    this,
                    () => Verbosity,
                    "Verbosity",
                    null,
                    "Verbosity level");

            // Persist settings
            settingsService.RegisterSettings(this, enabledProp, verboseProp);

            // Add user settings
            settingsService.RegisterUserSettings("Syntax Checker", enabledProp, verboseProp);

            m_syncContext = SynchronizationContext.Current;

            m_batchTimer = new Timerz { Interval = TimerIntervalMsec };
            m_batchTimer.Tick += BatchTimerTick;
            m_batchTimer.Start();
        }
Esempio n. 2
0
        void IInitializable.Initialize()
        {
            if (m_mainWindow != null)
            {
                m_mainWindow.Loaded += mainWindow_Loaded;
                m_mainWindow.Closing += mainWindow_Closing;
            }

            if (m_settingsService != null)
            {
                var autoLoadDocuments =
                    new BoundPropertyDescriptor(this, () => AutoLoadDocuments,
                                                "Auto-load Documents".Localize(), null,
                                                "Load previously open documents on application startup".Localize());
                var 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());
                var autoDocuments =
                    new BoundPropertyDescriptor(this, () => AutoDocuments, "AutoDocuments", null, null);

                m_settingsService.RegisterSettings(this, autoNewDocument, autoLoadDocuments, autoDocuments);
                m_settingsService.RegisterUserSettings("Documents".Localize(), autoNewDocument, autoLoadDocuments);
            }
        }
        public SledLuaFunctionParserService(ISettingsService settingsService)
        {
            var verboseSetting =
                new BoundPropertyDescriptor(
                    this,
                    () => Verbose,
                    Resources.Resource.Verbose,
                    Resources.Resource.LuaFunctionParser,
                    Resources.Resource.Verbose);

            settingsService.RegisterSettings(this, verboseSetting);
            settingsService.RegisterUserSettings(SledLuaSettings.Category, verboseSetting);
        }
Esempio n. 4
0
        void IInitializable.Initialize()
        {
            
            var snapAngleEditor = new NumericEditor(typeof(float));
            snapAngleEditor.ScaleFactor = 180.0 / Math.PI;
            string misc = "Misc".Localize();
            var userSettings = new System.ComponentModel.PropertyDescriptor[]
                {                                       
                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.BackColor, "BackgroundColor".Localize(), misc,
                        "Background color".Localize()),
                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.CameraFarZ, "FarZ".Localize(), misc,
                        "Camera Far Z".Localize()),
                                     
                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.ControlScheme, "ControlScheme".Localize(), misc,
                        "Control scheme".Localize()),
                                       
                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.SnapVertex,
                        "SnapVertex".Localize(),
                        misc,"Snap vertex".Localize()),

                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.RotateOnSnap,
                        "RotateOnSnap".Localize(),
                        misc, "Rotate on snap".Localize()),

                    new BoundPropertyDescriptor(
                        m_designView, () => m_designView.SnapAngle,
                        "Snap Angle".Localize(),
                        misc, "Snap to angle when using rotation manipulator." +
                              "Angle is in degrees. Set it to zero to disable snapping.".Localize(), snapAngleEditor,null)
                     
                };

            m_settingsService.RegisterUserSettings( "Editors".Localize() + "/" + "DesignView".Localize(), userSettings);
            m_settingsService.RegisterSettings(this, userSettings);

            var snapfrom = new BoundPropertyDescriptor(
                         m_designView, () => m_designView.SnapFrom,
                         "SnapMode".Localize(),null, null);
            m_settingsService.RegisterSettings(this, snapfrom);

            if (m_scriptingService != null)
                m_scriptingService.SetVariable("designView", m_designView);
        }
        /// <summary>
        /// Finishes initializing component by setting up settings service and registering commands</summary>
        public virtual void Initialize()
        {
            if (m_settingsService != null)
            {
                BoundPropertyDescriptor recentDocumentCount =
                    new BoundPropertyDescriptor(this, () => RecentDocumentCount,
                        "Recent Files Count".Localize("Number of recent files to display in File Menu"), null,
                        "Number of recent files to display in File Menu".Localize());

                BoundPropertyDescriptor recentDocuments =
                    new BoundPropertyDescriptor(this, () => RecentDocumentsAsCsv, "RecentDocuments", null, null);

                // Using the type name so that derived classes don't lose old user settings
                m_settingsService.RegisterSettings("Sce.Atf.Applications.RecentDocumentCommands",
                    recentDocumentCount,
                    recentDocuments);

                m_settingsService.RegisterUserSettings(
                    "Documents".Localize(),
                    recentDocumentCount);
            }

            if (CommandService != null)
            {
                var commandInfo = new CommandInfo(Command.Pin,
                    StandardMenu.File,
                    null,
                    "Pin file".Localize("Pin active file to the recent files list"),
                    "Pin active file to the recent files list".Localize(),
                    Keys.None,
                    Resources.PinGreenImage,
                    CommandVisibility.Menu);

                CommandService.RegisterCommand(commandInfo, this);

                // Add an empty entry so the Recent Files menu shows up even if there are no 
                // files in the list. This gets removed as soon as a file is added.
                m_emptyMruCommandInfo = new CommandInfo(Command.EmptyMru,
                    StandardMenu.File,
                    StandardCommandGroup.FileRecentlyUsed,
                    "Recent Files".Localize() + "/(" + "empty".Localize() + ")",
                    "No entries in recent files list".Localize(),
                    Keys.None);
                CommandService.RegisterCommand(
                    m_emptyMruCommandInfo,
                    this);
            }
        }
        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);
        }
Esempio n. 7
0
        public SledLanguageParserService(ISettingsService settingsService)
        {
            Verbosity = SledLanguageParserVerbosity.Overall;

            var verboseProp =
                new BoundPropertyDescriptor(
                    this,
                    () => Verbosity,
                    "Verbosity",
                    null,
                    "Verbosity level");

            // Persist settings
            settingsService.RegisterSettings(this, verboseProp);

            // Add user settings
            settingsService.RegisterUserSettings("Language Parser", verboseProp);

            m_syncContext = SynchronizationContext.Current;

            m_batchTimer = new Timerz { Interval = TimerIntervalMsec };
            m_batchTimer.Tick += BatchTimerTick;
            m_batchTimer.Start();
        }
Esempio n. 8
0
        void IInitializable.Initialize()
        {
            if (m_settingsService != null)
            {
                BoundPropertyDescriptor recentDocuments =
                    new BoundPropertyDescriptor(this, () => RecentDirectoriesAsXml, "RecentDirectories", null, null);

                // Using the type name so that derived classes don't lose old user settings
                m_settingsService.RegisterSettings("Sce.Atf.Applications.FileDialogService",
                    recentDocuments);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Finishes initializing component by setting up scripting service, subscribing to document
        /// events, and creating PropertyDescriptors for settings</summary>
        void IInitializable.Initialize()
        {
            if (m_scriptingService != null)
            {
                // load this assembly into script domain.
                m_scriptingService.LoadAssembly(GetType().Assembly);
                m_scriptingService.ImportAllTypes("TimelineEditorSample");
                m_scriptingService.ImportAllTypes("TimelineEditorSample.DomNodeAdapters");
                m_scriptingService.SetVariable("editor", this);

                m_contextRegistry.ActiveContextChanged += delegate
                {
                    EditingContext editingContext = m_contextRegistry.GetActiveContext<EditingContext>();
                    IHistoryContext hist = m_contextRegistry.GetActiveContext<IHistoryContext>();
                    m_scriptingService.SetVariable("editingContext", editingContext);
                    m_scriptingService.SetVariable("hist", hist);
                };
            }

            if (m_fileWatcherService != null)
            {
                m_fileWatcherService.FileChanged += fileWatcherService_FileChanged;
            }

            m_documentService.DocumentOpened += documentService_DocumentOpened;
            if (m_liveConnectService != null)
            {
                m_liveConnectService.MessageReceived += liveConnectService_MessageReceived;
            }

            var settings = new BoundPropertyDescriptor[] {
                new BoundPropertyDescriptor(typeof(D2dTimelineRenderer),
                    () => D2dTimelineRenderer.GlobalHeaderWidth,
                    "Header Width", "Appearance", "Width of Group/Track Header"),
                new BoundPropertyDescriptor(typeof(D2dTimelineRenderer),
                    () => D2dTimelineRenderer.GlobalKeySize, "Key Size", "Appearance", "Size of Keys"),
                new BoundPropertyDescriptor(typeof(D2dTimelineRenderer),
                    () => D2dTimelineRenderer.GlobalMajorTickSpacing, "Major Tick Spacing", "Appearance", "Pixels between major ticks"),
                new BoundPropertyDescriptor(typeof(D2dTimelineRenderer),
                    () => D2dTimelineRenderer.GlobalPickTolerance, "Pick Tolerance", "Behavior", "Picking tolerance, in pixels"),
                new BoundPropertyDescriptor(typeof(D2dTimelineRenderer),
                    () => D2dTimelineRenderer.GlobalTrackHeight, "Track Height", "Appearance", "Height of track, relative to units of time"),

                //manipulator settings
                new BoundPropertyDescriptor(typeof(D2dSnapManipulator), () => D2dSnapManipulator.SnapTolerance, "Snap Tolerance", "Behavior",
                    "The maximum number of pixels that a selected object will be snapped"),
                new BoundPropertyDescriptor(typeof(D2dSnapManipulator), () => D2dSnapManipulator.Color, "Snap Indicator Color", "Appearance",
                    "The color of the indicator to show that a snap will take place"),
                new BoundPropertyDescriptor(typeof(D2dScaleManipulator), () => D2dScaleManipulator.Color, "Scale Manipulator Color", "Appearance",
                    "The color of the scale manipulator")            };
            m_settingsService.RegisterUserSettings("Timeline Editor", settings);
            m_settingsService.RegisterSettings(this, settings);
        }
Esempio n. 10
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. Minimum value is 10".Localize());

                m_settingsService.RegisterSettings(this, descriptor);
                m_settingsService.RegisterUserSettings("Application", descriptor);

            }
            ComputeColors();
        }
Esempio n. 11
0
        void IInitializable.Initialize()
        {
            // on initialization, register our tree control with the hosting service
            m_controlHostService.RegisterControl(
                TreeControl,
                new ControlInfo(
                   Localizer.Localize("Addon Explorer"),
                   Localizer.Localize("Displays the current addon"),
                   StandardControlGroup.Left), // don't show close button
               this);

            BoundPropertyDescriptor[] settings = new BoundPropertyDescriptor[] {
                new BoundPropertyDescriptor(typeof(GlobalSettings),
                    () => GlobalSettings.CurrentProjectDirectory, "Current Project Directory".Localize(), "Paths".Localize(), "Path to current addon project.  Dont mess with this".Localize()),

            };

            this.settings.RegisterSettings(this, settings);

            TreeView = new ProjectView();
            this.TreeControl.DoubleClick += TreeControl_DoubleClick;

            SettingsService service = this.settings as SettingsService;
            service.LoadSettings();
            if(GlobalSettings.CurrentProjectDirectory != null)
            {
                OpenProject(ProjectLoader.OpenProjectFromFolder(GlobalSettings.CurrentProjectDirectory));
            }
            (TreeView as ProjectView).SelectionChanged += view_SelectionChanged;

            TreeControl.MouseUp += TreeControl_MouseUp;
        }
Esempio n. 12
0
        private void RegisterSettings()
        {
            string descr = "Root path for all resources".Localize();
            var resourceRoot =
                new BoundPropertyDescriptor(this, () => ResourceRoot,
                    "ResourceRoot".Localize("A user preference and the name of the preference in the settings file"),
                    null,
                    descr,
                    new FolderBrowserDialogUITypeEditor(descr), 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());
                    
            string docs = "Documents".Localize();
            m_settingsService.RegisterSettings(docs, resolveOnLoad);
            m_settingsService.RegisterUserSettings(docs, resolveOnLoad);

        }
Esempio n. 13
0
        public void TestStaticTypeWithLambdas()
        {
            MyStaticClass.Reset();
            BoundPropertyDescriptor test;

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticStringProperty, "StaticStringProperty", "", "");
            Assert.IsFalse(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals("uninitialized"));
            test.SetValue(null, "xxx");
            Assert.IsTrue(test.GetValue(null).Equals("xxx"));
            Assert.IsTrue(MyStaticClass.StaticStringProperty == "xxx");

            test = new BoundPropertyDescriptor(typeof(MyStaticClass),  () => MyStaticClass.StaticIntProperty, "StaticIntProperty", "", "");
            Assert.IsFalse(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals(5));
            test.SetValue(null, 10);
            Assert.IsTrue(test.GetValue(null).Equals(10));
            Assert.IsTrue(MyStaticClass.StaticIntProperty == 10);

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticStringAsymmetricalAccessProperty, "StaticStringAsymmetricalAccessProperty", "", "");
            Assert.IsTrue(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals("uninitialized"));
            test.SetValue(null, "xxx");
            Assert.IsTrue(test.GetValue(null).Equals("xxx"));
            Assert.IsTrue(MyStaticClass.StaticStringAsymmetricalAccessProperty == "xxx");

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticIntAsymmetricalProperty, "StaticIntAsymmetricalProperty", "", "");
            Assert.IsTrue(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals(5));
            test.SetValue(null, 10);
            Assert.IsTrue(test.GetValue(null).Equals(10));
            Assert.IsTrue(MyStaticClass.StaticIntAsymmetricalProperty == 10);
        }
Esempio n. 14
0
        /// <summary>
        /// Finishes initializing component by subscribing to event, registering control, and setting up Settings Service</summary>
        public virtual void Initialize()
        {
            Configure(out m_propertyGrid, out m_controlInfo);

            // create image for clone button.
            if (s_cloneImage == null)
            {
                s_cloneImage = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                using (Graphics g = Graphics.FromImage(s_cloneImage))
                {
                    g.Clear(Color.Transparent);
                    var rect = new Rectangle(1, 1, 8, 10);                        
                    g.FillRectangle(Brushes.White, rect);
                    g.DrawRectangle(Pens.Black, rect);
                    rect.Location = new Point(6, 5);
                    g.FillRectangle(Brushes.White, rect);
                    g.DrawRectangle(Pens.Black, rect);
                }
            }
            
            var cloneButton = new ToolStripButton();
            cloneButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            cloneButton.Image = s_cloneImage;            
            cloneButton.Name = "cloneButton";
            cloneButton.Size = new Size(29, 22);
            cloneButton.ToolTipText = "Clone this editor".Localize();
            cloneButton.Click += (sender, e) => Duplicate();            
            m_propertyGrid.ToolStrip.Items.Add(cloneButton);
            m_propertyGrid.PropertyGridView.ContextRegistry = ContextRegistry;
            m_propertyGrid.MouseUp += propertyGrid_MouseUp;

            ContextRegistry.ActiveContextChanged += contextRegistry_ActiveContextChanged;

            ControlHostService.RegisterControl(m_propertyGrid, m_controlInfo, this);

            if (SettingsService != null)
            {
                SettingsService.RegisterSettings(this,
                    new BoundPropertyDescriptor(m_propertyGrid, () => m_propertyGrid.Settings, "Settings", null, null));

                var groupDescr = new BoundPropertyDescriptor(this.GetType(), () => ClonedEditorGroup, "Docking", null,
                    "Initial docking group for duplicated property editors\r\nCenter, CenterPermanent, and Hidden are not accepted".Localize());

                SettingsService.RegisterSettings(this, groupDescr);
                SettingsService.RegisterUserSettings("Property Editor".Localize(), groupDescr);
            }
        }