예제 #1
0
        public DraftPostItemsGalleryCommand(IBlogPostEditingSite postEditingSite, CommandManager commandManager, bool isPost)
            : base((isPost ? CommandId.OpenPostSplit : CommandId.OpenDraftSplit))
        {
            this.postEditingSite = postEditingSite;
            _isPost = isPost;
            if (isPost)
            {
                draftCmdStart = (int)CommandId.OpenPostMRU0;
            }
            lock (_commandsLock)
            {
                // initialize commands
                for (int i = 0; i < _commands.Length; i++)
                {
                    _commands[i]          = new Command((CommandId)(i + draftCmdStart));
                    _commands[i].Execute += new EventHandler(DraftPostItemsGalleryCommand_Execute);
                    _commands[i].CommandBarButtonStyle = CommandBarButtonStyle.Provider;
                    _commands[i].On = false;
                }

                // add them to the command manager
                commandManager.Add(new CommandCollection(_commands));
                commandManager.Add(this);
            }
        }
        public BlogProviderButtonManager(CommandManager commandManager) : base(CommandId.BlogProviderButtonsGallery, false)
        {
            AllowSelection = false;

            lock (_commandsLock)
            {
                // initialize commands
                for (int i = 0; i < _commands.Length; i++)
                {
                    _commands[i]                       = new Command();
                    _commands[i].Identifier            = String.Format(CultureInfo.InvariantCulture, BlogProviderButtonCommandBarInfo.ProviderCommandFormat, i);
                    _commands[i].Execute              += new EventHandler(BlogProviderButton_Execute);
                    _commands[i].CommandBarButtonStyle = CommandBarButtonStyle.Provider;
                    _commands[i].On                    = false;
                }

                ExecuteWithArgs += new ExecuteEventHandler(BlogProviderButtonManager_ExecuteWithArgs);

                // add them to the command manager
                commandManager.Add(new CommandCollection(_commands));

                commandManager.Add(this);
            }

            commandViewWeblog      = commandManager.Add(CommandId.ViewWeblog, commandViewWeblog_Execute);
            commandViewWeblogAdmin = commandManager.Add(CommandId.ViewWeblogAdmin, commandViewWeblogAdmin_Execute);
        }
예제 #3
0
        public void AddAlias(String alias, ICommand command)
        {
            Alias a = new Alias(alias, command);

            cm.Add(a);
            Console.WriteLine("Succesfully created alias: '" + alias + "' of command: '" + command.Name + "'.");
        }
예제 #4
0
        public MarginCommand(CommandManager commandManager)
            : base(CommandId.MarginsGroup)
        {
            RepresentativeString = Res.Get(StringId.SpinnerPixelRepresentativeString);
            FormatString         = Res.Get(StringId.SpinnerPixelFormatString);

            // @RIBBON TODO: Have a way to initialize this.
            marginValue = new Padding(Convert.ToInt32(MinMargin));

            commandManager.BeginUpdate();

            commandLeftMargin = new SpinnerCommand(CommandId.AdjustLeftMargin, MinMargin, MaxMargin, MinMargin, Increment, DecimalPlaces, RepresentativeString, FormatString);
            commandManager.Add(commandLeftMargin, commandMargin_ExecuteWithArgs);

            commandTopMargin = new SpinnerCommand(CommandId.AdjustTopMargin, MinMargin, MaxMargin, MinMargin, Increment, DecimalPlaces, RepresentativeString, FormatString);
            commandManager.Add(commandTopMargin, commandMargin_ExecuteWithArgs);

            commandRightMargin = new SpinnerCommand(CommandId.AdjustRightMargin, MinMargin, MaxMargin, MinMargin, Increment, DecimalPlaces, RepresentativeString, FormatString);
            commandManager.Add(commandRightMargin, commandMargin_ExecuteWithArgs);

            commandBottomMargin = new SpinnerCommand(CommandId.AdjustBottomMargin, MinMargin, MaxMargin, MinMargin, Increment, DecimalPlaces, RepresentativeString, FormatString);
            commandManager.Add(commandBottomMargin, commandMargin_ExecuteWithArgs);

            commandManager.EndUpdate();
        }
