Пример #1
0
        //生成64位程序会导致无法用设计器编辑
        public MainWindow()
        {
            //由于蜜汁原因,在x64下频繁绘制足够大的GIF时,其它控件不会根据databinding自动刷新,所以需要让BindHandle手动调用MainWindow.Update()
            //不确定是否会产生额外的刷新
            BindHandleProviderExtension.main_window = this;
            InitializeComponent();
            //初始化
            var config = LoadConfig();

            InitButton.Visible = config.ShowInitButton;
            pixiv_client       = new Client(config);
            MainExplorer.SetClient(pixiv_client);
            TagBox.SetClient(pixiv_client);
            AuthorBox.SetClient(pixiv_client);
            queueComboBox.SetClient(pixiv_client);
            //UI
            //parent为主窗口的话,透明时会透出主窗口的背景,而主窗口背景不能设为透明,所以需要更改parent
            SystemTrayIcon.Icon           = Properties.Resources.baseIcon;
            PageLabel.Parent              = this.MainExplorer;
            PageLabel.Location            = new System.Drawing.Point(PageLabel.Location.X - MainExplorer.Location.X, PageLabel.Location.Y - MainExplorer.Location.Y);
            NextButton.Parent             = this.MainExplorer;
            NextButton.Location           = new System.Drawing.Point(NextButton.Location.X - MainExplorer.Location.X, NextButton.Location.Y - MainExplorer.Location.Y);
            PrevButton.Parent             = this.MainExplorer;
            PrevButton.Location           = new System.Drawing.Point(PrevButton.Location.X - MainExplorer.Location.X, PrevButton.Location.Y - MainExplorer.Location.Y);
            SwitchBookmarkButton.Parent   = this.MainExplorer;
            SwitchBookmarkButton.Location = new System.Drawing.Point(SwitchBookmarkButton.Location.X - MainExplorer.Location.X, SwitchBookmarkButton.Location.Y - MainExplorer.Location.Y);
            BookmarkPageLabel.Parent      = SwitchBookmarkButton;
            BookmarkPageLabel.Location    = new System.Drawing.Point(0, 0);
            //设置事件
            FormClosing                     += OnClose;//关闭按钮不关闭,而是最小化
            KeyUp                           += new KeyEventHandler(MainExplorer.OnKeyUp);
            NextButton.Click                += new EventHandler(MainExplorer.SlideRight);
            PrevButton.Click                += new EventHandler(MainExplorer.SlideLeft);
            idLabel.LinkClicked             += new LinkLabelLinkClickedEventHandler(MainExplorer.OpenInBrowser);
            OpenLocalLabel.LinkClicked      += new LinkLabelLinkClickedEventHandler(MainExplorer.OpenInLocal);
            SwitchBookmarkButton.MouseClick += new MouseEventHandler(MainExplorer.SwitchBookmarkStatus);
            queueComboBox.QueueChanged      += new EventHandler <QueueChangeEventArgs>(OnQueueComboBoxChanged);
            AuthorBox.AuthorModified        += (object sender, EventArgs e) => queueComboBox.UpdateContent();
            PlayButton.Click                += (object sender, EventArgs e) => MainExplorer.Play();
            RandomSlideCheckBox.Click       += (object sender, EventArgs e) => MainExplorer.random_slide = RandomSlideCheckBox.Checked;
            InitButton.Click                += (object sender, EventArgs e) => pixiv_client.InitTask().Wait();
            SystemTrayIcon.DoubleClick      += (object sender, EventArgs e) => this.Visible = !this.Visible;
            ExitAction.Click                += (object sender, EventArgs e) => { FormClosing -= OnClose; this.Close(); };//退出时先移除阻止关闭的handle
            //绑定属性
            PageLabel.DataBindings.Add(new Binding("Text", MainExplorer.GetBindHandle <string>("IndexText"), "Content"));
            DescBrowser.DataBindings.Add(new Binding("DocumentText", MainExplorer.GetBindHandle <string>("DescText"), "Content"));
            PlayButton.DataBindings.Add(new Binding("Text", MainExplorer.GetBindHandle <string>("TotalPageText"), "Content"));
            idLabel.DataBindings.Add(new Binding("Text", MainExplorer.GetBindHandle <string>("IdText"), "Content"));
            SwitchBookmarkButton.DataBindings.Add(new Binding("Image", MainExplorer.GetBindHandle <System.Drawing.Bitmap>("FavIcon"), "Content"));
            BookmarkPageLabel.DataBindings.Add(new Binding("Visible", MainExplorer.GetBindHandle <bool>("PageInvalid"), "Content"));
            TagBox.DataBindings.Add(new Binding("Tags", MainExplorer.GetBindHandle <List <string> >("Tags"), "Content"));
            AuthorBox.DataBindings.Add(new Binding("UserId", MainExplorer.GetBindHandle <int>("UserId"), "Content"));
            DataBindings.Add(new Binding("Text", pixiv_client.GetBindHandle <string>("VerifyState"), "Content"));

            //onListCheckBoxClick(null,null);
        }
Пример #2
0
        //HACK ドキュメントの定義と違うのは何故?
        //ドキュメント上
        //public const int WM_XBUTTONDOWN = 0x020B;
        //実際(ドキュメント上だとWM_APPCOMMAND)
        //public const int WM_XBUTTONDOWN = 0x0319;

        protected override void WndProc(ref Message m)
        {
            Debug.Print("Msg=" + m.Msg);
            Debug.Print("WParam=" + m.WParam.ToInt32());
            Debug.Print("LParam=" + m.LParam.ToInt32());
            Debug.Print("GET_XBUTTON_WPARAM=" + Macros.GET_XBUTTON_WPARAM((uint)m.WParam.ToInt32()));

            base.WndProc(ref m);

            //NOTE:WM_XBUTTONDOWNが何故かキャッチできず、WM_PARENTNOTIFYだと上手くいった。
            if (m.Msg == Macros.WM_PARENTNOTIFY)
            {
                if (Macros.GET_XBUTTON_WPARAM((uint)m.WParam.ToInt32()) == Macros.XBUTTONS.XBUTTON1)
                {
                    if (MainExplorer.ClientRectangle.Contains(MainExplorer.PointToClient(Cursor.Position)))
                    {
                        this.MainExplorer.NavigateLogLocation(NavigationLogDirection.Backward);
                    }
                    if (SubExplorer.ClientRectangle.Contains(SubExplorer.PointToClient(Cursor.Position)))
                    {
                        this.SubExplorer.NavigateLogLocation(NavigationLogDirection.Backward);
                    }
                }
                if (Macros.GET_XBUTTON_WPARAM((uint)m.WParam.ToInt32()) == Macros.XBUTTONS.XBUTTON2)
                {
                    if (MainExplorer.ClientRectangle.Contains(MainExplorer.PointToClient(Cursor.Position)))
                    {
                        this.MainExplorer.NavigateLogLocation(NavigationLogDirection.Forward);
                    }
                    if (SubExplorer.ClientRectangle.Contains(SubExplorer.PointToClient(Cursor.Position)))
                    {
                        this.SubExplorer.NavigateLogLocation(NavigationLogDirection.Forward);
                    }
                }
            }
        }
Пример #3
0
 private void OnQueueComboBoxChanged(object sender, QueueChangeEventArgs e)
 {
     using (BlockSyncContext.Enter())
         MainExplorer.SetList(pixiv_client.GetExploreQueue(e.type, e.name).Result);
 }