Ejemplo n.º 1
0
 void SetStatistical(Data.ShowData SD, TimeSpan TotalTime, TimeSpan ThisTime, TimeSpan FishTime, bool DivideByTitle)
 {
     if (SD == null)
     {
         DivideByTitleTextBlock.Text    = null;
         CatchFishTextBlock.Text        = null;
         ThisTimeTextBlock.Text         = null;
         ThisTotalTimeTextBlock.Text    = null;
         TotalTimeTextBlock.Text        = null;
         ThisPercentTextBlock.Text      = null;
         ThisTotalPercentTextBlock.Text = null;
         ActionNameTextBlock.Text       = null;
         TitleTextBlock.Text            = null;
         CatchFishTimeTextBlock.Text    = null;
         CatchFishPercentTextBlock.Text = null;
         return;
     }
     DivideByTitleTextBlock.Text    = DivideByTitle ? "是" : "否";
     CatchFishTextBlock.Text        = SD.IsCatchFish ? "是" : "否";
     ThisTimeTextBlock.Text         = Consts.TimeSpan2String(new TimeSpan(SD.Ticks));
     ThisTotalTimeTextBlock.Text    = Consts.TimeSpan2String(ThisTime);
     TotalTimeTextBlock.Text        = Consts.TimeSpan2String(TotalTime);
     ThisPercentTextBlock.Text      = (100.0 * SD.Ticks / TotalTime.Ticks).ToString("F3") + "%";
     ThisTotalPercentTextBlock.Text = (100.0 * ThisTime.Ticks / TotalTime.Ticks).ToString("F3") + "%";
     ActionNameTextBlock.Text       = Consts.GetFileName(SD.Action);
     TitleTextBlock.Text            = SD.Title;
     CatchFishTimeTextBlock.Text    = Consts.TimeSpan2String(FishTime);
     CatchFishPercentTextBlock.Text = (100.0 * FishTime.Ticks / TotalTime.Ticks).ToString("F3") + "%";
 }
Ejemplo n.º 2
0
        private void ShowForegroundWindow(object sender, EventArgs e)
        {
            var FW = GetForegroundWindow();

            /*
             * StringBuilder SB = new StringBuilder();
             * //char[] filepath = new char[10000];
             * //uint maxfilepathlength = 1000;
             * try
             * {
             *  GetWindowText(FW, SB, 1000);
             * }
             * catch (Exception ex)
             * {
             *  Debug.Write(ex.Message);
             * }
             */
            //Debug.Write(SB);
            //QueryFullProcessImageName(new IntPtr(GetCurrentProcessID(FW)), 0, filepath, ref maxfilepathlength);
            var P  = Process.GetProcessById(GetCurrentProcessID(FW));
            var PP = FindHostedProcess.Find();

            if (PP == null)
            {
                return;
            }
            TB.Text = PP.ProcessName + "|" + PP.MainModule.FileName + "|" + PP.MainWindowTitle;
            //Bitmap img = Consts.Base64String2Icon(Consts.Icon2Base64String(System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName))).ToBitmap();
            Icon icon  = System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName);
            Icon icon2 = Consts.Base64String2Icon(Consts.Icon2Base64String(icon));

            IMG.Source = Consts.ChangeBitmapToImageSource(icon2.ToBitmap());
        }
Ejemplo n.º 3
0
 public ListStackPanelItem(Data.ShowData SD)
 {
     InitializeComponent();
     IconImage.Source        = Consts.ChangeBitmapToImageSource(SD.I.ToBitmap());
     StartTimeTextBlock.Text = "开始时间:" + SD.Start.ToString(Consts.DateTimeFormatString);
     EndTimeTextBlock.Text   = "结束时间:" + SD.End.ToString(Consts.DateTimeFormatString);
     ActionTextBlock.Text    = Consts.GetFileName(SD.Action);
     FullFileName            = SD.Action;
     TitleTextBlock.Text     = SD.Title;
 }
