예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.Frame            = UIScreen.MainScreen.Bounds;
            View.BackgroundColor  = UIColor.White;
            View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            UILabel label = new UILabel(new RectangleF(0, 30, View.Frame.Width, 50));

            View.AddSubview(label);

            button = UIButton.FromType(UIButtonType.RoundedRect);

            button.Frame = new RectangleF(
                View.Frame.Width / 2 - buttonWidth / 2,
                View.Frame.Height / 2 - buttonHeight / 2,
                buttonWidth,
                buttonHeight);

            button.SetTitle("Click me", UIControlState.Normal);
            View.AddSubview(button);

            // Do the bindings.
            TestViewModel vm = new TestViewModel();

            BindingContext.Create(vm)
            .Add(s => s.TotalClicks, label, l => l.Text)
            .Add(s => s.TotalClicks, s => button.SetTitle("Total Clicks is now " + s.TotalClicks, UIControlState.Normal));

            CommandBinder.Create()
            .Add(button, "TouchUpInside", vm.IncrementCounter,
                 stateChanged: tf => button.Enabled = tf);
        }
예제 #2
0
 public void Awake()
 {
     _commandMap  = new CommandBinder();
     _modelMap    = new ModelBinder();
     _mediatorMap = new MediatorBinder();
     _dispatcher  = new Dispatcher();
 }
예제 #3
0
 public MVCSExtension(MediationMode mediationMode)
 {
     CommandBinder   = new CommandBinder();
     EventDispatcher = new EventDispatcherWithCommandProcessing((CommandBinder)CommandBinder);
     InjectionBinder = new InjectionBinder();
     MediationBinder = new MediationBinder(mediationMode, InjectionBinder);
 }
예제 #4
0
 public void Source_Is_Enabled_When_Target_ICommand_CanExecute_Is_True_During_Initialization()
 {
     var source = new MockEventSource();
     var target = new MockViewModelWithAction();
     var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command);
     binder.Bind();
     Assert.IsTrue(source.IsEnabled);
 }
예제 #5
0
 public void Awake()
 {
     _gameManager = GameManager.Instance;
     _dispatcher  = _gameManager.Dispatcher;
     _commandMap  = _gameManager.CommandMap;
     _gameManager.AddContext(this);
     OnRegister();
 }
예제 #6
0
 public void Target_Command_CallCount_Is_Zero_After_Initialization_Of_CommandBinder()
 {
     var source = new MockEventSource();
     var target = new MockViewModelWithAction();
     var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command);
     binder.Bind();
     Assert.AreEqual(0, target.Command.CallCount);
 }
예제 #7
0
        protected override void ExecuteAfterBindings()
        {
            InjectorBinder.Bind <Queries>().To <Queries>().ToSingleton();
            InjectorBinder.Bind <Database>().To <Database>().ToSingleton();

            CommandBinder.Bind <StartApp>()
            .To <StartModules>()
            .InSequence();
        }
예제 #8
0
 public void Target_Command_Is_Executed_When_Source_Event_Is_Raised_And_Command_Is_Enabled()
 {
     var source = new MockEventSource();
     var target = new MockViewModelWithAction();
     var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command);
     binder.Bind();
     source.RaiseMockEvent("foo");
     Assert.AreEqual(1, target.Command.CallCount);
 }
예제 #9
0
        protected override void ExecuteAfterBindings()
        {
            InjectorBinder.Bind <ProjectsHolder>().To <ProjectsHolder>().ToSingleton();
            InjectorBinder.Bind <Queries>().To <Queries>().ToSingleton();

            CommandBinder.Bind <StartApp>()
            .To <SetupCommand>()
            .InSequence();
        }
예제 #10
0
 public void Source_Is_Disabled_When_Target_Command_Becomes_Disabled()
 {
     var source = new MockEventSource();
     var target = new MockViewModelWithAction();
     var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command);
     target.Command.MaxCalls = 1;
     binder.Bind();
     source.RaiseMockEvent("foo");
     Assert.IsFalse(source.IsEnabled);
 }