예제 #5
0
        private MenuDefinitionEntryCollection GetSpellingSuggestions()
        {
            CommandManager commandManager = _spellingManager.CommandManager;
            MenuDefinitionEntryCollection listOfSuggestions = new MenuDefinitionEntryCollection();

            commandManager.SuppressEvents = true;
            commandManager.BeginUpdate();
            try
            {
                // provide suggestions
                SpellingSuggestion[] suggestions = _spellingManager.SpellingChecker.Suggest(_currentWord, DEFAULT_MAX_SUGGESTIONS, SUGGESTION_DEPTH);
                bool foundSuggestion             = false;
                if (suggestions.Length > 0)
                {
                    // add suggestions to list (stop adding when the quality of scores
                    // declines precipitously)
                    short lastScore = suggestions[0].Score;
                    for (int i = 0; i < suggestions.Length; i++)
                    {
                        SpellingSuggestion suggestion = suggestions[i];

                        //note: in some weird cases, like 's, a suggestion is returned but lacks a suggested replacement, so need to check that case
                        if ((lastScore - suggestion.Score) < SCORE_GAP_FILTER && (suggestion.Suggestion != null))
                        {
                            Command FixSpellingCommand = new Command(CommandId.FixWordSpelling);
                            FixSpellingCommand.Identifier += suggestion.Suggestion;
                            FixSpellingCommand.Text        = suggestion.Suggestion;
                            FixSpellingCommand.MenuText    = suggestion.Suggestion;
                            FixSpellingCommand.Execute    += new EventHandler(_spellingManager.fixSpellingApplyCommand_Execute);
                            FixSpellingCommand.Tag         = suggestion.Suggestion;
                            commandManager.Add(FixSpellingCommand);

                            listOfSuggestions.Add(FixSpellingCommand.Identifier, false, i == suggestions.Length - 1);
                            foundSuggestion = true;
                        }
                        else
                        {
                            break;
                        }

                        // update last score
                        lastScore = suggestion.Score;
                    }
                }
                if (!foundSuggestion)
                {
                    Command FixSpellingCommand = new Command(CommandId.FixWordSpelling);
                    FixSpellingCommand.Enabled = false;

                    commandManager.Add(FixSpellingCommand);
                    listOfSuggestions.Add(CommandId.FixWordSpelling, false, true);
                }
            }
            finally
            {
                commandManager.EndUpdate();
                commandManager.SuppressEvents = false;
            }
            return(listOfSuggestions);
        }
예제 #6
0
        public PostPropertiesBandControl(CommandManager commandManager)
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);

            InitializeComponent();

            categoryContext = new CategoryContext();

            controller = new SharedPropertiesController(this, null, categoryDropDown,
                                                        null, textTags, labelPageOrder, textPageOrder, labelPageParent, comboPageParent, null,
                                                        datePublishDate, fields, categoryContext);

            SimpleTextEditorCommandHelper.UseNativeBehaviors(commandManager,
                                                             textTags, textPageOrder);

            postPropertiesForm = new PostPropertiesForm(commandManager, categoryContext);
            if (components == null)
            {
                components = new Container();
            }
            components.Add(postPropertiesForm);

            postPropertiesForm.Synchronize(controller);

            commandManager.Add(CommandId.PostProperties, PostProperties_Execute);
            commandManager.Add(CommandId.ShowCategoryPopup, ShowCategoryPopup_Execute);


            linkViewAll.KeyDown += (sender, args) =>
            {
                if (args.KeyValue == ' ')
                {
                    linkViewAll_LinkClicked(sender, new LinkLabelLinkClickedEventArgs(null));
                }
            };

            // WinLive 180287: We don't want to show or use mnemonics on labels in the post properties band because
            // they can steal focus from the canvas.
            linkViewAll.Text            = TextHelper.StripAmpersands(Res.Get(StringId.ViewAll));
            linkViewAll.UseMnemonic     = false;
            labelPageParent.Text        = TextHelper.StripAmpersands(Res.Get(StringId.PropertiesPageParent));
            labelPageParent.UseMnemonic = false;
            labelPageOrder.Text         = TextHelper.StripAmpersands(Res.Get(StringId.PropertiesPageOrder));
            labelPageOrder.UseMnemonic  = false;
        }
예제 #7
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();

            //Logger.Information("To get sure that u know how to work with this server, i've added this");
            //Logger.Information("Remove the lines located in the given file named by this log's prefix");
            //
            ////
            //Environment.Exit(-1);
            ////

            //ServerTime = TimeSpan.Zero;

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _serverlistManager = new ServerlistManager();
        }