Ejemplo n.º 4
0
 private void GenerateNIC()
 {
     NIC = new NotifyIconComponent();
     NIC.NotifyIconText = "一个静悄悄的图标";
     NIC.ContextMenuStripItems.Add("显示/隐藏主界面");
     NIC.ContextMenuStripItems[0].Click += Visibility_Click;
     NIC.ContextMenuStripItems[0].Font   = new Font(NIC.ContextMenuStripItems[0].Font, NIC.ContextMenuStripItems[0].Font.Style | System.Drawing.FontStyle.Bold);
     NIC.ContextMenuStripItems.Add("设置挂机标题");
     NIC.ContextMenuStripItems[1].Click += ShowEnterName_Click;
     NIC.ContextMenuStripItems.Add("退出");
     NIC.ContextMenuStripItems[2].Click += Exit_Click;
     NIC.NotifyIconDoubleClick           = Visibility_Click;
     NIC.NotifyIconIcon = Consts.Base64String2Icon(Consts.IconClockStr);
 }
Ejemplo n.º 5
0
        public static List <Actions> GetActions(string StartDateTime, string EndDateTime)
        {
            DateTime SDT, EDT;

            try
            {
                SDT = Convert.ToDateTime(StartDateTime);
                EDT = Convert.ToDateTime(EndDateTime);
            }
            catch
            {
                return(null);
            }
            List <Actions> res = new List <Actions>();

            using (SQLiteConnection con = new SQLiteConnection("Data Source=Actions.db;Version=3;"))
            {
                con.Open();
                using (SQLiteDataAdapter ada = new SQLiteDataAdapter("SELECT * FROM Actions WHERE TimeStamp >= " + SDT.Ticks + " and TimeStamp <= " + EDT.Ticks + " ORDER BY TimeStamp", con))
                {
                    DataTable DT = new DataTable();
                    ada.Fill(DT);
                    foreach (DataRow r in DT.Rows)
                    {
                        if (res.Count > 999)
                        {
                            MessageBox.Show("条目过多,仅显示1000条。");
                            break;
                        }
                        Actions A = new Actions();
                        A.DateTime = new DateTime((long)r["TimeStamp"]);
                        //D.Year + "-" + D.Month + "-" + D.Day + " " + D.Hour + ":" + D.Minute + ":" + D.Second;
                        A.Type   = (int)(long)r["Type"];
                        A.Action = r["Action"].ToString();
                        A.Title  = r["Title"].ToString();
                        if (r["Icon"] != null && r["Icon"].ToString() != "")
                        {
                            A.Icon = Consts.Base64String2Icon(r["Icon"].ToString());
                        }
                        res.Add(A);
                    }
                }
            }
            return(res);
        }
Ejemplo n.º 6
0
        public static bool AddActions(Actions A)
        {
            using (SQLiteConnection con = new SQLiteConnection("Data Source=Actions.db;Version=3;"))
            {
                con.Open();
                using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO Actions (TimeStamp, Type, Action, Title, Icon) VALUES (@TS, @Type, @Action, @Title, @Icon)", con))
                {
                    cmd.Parameters.AddWithValue("@TS", DateTime.Now.Ticks);
                    if (A.Type != 0 && A.Type != 1)
                    {
                        return(false);
                    }
                    cmd.Parameters.AddWithValue("@Type", A.Type);
                    cmd.Parameters.AddWithValue("@Action", A.Action);
                    cmd.Parameters.AddWithValue("@Title", A.Title);
                    cmd.Parameters.AddWithValue("@Icon", Consts.Icon2Base64String(A.Icon));

                    cmd.ExecuteNonQuery();
                    return(true);
                }
            }
        }
