Example #1
0
        protected override void OnMouseRightButtonUp(MouseButtonEventArgs e)
        {
            Point position = e.GetPosition(this);

            DisplayBlock block = m_layout == null ? null : m_layout.Blocks.FirstOrDefault(x => x.CommitPosition.Contains(position));

            if (block != null)
            {
                int         lineIndex       = (int)(position.Y / m_layout.LineHeight);
                DisplayLine displayLine     = m_layout.Lines[lineIndex];
                Line        line            = m_blame.Lines[displayLine.LineNumber - 1];
                int         previousTopLine = Math.Max(1, line.OldLineNumber - lineIndex);

                Commit commit = block.RawCommit;
                m_blamePreviousMenuItem.CommandParameter      = commit.PreviousCommitId == null ? null : new BlamePreviousModel(commit.PreviousCommitId, commit.PreviousFileName, previousTopLine);
                m_viewCommitAtGitHubMenuItem.CommandParameter = m_blame.WebRootUrl != null && commit.Id != GitWrapper.UncommittedChangesCommitId ? new Uri(m_blame.WebRootUrl, "commit/" + commit.Id) : null;
                m_viewLineAtGitHubMenuItem.CommandParameter   = m_blame.WebRootUrl != null && commit.Id != GitWrapper.UncommittedChangesCommitId ? new Uri(m_blame.WebRootUrl, "blob/{0}/{1}#L{2}".FormatInvariant(commit.Id, block.RawBlock.FileName, line.LineNumber)) : null;
                ContextMenu.IsOpen = true;
            }
            else
            {
                m_blamePreviousMenuItem.CommandParameter      = null;
                m_viewCommitAtGitHubMenuItem.CommandParameter = null;
                m_viewLineAtGitHubMenuItem.CommandParameter   = null;
            }

            e.Handled = true;
            base.OnMouseRightButtonUp(e);
        }
Example #2
0
        public void ClearLine(DisplayLine line)
        {
            SendCommand((int)line);

            for (int i = 0; i < WIDTH; i++)
            {
                SendData(0x20);
            }
        }
Example #3
0
        private DisplayLine AdvanceLine(DisplayLine currentLine, DisplayLine lineToResetTo = DisplayLine.LineOne)
        {
            DisplayLine newLine = DisplayLine.LineOne;

            switch (currentLine)
            {
            case DisplayLine.LineOne:
                newLine = DisplayLine.LineTwo;
                break;

            case DisplayLine.LineTwo:
                newLine = DisplayLine.LineThree;
                break;

            case DisplayLine.LineThree:
                newLine = DisplayLine.LineFour;
                break;

            case DisplayLine.LineFour:
                newLine = lineToResetTo;

                Sleep(500);

                if (lineToResetTo == DisplayLine.LineOne)
                {
                    ClearDisplay();
                }
                else
                {
                    switch (lineToResetTo)
                    {
                    case DisplayLine.LineTwo:
                        ClearLine(DisplayLine.LineTwo);
                        ClearLine(DisplayLine.LineThree);
                        ClearLine(DisplayLine.LineFour);
                        break;

                    case DisplayLine.LineThree:
                        ClearLine(DisplayLine.LineThree);
                        ClearLine(DisplayLine.LineFour);
                        break;

                    case DisplayLine.LineFour:
                        ClearLine(DisplayLine.LineFour);
                        break;
                    }
                }
                break;
            }

            SendCommand((int)newLine);

            return(newLine);
        }
Example #4
0
        public void WriteString(string str, DisplayLine startLine = DisplayLine.LineOne)
        {
            int currentCharInLine    = 1;
            int remainingCharsInLine = WIDTH;

            DisplayLine currentLine = startLine;

            SendCommand((int)currentLine);

            string[] words = str.Split(' ');

            foreach (string word in words)
            {
                bool   breakWord   = false;
                byte[] asciiValues = Encoding.ASCII.GetBytes(word);

                remainingCharsInLine = WIDTH - currentCharInLine;

                if ((remainingCharsInLine == 0 && word.Length <= WIDTH) || (word.Length > remainingCharsInLine && word.Length <= WIDTH))
                {
                    currentLine       = AdvanceLine(currentLine, startLine);
                    currentCharInLine = 1;
                }
                else if (word.Length > WIDTH)
                {
                    breakWord = true;
                }

                for (int i = 0; i < word.Length; i++)
                {
                    remainingCharsInLine = WIDTH - currentCharInLine;
                    if (remainingCharsInLine == 0 && breakWord)
                    {
                        if (i != 0)
                        {
                            // only write the - if we have actually started writing the word
                            SendData(0x2D);
                        }

                        currentLine       = AdvanceLine(currentLine, startLine);
                        currentCharInLine = 1;
                    }

                    SendData(asciiValues[i]);
                    currentCharInLine++;
                }

                SendData(0x20);
                currentCharInLine++;
            }
        }