예제 #8
0
        public HyperlinkForm(CommandManager commandManager, bool showAllOptions)
        {
            _slimOptions = !showAllOptions;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            CommandManager            = commandManager;
            buttonInsert.Text         = Res.Get(StringId.InsertButtonText);
            buttonCancel.Text         = Res.Get(StringId.CancelButton);
            label1.Text               = Res.Get(StringId.UrlLabel);
            labelLinkText.Text        = Res.Get(StringId.LinkTextLabel);
            labelTitle.Text           = Res.Get(StringId.LinkTitleLabel);
            labelRel.Text             = Res.Get(StringId.LinkRelLabel);
            ckboxNewWindow.Text       = Res.Get(StringId.LinkNewWindowLabel);
            btnOptions.Text           = " " + Res.Get(StringId.LinkLinkTo);
            btnOptions.AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.LinkLinkTo));
            btnOptionsToolTip.SetToolTip(this.btnOptions, Res.Get(StringId.LinkOptionsTooltip));
            btnRemove.Text     = Res.Get(StringId.LinkRemoveLink);
            ckBoxGlossary.Text = Res.Get(StringId.LinkAddToGlossary);
            this.Text          = Res.Get(StringId.LinkFormTitle);

            CommandManager.BeginUpdate();

            CommandManager.Add(new CommandGlossary());

            CommandManager.EndUpdate();

            textBoxAddress.GotFocus   += new EventHandler(textBoxAddress_GotFocus);
            textBoxAddress.RightToLeft = System.Windows.Forms.RightToLeft.No;
            if (BidiHelper.IsRightToLeft)
            {
                textBoxAddress.TextAlign = HorizontalAlignment.Right;
            }
        }
        public SemanticHtmlGalleryCommand(CommandId commandId, IBlogPostEditingSite editingSite, TemplateHtmlDelegate templateHtmlDelegate, CommandManager commandManager, IHtmlEditorComponentContext componentContext)
            : base(commandId)
        {
            _editingSite      = editingSite;
            _componentContext = componentContext;

            _elements = new List <SemanticHtmlElementInfo>(7);
            _elements.Add(new SemanticHtmlElementInfo("p", _ELEMENT_TAG_ID.TAGID_P, Res.Get(StringId.Paragraph), SemanticHtmlPreviewManager.PreviewId_P, CommandId.ApplySemanticParagraph));
            _elements.Add(new SemanticHtmlElementInfo("h1", _ELEMENT_TAG_ID.TAGID_H1, Res.Get(StringId.Heading1), SemanticHtmlPreviewManager.PreviewId_H1, CommandId.ApplySemanticHeader1));
            _elements.Add(new SemanticHtmlElementInfo("h2", _ELEMENT_TAG_ID.TAGID_H2, Res.Get(StringId.Heading2), SemanticHtmlPreviewManager.PreviewId_H2, CommandId.ApplySemanticHeader2));
            _elements.Add(new SemanticHtmlElementInfo("h3", _ELEMENT_TAG_ID.TAGID_H3, Res.Get(StringId.Heading3), SemanticHtmlPreviewManager.PreviewId_H3, CommandId.ApplySemanticHeader3));
            _elements.Add(new SemanticHtmlElementInfo("h4", _ELEMENT_TAG_ID.TAGID_H4, Res.Get(StringId.Heading4), SemanticHtmlPreviewManager.PreviewId_H4, CommandId.ApplySemanticHeader4));
            _elements.Add(new SemanticHtmlElementInfo("h5", _ELEMENT_TAG_ID.TAGID_H5, Res.Get(StringId.Heading5), SemanticHtmlPreviewManager.PreviewId_H5, CommandId.ApplySemanticHeader5));
            _elements.Add(new SemanticHtmlElementInfo("h6", _ELEMENT_TAG_ID.TAGID_H6, Res.Get(StringId.Heading6), SemanticHtmlPreviewManager.PreviewId_H6, CommandId.ApplySemanticHeader6));

            _previewManager = new SemanticHtmlPreviewManager(_editingSite, templateHtmlDelegate, RibbonHelper.InGalleryImageWidth, RibbonHelper.InGalleryImageHeightWithoutLabel);

            _ids = new string[_elements.Count];
            for (int i = 0; i < _ids.Length; i++)
            {
                _ids[i] = _elements[i].HtmlId;

                int index = i;
                OverridableCommand command = new OverridableCommand(_elements[i].CommandId);
                command.Execute += (sender, e) => SelectedIndex = index;
                commandManager.Add(command);
            }
        }
