1月 27

    今天想比较两个相同名字的ISO文件有什么不同,不想专门费事的用一个专业的比较软件,只是想横向的大概比较一下各个文件夹夹的大小,在windows自带的资源管理器中找啊找啊,没有!一个一个文件夹看实在费劲,最终寻觅到一个小东东!虽然比较老了,但在我的XP SP2里边用的还是非常的好,谁有更好的别忘了留个言哦,先看看效果图把:

怎么样呢?虽然不是经常用,但总会用到滴….
需要下载一个DLL文件,点击下载

使用方法:

     ①下载文件解压得到2个压缩包“KB,MB,GBdisplay”和“MB version”,2个版本区别:
“KB,MB,GBdisplay”显示 KB,MB,GB单位的,但是不支持资源管理器的排序.
“MB version”是统一以MB为单位,可以在资源管理器里面排序的.

    选择你需要的解压一个,随便你放到哪里!然后 开始–运行– regsvr32 drive:\path\fs.dll 即可!以后不想用了就 regsvr32 /u drive:\path\fs.dll

    ②打开资源管理器,在标题兰单击“查看”图标,以“详细信息”方式排列文件(下图),然后在详细信息项目的那栏上鼠标右键,选择 folder size 即可(下图).

written by ocean

1月 12

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using XStock.ClassLibrary.Entity;

namespace XStock.ClassLibrary.Chart
{
   public class ImgHelper
   {

       int WIDTH = 300;

       int HEIGHT = 500;

       const int EDGE = 100;

       /// <summary>
       /// 放大的倍数,最少100
       /// </summary>
       const int MULTIPLE=200;

       /// <summary>
       /// 间隔
       /// </summary>
       const int INTERVAL = 10;

       Bitmap bitmap = null;
       Graphics graphics = null;
       decimal Max = decimal.MinValue;
       decimal Min = decimal.MaxValue;

       List<StackSingleInfo> list = null;

       public ImgHelper(List<StackSingleInfo> list)
       {

           this.list = list;

           this.list.Sort((a, b) => a.Date.CompareTo(b.Date));

           foreach (var item in list)
           {
               if (Max < item.High * MULTIPLE)
                   Max = item.High * MULTIPLE;
               if (Min > item.Low * MULTIPLE)
                   Min = item.Low * MULTIPLE;
           }
           Max += EDGE;
           if (Min > EDGE)
               Min -= EDGE;
           this.HEIGHT = (int)(Max – Min);

           this.WIDTH = list.Count * INTERVAL + EDGE * 2;

           bitmap = new Bitmap(WIDTH, HEIGHT);

           graphics = Graphics.FromImage(bitmap);

           graphics.Clear(Color.White);

           foreach (var item in this.list)
           {
               this.SetCandleLine(item);
           }

       }

       public void SetLine(DateTime start, decimal price1, DateTime end, decimal price2)
       {
           graphics.SmoothingMode = SmoothingMode.AntiAlias;
           graphics.DrawLine(new Pen(Color.Black), X(start), Y(price1), X(end), Y(price2));
       }
       public void SetTestLine(DateTime start, decimal price1, DateTime end, decimal price2,Color color)
       {
           graphics.SmoothingMode = SmoothingMode.AntiAlias;
           graphics.DrawLine(new Pen(color), X(start)+4, Y(price1), X(end)+4, Y(price2));
       }

       public void Save(string path)
       {
           bitmap.Save(path, ImageFormat.Jpeg);
       }

       private float X(DateTime date)
       {
           var find = list.Find(a => a.Date == date);

           int index = list.IndexOf(find);
           int x = EDGE + index * INTERVAL;
           return x;
       }

       public float Y(decimal price)
       {
           return HEIGHT – (int)(price * MULTIPLE – Min);
       }

       /// <summary>
       /// 设置label
       /// </summary>
       /// <param name="item"></param>
       /// <param name="SetLabelLastIsUp"></param>
       public void SetLabel(StackSingleInfo item, bool SetLabelLastIsUp)
       {
           decimal offset = 0.2M;
           decimal offsetBasic = 0.05M;

           decimal offsetSecondLine = 0.03M;

           graphics.SmoothingMode = SmoothingMode.AntiAlias;

           if (SetLabelLastIsUp)
           {
               graphics.DrawLine(new Pen(Color.Blue), X(item.Date), Y(item.High + offsetBasic), X(item.Date), Y(item.High + offset + offsetBasic));
               graphics.DrawString(item.Close.ToString("#.##"), new Font(new FontFamily("宋体"), 8), Brushes.Black, X(item.Date), Y(item.High + offset + offsetBasic * 2));
               graphics.DrawString(item.Date.ToString("yyyy-MM-dd HH:mm"), new Font(new FontFamily("宋体"), 8), Brushes.Black, X(item.Date), Y(item.High + offset + offsetBasic * 2 – offsetSecondLine));
           }
           else
           {
               graphics.DrawLine(new Pen(Color.Blue), X(item.Date), Y(item.Low – offsetBasic), X(item.Date), Y(item.Low – offset – offsetBasic));
               graphics.DrawString(item.Close.ToString("#.##"), new Font(new FontFamily("宋体"), 8), Brushes.Black, X(item.Date), Y(item.Low – offset – offsetBasic * 2));
               graphics.DrawString(item.Date.ToString("yyyy-MM-dd HH:mm"), new Font(new FontFamily("宋体"), 8), Brushes.Black, X(item.Date), Y(item.Low – offset – offsetBasic * 2 – offsetSecondLine));
           }

         
       }

