Example #1
0
        /// <summary>
        /// Formats the table of Messages based on the given list of Messages and colors.
        /// </summary>
        /// <param name="messages">The list of messages to display in the table</param>
        /// <param name="backColors">The list of alternating background colors to display in the table</param>
        /// <param name="textColors">The list of alternating text colors to display in the table</param>
        public void PopulateMessageTable(List<ActivEarth.Objects.Groups.Message> messages, Color[] backColors, Color[] textColors)
        {
            int colorIndex = 0;
            int textIndex = 0;

            messages.Reverse();
            foreach (ActivEarth.Objects.Groups.Message message in messages)
            {
                _wall.Rows.Add(MakeRowForTable(message, backColors[colorIndex], textColors[textIndex]));

                colorIndex++;
                if (colorIndex == backColors.Length)
                {
                    colorIndex = 0;
                }

                textIndex++;
                if (textIndex == textColors.Length)
                {
                    textIndex = 0;
                }
            }
            messages.Reverse();
            _wall.Width = new Unit(80, UnitType.Percentage);
        }
Example #2
0
		public static InitializerPath FromResolveResult(ResolveResult resolveResult)
		{
			InitializerPath initializerPath = null;
			var memberPath = new List<IMember>();
			var currentResolveResult = resolveResult;
			do {
				if (currentResolveResult is MemberResolveResult) {
					var memberResolveResult = (MemberResolveResult)currentResolveResult;
					memberPath.Add(memberResolveResult.Member);
					currentResolveResult = memberResolveResult.TargetResult;
				} else if (currentResolveResult is LocalResolveResult) {
					var localResolveResult = (LocalResolveResult)currentResolveResult;
					memberPath.Reverse();
					initializerPath = new InitializerPath(localResolveResult.Variable) {
						MemberPath = memberPath
					};
					break;
				} else if (currentResolveResult is ThisResolveResult) {
					break;
				} else {
					return null;
				}

			} while (currentResolveResult != null);

			if (initializerPath == null) {
				// This path is rooted at a member
				memberPath.Reverse();
				initializerPath = new InitializerPath(memberPath [0]) {
					MemberPath = memberPath.Skip(1).ToList()
				};
			}
			return initializerPath;
		}
Example #3
0
    static void Main()
    {
        Console.Write("Enter 16-bit signed number: ");
        int number = int.Parse(Console.ReadLine());
        string binaryNumber = "";

        List<int> digits = new List<int>();

        if (number >= 0)
        {
            while (number != 0)
            {
                digits.Add(number % 2);
                number /= 2;
            }

            digits.Reverse();

            for (int i = 0; i < digits.Count; i++)
            {
                binaryNumber += digits[i];
            }

            while (binaryNumber.Length % 16 != 0)
            {
                binaryNumber = "0" + binaryNumber;
            }
        }
        else
        {
            number = Math.Abs(number) - 1;

            while (number != 0)
            {
                digits.Add(number % 2);
                number /= 2;
            }

            digits.Reverse();

            for (int i = 0; i < digits.Count; i++)
            {
                if (digits[i] == 0)
                {
                    binaryNumber += "1";
                }
                else
                {
                    binaryNumber += "0";
                }
            }

            while (binaryNumber.Length % 16 != 0)
            {
                binaryNumber = "1" + binaryNumber;
            }
        }
        Console.Write("Result: ");
        Console.WriteLine(binaryNumber);
    }
        public GraphicsPathTest()
        {
            _thickPen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);

            List<CCVector2> path1 = new List<CCVector2>() {
                new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X + 100, path1[i].Y);

            _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);

            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X, path1[i].Y + 100);

            _gpath2r = new GraphicsPath(_thickPen, path1);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X - 100, path1[i].Y);

            _gpath2f = new GraphicsPath(_thickPen, path1);
        }
 private IEnumerator AnimateModuleExpandCoroutine(bool expand)
 {
     _isAnimating = true;
     var sprites = new List<Sprite>(ShowModuleSprites);
     if (!expand)
     {
         sprites.Reverse();
         foreach (var subsystem in Subsystems)
         {
             subsystem.SetActive(false);
         }
     }
     var moduleImage = ModuleButtonGO.GetComponent<Button>();
     foreach (var sprite in sprites)
     {
         moduleImage.image.sprite = sprite;
         moduleImage.image.rectTransform.sizeDelta = new Vector2(sprite.rect.width, sprite.rect.height);
         yield return new WaitForSeconds(0.03f);
     }
     if (expand)
     {
         sprites.Reverse();
         foreach (var subsystem in Subsystems)
         {
             subsystem.SetActive(true);
         }
     }
     _isAnimating = false;
 }