예제 #10
0
 void IBusManager.AddCommandUi(ICommand command)
 {
     if (CommandManager != null)
     {
         CommandManager.Add(command);
     }
 }
예제 #11
0
        /// <summary>
        /// Deletes the currently selected layer.
        /// </summary>
        private void DeleteLayerButton_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null || TryGetLayerIndex(map, out int layerIndex) == false)
            {
                return;
            }

            if (map.layers.Count == 1)
            {
                MessageBox.Show(this, "Tile must always have one layer.\nPlease add another before deleting this one!", "Info", MessageBoxButtons.OK);
                return;
            }

            // if the layer has tiles on it, display a warning that they are going to be also deleted.
            if (map.layers[layerIndex].tiles.Any(x => x.referencedTile != null) == true)
            {
                if (MessageBox.Show(this, "This layer has tiles on it. These would also be deleted!\nContinue?", "Warning", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }

            CommandManager.Add(new LayerRemoveCommand(map, layerIndex), true);
        }
예제 #12
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();
            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new UnbanCommands())
            .Add(new UserkickCommand())
            //.Add(new UserkickCommand())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new ClanCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _serverlistManager = new ServerlistManager();
        }
예제 #13
0
        private void InitializeCommands()
        {
            CommandManager.BeginUpdate();

            commandWeblogPicker = new CommandWeblogPicker();
            _editingSite.CommandManager.Add(commandWeblogPicker);
            _editingSite.WeblogListChanged -= EditingSiteOnWeblogListChanged;
            _editingSite.WeblogListChanged += EditingSiteOnWeblogListChanged;

            commandAddWeblog          = new Command(CommandId.AddWeblog);
            commandAddWeblog.Execute += new EventHandler(commandAddWeblog_Execute);
            CommandManager.Add(commandAddWeblog);

            commandConfigureWeblog          = new Command(CommandId.ConfigureWeblog);
            commandConfigureWeblog.Execute += new EventHandler(commandConfigureWeblog_Execute);
            CommandManager.Add(commandConfigureWeblog);

            commandSelectBlog = new SelectBlogGalleryCommand(_editingManager);
            commandSelectBlog.ExecuteWithArgs += new ExecuteEventHandler(commandSelectBlog_ExecuteWithArgs);
            commandSelectBlog.Invalidate();
            CommandManager.Add(commandSelectBlog);

            CommandManager.EndUpdate();

            // create the dynamic menu items that correspond to the available weblogs
            _switchWeblogCommandMenu = new DynamicCommandMenu(this);
        }
예제 #14
0
        private static void ProcessCommands([NotNull] WebDataService dataService, [NotNull] XElement commandsElement)
        {
            Debug.ArgumentNotNull(dataService, nameof(dataService));
            Debug.ArgumentNotNull(commandsElement, nameof(commandsElement));

            foreach (var submenuElement in commandsElement.Elements("submenu"))
            {
                var webCommandSubmenu = new WebCommandSubmenu(dataService, submenuElement);

                var submenu = submenuElement.GetElementValue("submenu");

                var commandDescriptor = new CommandManager.CommandDescriptor(webCommandSubmenu, submenu, typeof(WebCommand));

                CommandManager.Add(commandDescriptor);
            }

            foreach (var commandElement in commandsElement.Elements("command"))
            {
                var webCommand = new WebCommand(dataService, commandElement);

                var submenu = commandElement.GetElementValue("submenu");

                var commandDescriptor = new CommandManager.CommandDescriptor(webCommand, submenu, typeof(WebCommand));

                CommandManager.Add(commandDescriptor);
            }
        }
