コード例 #1
0
        public static Control NewControl(Model model, object o)
        {
            IHasCoordinate ihc = (IHasCoordinate)o;
            TextBox        tb  = new TextBox();

            tb.WordWrap      = false;
            tb.HideSelection = false;
            tb.Multiline     = true;
            tb.ScrollBars    = ScrollBars.Both;
            SourceTextView stv = new SourceTextView(model, tb);

            stv.FName = ihc.begin.file;
            if (ihc is AST)
            {
                AST p = (AST)ihc;
                while (p.parent != null && p.parent.begin.originalFile == ihc.begin.originalFile)
                {
                    p = p.parent;
                }
                stv.ASTRoot = p;
            }
            StreamReader sr = new StreamReader(ihc.begin.originalFile);

            tb.Text     = sr.ReadToEnd();
            tb.MouseUp += new MouseEventHandler(stv.Select);
            stv.ObjectChanged();
            return(tb);
        }
コード例 #2
0
        public static Control NewControl(Model model, object o)
        {
            IHasCoordinate ihc = (IHasCoordinate)o;
            TextBox        rtb = new TextBox();

            rtb.Multiline     = true;
            rtb.ScrollBars    = ScrollBars.Both;
            rtb.WordWrap      = false;
            rtb.HideSelection = false;
            ILTextView stv = new ILTextView(model, rtb);

            if (ihc is AST)
            {
                AST p = (AST)ihc;
                while (p.parent != null && p.parent.begin.file == ihc.begin.file && !(p is compilation_unit))
                {
                    p = p.parent;
                }
                stv.ASTRoot = p;
                if (stv.ASTRoot is compilation_unit)
                {
                    compilation_unit c        = (compilation_unit)stv.ASTRoot;
                    Tracking         tracking = new Tracking();
                    tracking_ilgen   ti       = new tracking_ilgen(tracking, c);
                    tracking.tracked = ti;
                    stv.tracking     = ti.create(c);
                    stv.Text         = stv.tracking.Text;
                }
            }
            rtb.MouseUp += new MouseEventHandler(stv.Select);
            stv.ObjectChanged();
            return(rtb);
        }
コード例 #3
0
 public object rewrite2AST()
 {
     if (!cached)
     {
         cached    = true;
         cachedAST = _rewrite2AST();
         IHasCoordinate ihc = cachedAST as IHasCoordinate;
         if (ihc != null)
         {
             ihc.begin = begin;
             ihc.end   = end;
         }
     }
     return(cachedAST);
 }
コード例 #4
0
        public static Control NewControl(Model model, object o)
        {
            IHasCoordinate ihc = (IHasCoordinate)o;
            TreeView       tv  = new TreeView();

            tv.HideSelection = false;
            CodeDomTreeView cdtv = new CodeDomTreeView(model, tv);

            if (ihc is AST)
            {
                cdtv.init((AST)ihc);
            }
            tv.MouseUp += new MouseEventHandler(cdtv.UserAfterSelect);
            cdtv.ObjectChanged();
            return(tv);
        }
コード例 #5
0
        public void ObjectChanged()
        {
            object o = model.CurrentObject;

            tb.HideSelection = true;
            if (o is IHasCoordinate)
            {
                IHasCoordinate ihc = (IHasCoordinate)o;
                if (ihc.begin.originalFile == FName)
                {
                    tb.SelectionStart  = ihc.begin.fileOffset;
                    tb.SelectionLength = ihc.end.fileOffset - ihc.begin.fileOffset;
                    tb.HideSelection   = false;
                    tb.ScrollToCaret();
                }
            }
        }
コード例 #6
0
ファイル: SourceTabView.cs プロジェクト: Paul1nh0/Singularity
        public void ObjectChanged()
        {
            object o = model.CurrentObject;

            AddRoot(o);
            if (o is IHasCoordinate)
            {
                IHasCoordinate ihc   = (IHasCoordinate)o;
                string         fname = ihc.begin.file;
                if (fname != null)
                {
                    if (!files.Contains(fname))
                    {
                        tab.SelectedTab = (TabPage)files[fname];
                    }
                }
            }
        }
コード例 #7
0
ファイル: SourceTabView.cs プロジェクト: Paul1nh0/Singularity
        public void AddRoot(object root)
        {
            object o = root;

            if (o is IHasCoordinate)
            {
                IHasCoordinate ihc   = (IHasCoordinate)o;
                string         fname = ihc.begin.file;
                if (fname != null)
                {
                    if (!files.Contains(fname))
                    {
                        TabPage tp = new TabPage();
                        tp.Text = fname;
                        tab.Controls.Add(tp);
                        Control ctl = nc(model, ihc);
                        ctl.Dock = DockStyle.Fill;
                        tp.Controls.Add(ctl);
                        files[fname] = tp;
                    }
                }
            }
        }
コード例 #8
0
 public static double DistanceTo(this IHasCoordinate coordinate, IHasCoordinate other)
 {
     return(GetDistanceBetween(coordinate.Latitude, coordinate.Longitude, other.Latitude, other.Longitude));
 }
コード例 #9
0
ファイル: xml.cs プロジェクト: Paul1nh0/Singularity
    static private void dump(string name, object i, string prefix, TextWriter wr)
    {
        if (i == null)
        {
            wr.WriteLine(prefix + "<" + name + "/>");
            return;
        }
        System.Type t = i.GetType();
        if (name == null)
        {
            name = t.Name;
        }
        if (t.IsValueType)
        {
            wr.WriteLine(prefix + "<" + name + ">" + i + "</" + name + ">");
        }
        else if (t == typeof(string))
        {
            wr.WriteLine(prefix + "<" + name + ">" + i + "</" + name + ">");
        }
        else if (t.IsArray)
        {
            wr.WriteLine(prefix + "<" + name + ">");
            foreach (object e in (object[])i)
            {
                dump(null, e, prefix, wr);
            }
            wr.WriteLine(prefix + "</" + name + ">");
        }
        else if (i is IList)
        {
            wr.WriteLine(prefix + "<" + name + ">");
            foreach (object e in (IList)i)
            {
                dump(null, e, prefix, wr);
            }
            wr.WriteLine(prefix + "</" + name + ">");
        }
        else
        {
            wr.WriteLine(prefix + "<" + name + ">");
            IHasCoordinate ihc = i as IHasCoordinate;
            if (ihc != null)
            {
                wr.WriteLine(prefix + "  <begin>" + ihc.begin.ToString() + "</begin>");
            }
            string inner = prefix + "  ";
            if (t.Name != name)
            {
                wr.WriteLine(inner + "<" + t.Name + ">");
                inner = inner + "  ";
            }
            FieldInfo[] fields = t.GetFields();
            foreach (FieldInfo f in fields)
            {
                object o = f.GetValue(i);
                string n = f.Name;
                if (f.Name != "parent" && f.Name != "global")
                {
                    dump(f.Name, o, inner + "  ", wr);
                }
            }

            if (t.Name != name)
            {
                wr.WriteLine(prefix + "  " + "</" + t.Name + ">");
            }
            if (ihc != null)
            {
                wr.WriteLine(prefix + "  <end>" + ihc.end.ToString() + "</end>");
            }
            wr.WriteLine(prefix + "</" + name + ">");
        }
    }
コード例 #10
0
 public static double DistanceTo(this IHasCoordinate coordinate, IHasCoordinate other)
 {
     return GetDistanceBetween(coordinate.Latitude, coordinate.Longitude, other.Latitude, other.Longitude);
 }