예제 #11
0
        protected override void Release()
        {
            if (IsResolved)
            {
                throw new CommandException(CommandExceptionType.AttemptToReleaseResolvedCommand);
            }

            IsResolved = true;
            IsRetained = false;
            CommandBinder.OnCommandFinish(this);
        }
        private void CreateAndBindCommands()
        {
            _fillStructurePopupOpenCommand = new Command(miFillFromSchema_Click);

            _subscriptions.Add(CommandBinder.Bind(miFillFromSchema, _fillStructurePopupOpenCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.FillStructure, x => miFillFromSchema.Enabled = x));

            _subscriptions.Add(CommandBinder.Bind(tsmiAddStructureItem, _controller.AddStructureItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddStructureItem, x => tsmiAddStructureItem.Enabled             = x));
            _subscriptions.Add(CommandBinder.Bind(tsbStructureAdd, _controller.AddStructureItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddStructureItem, x => tsbStructureAdd.Enabled                       = x));
            _subscriptions.Add(CommandBinder.Bind(tsbStructureDelete, _controller.DeleteStructureItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.DeleteStructureItem, x => tsbStructureDelete.Enabled           = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiDeleteStructureItem, _controller.DeleteStructureItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.DeleteStructureItem, x => tsmiDeleteStructureItem.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsbMetadataLoadAll, _controller.LoadContainerCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.LoadEntireContainer, x => tsbMetadataLoadAll.Enabled                 = x));
            _subscriptions.Add(CommandBinder.Bind(tsbMetadataDelete, _controller.DeleteMetadataItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.DeleteMetadataItem, x => tsbMetadataDelete.Enabled               = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiDeleteSchema, _controller.DeleteMetadataItemCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.DeleteMetadataItem, x => tsmiDeleteSchema.Enabled                 = x));

            _subscriptions.Add(CommandBinder.Bind(miAddLinkedServer, _controller.AddLinkedServerCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddServer, x => miAddLinkedServer.Enabled     = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddLinkedServer, _controller.AddLinkedServerCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddServer, x => tsmiAddLinkedServer.Visible = x));
            _subscriptions.Add(CommandBinder.Bind(miAddDatabase, _controller.AddDatabaseCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddDatabase, x => miAddDatabase.Enabled     = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddDatabase, _controller.AddDatabaseCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddDatabase, x => tsmiAddDatabase.Visible = x));
            _subscriptions.Add(CommandBinder.Bind(miAddSchema, _controller.AddSchemaCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddSchema, x => miAddSchema.Enabled             = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddSchema, _controller.AddSchemaCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddSchema, x => tsmiAddSchema.Visible         = x));
            _subscriptions.Add(CommandBinder.Bind(miAddPackage, _controller.AddPackageCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddPackage, x => miAddPackage.Enabled         = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddPackage, _controller.AddPackageCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddPackage, x => tsmiAddPackage.Visible     = x));
            _subscriptions.Add(CommandBinder.Bind(miAddTable, _controller.AddTableCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddTable, x => miAddTable.Enabled                         = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddTable, _controller.AddTableCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddTable, x => tsmiAddTable.Visible                     = x));
            _subscriptions.Add(CommandBinder.Bind(miAddView, _controller.AddViewCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddView, x => miAddView.Enabled                             = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddView, _controller.AddViewCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddView, x => tsmiAddView.Visible                         = x));
            _subscriptions.Add(CommandBinder.Bind(miAddProcedure, _controller.AddProcedureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddProcedure, x => miAddProcedure.Enabled         = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddProcedure, _controller.AddProcedureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddProcedure, x => tsmiAddProcedure.Visible     = x));
            _subscriptions.Add(CommandBinder.Bind(miAddSynonym, _controller.AddSynonymCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddSynonym, x => miAddSynonym.Enabled                 = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddSynonym, _controller.AddSynonymCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddSynonym, x => tsmiAddSynonym.Visible             = x));
            _subscriptions.Add(CommandBinder.Bind(miAddField, _controller.AddFieldCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddField, x => miAddField.Enabled                         = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddField, _controller.AddFieldCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddField, x => tsmiAddField.Visible                     = x));
            _subscriptions.Add(CommandBinder.Bind(miAddForeignKey, _controller.AddForeignKeyCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddForeignKey, x => miAddForeignKey.Enabled     = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiAddForeignKey, _controller.AddForeignKeyCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.AddForeignKey, x => tsmiAddForeignKey.Visible = x));

            _subscriptions.Add(CommandBinder.Bind(byNameToolStripMenuItem, _controller.SortSchemaByNameCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.SortByName, x => byNameToolStripMenuItem.Visible    = x));
            _subscriptions.Add(CommandBinder.Bind(byTypeToolStripMenuItem, _controller.SortSchemaByTypeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.SortByType, x => byTypeToolStripMenuItem.Visible    = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiMoveToTopContainer, _controller.MoveUpSchemaCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.MoveToTop, x => tsmiMoveToTopContainer.Visible           = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiMoveToBotContainer, _controller.MoveDownSchemaCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.MoveToBottom, x => tsmiMoveToBotContainer.Visible      = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiSortStructureByName, _controller.SortStructureByNameCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.SortByName, x => tsmiSortStructureByName.Visible = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiSortStructureByType, _controller.SortStructureByTypeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.SortByType, x => tsmiSortStructureByType.Visible = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiMoveStructureToTop, _controller.MoveUpStructureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.MoveToTop, x => tsmiMoveStructureToTop.Visible        = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiMoveStructureToBot, _controller.MoveDownStructureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.MoveToBottom, x => tsmiMoveStructureToBot.Visible   = x));

            _subscriptions.Add(CommandBinder.Bind(miClear, _controller.ClearSchemaCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ClearChildItems, x => miClear.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(miStructureClear, _controller.ClearStructureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ClearChildItems, x => miStructureClear.Enabled = x));

            _subscriptions.Add(CommandBinder.Bind(miStructureLoadAll, _controller.CreateStructureChildsCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.CreateChildStructure, x => miStructureLoadAll.Enabled = x));

            _subscriptions.Add(CommandBinder.Bind(miLoadAll, _controller.LoadSchemaChildsCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.LoadChildItems, x => miLoadAll.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiConnectAndLoad, _controller.ConnectAndLoadCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ConnectAndLoadChilds, x => tsmiConnectAndLoad.Enabled = x));

            _subscriptions.Add(ActiveQueryBuilder.View.WinForms.Images.Common.Add.Subscribe(x => tsddbAdd.Image = x));
        }
예제 #13
0
        public override void Dispose()
        {
            Context.OnStarting -= OnContextStarting;
            Context.OnStarted  -= OnContextStarted;
            Context.OnQuitting -= OnContextQuitting;
            Context.OnStopped  -= OnContextStopped;

            Context.OnModuleConstructing -= OnModuleConstructing;
            Context.OnModuleDisposing    -= OnModuleDisposing;

            CommandBinder.UnbindAll();
            InjectionBinder.UnbindAll();
        }
예제 #14
0
        protected override void ExecuteAfterBindings()
        {
            InjectorBinder.Bind <ProjectsHolder>().To <ProjectsHolder>().ToSingleton();
            InjectorBinder.Bind <Queries>().To <Queries>().ToSingleton();

            InjectorBinder.Bind <XmlDataLoader>().To <XmlDataLoader>().ToSingleton();

            CommandBinder.Bind <StartApp>()
            .To <CleanUpCommand>()
            .To <SetupCommand>()
            .To <ConvertToXElementCommand>()
            .InSequence();
        }
예제 #15
0
    /// <summary>
    /// Initializes an instance of <see cref="CliApplication"/>.
    /// </summary>
    public CliApplication(
        ApplicationMetadata metadata,
        ApplicationConfiguration configuration,
        IConsole console,
        ITypeActivator typeActivator)
    {
        Metadata       = metadata;
        Configuration  = configuration;
        _console       = console;
        _typeActivator = typeActivator;

        _commandBinder = new CommandBinder(typeActivator);
    }
예제 #16
0
        protected override void Fail(Exception exception)
        {
            if (IsResolved)
            {
                throw new CommandException(CommandExceptionType.AttemptToFailResolvedCommand);
            }

            IsResolved = true;
            Exception  = exception;
            IsRetained = false;
            IsFailed   = true;
            CommandBinder.OnCommandFail(this, exception);
        }
예제 #17
0
        public void Awake()
        {
            uManager = BaseGameManager.Instance;
            BaseGameManager.SetInstance(uManager);

            _commandMap  = uManager.commandMap;
            _modelMap    = uManager.modelMap;
            _mediatorMap = uManager.mediatorMap;
            _dispatcher  = uManager.dispatcher;

            Init();
            Bindings();
        }
예제 #18
0
        public void Awake()
        {
            uManager = BaseGameManager.Instance;
            BaseGameManager.SetInstance(uManager);

            _commandMap = uManager.commandMap;
            _modelMap = uManager.modelMap;
            _mediatorMap = uManager.mediatorMap;
            _dispatcher = uManager.dispatcher;

            Init();
            Bindings();
        }
예제 #19
0
        public void SetUp()
        {
            Command01.OnExecute          = null;
            Command01Copy.OnExecute      = null;
            Command01Fail.OnExecute      = null;
            CommandFailHandler.OnExecute = null;

            var binder = new CommandBinder();

            _binder     = binder;
            _dispatcher = new EventDispatcherWithCommandProcessing(binder);

            binder.InjectionBinder = new InjectionBinder();
            binder.Dispatcher      = _dispatcher;
        }
예제 #20
0
        private void BindCommands()
        {
            _addIncludeCommand    = new Command(tsbAdd_Click);
            _addExcludeCommand    = new Command(tsbAddExclude_Click);
            _deleteIncludeCommand = new Command(tsbDelete_Click);
            _deleteExcludeCommand = new Command(tsbDeleteExclude_Click);
            _editIncludeCommand   = new Command(tsbEditInclude_Click);
            _editExcludeCommand   = new Command(tsbEditExclude_Click);

            _subscriptions.Add(CommandBinder.Bind(tsbAddInclude, _addIncludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Add, x => tsbAddInclude.Enabled             = x));
            _subscriptions.Add(CommandBinder.Bind(tsbAddExclude, _addExcludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Add, x => tsbAddExclude.Enabled             = x));
            _subscriptions.Add(CommandBinder.Bind(tsbDeleteInclude, _deleteIncludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Delete, x => tsbDeleteInclude.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsbDeleteExclude, _deleteExcludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Delete, x => tsbDeleteExclude.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsbEditInclude, _editIncludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Edit, x => tsbEditInclude.Enabled         = x));
            _subscriptions.Add(CommandBinder.Bind(tsbEditExclude, _editExcludeCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Edit, x => tsbEditExclude.Enabled         = x));
        }
예제 #21
0
        protected override void ExecuteAfterBindings()
        {
            InjectorBinder.Bind <EntityFactory>().To <EntityFactory>().ToSingleton();
            InjectorBinder.Bind <IEntityManager>().To <EntityManager>().ToSingleton();
            InjectorBinder.Bind <World>().To <World>().ToSingleton();

            InjectorBinder.Bind <EntityMoving>().ToSingleton();
            InjectorBinder.Bind <EntityAttacking>().ToSingleton();
            InjectorBinder.Bind <EntityHealing>().ToSingleton();

            CommandBinder.Bind <StartApp>()
            .To <SetupEntityVariantsCommand>()
            .To <CreateEnvironmentCommand>()
            .To <CreateRandomEntitiesCommand>()
            .InSequence();
        }
예제 #22
0
        private void BindCommands()
        {
            _addIncludeCommand    = new Command(tsbAdd_Click);
            _addExcludeCommand    = new Command(tsbAddExclude_Click);
            _deleteIncludeCommand = new Command(tsbDelete_Click);
            _deleteExcludeCommand = new Command(tsbDeleteExclude_Click);
            _editIncludeCommand   = new Command(tsbEditInclude_Click);
            _editExcludeCommand   = new Command(tsbEditExclude_Click);

            _subscriptions.Add(CommandBinder.Bind(MenuItemIncludeAdd, _addIncludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Add, x => MenuItemIncludeAdd.IsEnabled             = x, false));
            _subscriptions.Add(CommandBinder.Bind(MenuItemExcludeAdd, _addExcludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Add, x => MenuItemExcludeAdd.IsEnabled             = x, false));
            _subscriptions.Add(CommandBinder.Bind(MenuItemIncludeRemove, _deleteIncludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Delete, x => MenuItemIncludeRemove.IsEnabled = x, false));
            _subscriptions.Add(CommandBinder.Bind(MenuItemExcludeRemove, _deleteExcludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Delete, x => MenuItemExcludeRemove.IsEnabled = x, false));
            _subscriptions.Add(CommandBinder.Bind(MenuItemIncludeEdit, _editIncludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Edit, x => MenuItemIncludeEdit.IsEnabled         = x, false));
            _subscriptions.Add(CommandBinder.Bind(MenuItemExcludeEdit, _editExcludeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.Edit, x => MenuItemExcludeEdit.IsEnabled         = x, false));
        }
예제 #23
0
        public ModelingDesigner()
        {
            this._blocks    = new BlockControlCollection();
            this._relations = new BlockRelationCollection();

            this._blocks.CollectionChanged    += OnBlocksChanged;
            this._relations.CollectionChanged += OnRelationsChanged;

            //默认添加几个命令。
            CommandBinder.Bind <DeleteBlockCommand>(this);
            CommandBinder.Bind <SelectAllCommand>(this);
            CommandBinder.Bind <OpenODMLCommand>(this);
            CommandBinder.Bind <SaveODMLCommand>(this);
            CommandBinder.Bind <RestoreODMLCommand>(this);
            CommandBinder.Bind <HideRelationCommand>(this);
            //CommandBinder.Bind<ToggleHiddenRelationsCommand>(this);//不易用。
        }
        private void CreateAndBindCommands()
        {
            _importContainerCommand = new Command(btnImportMetadataFromXml_Click);
            _exportContainerCommand = new Command(btnExportMetadataToXml_Click);
            _importStructureCommand = new Command(btnImportStructureFromXml_Click);
            _exportStructureCommand = new Command(btnExportStructureToXml_Click);

            _previewCommand     = new Command(BtnPreview_Click);
            _stopLoadingCommand = new Command(metadataEditorControl.StopLoading);

            _subscriptions.Add(CommandBinder.Bind(tsmiExportContainer, _exportContainerCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ExportContainer, x => tsmiExportContainer.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiImportContainer, _importContainerCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ImportContainer, x => tsmiImportContainer.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiExportStructure, _exportStructureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ExportStructure, x => tsmiExportStructure.Enabled = x));
            _subscriptions.Add(CommandBinder.Bind(tsmiImportStructure, _importStructureCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.ImportStructure, x => tsmiImportStructure.Enabled = x));

            _subscriptions.Add(CommandBinder.Bind(btnPreview, _previewCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.Preview, x => btnPreview.Enabled   = x));
            _subscriptions.Add(CommandBinder.Bind(btnStop, _stopLoadingCommand, ActiveQueryBuilder.View.WinForms.Commands.MetadataEditor.StopLoading, x => btnStop.Enabled = x));
        }
예제 #25
0
            public static T Bind <T>(IEnumerable <string> args, Action <Configurator> action)
                where T : CommandSettings, new()
            {
                // Configure
                var configurator = new Configurator(null);

                action(configurator);

                // Parse command tree.
                var parser = new CommandTreeParser(CommandModelBuilder.Build(configurator));
                var result = parser.Parse(args);

                // Bind the settings to the tree.
                CommandSettings settings = new T();

                CommandBinder.Bind(result.Tree, ref settings, new TypeResolverAdapter(null));

                // Return the settings.
                return((T)settings);
            }
예제 #26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button   button = FindViewById <Button>(Resource.Id.MyButton);
            TextView label  = FindViewById <TextView>(Resource.Id.TheLabel);

            // Do the bindings.
            TestViewModel vm = new TestViewModel();

            BindingContext.Create(vm)
            .Add(s => s.TotalClicks, label, l => l.Text)
            .Add(s => s.TotalClicks, s => button.Text = "Total Clicks is now " + s.TotalClicks);

            CommandBinder.Create().Add(button, "Click", vm.IncrementCounter);
        }