예제 #15
0
        public void RunConsoleInputLoop(CommandManager commandManager, Action reloadTranslations, Action <string> handleInput, Func <bool> continueWhile)
        {
            // prepare console
            this.Monitor.Log("Type 'help' for help, or 'help <cmd>' for a command's usage", LogLevel.Info);
            commandManager
            .Add(new HelpCommand(commandManager), this.Monitor)
            .Add(new HarmonySummaryCommand(), this.Monitor)
            .Add(new ReloadI18nCommand(reloadTranslations), this.Monitor);

            // start handling command line input
            Thread inputThread = new Thread(() =>
            {
                while (true)
                {
                    // get input
                    string input = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        continue;
                    }

                    // handle command
                    this.Monitor.LogUserInput(input);
                    handleInput(input);
                }
            });

            inputThread.Start();

            // keep console thread alive while the game is running
            while (continueWhile())
            {
                Thread.Sleep(1000 / 10);
            }
        }
        protected override void InitializeCommands()
        {
            CommandManager.BeginUpdate();
            base.InitializeCommands();

            CommandManager.Add(CommandId.UpdateWeblogStyle, commandUpdateWeblogStyle_Execute);

            commandViewUseStyles = CommandManager.Add(CommandId.ViewUseStyles, commandViewUseStyles_Execute);

            commandSemanticHtml = new SemanticHtmlGalleryCommand(CommandId.SemanticHtmlGallery, _postEditingSite, GetPreviewHtml, CommandManager, _currentEditor as IHtmlEditorComponentContext);
            commandSemanticHtml.ExecuteWithArgs += new ExecuteEventHandler(commandSemanticHtml_ExecuteWithArgs);
            commandSemanticHtml.ComponentContext = () => _currentEditor as IHtmlEditorComponentContext;
            CommandManager.Add(commandSemanticHtml);

            commandInsertablePlugins = new InsertablePluginsGalleryCommand();
            commandInsertablePlugins.ExecuteWithArgs += new ExecuteEventHandler(commandInsertablePlugins_ExecuteWithArgs);
            commandInsertablePlugins.LoadItems();
            CommandManager.Add(commandInsertablePlugins);

            commandInsertWebImage          = new Command(CommandId.WebImage);
            commandInsertWebImage.Execute += new EventHandler(commandInsertWebImage_Execute);
            CommandManager.Add(commandInsertWebImage);

            commandInsertExtendedEntry = CommandManager.Add(CommandId.InsertExtendedEntry, commandInsertExtendedEntry_Execute);

            EditorLoaded += new EventHandler(ContentEditor_EditorHtmlReloaded);

            // QAT
            CommandManager.Add(new GalleryCommand <CommandId>(CommandId.QAT));

            // Outspace
            CommandManager.Add(new RecentItemsCommand(_postEditingSite));

            CommandManager.Add(new GroupCommand(CommandId.InsertImageSplit, CommandManager.Get(CommandId.InsertPictureFromFile)));

            // WinLive 181138 - A targetted fix to ensure the InsertVideoSplit command is disabled if we don't support InsertVideo (e.g zh-CN doesn't support video)
            // The problem is related to Windows 7 #712524 & #758433 and this is a work around for this particular case.
            // The dropdown commands for this (InsertVideoFromFile etc) are already disabled based on the feature support. We explicitly set the state of
            // group command here so that it has the right state to begin with (otherwise a switch tab/app is required to refresh).
            GroupCommand commandInsertVideoSplit = new GroupCommand(CommandId.InsertVideoSplit, CommandManager.Get(CommandId.InsertVideoFromFile));

            commandInsertVideoSplit.Enabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.VideoProviders);
            CommandManager.Add(commandInsertVideoSplit);

            foreach (CommandId commandId in new CommandId[] {
                CommandId.SplitNew,
                CommandId.SplitSave,
                CommandId.SplitPrint,
                CommandId.PasteSplit,
                CommandId.FormatTablePropertiesSplit
            })
            {
                CommandManager.Add(new Command(commandId));
            }

            _commandClosePreview = CommandManager.Add(CommandId.ClosePreview, commandClosePreview_Execute, false);

            CommandManager.EndUpdate();
        }
            public SizeCommand(CommandManager commandManager, CommandId widthId, CommandId heightId, int width, int height)
            {
                _widthId  = widthId;
                _heightId = heightId;

                sizeValue = new Size(width, height);

                commandManager.BeginUpdate();

                commandManager.Add(
                    new SpinnerCommand(_widthId, MinSize.Width, MaxSize.Width, width, Increment, DecimalPlaces, RepresentativeString, FormatString),
                    command_ExecuteWithArgs);

                commandManager.Add(
                    new SpinnerCommand(_heightId, MinSize.Height, MaxSize.Height, height, Increment, DecimalPlaces, RepresentativeString, FormatString),
                    command_ExecuteWithArgs);

                commandManager.EndUpdate();
            }