Example #6
0
		public static AccessPath FromResolveResult(ResolveResult resolveResult)
		{
			var memberPath = new List<IMember>();
			var currentResolveResult = resolveResult;
			do {
				if (currentResolveResult is MemberResolveResult) {
					var memberResolveResult = (MemberResolveResult)currentResolveResult;
					memberPath.Add(memberResolveResult.Member);
					currentResolveResult = memberResolveResult.TargetResult;
				} else if (currentResolveResult is LocalResolveResult) {
					// This is the root variable
					var localResolveResult = (LocalResolveResult)currentResolveResult;
					memberPath.Reverse();
					return new AccessPath(localResolveResult.Variable) {
						MemberPath = memberPath
					};
				} else if (currentResolveResult is ThisResolveResult) {
					break;
				} else {
					// Unsupported path
					return null;
				}
			} while (currentResolveResult != null);

			memberPath.Reverse();
			return new AccessPath(null) {
				MemberPath = memberPath
			};
		}
Example #7
0
        public override void Setup (GraphicsDevice device)
        {
            _thickPen = new Pen(Color.Green, 15);

            List<Vector2> path1 = new List<Vector2>() {
                new Vector2(50, 50), new Vector2(100, 50), new Vector2(100, 100), new Vector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X + 100, path1[i].Y);

            _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);

            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X, path1[i].Y + 100);

            _gpath2r = new GraphicsPath(_thickPen, path1);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X - 100, path1[i].Y);

            _gpath2f = new GraphicsPath(_thickPen, path1);
        }
Example #8
0
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int frozenPosition = int.Parse(Console.ReadLine());

            // We don't need to roll the bits more than 18 times.
            int rollTimes = int.Parse(Console.ReadLine()) % 18;

            char[] bitArray = Convert.ToString(input, 2).ToCharArray();
            List<char> charList = new List<char>(bitArray);
            charList.Reverse();

            while (charList.Count <= 18) // Make sure the list contains 19 elements.
            {
                charList.Add('0');
            }

            char frozenBit = charList[frozenPosition];
            char temporary = '0';
            charList.RemoveAt(frozenPosition);

            for (int i = 0; i < rollTimes; i++)
            {
                temporary = charList.First();
                charList.RemoveAt(0);
                charList.Add(temporary);
            }

            charList.Insert(frozenPosition, frozenBit);

            charList.Reverse();
            string output = string.Join("", charList);
            Console.WriteLine(Convert.ToInt32(output, 2));
        }
Example #9
0
		static void Main(string[] args)
		{
			var arguments = new List<string>(args);
			var input = new List<string>();

			if (Console.IsInputRedirected)
			{
				string line;
				while ((line = Console.ReadLine()) != null)
				{
					input.Add(line);
				}
			}

			if (!arguments.Any())
			{
				//PrintHelp();
				return;
			}

			var fromEnd = false;
			if (arguments.Contains("-e"))
			{
				arguments.Remove("-e");
				fromEnd = true;
			}

			int take;
			if (!int.TryParse(arguments[0], out take))
			{
				return;
			}
			arguments.RemoveAt(0);

			var tempList = new List<string>(input);

			if (fromEnd)
			{
				tempList.Reverse();
			}

			if (take < 0)
			{
				take = tempList.Count + take;
			}

			tempList =
				//take < 0 ? tempList.Skip(tempList.Count + take).ToList() :
				tempList.Take(take).ToList();

			if (fromEnd)
			{
				tempList.Reverse();
			}

			foreach (var line in tempList)
			{
				Console.WriteLine(line);
			}
		}
Example #10
0
    public static void PrintResult(List<short> number, short userNum)
    {
        int counter = 0;
        Console.Write("\nThe Binary representation of {0} is: ", userNum);

        number.Reverse();
        if (number.Count < 16)
        {
            for (int i = number.Count; i < 16; i++)
            {
                number.Add(0);
            }
        }

        number.Reverse();

        foreach (short bit in number)
        {
            Console.Write(bit);
            counter++;

            if (counter % 4 == 0)
            {
                Console.Write(" ");
            }
        }

        Console.WriteLine();
    }