예제 #27
0
    private static Task <int> Execute(
        CommandTree leaf,
        CommandTree tree,
        CommandContext context,
        ITypeResolver resolver,
        IConfiguration configuration)
    {
        // Bind the command tree against the settings.
        var settings = CommandBinder.Bind(tree, leaf.Command.SettingsType, resolver);

        configuration.Settings.Interceptor?.Intercept(context, settings);

        // Create and validate the command.
        var command          = leaf.CreateCommand(resolver);
        var validationResult = command.Validate(context, settings);

        if (!validationResult.Successful)
        {
            throw CommandRuntimeException.ValidationFailed(validationResult);
        }

        // Execute the command.
        return(command.Execute(context, settings));
    }
예제 #28
0
        public void SetUp()
        {
            Command03.OnExecute                       = null;
            Command03Copy.OnExecute                   = null;
            Command03DoubleDeinit.OnExecute           = null;
            Command03DoubleDeinit.OnPostConstruct     = null;
            Command03DoubleDeinit.OnPreDestroy        = null;
            Command03Exception.OnExecute              = null;
            Command03Fail.OnExecute                   = null;
            Command03Retain.OnExecute                 = null;
            Command03Retain.OnFail                    = null;
            Command03RetainExceptionInstant.OnExecute = null;
            Command03RetainFailInstant.OnExecute      = null;
            Command03RetainReleaseInstant.OnExecute   = null;
            CommandFailHandler.OnExecute              = null;

            var binder = new CommandBinder();

            _binder     = binder;
            _dispatcher = new EventDispatcherWithCommandProcessing(binder);

            binder.InjectionBinder = new InjectionBinder();
            binder.Dispatcher      = _dispatcher;
        }