예제 #18
0
        /// <summary>
        /// Toggles visibility on the currently selected layer.
        /// </summary>
        private void LayerSetVisibleButton_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null || TryGetLayerIndex(map, out int layerIndex) == false)
            {
                return;
            }

            CommandManager.Add(new LayerSetVisible(map, map.layers[layerIndex]), true);
        }
        protected void InitializeCommands()
        {
            CommandManager cm = ((ICommandManagerHost)_contentEditorSite).CommandManager;

            commandVideoWebPreview          = new VideoWebPreviewCommand();
            commandVideoWebPreview.Execute += VideoWebPreview_Execute;
            cm.Add(commandVideoWebPreview);

            commandVideoWidescreenAspectRatio          = new Command(CommandId.VideoWidescreenAspectRatio);
            commandVideoWidescreenAspectRatio.Execute += VideoAspectRatio_Execute;
            commandVideoWidescreenAspectRatio.Tag      = VideoAspectRatioType.Widescreen;
            cm.Add(commandVideoWidescreenAspectRatio);

            commandVideoStandardAspectRatio          = new Command(CommandId.VideoStandardAspectRatio);
            commandVideoStandardAspectRatio.Execute += VideoAspectRatio_Execute;
            commandVideoStandardAspectRatio.Tag      = VideoAspectRatioType.Standard;
            cm.Add(commandVideoStandardAspectRatio);

            InitializeAlignmentMarginCommands(((ICommandManagerHost)_contentEditorSite).CommandManager);
            cm.Add(new GroupCommand(CommandId.FormatVideoGroup, commandVideoWebPreview));
        }
예제 #20
0
        /// <summary>
        /// Creates a new layer.
        /// </summary>
        private void CreateLayerButton_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null)
            {
                return;
            }

            CommandManager.Add(new LayerAddCommand(map, "New Layer"), true);
            layerListBox.SelectedIndex = map.layers.Count - 1;
        }
예제 #21
0
        public AlignmentCommand(CommandManager commandManager)
            : base(CommandId.AlignmentGallery, Alignment.None)
        {
            _commandAlignmentGroup = new GroupCommand(CommandId.AlignmentGroup, this);
            commandManager.Add(_commandAlignmentGroup);

            ExecuteWithArgs += new ExecuteEventHandler(AlignmentCommand_ExecuteWithArgs);

            // By default, we are disabled
            _commandAlignmentGroup.Enabled = false;
            base.Enabled = false;
        }
예제 #22
0
        private void InitializeCommands()
        {
            CommandManager.BeginUpdate();

            Command commandAddToDictionary = new Command(CommandId.AddToDictionary);

            commandAddToDictionary.Execute += new EventHandler(addToDictionary_Execute);
            CommandManager.Add(commandAddToDictionary);

            Command commandIgnoreAll = new Command(CommandId.IgnoreAll);

            commandIgnoreAll.Execute += new EventHandler(ignoreAllCommand_Execute);

            CommandManager.Add(commandIgnoreAll);
            CommandManager.Add(CommandId.IgnoreOnce, ignoreOnceCommand_Execute);

            Command commandOpenSpellingForm = new Command(CommandId.OpenSpellingForm);

            commandOpenSpellingForm.Execute += new EventHandler(openSpellingForm_Execute);
            CommandManager.Add(commandOpenSpellingForm);

            CommandManager.EndUpdate();
        }
예제 #23
0
        public void RunConsoleInputLoop(CommandManager commandManager, Action reloadTranslations, Action <string> handleInput, Func <bool> continueWhile)
        {
            // prepare console
            this.Monitor.Log("Type 'help' for help, or 'help <cmd>' for a command's usage", LogLevel.Info);
            commandManager
            .Add(new HelpCommand(commandManager), this.Monitor)
            .Add(new HarmonySummaryCommand(), this.Monitor)
            .Add(new ReloadI18nCommand(reloadTranslations), this.Monitor);

            // start handling command line input
            Thread inputThread = new Thread(() =>
            {
                while (true)
                {
                    // get input
                    string input = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        continue;
                    }

                    // handle command
                    this.Monitor.LogUserInput(input);
                    handleInput(input);
                }
            });

            inputThread.Start();

            // keep console thread alive while the game is running
            while (continueWhile())
            {
                Thread.Sleep(1000 / 10);
            }
            if (inputThread.ThreadState == ThreadState.Running)
#if NETFRAMEWORK
            { inputThread.Abort(); }