Example #5
0
    public void Add(DisplayLine line)
    {
        Lines.Add(line);
        int max = 0;

        foreach (var linec in Lines)
        {
            max = Math.Max(linec.TotalSize, max);
        }
        foreach (var linec in Lines)
        {
            linec.TotalSize = max;
        }
    }
Example #6
0
        protected UIItem(string name) : base(name)
        {
            var texts = new List <DisplayText>();

            for (int i = 0; i < _prop.Sizes.Count; i++)
            {
                texts.Add(new DisplayText());
            }
            Display = new DisplayLine
            {
                Canvas = _prop,
                Texts  = texts
            };
            Display.Texts[_prop.DynamicIndex] = new DisplayText(name, 0);                    //err
        }
Example #7
0
        public void WriteStringOnLine(string str, DisplayLine line = DisplayLine.LineOne, LineJustification justification = LineJustification.Left)
        {
            SendCommand((int)line);

            if (justification != LineJustification.Left)
            {
                str = JustifyString(str, justification);
            }

            byte[] asciiValues = Encoding.ASCII.GetBytes(str);

            for (int i = 0; i < str.Length && i < WIDTH; i++)
            {
                SendData(asciiValues[i]);
            }
        }
Example #8
0
            public void Test_TotalSize_and_Length()
            {
                DisplayLine line1 = new DisplayLine
                {
                    Canvas = new DisplayCanvas
                    {
                        Sizes = new List <int> {
                            0
                        },
                        DynamicIndex = 0
                    },
                    Texts = new List <DisplayText>
                    {
                        new DisplayText("test", 4)
                    }
                };//Total size = 4

                line1.TotalSize.Should().Be(line1.ToString().Length);
            }
Example #9
0
            public void Test_complex_display_dynamic_dimensions_with_lines()
            {
                ComplexDisplay display = new ComplexDisplay();

                DisplayLine line1 = new DisplayLine
                {
                    Canvas = new DisplayCanvas
                    {
                        Sizes = new List <int> {
                            0
                        },
                        DynamicIndex = 0
                    },
                    Texts = new List <DisplayText>
                    {
                        new DisplayText("test", 4)
                    }
                };//Total size = 4

                DisplayLine line2 = new DisplayLine
                {
                    Canvas = new DisplayCanvas
                    {
                        Sizes = new List <int> {
                            0
                        },
                        DynamicIndex = 0
                    },
                    Texts = new List <DisplayText>
                    {
                        new DisplayText("test", 5)
                    }
                };                  //Total size = 5

                display.Add(line1); //base size = 4
                display.Add(line2); //base size = 5
                //display.Add() modifies the size of each line so their size is equal to the longest line.
                //This is necessary so that lines with text after their name align.
                line1.TotalSize.Should().Be(5);
            }
        public void Setup()
        {
            m_PointOne = new Point(-10.0,
                                   -10.0);
            m_PointTwo = new Point(10.0,
                                   10.0);
            m_Points = new[]
                       {
                           m_PointOne,
                           m_PointTwo
                       };

            m_Line = new Line(0,
                              -10.0,
                              0.0,
                              10.0,
                              20.0);

            m_Converter = Substitute.For <ILineToWindowPointsConverter>();
            m_Converter.Points.Returns(m_Points);

            m_Sut = new DisplayLine(m_Converter,
                                    m_Line);
        }
Example #11
0
    public async Task Create()
    {
      var market = Market.DE;
      var curve = SwapCurve.EUROIS;

      var mkt = await BondMarket.Get(market, getCC());

      var datesContext = mkt.Today;

      var fwdDate =
        await
          getCC()
            .RollDateAsync(datesContext.SpotSettle.ToNodaLocalDate(), 3, Symmetry.Carbon.Model.DateUnit.M,
              Symmetry.Carbon.Model.BusinessDayConvention.Following, market.HolidayCode());

      var cmtstructure = mkt.CreateCMTStructure();

      var pricerSpot = await BondMarketPricer.Create(mkt, curve, datesContext, datesContext.SpotSettle, getCC());
      var pricerFwd = await BondMarketPricer.Create(mkt, curve, datesContext, fwdDate.ToDateTime(), getCC());

      var measures = new[] {BondMeasure.Yield, BondMeasure.MMS, BondMeasure.ASWyy, BondMeasure.ZSpread};
      var tenors = ExtensionMethods.CreateArray(1.25d, 52, x => x + 0.5d);

      Array.ForEach(tenors, tenor =>
      {
        var line = new DisplayLine();
        line.SetValue(DisplayLineField.Tenor, tenor, false);
        m_lines.Add(line);
        m_tenorToLine[line.Tenor] = line;
      });

      foreach (var measure in measures)
      {
        var cmtSpotImpl = cmtstructure.CreateCMTImpl(
          field_: measure,
          pricer_: pricerSpot,
          curve_: curve);

        var cmtFwdImpl = cmtstructure.CreateCMTImpl(
          field_: measure,
          pricer_: pricerFwd,
          curve_: curve);

        foreach (var tenor in tenors)
        {
          {
            var point = cmtSpotImpl.GetLivePoint(tenor, 1);
            point.ValueUpdated += handleSpotPointUpdated;
            if (!point.Value.IsZero())
              setSpotValueFromPoint(point);
          }
          {
            var point = cmtFwdImpl.GetLivePoint(tenor, 1);
            point.ValueUpdated += handleFwdPointUpdated;
            if (!point.Value.IsZero())
              setfwdValueFromPoint(point);
          }
        }
      }

      boundInfraGrid1.Bind(m_lines);
    }
