①Env.csにライン種類の変数を作成
        public enum Linemode { FreeLine, Horizontal, Fibonacci };
        private static Linemode _linemode;
        public static Linemode LineMode {
            get { return _linemode; }
            set { _linemode = value ; }
        }
②command.csのCIDに追加
        ToggleFreeline,
        ToggleHorizontal,
        ToggleFibonatti,
「internal class CommandExec {」にライン変更コマンドを追加
         public static CommandResult ChangeLineMode( Env.Linemode mode) {
            Env.LineMode = mode;
            Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "FreeLine"].Checked = false ;
            Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "Horizontal"].Checked = false ;
            Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "Fibonatti"].Checked = false ;
            switch (mode)
            {
                case Env .Linemode.Horizontal:
                    Env.Frame.SetStatusBarText("水平線の描画" , "Click Price");
                    Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "Horizontal"].Checked = true;
                    break;
                case Env .Linemode.Fibonacci:
                    Env.Frame.SetStatusBarText("フィボナッチ リトレースメント" , "Click and Drag");
                    Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "Fibonatti"].Checked = true;
                    break;
                default:
                    Env.Frame.SetStatusBarText("" , "");
                    Env.Frame.Menu.MenuItems[1].MenuItems["LineMode"].MenuItems[ "FreeLine"].Checked = true;
                    break;
            }
            RefreshChart();
            return CommandResult .Succeeded;
        }