#else
            {                   // Thread.Abort is unsupported in .NET Core/Standard, and doesn't work. Throw the exception explicitly.
                throw (ThreadAbortException)typeof(ThreadAbortException)
                      .GetConstructor(
                          System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic,
                          null,
                          Type.EmptyTypes,
                          null
                          ).Invoke(null);
            }
#endif
        }
예제 #24
0
        /// <summary>
        /// Moves the currently selected layer up by one.
        /// </summary>
        private void MoveLayerUp_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null || TryGetLayerIndex(map, out int layerIndex) == false)
            {
                return;
            }

            if (layerIndex == map.layers.Count - 1)
            {
                return;
            }

            CommandManager.Add(new MoveLayerCommand(map, true, layerIndex), true);
            layerListBox.SelectedIndex = layerIndex + 1;
        }
예제 #25
0
        /// <summary>
        /// Moves the currently selected layer down by one.
        /// </summary>
        private void MoveLayerDown_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null || TryGetLayerIndex(map, out int layerIndex) == false)
            {
                return;
            }

            if (layerIndex == 0)
            {
                return;
            }

            MoveLayerCommand mlc = new MoveLayerCommand(map, false, layerIndex);

            CommandManager.Add(mlc, true);
            layerListBox.SelectedIndex = layerIndex - 1;
        }
예제 #26
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();

            //ServerTime = TimeSpan.Zero;

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), (Action <TimeSpan>)Worker);
            _serverlistManager = new ServerlistManager();
        }
예제 #27
0
        /// <summary>
        /// Opens a dialog to rename the currently selected layer.
        /// </summary>
        private void LayerRenameButton_Click(object sender, EventArgs e)
        {
            Map map = mainMapControl.Map;

            if (map == null || TryGetLayerIndex(map, out int layerIndex) == false)
            {
                return;
            }

            // open the dialog.
            RenameForm rename = new RenameForm(map.layers[layerIndex].name);

            rename.ShowDialog(this);
            // should the name change?
            if (rename.ShouldChange == true)
            {
                string toChangeTo = rename.ChangeTo;
                CommandManager.Add(new RenameLayerCommand(map, toChangeTo, map.layers[layerIndex]), true);
            }
            rename.Dispose();
        }
예제 #28
0
        private GameServer(Configuration config)
            : base(config)
        {
            RegisterMappings();
            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new BanCommands())
            .Add(new UnbanCommands())
            .Add(new UserkickCommand())
            .Add(new KickCommand())
            .Add(new AllkickCommand())
            .Add(new RoomkickCommand())
            .Add(new AdminCommands())
            .Add(new NoticeCommand())
            .Add(new WholeNoticeCommand())
            .Add(new ClanCommands())
            .Add(new InventoryCommands())
            .Add(new SearchCommand())
            .Add(new CommandWrapper())
            .Add(new HelpCommand());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());
            ClubManager    = new ClubManager(ResourceCache.GetClubs());

            _worker       = new ThreadLoop(TimeSpan.FromMilliseconds(100), Worker);
            _worker2      = new ThreadLoop(TimeSpan.FromSeconds(1), Worker2);
            _workerDelta  = new AccurateDelta(TimeSpan.Zero);
            _worker2Delta = new AccurateDelta(TimeSpan.Zero);

            _serverlistManager = new ServerlistMgr();
            AverageWorkerDelta.Enqueue(0);
            HighWorkerDelta.TryAdd(0, 0);
        }
예제 #29
0
 public void RegisterCommand(ICommandRule rule)
 {
     CommandManager.Add(rule);
 }
