Ejemplo n.º 1
0
        private void OnInt32PropertyChanged(Entity sender, Int32PropertyChangeEventArgs args)
        {
            if (args.OldValue.Equals(args.NewValue))
            {
                return;
            }

            var menu = mainMenu.OnChangeMenu.Int32;

            if (!menu.Enabled || menu.HeroesOnly && !(sender is Hero) ||
                menu.IgnoreUseless && Data.IgnoredInt32.Contains(args.PropertyName))
            {
                return;
            }

            const Color       Color = Color.Cyan;
            const Logger.Type Type  = Logger.Type.Int32;

            logger.Write("Int32 property changed", Type, Color, true);
            logger.Write("Sender name: " + sender.Name, Type, Color);
            logger.Write("Sender classID: " + sender.ClassId, Type, Color);
            logger.Write("Property name: " + args.PropertyName, Type, Color);
            logger.Write("Property values: " + args.OldValue + " => " + args.NewValue, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 2
0
        private void OnModifierRemoved(Unit sender, ModifierChangedEventArgs args)
        {
            var menu = mainMenu.OnAddRemove.Modifiers;

            if (!menu.OnRemoveEnabled || menu.HeroesOnly && !(sender is Hero))
            {
                return;
            }

            var modifier = args.Modifier;

            if (modifier == null || !modifier.IsValid || menu.IgnoreUseless &&
                Data.IgnoredModifiers.Contains(modifier.Name))
            {
                return;
            }

            const Color       Color = Color.Red;
            const Logger.Type Type  = Logger.Type.Modifier;

            logger.Write("Modifier removed", Type, Color, true);
            logger.Write("Sender name: " + sender?.Name, Type, Color);
            logger.Write("Sender classID: " + sender?.ClassId, Type, Color);
            logger.Write("Name: " + modifier.Name, Type, Color);
            logger.Write("Texture name: " + modifier.TextureName, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 3
0
        private void OnStringPropertyChanged(Entity sender, StringPropertyChangeEventArgs args)
        {
            if (args.OldValue.Equals(args.NewValue))
            {
                return;
            }

            var menu = mainMenu.OnChangeMenu.Strings;

            if (!menu.Enabled || menu.HeroesOnly && !(sender is Hero))
            {
                return;
            }

            const Color       Color = Color.Cyan;
            const Logger.Type Type  = Logger.Type.String;

            logger.Write("String property changed", Type, Color, true);
            logger.Write("Sender name: " + sender.Name, Type, Color);
            logger.Write("Sender classID: " + sender.ClassId, Type, Color);
            if (sender.Owner != null)
            {
                logger.Write("Owner Name: " + sender.Owner.Name, Type, Color);
                logger.Write("Owner classID: " + sender.Owner.ClassId, Type, Color);
            }
            logger.Write("Property name: " + args.PropertyName, Type, Color);
            logger.Write("Property values: " + args.OldValue + " => " + args.NewValue, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 4
0
        //Overload for adding color to the text
        public void  centerText(string input, System.ConsoleColor color, bool slowType = true)
        {
            int stringLength = (input.Length / 2);
            int windowLength = (Console.WindowWidth / 2);

            char[] line = input.ToCharArray();

            Console.ForegroundColor = color;

            Console.SetCursorPosition((windowLength - stringLength), Console.CursorTop);

            if (slowType == true)
            {
                foreach (char c in line)
                {
                    Console.Write(c);
                    Thread.Sleep(25);
                }
            }
            else
            {
                Console.Write(input);
            }

            Console.ResetColor();
            newLine();
        }
Ejemplo n.º 5
0
        private void OnFloatPropertyChanged(Entity sender, FloatPropertyChangeEventArgs args)
        {
            if (args.OldValue.Equals(args.NewValue))
            {
                return;
            }

            var menu = mainMenu.OnChangeMenu.Floats;

            if (!menu.Enabled || menu.HeroesOnly && !(sender is Hero) ||
                menu.IgnoreUseless && Data.IgnoredFloats.Contains(args.PropertyName) || menu.IgnoreSemiUseless &&
                Data.SemiIgnoredFloats.Contains(args.PropertyName))
            {
                return;
            }

            const Color       Color = Color.Cyan;
            const Logger.Type Type  = Logger.Type.Float;

            logger.Write("Float property changed", Type, Color, true);
            logger.Write("Sender name: " + sender.Name, Type, Color);
            logger.Write("Sender classID: " + sender.ClassId, Type, Color);
            if (sender.Owner != null)
            {
                logger.Write("Owner Name: " + sender.Owner.Name, Type, Color);
                logger.Write("Owner classID: " + sender.Owner.ClassId, Type, Color);
            }
            logger.Write("Property name: " + args.PropertyName, Type, Color);
            logger.Write("Property values: " + args.OldValue + " => " + args.NewValue, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 6
0
        private void OnModifierAdded(Unit sender, ModifierChangedEventArgs args)
        {
            var menu = mainMenu.OnAddRemove.Modifiers;

            if (!menu.OnAddEnabled || menu.HeroesOnly && !(sender is Hero))
            {
                return;
            }

            var modifier = args.Modifier;

            DelayAction.Add(
                1,
                () =>
            {
                if (modifier == null || !modifier.IsValid ||
                    menu.IgnoreUseless && Data.IgnoredModifiers.Contains(modifier.Name))
                {
                    return;
                }

                const Color Color      = Color.Green;
                const Logger.Type Type = Logger.Type.Modifier;

                logger.Write("Modifier added", Type, Color, true);
                logger.Write("Sender name: " + sender?.Name, Type, Color);
                logger.Write("Sender network name: " + sender?.NetworkName, Type, Color);
                logger.Write("Sender classID: " + sender?.ClassId, Type, Color);
                logger.Write("Name: " + modifier.Name, Type, Color);
                logger.Write("Texture name: " + modifier.TextureName, Type, Color);
                logger.Write("Elapsed time: " + modifier.ElapsedTime, Type, Color);
                logger.Write("Remaining time: " + modifier.RemainingTime, Type, Color);
                logger.EmptyLine();
            });
        }
Ejemplo n.º 7
0
        private void OnHandlePropertyChanged(Entity sender, HandlePropertyChangeEventArgs args)
        {
            var menu = mainMenu.OnChangeMenu.Handles;

            if (!menu.Enabled || menu.HeroesOnly && !(sender is Hero))
            {
                return;
            }

            const Color       Color = Color.Cyan;
            const Logger.Type Type  = Logger.Type.Handle;

            logger.Write("Handle property changed", Type, Color, true);
            logger.Write("Sender name: " + sender.Name, Type, Color);
            logger.Write("Sender network name: " + sender.NetworkName, Type, Color);
            logger.Write("Sender classID: " + sender.ClassId, Type, Color);
            if (sender.Owner != null)
            {
                logger.Write("Owner Name: " + sender.Owner.Name, Type, Color);
                logger.Write("Owner Network Name: " + sender.Owner.NetworkName, Type, Color);
                logger.Write("Owner classID: " + sender.Owner.ClassId, Type, Color);
            }
            logger.Write("Property name: " + args.PropertyName, Type, Color);
            logger.Write("Property value: " + args.OldValue?.Name, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 8
0
        private void OnTrackingProjectileRemoved(TrackingProjectileEventArgs args)
        {
            var menu = mainMenu.OnAddRemove.Projectiles;

            if (!menu.OnRemoveEnabled || menu.HeroesOnly && !(args.Projectile?.Source is Hero))
            {
                return;
            }

            var projectile = args.Projectile;

            if (projectile?.Source == null)
            {
                return;
            }

            const Color       Color = Color.Red;
            const Logger.Type Type  = Logger.Type.Projectile;

            logger.Write("Projectile removed", Type, Color, true);
            logger.Write("Source name: " + projectile.Source.Name, Type, Color);
            logger.Write("Source classID: " + projectile.Source.ClassId, Type, Color);
            logger.Write("Speed: " + projectile.Speed, Type, Color);
            logger.Write("Position: " + projectile.Position, Type, Color);
            logger.Write("Target name: " + projectile.Target?.Name, Type, Color);
            logger.Write("Target classID: " + projectile.Target?.ClassId, Type, Color);
            logger.Write("Target position: " + projectile.TargetPosition, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 9
0
 public void Restaurant()
 {
     ActivationNbr  = 5;
     Color          = ConsoleColor.Red;
     CardNameEffect = "Restaurant : Recevez 2 pièces du joueur qui a lancé le dé ";
     Cost           = 4;
 }
Ejemplo n.º 10
0
 static void Write(string text, int row, int col, System.ConsoleColor backgroundColor = ConsoleColor.Black)
 {
     Console.SetCursorPosition(col, row);
     Console.BackgroundColor = backgroundColor;
     Console.Write(text);
     Console.BackgroundColor = ConsoleColor.Black;
 }
Ejemplo n.º 11
0
 public void ChampsDeBlé()
 {
     ActivationNbr  = 1;
     Color          = ConsoleColor.Blue;
     CardNameEffect = "Champs de blé : Recevez 1 pièce";
     Cost           = 1;
 }
Ejemplo n.º 12
0
 public Pixel(bool activo)
 {
     cFondo      = Color.Black;
     cLetra      = Color.Green;
     letra       = ' ';
     this.activo = activo;
 }
Ejemplo n.º 13
0
 public void Ferme()
 {
     ActivationNbr  = 1;
     Color          = ConsoleColor.Blue;
     CardNameEffect = "Ferme : Recevez 1 pièce";
     Cost           = 2;
 }
Ejemplo n.º 14
0
 public void Café()
 {
     ActivationNbr  = 3;
     Color          = ConsoleColor.Red;
     CardNameEffect = "Café : Recevez 1 pièce du joueur qui a lancé le dé";
     Cost           = 2;
 }
Ejemplo n.º 15
0
 public Pixel(Color colorFondo, Color colorLetra)
 {
     cFondo = colorFondo;
     cLetra = colorLetra;
     letra  = ' ';
     activo = true;
 }
Ejemplo n.º 16
0
 public Pixel()
 {
     cFondo = Color.Black;
     cLetra = Color.Green;
     letra  = ' ';
     activo = true;
 }
Ejemplo n.º 17
0
 public Pixel(Color color)
 {
     cFondo = color;
     cLetra = Color.Green;
     letra  = ' ';
     activo = true;
 }
Ejemplo n.º 18
0
 public void Superette()
 {
     ActivationNbr  = 4;
     Color          = ConsoleColor.Green;
     CardNameEffect = "Superette : Recevez 3 pièces";
     Cost           = 2;
 }
Ejemplo n.º 19
0
 public void Forêt()
 {
     ActivationNbr  = 5;
     Color          = ConsoleColor.Blue;
     CardNameEffect = "Forêt : Recevez 1 pièce";
     Cost           = 2;
 }
Ejemplo n.º 20
0
 public void Boulangerie()
 {
     ActivationNbr  = 2;
     Color          = ConsoleColor.Green;
     CardNameEffect = "Boulangerie : Recevez 2 pièces";
     Cost           = 1;
 }
        public static int SetColor(System.ConsoleColor color, byte r, byte g, byte b)
        {
            CONSOLE_SCREEN_BUFFER_INFO_EX csbe = new CONSOLE_SCREEN_BUFFER_INFO_EX();

            csbe.cbSize = (uint)Marshal.SizeOf(csbe);                   // 96 = 0x60
            IntPtr hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);    // 7

            if (hConsoleOutput == INVALID_HANDLE_VALUE)
            {
                return(Marshal.GetLastWin32Error());
            }
            bool brc = GetConsoleScreenBufferInfoEx(hConsoleOutput, ref csbe);

            if (!brc)
            {
                return(Marshal.GetLastWin32Error());
            }

            csbe.ColorTable[(int)color] = new COLORREF(r, g, b);

            ++csbe.srWindow.Bottom;
            ++csbe.srWindow.Right;
            brc = SetConsoleScreenBufferInfoEx(hConsoleOutput, ref csbe);
            if (!brc)
            {
                return(Marshal.GetLastWin32Error());
            }
            return(0);
        }
Ejemplo n.º 22
0
        private void AddMessage(ConsoleColor color, DateTime dt, string message, CancellationToken token)
        {
            using (var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, _token.Token))
            {
                var task = Task.Run(() =>
                {
                    lock (Lock)
                    {
                        try
                        {
                            System.Console.ForegroundColor = color;
                            System.Console.WriteLine($"[{dt:HH:mm:ss.ffff}]:{message}");
                        }
                        catch (Exception e)
                        {
                            System.Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine(e.Message);
                        }
                        finally
                        {
                            System.Console.ForegroundColor = _consoleColor;
                        }
                    }
                }, linkedTokenSource.Token);

                lock (_tasks)
                {
                    _tasks.Add(task);
                    _tasks.RemoveAll(t => t.IsCompleted);
                }
            }
        }
Ejemplo n.º 23
0
        ////public static void OnAlert(object sender, CountDownMessageEventArgs ce)
        ////{
        ////    Console.WriteLine("[IRC] " + ce.CountdownMessage);
        ////    si.SendMessage(ce.CountdownMessage);
        ////}

        ///// <summary>
        ///// Event Fired when countdown has reached 0
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        ////public static void OnFinished(object sender, EventArgs e)
        ////{
        ////    // Sleep after the timer is done for 20 minutes (average length of an anime)
        ////    // System.Threading.Thread.Sleep((int)new TimeSpan(0, 20, 0).TotalMilliseconds);
        ////    // si.Quit();
        ////    // Environment.Exit(0);
        ////}
        ///// <summary>
        ///// Event fired when IRC has connected successfully
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        ////public static void Connected(object sender, EventArgs e)
        ////{
        ////    Console.WriteLine("[IRC] Connected Event Fired");
        ////}


        private static void PrintToConsoleWithColor(string message, System.ConsoleColor color)
        {
            System.ConsoleColor backup = Console.ForegroundColor;
            Console.ForegroundColor = color;
            System.Console.WriteLine(message);
            Console.ForegroundColor = backup;
        }
Ejemplo n.º 24
0
 public void Stade()
 {
     ActivationNbr  = 6;
     Color          = ConsoleColor.Blue;
     CardNameEffect = "Stade : Recevez 4 pièce";
     Cost           = 6;
 }
Ejemplo n.º 25
0
        private void OnAnimationChanged(Entity sender, EventArgs args)
        {
            var menu = mainMenu.OnChangeMenu.Animations;

            if (!menu.Enabled || menu.HeroesOnly && !(sender is Hero))
            {
                return;
            }

            const Color       Color = Color.Cyan;
            const Logger.Type Type  = Logger.Type.Animation;

            logger.Write("Animation changed", Type, Color, true);
            logger.Write("Sender name: " + sender.Name, Type, Color);
            logger.Write("Sender network name: " + sender.NetworkName, Type, Color);
            logger.Write("Sender classID: " + sender.ClassId, Type, Color);
            if (sender.Owner != null)
            {
                logger.Write("Owner Name: " + sender.Owner.Name, Type, Color);
                logger.Write("Owner Network Name: " + sender.Owner.NetworkName, Type, Color);
                logger.Write("Owner classID: " + sender.Owner.ClassId, Type, Color);
            }
            logger.Write("Name: " + sender.Animation.Name, Type, Color);
            logger.EmptyLine();
        }
Ejemplo n.º 26
0
        }     //end region

        #endregion

        //BOARD SETUP FUNCTIONS
        #region DRAW SQUARE FUNCTION
        static void DrawSquareFunc(string XandY, System.ConsoleColor color)  //DRAW A SINGLE SQUARE AT ANY POSITION AND ANY COLOR
        //CHANGE BACKBROUND COLOR
        {
            Console.BackgroundColor = color;
            Console.ForegroundColor = color;

            //CONVERT NUMBER
            ConvertBoardSlot(XandY);

            //PLACE BOARD TILE
            Console.SetCursorPosition(BoardStoredCoords[0], BoardStoredCoords[1]);

            //LOOPS TO WRITE THE BOARD SQUARE PATTERN
            for (int index = 0; index < SquarePosHeight; index++)
            {
                for (int index2 = 0; index2 < SquarePosWidth; index2++)
                {
                    Console.Write(Block);
                }//end for
                //MOVES CURSER POSITION ON Y AXIS DOWN BY 1
                Console.SetCursorPosition(BoardStoredCoords[0], BoardStoredCoords[1] + (index + 1));
            }//end for

            //RESET COLOR
            Console.ResetColor();
        }//end function
Ejemplo n.º 27
0
        static IDisposable Color(System.ConsoleColor color)
        {
            var originalColor = Console.ForegroundColor;

            Console.ForegroundColor = color;
            return(new ActionOnDispose(() => Console.ForegroundColor = originalColor));
        }
Ejemplo n.º 28
0
        public void AddTask()
        {
            System.ConsoleColor color = System.ConsoleColor.Yellow;
            ColorConsole.WriteLine("Dodawanie nowego zadania. Dołacz opis do nowego zadania:", color);
            description = Console.ReadLine();

            ColorConsole.WriteLine("Wpisz datę rozpoczęcia zadania według formatu:{yyyy-MM-dd}", color);
            var loadDate = Console.ReadLine();

            startDate = Convert.ToDateTime(loadDate);

            ColorConsole.WriteLine("Potwierdź czy zadanie ma być całodniowe? {t/n}", color);
            var allday = Console.ReadLine();

            if (allday == "n")
            {
                allDay = false;
                ColorConsole.WriteLine("Wpisz godzinę, rozpoczęcia zadania według formatu {hh:mm:ss}", color);
                loadDate = Console.ReadLine();
                TimeSpan time = new TimeSpan(Convert.ToDateTime(loadDate).Hour, Convert.ToDateTime(loadDate).Minute, Convert.ToDateTime(loadDate).Second);
                startDate += time;

                ColorConsole.WriteLine("Wybierz jedną z opcji", color);
                ColorConsole.WriteLine("Wpisz pełną datę zakończenia zadania używając komendy 'AddDate'", color);
                ColorConsole.WriteLine("Wpisz jak długo będzie trwało dane zadanie według określonego formatu {hh:mm:ss}.", color);
                loadDate = Console.ReadLine();

                if (loadDate != "AddDate")
                {
                    time       = new TimeSpan(Convert.ToDateTime(loadDate).Hour, Convert.ToDateTime(loadDate).Minute, Convert.ToDateTime(loadDate).Second);
                    startDate += time;
                }
                else
                {
                    ColorConsole.WriteLine("Wpisz datę ukończenia zadania według formatu {yyyy-MM-dd hh:mm:ss", color);
                    loadDate = Console.ReadLine();
                    endDate  = Convert.ToDateTime(loadDate);
                }
            }
            else if (allday == "t")
            {
                allDay = true;
            }
            ColorConsole.WriteLine("Określ czy zadanie powinno być ważne? {t/n}", color);
            string important = Console.ReadLine();

            if (important == "t")
            {
                Important = true;
            }
            else if (important == "n")
            {
                Important = false;
            }
            else
            {
                ColorConsole.WriteLine("Wpisałeś nieodpowiednie komendy!!! Wpisz znak 'T' albo znak 'N'", System.ConsoleColor.Red);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 打个日志
        /// </summary>
        /// <param name="str"></param>
        /// <param name="color"></param>
        static void WriteColorLine(string str, System.ConsoleColor color)
        {
            ConsoleColor currentForeColor = Console.ForegroundColor;

            Console.ForegroundColor = color;
            Console.WriteLine(str);
            Console.ForegroundColor = currentForeColor;
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Log text to the console.
 /// </summary>
 /// <param name="message">The message to log</param>
 /// <param name="colour">The colour to display the message in</param>
 /// <param name="filePath">Ignore this</param>
 /// <param name="lineNumber">See filePath</param>
 /// <param name="callerName">See filePath</param>
 public static void Log(string message, System.ConsoleColor colour = System.ConsoleColor.Gray, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string callerName = "")
 {
     lock (Console.Out)
     {
         Console.ForegroundColor = colour;
         Console.WriteLine($"[{DateTime.Now}] <thread {System.Threading.Thread.CurrentThread.ManagedThreadId.ToString("X")}> <{Path.GetFileName(filePath)}:line {lineNumber}> {callerName}: {message}");
     }
 }
 public static void WrapConsoleMessageWithColor(this string message, System.ConsoleColor color, bool useNewLine)
 {
     if (!_initialColorSaved)
     {
         _initialColorSaved = true;
         _initialColor = System.Console.ForegroundColor;
     }
     System.Console.ForegroundColor = color;
     if (useNewLine)
         System.Console.WriteLine(message);
     else
         System.Console.Write(message);
     System.Console.ForegroundColor = _initialColor;
 }
Ejemplo n.º 32
0
        public static void WriteLine(string input, Color foreground, Color background, int padding = -48)
        {
            input = input ?? "";

            string[] lines = input.Split('\n');
            string format = (padding < 0 ? $"{{0,{padding}}}" : "{0}");

            foreach (string line in lines)
            {
                Console.ResetColor();
                Console.Write("".PadLeft(4, ' '));

                Console.ForegroundColor = foreground;
                Console.BackgroundColor = background;
                Console.WriteLine(string.Format(format, line));
            }
        }
Ejemplo n.º 33
0
 public ConsoleColorer(ConsoleColor @new)
 {
     this.old = Console.ForegroundColor;
     //Console.ForegroundColor = @new;
 }
Ejemplo n.º 34
0
 public ConsoleColor(System.ConsoleColor color)
 {
     _previousColor = Console.ForegroundColor;
     Console.ForegroundColor = color;
 }