さらに「public CommandResult Exec() {」に以下を追加
  case CID .ToggleFreeline:
      return CommandExec .ChangeLineMode(Env.Linemode.FreeLine);
  case CID .ToggleHorizontal:
      return CommandExec .ChangeLineMode(Env.Linemode.Horizontal);
  case CID .ToggleFibonatti:
      return CommandExec .ChangeLineMode(Env.Linemode.Fibonacci);
「internal class CommandCollection : ICloneable {」の「private void Init(StorageNode keys) {」に以下を追加
            AddCommand( CID.ToggleFreeline, "Free Line" , keys, Keys.None);
            AddCommand( CID.ToggleHorizontal, "Horizontal Line" , keys, Keys.None);
            AddCommand( CID.ToggleFibonatti, "Fibonatti" , keys, Keys.None);
③ライン種類選択用のメニュー作成
MainFrame.cs
        private ZMenuItem _menuLineMode;
        private ZMenuItem _menuFreeLine;
        private ZMenuItem _menuHorizontal;
        private ZMenuItem _menuFibonatti;
さらに「InitializeComponent()」で各変数初期化を追加
            this._menuLineMode = new ZMenuItem();
            this._menuFreeLine = new ZMenuItem();
            this._menuHorizontal = new ZMenuItem();
            this._menuFibonatti = new ZMenuItem();
// _menuView のメニューにこれを追加
「this._menuView.MenuItems.AddRange(」の中に , this._menuLineMode を追加
追加した位置番号に以下を追加(以下は9[10番目]に追加した例)
   this._menuLineMode.Index = 9;
       this._menuLineMode.MenuItems.AddRange(new ZMenuItem[] {
       this._menuFreeLine, this._menuHorizontal, this._menuFibonatti});
            this._menuLineMode.Text = "Line Mode" ;
            this._menuLineMode.Name = "LineMode" ;
            this._menuFreeLine.Index = 0;
            this._menuFreeLine.Text = "Free Line" ;
            this._menuFreeLine.Name = "FreeLine" ;
            this._menuFreeLine.Checked = true ;
            this._menuFreeLine.Click += new System.EventHandler( this.OnMenu);
            this._menuFreeLine.CID = CID .ToggleFreeline;
            this._menuHorizontal.Index = 1;
            this._menuHorizontal.Text = "Horizontal Line" ;
            this._menuHorizontal.Name = "Horizontal" ;
            this._menuHorizontal.Click += new System.EventHandler( this.OnMenu);
            this._menuHorizontal.CID = CID .ToggleHorizontal;
            this._menuFibonatti.Index = 2;
            this._menuFibonatti.Text = "Fibonatti Retracement" ;
            this._menuFibonatti.Name = "Fibonatti" ;
            this._menuFibonatti.Click += new System.EventHandler( this.OnMenu);
            this._menuFibonatti.CID = CID .ToggleFibonatti;
これ以降のIndexの番号(元の9以降)を変更しておく
④FreeLine.csの「internal class FreeLine {」に変数等追加
  private bool _price;
       public FreeLine(Point p1, Point p2, bool price) {
           _pivot = p1;
           _destination = p2;
           _id = -1;
           _price = price;
        }
        public bool Price {
            get { return _price; }
  }

       public SolidFreeLine ToSolid(DataFarm farm, int firstdateindex, Trans value_to_y, bool showPrice){
           SolidFreeLine fl = ToSolid(farm, firstdateindex, value_to_y);
           fl.WithSpace = showPrice;
           return fl;
       }
「internal class SolidFreeLine {」に以下を追加
       private bool _withprice = false;
       public bool WithSpace {
           get { return _withprice; }
           set { _withprice = value ; }
        }
⑤ChartDrawing.csの「internal class ChartDrawing」に以下を追加
      public void FixFreeLine(FreeLine fl, bool showPrice){
          Env.FreeLines.Add(_brand, Env .CurrentIndicators.Format, _pref.LogScale, fl.ToSolid(_brand.ReserveFarm(), _firstDateIndex, _priceTrans, showPrice));
             _freeLines.Add(fl);
      }
⑥ChartCanvas.cs
ローカル変数追加
      private FreeLine _horizontalLine;
      private FreeLine [] _fibonattiLine;
      private int _posY;
      private Point [] _pointFibo;
「protected override void OnMouseDown( MouseEventArgs e) {」の以下をコメントまたは削除
      foreach (FreeLine line in _drawing.FreeLines)
      {
          if (line.DrawMode == FreeLine .LineDrawMode.Hilight && e.Button == MouseButtons.Left)
          {
               _diffX = line.Destination.X - line.Pivot.X;
              _diffY = line.Destination.Y - line.Pivot.Y;
               _destX = line.Destination.X;
               _destY = line.Destination.Y;
               _pivotX = line.Pivot.X;
               _pivotY = line.Pivot.Y;
           }
      }
   _currentFreeLine = new FreeLine (new Point(e.X, e.Y));
以下に変更
     switch (Env .LineMode) {
         case Env .Linemode.Horizontal:
             _pointFibo = null;
              _fibonattiLine = null;
              _posY = e.Y;
             Commands. CommandExec.ChangeLineMode(Env .Linemode.FreeLine);
             _currentFreeLine = null;
             break;
         case Env .Linemode.Fibonacci:
             _fibonattiLine = new FreeLine [5];
              _pointFibo = new Point [2];
              _pointFibo[0] = new Point (e.X, e.Y);
             _currentFreeLine = null;
             int priceWidth = 60;
             _fibonattiLine[0] = new FreeLine (new Point(priceWidth, _pointFibo[0].Y), new Point(Env.Layout.ChartAreaWidth, _pointFibo[0].Y), true);
             _drawing.FixFreeLine(_fibonattiLine[0], true);
             break;
       default:
            _fibonattiLine = null;
            _pointFibo = null;
           _currentFreeLine = new FreeLine (new Point(e.X, e.Y));
           break;
     }

「protected override void OnMouseMove( MouseEventArgs ev) {」の
「//今引いている直線の再描画」の直後に以下を追加
      if (_fibonattiLine != null && _pointFibo != null)
      {
          _pointFibo[1] = new Point (ev.X, ev.Y);
          _fibonattiLine[4] = new FreeLine (_pointFibo[1]);
          Invalidate(_fibonattiLine[4].GetInclusion( this.ClientRectangle), false );
          _fibonattiLine[4].Destination = new Point (Env.Layout.ChartAreaWidth, _pointFibo[1].Y);
      }

「private void OnMouseUp( object sender, MouseEventArgs args) {」を以下にすべて変更
 private void OnMouseUp(object sender, MouseEventArgs args) {
    if(args.Button==MouseButtons .Right) {
      ContextMenu m = Env .Frame.CreateContextMenu();
      m.Show( this, new Point(args.X, args.Y));
    }
    else if (args.Button==MouseButtons.Left) {
      if(_currentFreeLine!=null ) {
        if(_drawing.FreeLineCount==10) {
          Util.Warning(Env .Frame, "線は1銘柄につき10本までしか引けません" );
          Invalidate();
        }
      else if (Env.FreeLines.Count==1000) {
        Util.Warning(Env .Frame, "線は全部で1000本までしか引けません" );
        Invalidate();
      }
      else if (_currentFreeLine.PivotHasEnoughDistanceTo(_currentFreeLine.Destination))
      {
        switch (Env .LineMode)
        {
          case Env .Linemode.Fibonacci:
            Commands. CommandExec.ChangeLineMode(Env .Linemode.FreeLine);
            break;
          default:
            _drawing.FixFreeLine(_currentFreeLine);
            break;
       }
     }
     _currentFreeLine = null;
   }
   else
   {
     switch (Env .LineMode)
     {
       case Env .Linemode.Fibonacci:
         if (_pointFibo != null )
         {
           _pointFibo[1] = new Point (args.X, args.Y);
           int priceWidth = 60;
           int[] y = new int[5];
           y[0] = _pointFibo[0].Y;
           y[4] = _pointFibo[1].Y;
           y[1] = System.Convert.ToInt32(y[0] + (y[4] - y[0]) * 0.382);
           y[2] = System.Convert.ToInt32(y[0] + (y[4] - y[0]) * 0.5);
           y[3] = System.Convert.ToInt32(y[0] + (y[4] - y[0]) * 0.618);
           for (int i = 1; i < 5; i++)
           {
             _fibonattiLine[i] = new FreeLine(new Point(priceWidth, y[i]), new Point (Env.Layout.ChartAreaWidth, y[i]), true);
             _drawing.FixFreeLine(_fibonattiLine[i], true);
           }
           _pointFibo = null;
           Commands. CommandExec.ChangeLineMode(Env .Linemode.FreeLine);
        }
        break;
      }
    }
     if (_drawing.RemoveHighlitedFreeLines()) Invalidate(); //削除されたやつがあればInvalidate
   }
  }