예제 #1
0
    /// <summary>
    /// 保存文件
    /// </summary>
    /// <param name="eDir"></param>
    public void SaveDirToFile(EDIR eDir)
    {
        UpdateFile();
        //文件读写流
        StreamReader sr = new StreamReader(path);
                //读取内容
                string result = sr.ReadToEnd();

        sr.Close();
        sr.Dispose();

                //文件流
                FileStream fs = File.OpenWrite(path);
        //第二步填充内容
        StringBuilder sb = new StringBuilder();

        sb.Append(result + eDir.GetHashCode() + ",");
        byte[] map = Encoding.UTF8.GetBytes(sb.ToString());
        fs.Write(map, 0, map.Length);
        fs.Close();
        fs.Dispose();
    }
예제 #2
0
        private void BuildMe(EDIR BodyDir)
        {
            try
            {
                SzChInternaly = true;
                System.Drawing.Drawing2D.GraphicsPath gr = new System.Drawing.Drawing2D.GraphicsPath();
                switch (BodyDir)
                {
                case EDIR.Horizontal:
                    this.Size = new Size(this.Width, _BorderWidth + 10);
                    gr.AddRectangle(new Rectangle(0, (-_BorderWidth + this.Height) / 2, this.Width, _BorderWidth));
                    break;

                case EDIR.Vertical:
                    this.Size = new Size(_BorderWidth + 10, this.Height);
                    gr.AddRectangle(new Rectangle((-_BorderWidth + this.Width) / 2, 0, _BorderWidth, this.Height));
                    break;

                case EDIR.Slash:
                    try
                    {
                        // CType(_BorderWidth * Height / Width, Integer)
                        for (int i = 0; i <= Convert.ToInt32(Math.Pow(Math.Pow(Width, 2) + Math.Pow(Height, 2), 0.5)); i += _BorderWidth)
                        {
                            switch (_DrawStyle)
                            {
                            case eStyle.circ:
                                gr.AddPie(i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth, 0, 360);
                                break;

                            case eStyle.rect:
                                gr.AddRectangle(new Rectangle(i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth));
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;

                case EDIR.BKSlash:
                    try
                    {
                        // CType(_BorderWidth * Height / Width, Integer)
                        for (int i = 0; i <= Convert.ToInt32(Math.Pow(Math.Pow(this.Height, 2) + Math.Pow(this.Width, 2), 0.5)); i += _BorderWidth)
                        {
                            switch (_DrawStyle)
                            {
                            case eStyle.circ:
                                gr.AddPie(Width - 1 - i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth, 0, 360);
                                break;

                            case eStyle.rect:
                                gr.AddRectangle(new Rectangle(Width - 1 - i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth));
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;
                }
                this.Region   = new Region(gr);
                SzChInternaly = false;
            }
            catch
            {
            }
        }