コード例 #1
0
        public void Print(bool printAttributes = false, bool shortPath = false, string prefix = "", string postfix = "", int paddingRight = -1, string linePrefix = "")
        {
            var bg    = GetCmd(EchoDirectives.b + "", DefaultBackground.ToString().ToLower());
            var fg    = GetCmd(EchoDirectives.f + "", DefaultForeground.ToString().ToLower());
            var color = (IsDirectory) ? NormalDirectoryColorization : FileColorization;

            if (!IsSystem && IsDirectory && !IsReadOnly)
            {
                color += WritableDirectoryColorization;
            }
            if (IsSystem && !IsDirectory)
            {
                color += SystemColorization + bg;
            }
            if (IsSystem && IsDirectory && !IsReadOnly)
            {
                color += SystemWritableDirectoryColorization;
            }
            if (IsFile && IsReadOnly)
            {
                color += ReadOnlyFileColorization;
            }
            var    endcolor = bg + fg;
            var    r        = "";
            var    attr     = "";
            string hidden   = "";

            if (printAttributes)
            {
                var dir = IsDirectory ? "d" : "-";
                var ro  = IsReadOnly ? "r-" : "rw";
                var sys = IsSystem ? "s" : "-";
                var h   = IsHidden ? "h" : "-";
                //var c = IsCompressed ? "c" : "-";
                var a      = IsArchive ? "a" : "-";
                var size   = (IsDirectory) ? "" : HumanFormatOfSize(((FileInfo)FileSystemInfo).Length, 2);
                var moddat = FileSystemInfo.LastWriteTime;
                hidden = IsHidden ? "*" : "";
                var dat     = (moddat.Year != System.DateTime.Now.Year) ? moddat.Year + "" : "";
                var smoddat = $"{dat,4} {moddat.ToString("MMM", CultureInfo.InvariantCulture),-3} {moddat.Day,-2} {moddat.Hour.ToString().PadLeft(2,'0')}:{moddat.Minute.ToString().PadLeft(2,'0')}";
                attr = $" {dir}{ro}{sys}{h}{a} {size,10} {smoddat}  ";
            }
            var name  = shortPath ? FileSystemInfo.Name : FileSystemInfo.FullName;
            var quote = name.Contains(' ') ? "\"" : "";
            var pdr   = paddingRight - name.Length;

            if (!string.IsNullOrWhiteSpace(quote))
            {
                pdr -= 2;
            }
            var rightspace = (paddingRight > -1) ? endcolor + "".PadRight(pdr > 0?pdr:1, ' ') : "";

            r += $"{linePrefix}{attr}{color}{prefix}{quote}{name}{quote}{hidden}{rightspace}{postfix}";
            Out.Echo(r + ColorSettings.Default);
            if (HasError)
            {
                Out.Echo($" {ErrorColorization}{GetError()}");
            }
        }
コード例 #2
0
ファイル: Level02.cs プロジェクト: JohanGl/Moon
        public void Initialize(GameContext context)
        {
            // Initialize the background
            background = new DefaultBackground();
            background.Initialize(context);

            starHandler = new StarHandler(context);

            Player = new Player();
            Player.Initialize(context);

            playerInfo = new PlayerInfo();
            playerInfo.Initialize(context, 4);

            Reset();
        }