예제 #29
0
 public void Awake()
 {
     _commandManager = new CommandBinder();
     _dispatcher     = new DispatchManager();
     _contexts       = new Dictionary <Type, IContext>();
 }
예제 #30
0
        private readonly CommandBinder _commandBinder;   // The final type must be specified to escape AOT issues.

        public EventDispatcherWithCommandProcessing(CommandBinder commandBinder)
        {
            _dispatcher    = new EventDispatcher();
            _commandBinder = commandBinder;
        }
예제 #31
0
        private void CreateAndBindCommands()
        {
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.DatabaseSchemaCaption.Subscribe(x => LabelHeaderDatabase.Text = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.MetadataStructureCaption.Subscribe(x =>
                                                                                                       LabelHeaderMeatdaStructure.Text = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.PropertiesBarCaption.Subscribe(x => LabelHeaderProperties.Text = x));

            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByServer.Subscribe(x => CheckBoxByServer.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByDatabase.Subscribe(x => CheckBoxByDatabase.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupBySchema.Subscribe(x => CheckBoxBySchema.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByTypes.Subscribe(x => CheckBoxByTypes.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GenerateObjects.Subscribe(x => CheckBoxGenerateObjects.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.StructureWillBeCleared.Subscribe(x => TextBlockWarning.Text = x));
            _subscriptions.Add(ActiveQueryBuilder.Core.Localization.Common.Proceed.Subscribe(x => ButtonProceed.Content         = x));
            _subscriptions.Add(ActiveQueryBuilder.Core.Localization.Common.Cancel.Subscribe(x => ButtonCancel.Content           = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataLoadAll, _controller.LoadContainerCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.LoadEntireContainer, x => MenuItemMetadataLoadAll.IsEnabled = x,
                                                  false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemDatabaseDelete, _controller.DeleteMetadataItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteMetadataItem, x => MenuItemDatabaseDelete.IsEnabled = x,
                                                  false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureAdd, _controller.AddStructureItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddStructureItem,
                                                  x => MenuItemMetadataStructureAdd.IsEnabled = x, false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureDelete,
                                                  _controller.DeleteStructureItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteMetadataItem,
                                                  x => MenuItemMetadataStructureDelete.IsEnabled = x, false));

            _fillStructurePopupOpenCommand = new Command(MenuItemMetadataStructureFillFromSchema_OnClick);

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddLinkedServer, _controller.AddLinkedServerCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddServer, x => MenuItemAddLinkedServer.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddDatabase, _controller.AddDatabaseCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddDatabase, x => MenuItemAddDatabase.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddSchema, _controller.AddSchemaCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSchema, x => MenuItemAddSchema.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddPackage, _controller.AddPackageCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddPackage, x => MenuItemAddPackage.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddTable, _controller.AddTableCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddTable, x => MenuItemAddTable.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddView, _controller.AddViewCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddView, x => MenuItemAddView.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddProcedure, _controller.AddProcedureCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddProcedure, x => MenuItemAddProcedure.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddSynonym, _controller.AddSynonymCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSynonym, x => MenuItemAddSynonym.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddField, _controller.AddFieldCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddField, x => MenuItemAddField.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddForeignKey, _controller.AddForeignKeyCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddForeignKey, x => MenuItemAddForeignKey.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureFillFromSchema,
                                                  _fillStructurePopupOpenCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.FillStructure,
                                                  x => MenuItemMetadataStructureFillFromSchema.IsEnabled = x));

            Loaded += (sender, args) =>
            {
                _controller.UpdateStructureCommands();
                _controller.UpdateContainerCommands();
            };
        }
예제 #32
0
        private void DatabaseSchemaTree_OnValidateItemContextMenu(object sender, MetadataStructureItemMenuEventArgs e)
        {
            _contextMenuSubscriptions = new CompositeDisposable();

            var menu = e.Menu;

            menu.ClearItems();

            if (OpenContainerLoadFormIfNotConnected &&
                (_sqlContext.MetadataProvider == null || !_sqlContext.MetadataProvider.Connected))
            {
                var contextMenuItemSchemaConnectAndLoad = (MenuItem)menu.AddItem("", null, false, false, null, null);

                _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaConnectAndLoad,
                                                      _controller.ConnectAndLoadCommand,
                                                      ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.ConnectAndLoadChilds,
                                                      x => contextMenuItemSchemaConnectAndLoad.IsEnabled = x));
            }

            if (!(OpenContainerLoadFormIfNotConnected &&
                  (_sqlContext.MetadataProvider == null || !_sqlContext.MetadataProvider.Connected)))
            {
                var contextMenuItemSchemaLoadChildDatabase =
                    (MenuItem)menu.AddItem("", null, false, false, null, null);

                _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaLoadChildDatabase,
                                                      _controller.LoadSchemaChildsCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.LoadChildItems,
                                                      x => contextMenuItemSchemaLoadChildDatabase.IsEnabled = x));
            }

            var contextMenuItemSchemaDelete = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaDelete, _controller.DeleteMetadataItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteMetadataItem,
                                                  x => contextMenuItemSchemaDelete.IsEnabled = x));

            var contextMenuItemSchemaClearChild = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaClearChild, _controller.ClearSchemaCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.ClearChildItems,
                                                  x => contextMenuItemSchemaClearChild.IsEnabled = x));

            menu.AddSeparator();

            var contextMenuItemSchemaAddLinkedServer = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddLinkedServer,
                                                  _controller.AddLinkedServerCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddServer,
                                                  x => contextMenuItemSchemaAddLinkedServer.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddDatabase = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddDatabase, _controller.AddDatabaseCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddDatabase,
                                                  x => contextMenuItemSchemaAddDatabase.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddSchema = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddSchema, _controller.AddSchemaCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSchema,
                                                  x => contextMenuItemSchemaAddSchema.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddPackage = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddPackage, _controller.AddPackageCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddPackage,
                                                  x => contextMenuItemSchemaAddPackage.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddTable = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddTable, _controller.AddTableCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddTable,
                                                  x => contextMenuItemSchemaAddTable.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddView = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddView, _controller.AddViewCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddView,
                                                  x => contextMenuItemSchemaAddView.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddProcedure = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddProcedure, _controller.AddProcedureCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddProcedure,
                                                  x => contextMenuItemSchemaAddProcedure.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddSynonym = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddSynonym, _controller.AddSynonymCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSynonym,
                                                  x => contextMenuItemSchemaAddSynonym.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddField = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddField, _controller.AddFieldCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddField,
                                                  x => contextMenuItemSchemaAddField.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaAddForeignKey = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaAddForeignKey, _controller.AddForeignKeyCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddForeignKey,
                                                  x => contextMenuItemSchemaAddForeignKey.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextSubMenuItemSchemaSort = (MenuItem)menu.AddSubMenu("");

            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.Sort.Subscribe(x => contextSubMenuItemSchemaSort.Header = x));

            var contextSubMenuItemSchemaSortByName =
                (MenuItem)((ICustomSubMenu)contextSubMenuItemSchemaSort).AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextSubMenuItemSchemaSortByName,
                                                  _controller.SortSchemaByNameCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.SortByName,
                                                  x => contextSubMenuItemSchemaSortByName.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextSubMenuItemSchemaSortByTypeAndName =
                (MenuItem)((ICustomSubMenu)contextSubMenuItemSchemaSort).AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextSubMenuItemSchemaSortByTypeAndName,
                                                  _controller.SortSchemaByTypeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.SortByType,
                                                  x => contextSubMenuItemSchemaSortByTypeAndName.Visibility =
                                                      x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaMoveToTop = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaMoveToTop, _controller.MoveUpSchemaCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.MoveToTop,
                                                  x => contextMenuItemSchemaMoveToTop.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemSchemaMoveToBottom = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemSchemaMoveToBottom,
                                                  _controller.MoveDownSchemaCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.MoveToBottom,
                                                  x => contextMenuItemSchemaMoveToBottom.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            _controller.UpdateContainerCommands();
            menu.Closing += Menu_Closing;
        }