Example #11
0
    static void Main()
    {
        Console.Write("number: ");
        int binary = int.Parse(Console.ReadLine());
        string binaryNumber = "";

        List<int> digits = new List<int>();

        if (binary >= 0)
        {
            while (binary != 0)
            {
                digits.Add(binary % 2);
                binary /= 2;
            }

            digits.Reverse();

            for (int i = 0; i < digits.Count; i++)
            {
                binaryNumber += digits[i];
            }

            while (binaryNumber.Length % 16 != 0)
            {
                binaryNumber = "0" + binaryNumber;
            }
        }
        else
        {
            binary = Math.Abs(binary) - 1;

            while (binary != 0)
            {
                digits.Add(binary % 2);
                binary /= 2;
            }

            digits.Reverse();

            for (int i = 0; i < digits.Count; i++)
            {
                if (digits[i] == 0)
                {
                    binaryNumber += "1";
                }
                else
                {
                    binaryNumber += "0";
                }
            }

            while (binaryNumber.Length % 16 != 0)
            {
                binaryNumber = "1" + binaryNumber;
            }
        }
        Console.Write("Result: ");
        Console.WriteLine(binaryNumber);
    }
        static void Main(string[] args)
        {
            Console.Write("Enter 16-bit signed number: ");
            int number = int.Parse(Console.ReadLine());

            List<int> digits = new List<int>();

            if (number >= 0)
            {
                while (number != 0)
                {
                    digits.Add(number % 2);
                    number /= 2;
                }

                while (digits.Count % 16 != 0)
                {
                    digits.Add(0);
                }
                digits.Reverse();
            }
            else
            {
                number = Math.Abs(number) - 1;

                while (number != 0)
                {
                    digits.Add(number % 2);
                    number /= 2;
                }

                List<int> negativeNumber = new List<int>();
                for (int i = 0; i < digits.Count; i++)
                {
                    if (digits[i] == 0)
                    {
                        negativeNumber.Add(1);
                    }
                    else
                    {
                        negativeNumber.Add(0);
                    }
                }
                digits = negativeNumber;

                while (digits.Count % 16 != 0)
                {
                    digits.Add(1);
                }
                digits.Reverse();
            }
            Console.Write("Binary representation: ");
            foreach (var item in digits)
            {
                Console.Write(item);
            }
            Console.WriteLine();
        }
Example #13
0
        static void Main()
        {
            int number = int.Parse(Console.ReadLine());
            List<int> binNumber = new List<int>();
            StringBuilder binary = new StringBuilder();
            if (number > 0)
            {

                while (number > 0)
                {
                    binNumber.Add(number % 2);
                    number /= 2;
                }
                while (binNumber.Count % 16 != 0)
                {
                    binNumber.Add(0);
                }
                binNumber.Reverse();

                for (int i = 0; i < binNumber.Count; i++)
                {
                    binary.Append(binNumber[i]);
                }

                Console.WriteLine(binary);
            }
            else
            {

                number = Math.Abs(number) - 1;
                while(number>0)
                {
                    binNumber.Add(number % 2);
                    number /= 2;
                }
                while (binNumber.Count % 16 != 0)
                {
                    binNumber.Add(0);
                }
                binNumber.Reverse();
                for (int i = 0; i < binNumber.Count; i++)
                {
                    if (binNumber[i] == 0)
                    {
                        binary.Append(1);
                    }
                    else
                    {
                        binary.Append(0);
                    }
                }
                Console.WriteLine(binary);

            }
        }