예제 #30
0
        private GameServer()
            : base(new GameSessionFactory(), ArrayPool <byte> .Create(1 * 1024 * 1024, 50), Config.Instance.PlayerLimit)
        {
            #region Filter Setup

            var config      = new ProudConfig(new Guid("{beb92241-8333-4117-ab92-9b4af78c688f}"));
            var proudFilter = new ProudServerPipe(config);
#if DEBUG
            proudFilter.UnhandledProudCoreMessage += (s, e) => Logger.Warn().Message("Unhandled ProudCoreMessage {0}", e.Message.GetType().Name).Write();
            proudFilter.UnhandledProudMessage     +=
                (s, e) => Logger.Warn().Message("Unhandled UnhandledProudMessage {0}: {1}", e.Message.GetType().Name, e.Message.ToArray().ToHexString()).Write();
#endif
            Pipeline.AddFirst("proudnet", proudFilter);
            Pipeline.AddLast("s4_protocol", new NetspherePipe(new GameMessageFactory()));

            Pipeline.AddLast("firewall", new FirewallPipe())
            .Add(new PacketFirewallRule <GameSession>())
            .Get <PacketFirewallRule <GameSession> >()

            .Register <CLoginReqMessage>(s => !s.IsLoggedIn())
            .Register <CCreateCharacterReqMessage>(s => s.IsLoggedIn())
            .Register <CSelectCharacterReqMessage>(s => s.IsLoggedIn())
            .Register <CDeleteCharacterReqMessage>(s => s.IsLoggedIn())
            .Register <CAdminShowWindowReqMessage>(s => s.IsLoggedIn())
            .Register <CAdminActionReqMessage>(s => s.IsLoggedIn())
            .Register <CGetChannelInfoReqMessage>(s => s.IsLoggedIn())
            .Register <CChannelEnterReqMessage>(s => s.IsLoggedIn() && s.Player.Channel == null)
            .Register <CChannelLeaveReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null)
            .Register <CNewShopUpdateCheckReqMessage>(s => s.IsLoggedIn())
            .Register <CLicensedReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null)
            .Register <CExerciseLicenceReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null)
            .Register <CBuyItemReqMessage>(s => s.IsLoggedIn())
            .Register <CRandomShopRollingStartReqMessage>(s => s.IsLoggedIn())
            .Register <CRandomShopItemSaleReqMessage>(s => s.IsLoggedIn())
            .Register <CUseItemReqMessage>(s => s.IsLoggedIn())
            .Register <CRepairItemReqMessage>(s => s.IsLoggedIn())
            .Register <CRefundItemReqMessage>(s => s.IsLoggedIn())
            .Register <CDiscardItemReqMessage>(s => s.IsLoggedIn())
            .Register <CEnterPlayerReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.IsConnecting)
            .Register <CMakeRoomReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room == null)
            .Register <CGameRoomEnterReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room == null)
            .Register <CJoinTunnelInfoReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null)
            .Register <CChangeTeamReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null)
            .Register <CPlayerGameModeChangeReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null)

            .Register <CScoreKillReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreKillAssistReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreOffenseReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreOffenseAssistReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreDefenseReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreDefenseAssistReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreTeamKillReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreHealAssistReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreSuicideReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreReboundReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.Room.Host == s.Player && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)
            .Register <CScoreGoalReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.Room.Host == s.Player && s.Player.RoomInfo.State != PlayerState.Lobby && s.Player.RoomInfo.State != PlayerState.Spectating)

            .Register <CBeginRoundReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.Room.Master == s.Player)
            .Register <CReadyRoundReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State == PlayerState.Lobby)
            .Register <CEventMessageReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null)
            .Register <CItemsChangeReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player.RoomInfo.State == PlayerState.Lobby)
            .Register <CAvatarChangeReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && (s.Player.RoomInfo.State == PlayerState.Lobby || s.Player.Room.GameRuleManager.GameRule.StateMachine.IsInState(GameRuleState.HalfTime)))
            .Register <CChangeRuleNotifyReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null && s.Player.Room != null && s.Player == s.Player.Room.Master && s.Player.Room.GameRuleManager.GameRule.StateMachine.IsInState(GameRuleState.Waiting))

            .Register <CClubAddressReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null)
            .Register <CClubInfoReqMessage>(s => s.IsLoggedIn() && s.Player.Channel != null);

            //FilterList.AddLast("spam_filter", new SpamFilter { RepeatLimit = 30, TimeFrame = TimeSpan.FromSeconds(3) });

            Pipeline.AddLast("s4_service", new ServicePipe())
            .Add(new AuthService())
            .Add(new CharacterService())
            .Add(new GeneralService())
            .Add(new AdminService())
            .Add(new ChannelService())
            .Add(new ShopService())
            .Add(new InventoryService())
            .Add(new RoomService())
            .Add(new ClubService())
            .UnhandledMessage += OnUnhandledMessage;

            #endregion

            RegisterMappings();

            //ServerTime = TimeSpan.Zero;
            _chatServer = new ChatServer(this);
            RelayServer = new RelayServer(this);

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());

            _worker     = new ThreadLoop(TimeSpan.FromMilliseconds(100), (Action <TimeSpan>)Worker);
            _authWebAPI = new AuthWebAPIClient();
        }