Ejemplo n.º 7
0
        double GetShowData()
        {
            ShowDataList.Clear();
            SectorDataList.Clear();
            Consts.ResetNextBrush();

            var Actions = Data.GetActions(StartYMDTextBlock.Text + " " + StartHMSTextBlock.Text, EndYMDTextBlock.Text + " " + EndHMSTextBlock.Text);

            var lastmove = new DateTime(0);

            if (Actions.Count > 0)
            {
                lastmove = Actions[0].DateTime;
            }
            foreach (var a in Actions)
            {
                Data.ShowData last = null;
                if (ShowDataList.Count != 0)
                {
                    last = ShowDataList.Last();
                }

                if (a.Type == 0)
                {
                    if (last == null || last.Action != a.Action || last.Title != a.Title)
                    {
                        if (a.DateTime - lastmove > Consts.ActiveTimeSpan)
                        {
                            var fishdata = new Data.ShowData()
                            {
                                I           = Consts.Base64String2Icon(Consts.IconFishStr),
                                Start       = lastmove,
                                End         = a.DateTime,
                                Action      = Consts.CatchFishString,
                                IsCatchFish = true,
                                Title       = ""
                            };
                            ShowDataList.Add(fishdata);
                            last = ShowDataList.Last();
                        }
                        var SD = new Data.ShowData()
                        {
                            I      = a.Icon,
                            Start  = a.DateTime,
                            End    = a.DateTime,
                            Action = a.Action,
                            Title  = a.Title,
                        };
                        SD.IsCatchFish = CatchFishEvents.Any(str => { return(str == SD.ActionTitle); });
                        if (last != null)
                        {
                            last.End = SD.Start;
                        }
                        ShowDataList.Add(SD);
                        lastmove = a.DateTime;
                    }
                    else
                    {
                        last.End = a.DateTime;
                    }
                }
                else
                {
                    if ((a.DateTime - lastmove) > Consts.ActiveTimeSpan)
                    {
                        if (ShowDataList.Count == 0)
                        {
                            goto End;
                        }
                        var lastshowdata = new Data.ShowData(ShowDataList.Last());
                        var fishdata     = new Data.ShowData()
                        {
                            I           = Consts.Base64String2Icon(Consts.IconFishStr),
                            Start       = lastmove,
                            End         = a.DateTime,
                            Action      = Consts.CatchFishString,
                            IsCatchFish = true,
                            Title       = ""
                        };
                        ShowDataList.Last().End = lastmove;
                        ShowDataList.Add(fishdata);
                        lastshowdata.Start = lastshowdata.End = a.DateTime;
                        ShowDataList.Add(lastshowdata);
                    }
                    End :;
                    lastmove = a.DateTime;
                }
            }

            var tmplist = ShowDataList;

            ShowDataList = new List <Data.ShowData>();
            foreach (var i in tmplist)
            {
                if (ShowDataList.Count > 0 && i.Action == ShowDataList.Last().Action&& i.Title == ShowDataList.Last().Title)
                {
                    ShowDataList.Last().End = i.End;
                }
                else if (i.Ticks > Consts.MinimumCountTimeSpan.Ticks)
                {
                    ShowDataList.Add(i);
                }
                else if (ShowDataList.Count > 0)
                {
                    ShowDataList.Last().End = i.End;
                }
            }

            if (ShowDataList.Count == 0)
            {
                return(0);
            }

            double totalTime = (ShowDataList.Last().End - ShowDataList[0].Start).Ticks;

            foreach (var data in ShowDataList)
            {
                bool newdata = true;
                foreach (var old in SectorDataList)
                {
                    if (old.Action == data.Action && old.Title == data.Title)
                    {
                        newdata    = false;
                        old.Ticks += data.Ticks;
                        data.Color = old.Color;
                    }
                }
                if (newdata)
                {
                    data.Color = Consts.NextBrush;
                    var TSD = new Data.ShowData(data);
                    SectorDataList.Add(TSD);
                }
            }
            SectorDataList.Sort((Data.ShowData x, Data.ShowData y) => {
                return(y.Ticks.CompareTo(x.Ticks));
            });
            return(totalTime);
        }