Example #14
0
    protected void handleDone(List<FmriRequest> reqList, Table dest, string status, Color bg, Color fg)
    {
        reqList.Reverse();
        foreach (FmriRequest req in reqList)
        {
            TableRow r = new TableRow();
            r.Height = 40;

            TableCell c;

            c = new TableCell();
            c.Text = status;
            c.BackColor = bg;
            c.ForeColor = fg;
            r.Cells.Add(c);

            AddCells(r.Cells, req);

            c = new TableCell();
            c.Text = Convert.ToString(req.TimeExecuted);
            r.Cells.Add(c);

            c = new TableCell();
            if (req.Result.Contains("Out of memory"))
            {
                req.Result = "Out of memory.";
            }
            if (req.Result.Trim() != "OK")
            {
                c.ForeColor = Color.Red;
            }
            c.Text = req.Result;
            r.Cells.Add(c);

            if (req.Result.Trim() == "OK")
            {
                c = new TableCell();
                c.Text = "<a href=\"Results.aspx?id=" + req.AreaStringWithThresholdMD5 + "&id2=" + req.AreaStringMD5 + "\" class=\"small orange awesome\">Results</a>";
                r.Cells.Add(c);

                c = new TableCell();
                c.Text = "<a href=\"Excel/" + req.AreaStringMD5 + ".csv\"\" class=\"small awesome\">Excel</a>&nbsp;&nbsp;<a href=\"Excel/" + req.AreaStringMD5 + ".zip\"\" class=\"small awesome\">Zipped</a>";
                r.Cells.Add(c);

                c = new TableCell();
                c.Text = "<a href=\"Cliques/" + req.AreaStringWithThresholdMD5 + ".txt\"\" class=\"small awesome\">Cliques</a>";
                r.Cells.Add(c);
            }

            dest.Rows.Add(r);
        }
        reqList.Reverse();
    }
Example #15
0
    public static void ConvertFromDec(int number, int baseTo)
    {
        List<int> result = new List<int>();
        if (baseTo > 10)
        {
            while (number > 0)
            {
                result.Add(number % baseTo);
                number = number / baseTo;
            }

            result.Reverse();
            foreach (var item in result)
            {
                switch (item)
                {
                    case 10: Console.Write("A");
                        break;
                    case 11: Console.Write("B");
                        break;
                    case 12: Console.Write("C");
                        break;
                    case 13: Console.Write("D");
                        break;
                    case 14: Console.Write("E");
                        break;
                    case 15: Console.Write("F");
                        break;
                    default: Console.Write(item);
                        break;
                }
            }

            Console.WriteLine();
        }
        else
        {
            while (number > 0)
            {
                result.Add(number % baseTo);
                number = number / baseTo;
            }

            result.Reverse();
            foreach (var item in result)
            {
                Console.Write(item);
            }

            Console.WriteLine();
        }
    }
