Example #1
0
        public BannerLayout()
        {
            var userAvatarFile          = Program.AppSetting.In("Setting").In("Avatar");
            var userAvatarFilePath      = userAvatarFile.GetInfo("Default", null);
            var userBannerImageFilePath = userAvatarFile.GetInfo("Banner", null);

            avatar = new Bar.BtnAvatar((x) =>
            {
                bool success  = false;
                var path      = SetImageNew(userAvatarFile, "Default", "更换头像");
                avatar.Avatar = path == null || path.Length == 0?Properties.Resources.defaultAvatar :  LoadPathImage(path, out success);
                if (!success)
                {
                    userAvatarFile.SetInfo("Default", "");
                }
                avatar.Invalidate();
                //TODO 可能可以显示下用户信息
            })
            {
                Avatar    = userAvatarFilePath == null || userAvatarFilePath.Length == 0 ? Properties.Resources.defaultAvatar : LoadPathImage(userAvatarFilePath, out bool s),
                Parent    = this,
                BackColor = this.BackColor
            };
            banner = new Bar.BtnImage((x) => {
                var path      = SetImageNew(userAvatarFile, "Banner");
                bool succress = false;
                banner.Image  = path == null || path.Length == 0 ? GetRandomBanner() : LoadPathImage(path, out succress);
                if (!succress)
                {
                    userAvatarFile.SetInfo("Banner", "");
                }
                banner.Invalidate();
            })
            {
                Image     = userBannerImageFilePath == null || userBannerImageFilePath.Length == 0 ? GetRandomBanner(): LoadPathImage(userBannerImageFilePath, out bool ss),
                Parent    = this,
                BackColor = this.BackColor
            };
        }
        public MenuPanel()
        {
            if (!Program.CheckAdminUAC())
            {
                cmdUAC = new Button
                {
                    Location = new System.Drawing.Point(0, 300),
                    Size     = new System.Drawing.Size(123, 24),
                    TabIndex = 0,
                    Text     = "权限未开启",
                    UseVisualStyleBackColor = true,
                    FlatStyle = FlatStyle.System,
                    Parent    = this,
                };
                cmdUAC.Click += (x, xx) => { Program.RunAsAdministrator(); };
                Program.SetControlUACFlag(cmdUAC);
            }
            this.BackColor = System.Drawing.Color.FromArgb(255, 50, 50, 50);
            Font           = new System.Drawing.Font("微软雅黑", 12);

            //ShowUserInfoOfDay = new Bar.BtnNormal[3];
            //for (int i = 0; i < 3; i++)
            //{
            //	ShowUserInfoOfDay[i] = new Bar.BtnNormal((x) => { })
            //	{
            //		Text = "喵喵喵",
            //		Font = this.Font,
            //		Parent = this,
            //		deactiveColor = System.Drawing.Color.FromArgb(255, 91, 155, 213)
            //	};
            //}
            cmdDND = new Bar.BtnCmd((x) => { Program.OnDND = !cmdDND.StateIsON; })
            {
                Text          = "开启免打扰|关闭免打扰",
                ImageActive   = Resources.DNDon,
                ImageDeactive = Resources.DNDoff,
                Font          = this.Font,
                Parent        = this,
                StateIsON     = !Program.OnDND
            };
            cmdHider = new Bar.BtnCmd((x) => {
                Program.frmMain.ui.ExpandMenu(false);
                Program.frmMain.ui.clock.Visible = false;
                Program.frmMain.ui.clock.隐藏();
                Program.frmMain.ui.menuPanel.cmdShowTomato.StateIsON = true;
                更新饼图();
            })
            {
                Text          = "显示图表|隐藏图表",
                ImageDeactive = Resources.隐藏饼图,
                ImageActive   = Resources.显示饼图,
                Font          = this.Font,
                //ForeColor=Color.White,
                Parent = this
            };
            cmdPauser = new Bar.BtnCmd((x) => {
                Program.frmMain.BtnRunningCommand_Click();
            })
            {
                Text          = "继续统计|暂停统计",
                ImageActive   = Resources.开始统计,
                ImageDeactive = Resources.停止统计,
                Font          = this.Font,
                //ForeColor = Color.White,
                Parent = this
            };
            //cmdGraphic = new Bar.BtnCmd((x) => { })
            //{
            //	Text = "隐藏分析|分析交集",
            //	Image = Resources.图表,
            //	Font=this.Font,
            //	//ForeColor = Color.White,
            //	Parent = this
            //};

            cmdFlashEnable = new Bar.BtnCmd((x) => {
                Program.UsedFlash = !cmdFlashEnable.StateIsON;
            })
            {
                Text          = "启用动画|关闭动画",
                ImageActive   = Resources.打开动画,
                ImageDeactive = Resources.关闭动画,
                Font          = this.Font,
                //ForeColor = Color.White,
                Parent    = this,
                StateIsON = !Program.UsedFlash
            };
            cmdShowTomato = new Bar.BtnCmd((x) => {
                Program.frmMain.ui.HideAll(!cmdShowTomato.StateIsON);
                this.OnResize(EventArgs.Empty);
            })
            {
                Text          = "打开番茄|关闭番茄",
                ImageActive   = Resources.番茄,
                ImageDeactive = null,
                Font          = this.Font,
                Parent        = this,
                StateIsON     = true
            };
            cmdPauseTomato = new Bar.BtnCmd((x) => {
                Program.frmMain.ui.clock.Pause = !Program.frmMain.ui.clock.Pause;
            })
            {
                Parent        = this,
                Text          = "暂停番茄|继续番茄",
                ImageActive   = Resources.番茄暂停,
                ImageDeactive = null,
                StateIsON     = true,
                Font          = this.Font
            };
            cmdAutoCurrentVersion = new Bar.BtnCmd((x) => {
                if (!Program.CheckAdminUAC())
                {
                    Program.RunAsAdministrator();
                }
                Program.AutoCurrentVersion = !cmdAutoCurrentVersion.StateIsON;
            })
            {
                Text          = "开机启动|取消启动",
                ImageActive   = Resources.开机启动,
                ImageDeactive = Resources.停止开机启动,
                Font          = this.Font,
                //ForeColor = Color.White,
                Parent    = this,
                StateIsON = !Program.AutoCurrentVersion
            };

            SelectQueryDay    = new Bar.BtnCmd[4];
            SelectQueryDay[0] = new Bar.BtnCmd((x) => {
                Program.QueryingDay = DataCore.DayStamp(DateTime.Now).ToString();
                SwitchButton(0);
            })
            {
                Parent = this, Font = this.Font, Text = "今天", ImageActive = Resources.单天
            };
            SelectQueryDay[1] = new Bar.BtnCmd((x) => {
                Program.QueryingDay = (DataCore.DayStamp(DateTime.Now) - 1).ToString();
                SwitchButton(1);
            })
            {
                Parent = this, Font = this.Font, Text = "昨天", ImageActive = Resources.昨天
            };
            SelectQueryDay[2] = new Bar.BtnCmd((x) => {
                var date = InputBox.ShowInputBox("", "请按照格式输入日期", DateTime.Now.Date.ToShortDateString());
                try
                {
                    Program.QueryingDay = DataCore.DayStamp(Convert.ToDateTime(date)).ToString();
                    SwitchButton(2);
                }
                catch (Exception ex)
                {
                }
            })
            {
                Parent = this, Font = this.Font, Text = "其他..", ImageActive = Resources.日期
            };
            SelectQueryDay[3] = new Bar.BtnCmd((x) => {
                Program.QueryingDay = "SumDay";
                SwitchButton(3);
            })
            {
                Parent = this, Font = this.Font, Text = "总计", ImageActive = Resources.总计
            };

            logo = new Bar.BtnImage((x) => { })
            {
                Parent    = this,
                Image     = Resources.Logo,
                BackColor = this.BackColor, Center = true
            };
            //菜单下方的控件将不显示左侧栏目
            menu.Parent = this;
            SwitchButton(0);
        }