예제 #33
0
        private void MetadataStructureTree_OnValidateItemContextMenu(object sender, MetadataStructureItemMenuEventArgs e)
        {
            _contextMenuSubscriptions = new CompositeDisposable();

            var menu = e.Menu;

            menu.ClearItems();

            var contextMenuItemStructureAddItem = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureAddItem, _controller.AddStructureItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddStructureItem,
                                                  x => contextMenuItemStructureAddItem.IsEnabled = x));

            var contextMenuItemStructureDelete = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureDelete,
                                                  _controller.DeleteStructureItemCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteStructureItem,
                                                  x => contextMenuItemStructureDelete.IsEnabled = x));

            var contextMenuItemStructureCreateChild = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureCreateChild,
                                                  _controller.CreateStructureChildsCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.CreateChildStructure,
                                                  x => contextMenuItemStructureCreateChild.IsEnabled = x));

            var contextMenuItemStructureClearChild = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureClearChild, _controller.ClearStructureCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.ClearChildItems,
                                                  x => contextMenuItemStructureClearChild.IsEnabled = x));

            var contextSubMenuItemStructureSort = (MenuItem)menu.AddSubMenu("");

            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.Sort.Subscribe(x => contextSubMenuItemStructureSort.Header = x));

            var contextSubMenuItemStructureSortByName =
                (MenuItem)((ICustomSubMenu)contextSubMenuItemStructureSort).AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextSubMenuItemStructureSortByName,
                                                  _controller.SortStructureByNameCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.SortByName,
                                                  x => contextSubMenuItemStructureSortByName.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextSubMenuItemStructureSortByTypeAndName =
                (MenuItem)((ICustomSubMenu)contextSubMenuItemStructureSort).AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextSubMenuItemStructureSortByTypeAndName,
                                                  _controller.SortStructureByTypeCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.SortByType,
                                                  x => contextSubMenuItemStructureSortByTypeAndName.Visibility =
                                                      x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemStructureMoveToTop = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureMoveToTop, _controller.MoveUpStructureCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.MoveToTop,
                                                  x => contextMenuItemStructureMoveToTop.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            var contextMenuItemStructureMoveToBottom = (MenuItem)menu.AddItem("", null, false, false, null, null);

            _subscriptions.Add(CommandBinder.Bind(contextMenuItemStructureMoveToBottom,
                                                  _controller.MoveDownStructureCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.MoveToBottom,
                                                  x => contextMenuItemStructureMoveToBottom.Visibility = x ? Visibility.Visible : Visibility.Collapsed));

            menu.Closing += Menu_Closing;
        }