Example #16
0
        public static void putKeyWordInCache(string keyword,string section)
        {

            if (File.Exists(filePath.KEYWORDFILEPATH))
            {

                StringBuilder temp = new StringBuilder(KEYWORDLENGTH);
                int re = GetPrivateProfileString(section, "history", "", temp, KEYWORDLENGTH, filePath.KEYWORDFILEPATH);
                string t = temp.ToString();
                
                char[] chSplit = ",".ToCharArray();
                string[] key = t.Split(chSplit);
                
                List<string> keyList = new List<string>(key);

                if (keyList.Contains(keyword))
                {
                    if (keyword != keyList[0])
                    {                      
                        keyList.Remove(keyword);
                        keyList.Reverse();
                        keyList.Add(keyword);
                        keyList.Reverse();
                    }
                }
                else
                {
                    if (keyList.Count() == CACHESIZE)
                    {
                        keyList.Remove(keyList[CACHESIZE - 1]);
                    }
                    keyList.Reverse();
                    keyList.Add(keyword);
                    keyList.Reverse();
                }

                string value = null;
                foreach (string s in keyList)
                {
                    if (keyList.Last() != s)
                        value += s + ",";
                    else
                        value += s;
                }

                WritePrivateProfileString(section, "history", value, filePath.KEYWORDFILEPATH);

            }
        }
 static void Main(string[] args)
 {
     using (StreamReader reader = File.OpenText(args[0]))
         while (!reader.EndOfStream)
         {
             string line = reader.ReadLine();
             if (null == line)
                 continue;
             string[] Timestamps = line.Trim().Split(' ');
             Dictionary<int, string> output = new Dictionary<int, string>();
             List<int> timediff = new List<int>();
             foreach(string item in Timestamps)
             {
                 string[] hhmmss = item.Split(':');
                 int time = Convert.ToInt32(hhmmss[0]) * 3600 + Convert.ToInt32(hhmmss[1]) * 60 + Convert.ToInt32(hhmmss[2]);
                 output.Add(time,item);
                 timediff.Add(time);
             }
             timediff.Sort();
             timediff.Reverse();
             foreach(var item in timediff)
             {
                 Console.Write(output[item]+' ');
             }
             Console.WriteLine();
         }
 }
        public PathViewModel(RepositoryNavigationRequest request, AbstractTreeNode node)
        {
            Elements = new List<Element>();

            CurrentItem = new Element(
                new RepositoryNavigationRequest(request) { Path = node.Path },
                request.Treeish,
                node);

            var currentNode = node;

            while (currentNode.Parent != null)
            {
                currentNode = currentNode.Parent;
                if (currentNode.Parent != null)
                {
                    Elements.Add(
                        new Element(new RepositoryNavigationRequest(request) { Path = currentNode.Path },
                        request.Treeish,
                        currentNode));
                }
            }

            Elements = new List<Element>(Elements.Reverse());
            Root = new Element(request, request.Treeish, currentNode);
            IsRootEqualToCurrentItem = (currentNode == node);
        }
        public override void Start()
        {
            if (_actuator.Actuators.Count < 2)
            {
                return;
            }

            Frames.Clear();

            var orderedActuators = new List<IStateMachine>(_actuator.Actuators);
            if (!_isForward)
            {
                orderedActuators.Reverse();
            }

            double frameLength = _duration.TotalMilliseconds/(orderedActuators.Count - 1);

            for (int i = 0; i < orderedActuators.Count; i++)
            {
                var actuator = orderedActuators[i];
                var offset = TimeSpan.FromMilliseconds(frameLength * i);

                WithFrame(new Frame().WithTargetState(actuator, _targetState).WithStartTime(offset));
            }

            var lastFrame = new Frame().WithStartTime(_duration);
            foreach (var actuator in _actuator.Actuators)
            {
                lastFrame.WithTargetState(actuator, _targetState);
            }

            WithFrame(lastFrame);
            base.Start();
        }
        public string GetTitle()
        {
            string title = "";

            if (ParentFrame == null)
            {
                title = "DefaultContent";
            }
            else
            {
                List<string> frameTitles = new List<string>();
                var frame = this;
                while (frame.ParentFrame != null)
                {
                    string frameTitle = !String.IsNullOrEmpty(frame.LocatorNameOrId)
                                        ? frame.LocatorNameOrId
                                        : frame.Index.ToString();
                    frameTitles.Add(frameTitle);
                    frame = frame.ParentFrame;
                }

                frameTitles.Reverse();

                title = String.Join(".", frameTitles);
            }

            return title;
        }
Example #21
0
        public Position GetNextPosition(Position playerPosition)
        {
            _positions = Waypoints.ToList();

            if (_position == _positions.Count)
            {
                if (StraightRoute)
                {
                    Waypoints = new ObservableCollection<Position>(Waypoints.Reverse());
                    _positions.Reverse();
                }
                _position = 0;
            }

            var distance = Distance(playerPosition, _positions[_position]);

            if (distance > 15)
            {
                var closest = _positions.OrderBy(x => Distance(playerPosition, x)).FirstOrDefault();
                _position = _positions.IndexOf(closest);
            }

            var newPosition = _positions[_position];

            _position++;

            return newPosition;
        }
Example #22
0
        public static IEnumerable<Page> Breadcrumb()
        {
            List<Page> breadcrumbPages = new List<Page>();
            var defaultPage = ServiceFactory.PageManager.GetDefaultPage(Page_Context.Current.PageRequestContext.Page.Site);
            if (defaultPage == Page_Context.Current.PageRequestContext.Page)
            {
                return breadcrumbPages;
            }
            var currentPage = Page_Context.Current.PageRequestContext.Page.Parent;
            while (currentPage != null)
            {
                currentPage = currentPage.LastVersion(Page_Context.Current.PageRequestContext.Site).AsActual();

                if (currentPage.Navigation != null
                    && currentPage.Navigation.ShowInCrumb.Value == true && currentPage.Published.HasValue && currentPage.Published.Value == true)
                {
                    breadcrumbPages.Add(currentPage);
                }

                currentPage = currentPage.Parent;
            }
            if (breadcrumbPages.LastOrDefault() != defaultPage)
            {
                defaultPage = defaultPage.AsActual();

                if (defaultPage.Navigation != null
                && defaultPage.Navigation.ShowInCrumb.Value == true && defaultPage.Published.HasValue && defaultPage.Published.Value == true)
                {
                    breadcrumbPages.Add(defaultPage);
                }
            }

            breadcrumbPages.Reverse();
            return breadcrumbPages;
        }
