public ReplaceDialog(StringArgs args)
 {
     InitializeComponent();
     myArgs                   = args as ReplaceArgs;
     FromTextBox.Text         = myArgs.From;
     ToTextBox.Text           = myArgs.To;
     AreaComboBox.ItemsSource = cases;
 }
Exemplo n.º 2
0
        public void Replace(ReplaceArgs opt)
        {
            var existing = Processor.Hosts[opt.Name];

            Processor.Hosts[opt.Name] = opt.Address;

            opt.Result.Message = string.Format("host entry changed for {0} from {1} to {2}", opt.Name, opt.Address, existing);
        }
        public Replace(StringArgs args)
        {
            InitializeComponent();


            myArgs           = args as ReplaceArgs;
            fromTextBox.Text = myArgs.From;
            toTextBox.Text   = myArgs.To;
        }
 public ReplaceArgsDialog(ReplaceArgs args)
 {
     InitializeComponent();
     finderTextBox.Text   = args.Finder;
     replacerTextBox.Text = args.Replacer;
 }
 public ReplaceDialog(ReplaceArgs args)
 {
     InitializeComponent();
     needleTextBox.Text = args.Needle;
     hammerTextBox.Text = args.Hammer;
 }
Exemplo n.º 6
0
        internal static void Draw( Player player, Command cmd, DrawMode mode ) {
            string blockName = cmd.Next();
            Block block = Block.Undefined;

            Permission permission = Permission.Build;

            // if a type is specified in chat, try to parse it
            if( blockName != null ) {
                block = Map.GetBlockByName( blockName );

                switch( block ) {
                    case Block.Admincrete:
                        permission = Permission.PlaceAdmincrete; break;
                    case Block.Air:
                        permission = Permission.Delete; break;
                    case Block.Water:
                    case Block.StillWater:
                        permission = Permission.PlaceWater; break;
                    case Block.Lava:
                    case Block.StillLava:
                        permission = Permission.PlaceLava; break;
                    case Block.Undefined:
                        player.MessageNow( "{0}: Unrecognized block: {1}",
                                           mode, blockName );
                        return;
                }
            } // else { use the last-used-block }

            // ReplaceNot does not need permission (since the block is EXCLUDED)
            if( !player.Can( permission ) && mode != DrawMode.ReplaceNot ) {
                player.MessageNow( "{0}: You are not allowed to draw with this block ({1})",
                                   mode, blockName );
                return;
            }

            object selectionArgs = (byte)block;
            SelectionCallback callback;

            switch( mode ) {
                case DrawMode.Cuboid:
                    callback = CuboidCallback;
                    break;

                case DrawMode.CuboidHollow:
                case DrawMode.EllipsoidHollow:
                case DrawMode.SphereHollow:
                    if( mode == DrawMode.CuboidHollow ) {
                        callback = CuboidHollowCallback;
                    } else if( mode == DrawMode.EllipsoidHollow ) {
                        callback = EllipsoidHollowCallback;
                    } else {
                        callback = SphereHollowCallback;
                    }
                    string innerBlockName = cmd.Next();
                    Block innerBlock = Block.Undefined;
                    if( innerBlockName != null ) {
                        innerBlock = Map.GetBlockByName( innerBlockName );
                        if( innerBlock == Block.Undefined ) {
                            player.Message( "{0}: Unrecognized block: {1}",
                                            mode, innerBlockName );
                        }
                    }
                    selectionArgs = new HollowShapeArgs {
                        OuterBlock = block,
                        InnerBlock = innerBlock
                    };
                    break;

                case DrawMode.CuboidWireframe:
                    callback = CuboidWireframeCallback;
                    break;

                case DrawMode.Ellipsoid:
                    callback = EllipsoidCallback;
                    break;

                case DrawMode.Sphere:
                    callback = SphereCallback;
                    break;

                case DrawMode.Replace:
                case DrawMode.ReplaceNot:

                    string affectedBlockName = cmd.Next();

                    if( affectedBlockName == null ) {
                        if( mode == DrawMode.ReplaceNot ) {
                            cdReplaceNot.PrintUsage( player );
                        } else {
                            cdReplace.PrintUsage( player );
                        }
                        return;
                    }

                    List<Block> affectedTypes = new List<Block> { block };

                    do {
                        Block affectedType = Map.GetBlockByName( affectedBlockName );
                        if( affectedType != Block.Undefined ) {
                            affectedTypes.Add( affectedType );
                        } else {
                            player.MessageNow( "{0}: Unrecognized block type: {1}", mode, affectedBlockName );
                            return;
                        }
                    } while( (affectedBlockName = cmd.Next()) != null );

                    Block[] replacedTypes = affectedTypes.Take( affectedTypes.Count - 1 ).ToArray();
                    Block replacementType = affectedTypes.Last();
                    selectionArgs = new ReplaceArgs {
                        DoExclude = (mode == DrawMode.ReplaceNot),
                        Types = replacedTypes,
                        ReplacementBlock = replacementType
                    };
                    callback = ReplaceCallback;

                    if( mode == DrawMode.ReplaceNot ) {
                        player.MessageNow( "ReplaceNot: Ready to replace everything EXCEPT ({0}) with {1}",
                                           replacedTypes.JoinToString(),
                                           replacementType );
                    } else {
                        player.MessageNow( "Replace: Ready to replace ({0}) with {1}",
                                           replacedTypes.JoinToString(),
                                           replacementType );
                    }

                    break;

                case DrawMode.Line:
                    callback = LineCallback;
                    break;

                default:
                    throw new ArgumentOutOfRangeException( "mode" );
            }

            player.SetCallback( 2, callback, selectionArgs, Permission.Draw );

            if( block != Block.Undefined ) {
                player.MessageNow( "{0} ({1}): Click a block or use &H/mark",
                                   mode, block );
            } else {
                player.MessageNow( "{0}: Click a block or use &H/mark",
                   mode, block );
            }
        }