       /// <summary>
       /// 设置蜡烛图
       /// </summary>
       /// <param name="item"></param>
       public void SetCandleLine(StackSingleInfo item)
       {
           Color color = (item.Close > item.Open) ? Color.Red : Color.Green;
           graphics.SmoothingMode = SmoothingMode.AntiAlias;

           graphics.DrawLine(new Pen(color), X(item.Date) – 2, Y(item.HighPoint), X(item.Date) – 2, Y(item.LowPoint));
           graphics.DrawLine(new Pen(color), X(item.Date) – 1, Y(item.HighPoint), X(item.Date) – 1, Y(item.LowPoint));
           graphics.DrawLine(new Pen(color), X(item.Date), Y(item.High), X(item.Date), Y(item.Low));
           graphics.DrawLine(new Pen(color), X(item.Date) + 1, Y(item.HighPoint), X(item.Date) + 1, Y(item.LowPoint));
           graphics.DrawLine(new Pen(color), X(item.Date) + 2, Y(item.HighPoint), X(item.Date) + 2, Y(item.LowPoint));
       }

       public void SetCircle(DateTime date, decimal price)
       {
           Brush redBrush = new SolidBrush(Color.Blue);
           graphics.FillEllipse(redBrush, new Rectangle((int)X(date), (int)Y(price), 4, 4));
       }

       //public void SetSoldLine(DateTime startDate, DateTime endDate)
       //{
       //    var start = list.Find(a => a.Date == startDate);
       //    var end = list.Find(a => a.Date == endDate);
       //    graphics.SmoothingMode = SmoothingMode.AntiAlias;
       //    graphics.DrawLine(new Pen(Color.Red), X(start.Date), Y(start.High), X(end.Date), Y(end.Low));
       //}

   }
}

written by ocean