Example #23
0
    static void Main(string[] args)
    {
        Console.Write("Write a decimal number to convert to hex: ");
        int num = int.Parse(Console.ReadLine());
        int remainder;

        List<int> hexNumber = new List<int>();

        do
        {
            remainder = num % 16;
            hexNumber.Add(remainder);
            num = num / 16;
        } while (num != 0);

        hexNumber.Reverse();

        Console.Write("\nThe hex representation of the number you entered is: ");
        for (int i = 0; i < hexNumber.Count; i++)
        {
            if (hexNumber[i] > 9)
            {
                Console.Write("{0} ", (char)(hexNumber[i]+55)); // you look at the ASCII table you will see that from 65 -> the symbols are "A,B,C...."
            }
            else
            Console.Write("{0} ", hexNumber[i]);
        }
        Console.WriteLine("\n");
    }
 /// <summary>
 ///     Formats the given parameters to call a function.
 /// </summary>
 /// <param name="parameters">An array of parameters.</param>
 /// <returns>The mnemonics to pass the parameters.</returns>
 public string FormatParameters(IntPtr[] parameters)
 {
     // Declare a var to store the mnemonics
     var ret = new StringBuilder();
     var paramList = new List<IntPtr>(parameters);
     // Store the first parameter in the ECX register
     if (paramList.Count > 0)
     {
         ret.AppendLine("mov ecx, " + paramList[0]);
         paramList.RemoveAt(0);
     }
     // Store the second parameter in the EDX register
     if (paramList.Count > 0)
     {
         ret.AppendLine("mov edx, " + paramList[0]);
         paramList.RemoveAt(0);
     }
     // For each parameters (in reverse order)
     paramList.Reverse();
     foreach (var parameter in paramList)
     {
         ret.AppendLine("push " + parameter);
     }
     // Return the mnemonics
     return ret.ToString();
 }
Example #25
0
    public override void LoadWidget()
    {
        StringDictionary settings = GetSettings();
        int numberOfComments = DEFAULT_NUMBER_OF_COMMENTS;
        if (settings.ContainsKey("numberofcomments"))
            numberOfComments = int.Parse(settings["numberofcomments"]);

        if (HttpRuntime.Cache["widget_recentcomments"] == null)
        {
            List<Comment> comments = new List<Comment>();

            foreach (Post post in Post.Posts)
            {
                if (post.IsVisible)
                {
                    comments.AddRange(post.Comments.FindAll(delegate(Comment c) { return c.IsApproved && c.Email.Contains("@"); }));
                }
            }

            comments.Sort();
            comments.Reverse();

            int max = Math.Min(comments.Count, numberOfComments);
            List<Comment> list = comments.GetRange(0, max);
            HttpRuntime.Cache.Insert("widget_recentcomments", list);
        }

        string content = RenderComments((List<Comment>)HttpRuntime.Cache["widget_recentcomments"], settings);

        LiteralControl html = new LiteralControl(content); //new LiteralControl((string)HttpRuntime.Cache["widget_recentcomments"]);
        phPosts.Controls.Add(html);
    }
Example #26
0
        public static List<List<int>> GetYarns(int finalSequenceLength, int yarnLength, bool reverse)
        {
            if ((finalSequenceLength - yarnLength) % ( yarnLength -1)  != 0)
            {
                throw new ArgumentException("finalSequenceLength and yarnLength are incompatible");
            }

            var yarnCount = finalSequenceLength / yarnLength;

            var yarns = new List<List<int>>();
            int start = 1;

            int loops = 1 + (finalSequenceLength - yarnLength) / (yarnLength - 1);

            for (int i = 0; i < loops; i++)
            {
                var yarn = Enumerable.Range(start, yarnLength);
                yarns.Add(yarn.ToList());
                start += yarnLength - 1;
            }

            if (reverse)
            {
                yarns.Reverse();
            }

            return yarns;
        }