예제 #34
0
    public void init(object gm)
    {
        if (File.Exists("log.txt"))
        {
            logOut = File.AppendText("log.txt");
        }
        else
        {
            logOut = File.CreateText("log.txt");
        }
#if DEBUG
        this.debugOut = File.CreateText("debug.log");
#endif

        this.log("====init() was called====");
        try {
            this.fGameManager = (FengGameManagerMKII)gm;
            GameObject go = new GameObject();
            go.name = "ModUI";
            GameObject.DontDestroyOnLoad(go);
            this.modUI = go.AddComponent <ModUI>();

            this.log("----Initializing mod.");
            this.log("Loading the configuration.");
            this.config = ConfigManager.load("config.cfg");
            this.log("Loading settings file.");
            if (File.Exists("settings.json"))
            {
                try {
                    this.settingsObject = JsonObject.fromFile("settings.json");
                    File.Move("settings.json", "settings.json.corrupted" + UnityEngine.Random.Range(0, 10000));
                }catch (JsonException e) {
                    this.log(e);
                    this.settingsObject = new JsonObject();
                }
            }
            else
            {
                this.settingsObject = new JsonObject();
            }

            this.taskManager = new TaskManager();
            gameModInterface = new GameModEventInterface(this);

            this.spawnController = new SpawnController(this.fGameManager, config.get("TitanWaveAmountFunction"), config.get("WaveEndMessage"));

            this.commandBinder = new CommandBinder(this.taskManager);

            this.cManager = new CManager();

            this.nameManager = new NameManager(this.config);
            commandManager   = new CommandManager();

            PhotonNetwork.OnEventCall = this.eventCallback;

            this.averageDamage = float.Parse(config.get("averageDamage"));

            this.log("Initializing extras.");

            this.log("Creating the greeter.");
            greeter = new PlayerGreeter(this);
            this.log("Creating the mod thread.");
            bct  = new MainModThread(this);
            opcm = new OtherPlayerCommandsManager(this.fGameManager);

            thController = new TitanHealthController();

            this.nameChanger = new NameChanger(this);

            this.lagController = new LagController();

            KillCmd.titanName = this.config.get("killTitanName");
            this.setChatLogEnabled(this.getConfig().getBool("chatLogEnabled"));

            this.setUseGas(true);
            this.setUseBlades(true);

            this.log("Registering mod API");
            AoTModAPI.AoTModAPI.setModAPI(this.gameModInterface);

            this.log("Updating values from the settings file.");
            this.log("Starting mod thread.");
            bct.start();
        } catch (System.Exception e) {
            this.log("Error while initializing mod, who knows what will happen.");
            this.log(e);
        }

        this.messagePrefix = this.getConfig().get("messagePrefix");
        this.messageSuffix = this.getConfig().get("messageSuffix");

        this.log("Mod initialized.");

        ModMain.instance = this;
        this.log("Instance: " + ModMain.instance);
        this.commandManager.buildHelpList();
    }
 public DefaultCommandDispatcher(Type commandType)
 {
     _commandBinder = new CommandBinder(commandType);
 }