1月 12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace XStock.ClassLibrary.Net
{
   public  class NetHelper
    {
    
       static Encoding GB2312 = Encoding.GetEncoding("gb2312");
       /// <summary>
       /// 下载股票行情信息,from sina
       /// </summary>
       /// <param name="url"></param>
       /// <returns></returns>
       public static string DownStockCurrentPrice(string url)
       {
           return DownloadFromUrl(url, GB2312);
       }
     
       /// <summary>
        /// http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/index.aspx?type=s&style=10&sortType=A&sortRule=1&pageSize=31&page=1&jsName=quote_data&Reference=xml&_g=0.8787947254094691
        /// http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/index.aspx?type=s&style=20&sortType=A&sortRule=1&pageSize=31&page=1&jsName=quote_data&Reference=xml&_g=0.7636787883671452
       /// </summary>
       /// <param name="url"></param>
       /// <returns></returns>
       public static string DownStockList(string url)
       {
           return DownloadFromUrl(url, Encoding.UTF8);
       }
    
           
     
        static int DOWNLOAD_TIMEOUT = 30 * 1000;
        public static string DownloadFromUrl(string url,Encoding encoding)
        {
            int count = 0;
            while (count < 3)
            {
                try
                {
                    HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                    request.Timeout = DOWNLOAD_TIMEOUT;
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    System.IO.Stream responseStream = response.GetResponseStream();
                    System.IO.StreamReader reader = new System.IO.StreamReader(responseStream, encoding);
                    string srcString = reader.ReadToEnd();
                    return srcString;
                }
                catch (Exception ex)
                {
                   // throw ex;
                    //Console.WriteLine("----------Error:" + ex.Message + url);
                    //return string.Empty;
                    count++;
                }
            }
            Console.WriteLine("错线错误" + url);
    
            return string.Empty;
        }
    
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XStock.ClassLibrary.Entity;
using XStock.ClassLibrary.Unit;
using System.Text.RegularExpressions;
using XStock.ClassLibrary.Enum;
namespace XStock.ClassLibrary.Net
{
    public class NetManager
    {
        public static List<StockBasicInfo> GetAllStockInfosListFromNet()
        {
    
            List<string> urls = new List<string>() { 
                "http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/index.aspx?type=s&style=10&sortType=A&sortRule=1&pageSize=5000&page=1&jsName=quote_data&Reference=xml&_g=" + RandomHelper.Timestamp,
                "http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/index.aspx?type=s&style=20&sortType=A&sortRule=1&pageSize=5000&page=1&jsName=quote_data&Reference=xml&_g=" + RandomHelper.Timestamp
            };
            List<StockBasicInfo> result = new List<StockBasicInfo>();
            foreach (var url in urls)
            {
                string SH_A_Html = NetHelper.DownStockList(url);
                if (SH_A_Html.Length > 0)
                {
                    string arrString = RegexManager.ExtractValue(SH_A_Html, "\\[\\\"(.*?)\\\"\\]");
                    var items = Regex.Split(arrString, "\",\"");
                    foreach (var item in items)
                    {
                        var cells = item.Split(',');
                        StockBasicInfo stock = new StockBasicInfo();
                        stock.Name = cells[2];
                        stock.Code = cells[1];
                        stock.CirculationStock = cells[cells.Length - 1].ToDecimal();
                        stock.CurrentPrice = cells[5].ToDecimal();
                        if (url.Contains("style=10"))
                            stock.Location = EnumListingLocation.SH;
                        else if (url.Contains("style=20"))
                            stock.Location = EnumListingLocation.SZ;
                        result.Add(stock);
                    }
                }
            }
            //if (result.Count > 3)
            //    result = result.GetRange(0, 3);
            return result;
        }
    
    
        public static void NetGetStockInfo(StockInfo stockInfo)
        {
            ////http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=sz000002&scale=30&ma=no&datalen=1023
            ////http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=sh{0}&scale={1}&ma=no&datalen=1023
            string url = string.Format("http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol={0}{1}&scale={2}&ma=no&datalen=1023",
                stockInfo.Location.ToString(), stockInfo.Code, (int)stockInfo.Level);
            string html = NetHelper.DownStockCurrentPrice(url);
    
            DateTime startTime = DateTime.Now.AddDays(-5);
            stockInfo.Items.RemoveAll(a => a.Date > startTime);
            if (html.Length > 0)
            {
                var items = Regex.Split(html, "},{");
                foreach (var item in items)
                {
                    var current = new StackSingleInfo()
                    {
                        Date = RegexManager.ExtractValue(item, "day:\"(.*?)\"").ToDateTime(),
                        Open = RegexManager.ExtractValue(item, "open:\"(.*?)\"").ToDecimal(),
                        High = RegexManager.ExtractValue(item, "high:\"(.*?)\"").ToDecimal(),
                        Low = RegexManager.ExtractValue(item, "low:\"(.*?)\"").ToDecimal(),
                        Close = RegexManager.ExtractValue(item, "close:\"(.*?)\"").ToDecimal(),
                        Volume = RegexManager.ExtractValue(item, "volume:\"(.*?)\"").ToDecimal()
                    };
                    var find = stockInfo.Items.Find(a => a.Date == current.Date);
                    if (find == null)
                    {
                        stockInfo.Items.Add(current);
                    }
                }
            }
            stockInfo.Items.Sort((a, b) => a.Date.CompareTo(b.Date));
        }
    
    
        /// <summary>
        /// 获取日线级别的交易记录
        /// </summary>
        /// <param name="stockInfo"></param>
        public static void NetGetStockInfoDay(StockInfo stockInfo, DateTime start, DateTime end)
        {
            string url = string.Format("http://biz.finance.sina.com.cn/stock/flash_hq/kline_data.php?symbol={0}{1}&end_date={2}&begin_date={3}",
                stockInfo.Location.ToString(),
                stockInfo.Code,
                end.ToString("yyyyMMdd"),
                start.ToString("yyyyMMdd"));
            string html = NetHelper.DownloadFromUrl(url, Encoding.UTF8);
            html = RegexManager.ExtractValue(html, "<control>(.*?)</control>");
            var items = Regex.Split(html, "/>");
            foreach (var item in items)
            {
                if (item.Length < 20)
                    continue;
                var current = new StackSingleInfo()
                {
                    Date = RegexManager.ExtractValue(item, "d=\"(.*?)\"").ToDateTime(),
                    Open = RegexManager.ExtractValue(item, "o=\"(.*?)\"").ToDecimal(),
                    High = RegexManager.ExtractValue(item, "h=\"(.*?)\"").ToDecimal(),
                    Low = RegexManager.ExtractValue(item, "l=\"(.*?)\"").ToDecimal(),
                    Close = RegexManager.ExtractValue(item, "c=\"(.*?)\"").ToDecimal(),
                    Volume = RegexManager.ExtractValue(item, "v=\"(.*?)\"").ToDecimal()
                };
                stockInfo.Items.Add(current);
            }
        }
    }
}
//<content d="2008-01-03" o="86.000" h="86.000" c="85.030" l="82.660" v="390326" bl="" />

written by ocean

1月 12

   public static void PartingAnalyseStockInfo(StockInfo stockInfo)
        {

            int start = 1;

            if (stockInfo.Items.Count < 10)
                return;
            if (IsContain(stockInfo.Items[0], stockInfo.Items[1]))
                return;

            int lastPrevIndex = 0;
            StackSingleInfo lastPrev = stockInfo.Items[lastPrevIndex].Clone();

            int prevIndex = 1;
            StackSingleInfo prev = stockInfo.Items[prevIndex].Clone();

 

            for (int index = 2; index < stockInfo.Items.Count; index++)
            {
                if (IsContain(stockInfo.Items[index], prev))//有包含关系
                {

                    if (stockInfo.Items[index].High <= prev.LogicHigh
                        && stockInfo.Items[index].Low >= prev.LogicLow)//前面包含当前的
                    {
                        if (IsEnumTrend(lastPrev, prev) == EnumTrend.Down)//向下
                        {
                            stockInfo.Items[prevIndex].LogicHigh = Math.Min(stockInfo.Items[index].LogicHigh, stockInfo.Items[prevIndex].LogicHigh);
                            stockInfo.Items[index].PropertyPoint = EnumPropertyPoint.ContainPoint;
                        }
                        else
                        {
                            stockInfo.Items[prevIndex].LogicLow = Math.Max(stockInfo.Items[index].LogicLow, stockInfo.Items[prevIndex].LogicLow);
                            stockInfo.Items[index].PropertyPoint = EnumPropertyPoint.ContainPoint;
                        }
                        prev = stockInfo.Items[prevIndex].Clone();
                    }
                    else//当前的包含前面de
                    {
                        if (IsEnumTrend(lastPrev, prev) == EnumTrend.Down)//向下
                        {
                            stockInfo.Items[index].LogicHigh = Math.Min(stockInfo.Items[prevIndex].LogicHigh, stockInfo.Items[index].LogicHigh);
                            stockInfo.Items[prevIndex].PropertyPoint = EnumPropertyPoint.ContainPoint;
                        }
                        else
                        {
                            stockInfo.Items[index].LogicLow = Math.Max(stockInfo.Items[index].LogicLow, stockInfo.Items[prevIndex].LogicLow);
                            stockInfo.Items[prevIndex].PropertyPoint = EnumPropertyPoint.ContainPoint;
                        }
                        prev = stockInfo.Items[index].Clone();
                        prevIndex = index;
                    }
                }
                else
                {
                    lastPrevIndex = prevIndex;
                    lastPrev = prev.Clone();

                    prevIndex = index;
                    prev = stockInfo.Items[index].Clone();
                }
            }

 

 

            List<StackSingleInfo> temp = Copy(stockInfo.Items);
            temp = temp.FindAll(a => a.PropertyPoint != EnumPropertyPoint.ContainPoint);

            if (temp.Count >= 3)
            {
                for (int index = 1; index < temp.Count-1; index++)
                {
                    EnumPropertyPoint enumPropertyPoint = CheckEnumPropertyPoint(temp[index – 1], temp[index], temp[index + 1]);
                    if (enumPropertyPoint == EnumPropertyPoint.HighPoint || enumPropertyPoint== EnumPropertyPoint.LowPoint)
                    {
                        stockInfo.Items.Find(a => a.Date == temp[index].Date).PropertyPoint = enumPropertyPoint;
                        temp[index].PropertyPoint = enumPropertyPoint;
                    }
                }
            }

            //if (temp.Count >= 5)
            //{
            //    for (int index = 2; index < temp.Count – 2; index++)
            //    {
            //        EnumPropertyPoint enumPropertyPoint = CheckEnumPropertyPoint2( index ,temp);
            //        stockInfo.Items.Find(a => a.Date == temp[index].Date).PropertyPoint = enumPropertyPoint;
            //    }
            //}

            ChartManager chartManager = new ChartManager();
            chartManager.CreateImg(stockInfo); 
        }

written by ocean

1月 12

 /// <summary>
       /// 是否有包含关系
       /// </summary>
       /// <param name="item1"></param>
       /// <param name="item2"></param>
       /// <returns></returns>
       private static bool IsContain(StackSingleInfo item1, StackSingleInfo item2)
       {
           if (item1 == null || item2 == null)
               return false;
           if (item1.LogicHigh >= item2.LogicHigh
               && item2.LogicLow >= item1.LogicLow)
               return true;
           if (item2.LogicHigh >= item1.LogicHigh
               && item1.LogicLow >= item2.LogicLow)
               return true;
           return false;
       }

written by ocean