Example #27
0
 private void exploreXafErrors_Execute(ExecuteEventArgs ea) {
     Project startUpProject = CodeRush.ApplicationObject.Solution.FindStartUpProject();
     Property outPut = startUpProject.ConfigurationManager.ActiveConfiguration.FindProperty(ConfigurationProperty.OutputPath);
     bool isWeb = IsWeb(startUpProject);
     string fullPath = startUpProject.FindProperty(ProjectProperty.FullPath).Value + "";
     string path = Path.Combine(fullPath, outPut.Value.ToString()) + "";
     if (isWeb)
         path = Path.GetDirectoryName(startUpProject.FullName);
     Func<Stream> streamSource = () => {
         var path1 = path + "";
         File.Copy(Path.Combine(path1, "expressAppFrameWork.log"), Path.Combine(path1, "expressAppFrameWork.locked"), true);
         return File.Open(Path.Combine(path1, "expressAppFrameWork.locked"), FileMode.Open, FileAccess.Read, FileShare.Read);
     };
     var reader = new ReverseLineReader(streamSource);
     var stackTrace = new List<string>();
     foreach (var readline in reader) {
         stackTrace.Add(readline);
         if (readline.Trim().StartsWith("The error occured:") || readline.Trim().StartsWith("The error occurred:")) {
             stackTrace.Reverse();
             string errorMessage = "";
             foreach (string trace in stackTrace) {
                 errorMessage += trace + Environment.NewLine;
                 if (trace.Trim().StartsWith("----------------------------------------------------"))
                     break;
             }
             Clipboard.SetText(errorMessage);
             break;
         }
     }
 }
Example #28
0
        /* Patter for combinations (from largest to smallest)
        10 * 10
        10 * 9
        9 * 9
        10 * 8
        9 * 8
        10 * 7
        8 * 8
        9 * 7

        8 * 7
        7 * 7
        7 * 6
        */
        static void Main(string[] args)
        {
            int result = 0;
            int min = 800; // Speed things up... don't test all the numbers.
            int max = 999;
            List<int> products = new List<int>(max * max);
            for (int ii = max; ii >= min; ii--) // Only 3 digit numbers
            {
                for (int jj = ii; jj > min; jj--)
                {
                    int product = ii * jj;
                    if (!products.Contains(product))
                    {
                        products.Add(product);
                    }
                }
            }

            products.Sort();
            products.Reverse();

            foreach( int product in products)
            {
                if (is_palindrom(product))
                {
                    result = product;
                    break;
                }
            }

            Console.WriteLine(result);
            Console.WriteLine("Press ENTER to Exit");
            Console.ReadLine();
        }
                private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
                {
                    var path = new List<int>();
                    var root = _tree.GetRoot();

                    while (node != root)
                    {
                        for (; node.Parent != null; node = node.Parent)
                        {
                            var index = GetChildIndex(node);
                            path.Add(index);
                        }

                        // if we were part of structure trivia, continue searching until we get to the true root
                        if (node.IsStructuredTrivia)
                        {
                            var trivia = node.ParentTrivia;
                            var triviaIndex = GetTriviaIndex(trivia);
                            path.Add(triviaIndex);
                            var tokenIndex = GetChildIndex(trivia.Token);
                            path.Add(tokenIndex);
                            node = trivia.Token.Parent;
                            continue;
                        }
                        else if (node != root)
                        {
                            throw new InvalidOperationException(CSharpWorkspaceResources.Node_does_not_descend_from_root);
                        }
                    }

                    path.Reverse();
                    return path.ToImmutableArray();
                }
Example #30
0
        public static List<string> PathToDirectoryList(string path)
        {
            var namestack = new List<string>();

            if (path == Path.GetPathRoot(path))
            {
                namestack.Add(path);
                return namestack;
            }

            while (true)
            {
                var currentlevel = Path.GetFileName(path) ?? string.Empty;
                if (currentlevel.Length > 0)
                {
                    path = path.Remove(path.Length - currentlevel.Length);
                }
                namestack.Add(currentlevel);
                if (path == Path.GetPathRoot(path))
                {
                    namestack.Add(path);
                    break;
                }
                path = path.TrimEnd('\\');
            }
            namestack.Reverse();
            return namestack;
        }