///////////////////////////////////////////
//ListViewの項目の並び替えに使用するクラス
///////////////////////////////////////////
public class ListViewItemComparer : IComparer
{
private int m_column;
private static int m_order = 1; //毎回呼ばれるたびに正順、逆順を交代させるフラグ
/////////////////////////////////////////////////
//命令セットクラス(名称と説明付きの命令セット)
/////////////////////////////////////////////////
public class TGSet
{ //クラスメンバー List<int[]> CmdSet; //命令配列 public string Name {get; set;} //命令セット名 public string Description {get; set;} //説明
(以下略)
命令リストクラス(TGList)のデータ部分は
///////////////////////////////////////////
//命令リストクラス-命令セットの集合クラス
///////////////////////////////////////////
public class TGList
{ //クラスメンバー List<TGSet> CmdList; public string FileName {get; set;} //ファイル入出力名 (以下略)
///////////////////////////////////////////////////////////////////////////////
// TGEライブラリー (TGE.dll)
// Copyright (c) 2026 by Ysama
//
// 【概要】
//LOGOベースの描画命令を纏めた「命令セット(TGSet)」、その一覧である「命令リス
//ト(TGList)」、「命令リスト」から指定した命令セットで、繰り返しを含め実行順を
//定める「実行リスト(TGList)」及び編集ダイアログをまとめたNakov.TurtleGraphics
//の命令編集ライブラリー
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.Collections.Generic; //Listを使う為
using System.IO; //FIle関係
using System.Text; //Encoding.GetEncoding を使用するのに必要
using Nakov.TurtleGraphics; //TurtleGraphicsを使う為
namespace TGE
{ /////////////////////////////////////////////
//TurtleGraphics命令を編集するラッパークラス
/////////////////////////////////////////////
public class TGEdit {
//クラスフィールド public TGSet CmdSet; //命令セット({コマンド番号, 引数}の整数配列 ) public TGList CmdList; //命令リスト(命令セットの一覧)
public TGList ExeList; //実行リスト(指定する命令セットの実行順リスト)
//コンストラクター
public TGEdit(Form form = null)
{
if(form == null)
Turtle.Init();
else
Turtle.Init(form);
CmdSet = new TGSet();
CmdList = new TGList();
ExeList = new TGList();
}
//TurtleGraphicsのDispose/Reset
public void Reset()
{
Turtle.Reset();
}
//亀の表示/非表示を確認する
public bool IsTurtleShown()
{
return Turtle.ShowTurtle;
}
/////////////////////////////////////////////////
//命令セットクラス(名称と説明付きの命令セット)
/////////////////////////////////////////////////
public class TGSet
{ //クラスメンバー
List<int[]> CmdSet; //命令配列
public string Name {get; set;} //命令セット名
public string Description {get; set;} //説明
//コンストラクター1
public TGSet()
{
CmdSet = new List<int[]>();
Name = String.Empty;
Description = String.Empty;
}
//コンストラクター1
public TGSet(string name, string description)
{
CmdSet = new List<int[]>();
Name = name; //再設定自由
Description = description; //再設定自由
}
//コピーコンストラクター
public TGSet(TGSet copy)
{
CmdSet = new List<int[]>(copy.CmdSet);
Name = copy.Name;
Description = copy.Description;
}
//初期化
public void Clear()
{
CmdSet.Clear();
Name = String.Empty;
Description = String.Empty;
}
//命令セットの命令数
public int Count()
{
return CmdSet.Count;
}
//命令セットの設定(1)
public void Set(TGSet tgs)
{
CmdSet.Clear();
CmdSet = new List<int[]>(tgs.CmdSet);
Name = tgs.Name;
Description = tgs.Description;
}
//命令セットの設定(2)
public void Set(List<int[]> list, string name, string description)
{
CmdSet.Clear();
CmdSet = new List<int[]>(list);
Name = name;
Description = description;
}
//n番目の命令取得
public int[] GetCmd(int n)
{
if(n < 0 || n > CmdSet.Count - 1)
return new int[] {-1, -1, -1, -1}; //エラー
else
return CmdSet[n];
}
//n番目の命令設定(1)(命令番号cmdは必須、定数引数arg1は重要、arg2とarg3はオプション扱い)
public bool SetCmd(int n, int cmd, int arg1, int arg2 = 0, int arg3 = 0)
{
if(n < 0 || n > CmdSet.Count - 1)
return false;
CmdSet[n] = new int[] {cmd, arg1, arg2, arg3}; //Deep copy
return true;
}
//n番目の命令設定(2)
public bool SetCmd(int n, int[] cmd)
{
if(n < 0 || n > CmdSet.Count - 1 || cmd.Length != 4)
return false;
CmdSet[n] = cmd;
return true;
}
//命令の追加(命令番号cmdは必須、定数引数arg1は重要、arg2とarg3はオプション扱い)
public void AddCmd(int cmd, int arg1, int arg2 = 0, int arg3 = 0)
{
CmdSet.Add(new int[] {cmd, arg1, arg2, arg3}); //Deep copy
}
public class TGEdit
{ //命令リスト(クラス内)クラス-名称と説明付きの命令セット public class TGList
{ //クラスメンバー public List<int[]> intList; public string Name {get; set;} public string Description {get; set;} //コンストラクター public TGList(string name = "", string description = "")
{
intList = new List<int[]>();
Name = name;
Description = description;
} //コピーコンストラクター public TGList(TGList copy)
{
intList = new List<int[]>(copy.intList);
Name = copy.Name;
Description = copy.Description;
}
}
//RGEditのクラスフィールド TGList CmdSet = new TGList(); //命令セット({コマンド番号, 引数}の整数配列 ) List<TGList> CmdList = new List<TGList>(); //命令リスト(命令セットの一覧) List<TGList> ExeList = new List<TGList>(); //実行リスト(指定する命令セットの実行順リスト) (略)
/////////////////////////////////////////////////
//命令セットクラス(名称と説明付きの命令セット)
///////////////////////////////////////////////// public class TGSet
{ //クラスメンバー
List<int[]> CmdSet; //命令配列 public string Name {get; set;} //命令セット名 public string Description {get; set;} //説明
//TurtleGraphics命令を編集するラッパークラス
///////////////////////////////////////////// public class TGEdit
{
//クラスフィールド public TGSet CmdSet; //命令セット({コマンド番号, 引数}の整数配列 ) public TGList CmdList; //命令リスト(命令セットの一覧) public TGList ExeList; //実行リスト(指定する命令セットの実行順リスト) (以下略)
(3)ご自身でコンパイルして使ってみたい、という方にはBCCForm and BCCSkeltonパッケージの中の(MSCompAssでもバッチファイルでも直ぐ様にコンパイルですことができるように)↓を「SampleBCCSkelton」-「MSCompAss」-「Debug」-「Samples」-「TGEditor」フォールダーに入れておきます。