コード例 #3
0
        public void Echo(EchoEvaluationContext ctx)
        {
            var(@out, context, opts) = ctx;
            if (context.EchoMap.MappedCall(this, ctx))
            {
                return;
            }

            var options = opts as FileSystemPathFormattingOptions;

            options ??= (FileSystemPathFormattingOptions)
            context.ShellEnv.GetValue <FileSystemPathFormattingOptions>(ShellEnvironmentVar.display_fileSystemPathFormattingOptions)
            .InitFrom(opts);

            if (options.IsRawModeEnabled)
            {
                var rs = options.ShortPath ? FileSystemInfo.Name : UnescapePathSeparators(FileSystemInfo.FullName);
                var q  = rs.Contains(' ') ? "\"" : "";
                rs = q + rs + q;
                @out.Echo(rs, options.LineBreak, options.IsRawModeEnabled);
                return;
            }

            var bg    = GetCmd(EchoDirectives.b + "", DefaultBackground.ToString().ToLower());
            var fg    = GetCmd(EchoDirectives.f + "", DefaultForeground.ToString().ToLower());
            var color = (IsDirectory) ? NormalDirectoryColorization : FileColorization;

            if (!IsSystem && IsDirectory && !IsReadOnly)
            {
                color += WritableDirectoryColorization;
            }
            if (IsSystem && !IsDirectory)
            {
                color += SystemColorization + bg;
            }
            if (IsSystem && IsDirectory && !IsReadOnly)
            {
                color += SystemWritableDirectoryColorization;
            }
            if (IsFile && IsReadOnly)
            {
                color += ReadOnlyFileColorization;
            }
            var    endcolor = bg + fg + ANSI.RSTXTA;
            var    r        = "";
            var    attr     = "";
            string hidden   = "";

            if (options.PrintAttributes)
            {
                var dir = IsDirectory ? "d" : "-";
                var ro  = IsReadOnly ? "r-" : "rw";
                var sys = IsSystem ? "s" : "-";
                var h   = IsHidden ? "h" : "-";
                //var c = IsCompressed ? "c" : "-";
                var a    = IsArchive ? "a" : "-";
                var size = (IsDirectory || FileSystemInfo == null) ? "" : HumanFormatOfSize(((FileInfo)FileSystemInfo).Length, 2);
                hidden = IsHidden ? "*" : "";
                string smoddat = "";
                if (FileSystemInfo != null)
                {
                    var moddat = FileSystemInfo.LastWriteTime;
                    var dat    = (moddat.Year != System.DateTime.Now.Year) ? moddat.Year + "" : "";
                    smoddat = $"{dat,4} {moddat.ToString("MMM", CultureInfo.InvariantCulture),-3} {moddat.Day,-2} {moddat.Hour.ToString().PadLeft(2, '0')}:{moddat.Minute.ToString().PadLeft(2, '0')}";
                }
                attr = $" {dir}{ro}{sys}{h}{a} {size,10} {smoddat}  ";
            }
            var name  = options.ShortPath ? FileSystemInfo.Name : UnescapePathSeparators(FileSystemInfo.FullName);
            var quote = name.Contains(' ') ? "\"" : "";
            var pdr   = options.PaddingRight - name.Length;

            if (!string.IsNullOrWhiteSpace(quote))
            {
                pdr -= 2;
            }
            var rightspace = (options.PaddingRight > -1) ? endcolor + "".PadRight(pdr > 0 ? pdr : 1, ' ') : "";

            r += $"(rsf){options.LinePrefix}{attr}{color}{options.Prefix}{quote}{name}{quote}{hidden}{rightspace}{options.Postfix}";
            @out.Echo(r + context.ShellEnv.Colors.Default);
            if (HasError)
            {
                @out.Echo($" {ErrorColorization}{GetError()}");
            }
            @out.Echo(ANSI.RSTXTA); // @TODO: convention - si modif des couleurs uniquement ?? ou est-ce un hack pour la fin de ligne ?? a pour contrat de resetter f et b + unset text decoration
        }
コード例 #4
0
ファイル: Level09.cs プロジェクト: JohanGl/Moon
        public void Initialize(GameContext context)
        {
            // Initialize the background
            background = new DefaultBackground();
            background.Initialize(context);

            starHandler = new StarHandler(context);

            rail = context.Content.Load<Texture2D>("Scenes/Levels/Custom/Rail");

            Player = new Player();
            Player.Initialize(context);

            playerInfo = new PlayerInfo();
            playerInfo.Initialize(context, 4);

            Reset();

            railPosition = new Vector2(0, Player.Position.Y + 40 - 8);
        }
コード例 #5
0
ファイル: Level08.cs プロジェクト: JohanGl/Moon
        public void Initialize(GameContext context)
        {
            this.context = context;

            // Initialize the background
            background = new DefaultBackground();
            background.Initialize(context);

            starHandler = new StarHandler(context);

            Player = new Player();
            Player.Initialize(context);

            playerInfo = new PlayerInfo();
            playerInfo.Initialize(context, 8);

            blackHoles = new BlackHole[2];
            blackHoles[0] = new BlackHole();
            blackHoles[0].Initialize(context);
            blackHoles[0].Position = new Vector2(32, 32);

            Reset();

            InitializeShakeGestures();
        }
コード例 #6
0
ファイル: Level07.cs プロジェクト: JohanGl/Moon
        public void Initialize(GameContext context)
        {
            this.context = context;

            // Initialize the background
            background = new DefaultBackground();
            background.Initialize(context);

            starHandler = new StarHandler(context);

            Player = new Player();
            Player.Initialize(context);

            playerInfo = new PlayerInfo();
            playerInfo.Initialize(context, 6);

            blackHole = new BlackHole();
            blackHole.Initialize(context);
            blackHole.Position = new Vector2(Device.HalfWidth, Device.HalfHeight);

            Reset();
        }