Example #12
0
        private DisplayLine AdvanceLine(DisplayLine currentLine, DisplayLine lineToResetTo = DisplayLine.LineOne)
        {
            DisplayLine newLine = DisplayLine.LineOne;

            switch (currentLine)
            {
                case DisplayLine.LineOne:
                    newLine = DisplayLine.LineTwo;
                    break;
                case DisplayLine.LineTwo:
                    newLine = DisplayLine.LineThree;
                    break;
                case DisplayLine.LineThree:
                    newLine = DisplayLine.LineFour;
                    break;
                case DisplayLine.LineFour:
                    newLine = lineToResetTo;

                    Sleep(500);

                    if (lineToResetTo == DisplayLine.LineOne)
                    {
                        ClearDisplay();
                    }
                    else
                    {
                        switch (lineToResetTo)
                        {
                            case DisplayLine.LineTwo:
                                ClearLine(DisplayLine.LineTwo);
                                ClearLine(DisplayLine.LineThree);
                                ClearLine(DisplayLine.LineFour);
                                break;
                            case DisplayLine.LineThree:
                                ClearLine(DisplayLine.LineThree);
                                ClearLine(DisplayLine.LineFour);
                                break;
                            case DisplayLine.LineFour:
                                ClearLine(DisplayLine.LineFour);
                                break;
                        }
                    }
                    break;
            }

            SendCommand((int)newLine);

            return newLine;
        }
Example #13
0
        public void WriteStringOnLine(string str, DisplayLine line = DisplayLine.LineOne, LineJustification justification = LineJustification.Left)
        {
            SendCommand((int)line);

            if (justification != LineJustification.Left)
            {
                str = JustifyString(str, justification);
            }

            byte[] asciiValues = Encoding.ASCII.GetBytes(str);

            for (int i = 0; i < str.Length && i < WIDTH; i++)
            {
                SendData(asciiValues[i]);
            }
        }
Example #14
0
        public void WriteString(string str, DisplayLine startLine = DisplayLine.LineOne)
        {
            int currentCharInLine = 1;
            int remainingCharsInLine = WIDTH;

            DisplayLine currentLine = startLine;
            SendCommand((int)currentLine);

            string[] words = str.Split(' ');

            foreach (string word in words)
            {
                bool breakWord = false;
                byte[] asciiValues = Encoding.ASCII.GetBytes(word);

                remainingCharsInLine = WIDTH - currentCharInLine;

                if ((remainingCharsInLine == 0 && word.Length <= WIDTH) || (word.Length > remainingCharsInLine && word.Length <= WIDTH))
                {
                    currentLine = AdvanceLine(currentLine, startLine);
                    currentCharInLine = 1;
                }
                else if (word.Length > WIDTH)
                {
                    breakWord = true;
                }

                for (int i = 0; i < word.Length; i++)
                {
                    remainingCharsInLine = WIDTH - currentCharInLine;
                    if (remainingCharsInLine == 0 && breakWord)
                    {

                        if (i != 0)
                        {
                            // only write the - if we have actually started writing the word
                            SendData(0x2D);
                        }

                        currentLine = AdvanceLine(currentLine, startLine);
                        currentCharInLine = 1;
                    }

                    SendData(asciiValues[i]);
                    currentCharInLine++;
                }

                SendData(0x20);
                currentCharInLine++;
            }
        }
Example #15
0
        public void ClearLine(DisplayLine line)
        {
            SendCommand((int)line);

            for (int i = 0; i < WIDTH; i++)
            {
                SendData(0x20);
            }
        }
 public LDC_DispLine_Link(LiveDayComparison ldc_, DisplayLine line_ )
 {
 }