Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();



            //讓視窗可以拖曳
            this.MouseLeftButtonDown += (sender, e) => {
                try {
                    this.DragMove();
                } catch { }
            };



            ((UIElement)dockPanel_功能列.Content).MouseWheel += new MouseWheelEventHandler((object sender, MouseWheelEventArgs e) => {
                int x = e.Delta;

                if (x > 0)
                {
                    dockPanel_功能列.LineLeft();
                }
                else
                {
                    dockPanel_功能列.LineRight();
                }
            });



            new F_快速鍵偵測(this).Show();
            SET = new C_setting(this);

            SET.fun_開啟程式時讀取上次設定(0);

            this.Closing += (sender, e) => {
                if (Directory.Exists(System.Windows.Forms.Application.StartupPath + "/data") == false)
                {
                    //新增資料夾
                    Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "/data");
                }

                SET.fun_儲存設定();
            };



            s_資料夾路徑 = System.Windows.Forms.Application.StartupPath + @"\img";

            if (Directory.Exists(s_資料夾路徑) == false)
            {
                //新增資料夾
                Directory.CreateDirectory(s_資料夾路徑);
            }

            web_資料夾.Navigate(s_資料夾路徑);



            but_截圖.Click += (sender, e) => {
                if (Top != -5000)
                {
                    d_記錄視窗位子 = Top;
                    Top      = -5000;
                    new W_截圖(this).Show();
                }
            };


            but_清空.Click += (sender, e) => {
                var w = new W_對話(this);
                w.set_text("\n確定要把所有圖片移到『資源垃圾桶』?\n");
                w.set_yes(() => {
                    // 取得資料夾內所有檔案
                    foreach (string fname in System.IO.Directory.GetFiles(s_資料夾路徑))
                    {
                        try {
                            //File.Delete(fname);
                            //把檔案移到垃圾桶,並顯示詢問視窗
                            Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(fname,
                                                                               Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
                                                                               Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
                        } catch { }
                    }
                });
                w.fun_how(this);
            };


            but_重新整理.Click += (sender, e) => {
                if (Directory.Exists(s_資料夾路徑) == false)
                {
                    Directory.CreateDirectory(s_資料夾路徑); //新增資料夾
                }
                try {
                    web_資料夾.Navigate(s_資料夾路徑);
                } catch { }
            };


            but_開啟資料夾.Click += (sender, e) => {
                if (Directory.Exists(s_資料夾路徑) == false)  //如果資料夾不存在就新增
                {
                    Directory.CreateDirectory(s_資料夾路徑);
                }
                try {
                    System.Diagnostics.Process.Start("explorer.exe", s_資料夾路徑);
                } catch { }
            };



            but_設定.Click += (sender, e) => {
                if (w_設定 != null)
                {
                    w_設定.Close();
                    w_設定 = null;
                }
                w_設定         = new W_設定(this);
                w_設定.Topmost = this.Topmost;
                w_設定.Owner   = this;
                w_設定.Show();
            };



            this.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, this.OnCloseWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, this.OnMaximizeWindow, this.OnCanResizeWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, this.OnMinimizeWindow, this.OnCanMinimizeWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, this.OnRestoreWindow, this.OnCanResizeWindow));
            //this.Style = new Style( StyleProperty.OwnerType);



            this.Loaded += MainWindow_Loaded;
            notifyShowBall.SetBalloonTip();
            notifyShowBall.notifyIcon1.Click += (s, e) =>
            {
                notifyShowBall.notifyIcon1.Visible = false;
                this.Show();
            };
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();

            C_Adapter.Initialize();

            c_視窗改變大小 = new C_視窗拖曳改變大小(this);
            this.SourceInitialized += new System.EventHandler(c_視窗改變大小.MainWindow_SourceInitialized);//右下角拖曳


            //初始化web
            wbo     = new WebBrowserOverlay(border_web);
            web_資料夾 = wbo.WebBrowser;


            //初始化頁籖物件
            Action <String> ac_點擊 = new Action <String>((String x) => {
                String s_path = func_取得儲存根目錄() + "\\" + x;

                if (bool_單層儲存路徑)
                {
                    s_path = func_取得儲存根目錄();
                }

                if (Directory.Exists(s_path) == false)
                {
                    Directory.CreateDirectory(s_path);
                }
                web_資料夾.Navigate(s_path);
            });
            Action <String> ac_切換 = new Action <String>((String x) => {
            });

            c_分頁           = new C_頁籤拖曳(stackPanel_1);
            c_分頁.ac_change = ac_切換;
            c_分頁.ac_click  = ac_點擊;



            c_右下角圖示 = new C_右下角圖示(this);
            c_右下角圖示.func_隱藏();



            SET = new C_setting(this);
            SET.fun_開啟程式時讀取上次設定(0);

            //初始化分頁
            func_分頁重新整理(true);


            //讓視窗可以拖曳
            dockPanel_功能列.MouseLeftButtonDown += (sender, e) => {
                try {
                    c_視窗改變大小.ResizeWindow(ResizeDirection.Move);//拖曳視窗
                } catch { }
            };
            lab_標題列.MouseLeftButtonDown += (sender, e) => {
                try {
                    c_視窗改變大小.ResizeWindow(ResizeDirection.Move);//拖曳視窗
                } catch { }
            };
            scroll_分頁捲軸容器.MouseLeftButtonDown += (sender, e) => {
                var obj = e.OriginalSource;
                if (obj == scroll_分頁捲軸容器)
                {
                    try {
                        this.DragMove();
                    } catch { }
                }
            };

            //雙擊全螢幕
            dockPanel_功能列.MouseDoubleClick += (sender, e) => {
                if (e.RightButton == MouseButtonState.Pressed)
                {
                    return;
                }
                var obj = e.OriginalSource;
                System.Console.WriteLine(obj);
                if (obj is Border || obj is System.Windows.Shapes.Path)
                {
                    return;
                }
                if (WindowState != WindowState.Maximized)
                {
                    WindowState = WindowState.Maximized;
                }
                else
                {
                    WindowState = WindowState.Normal;
                }
            };
            lab_標題列.MouseDoubleClick += (sender, e) => {
                if (e.RightButton == MouseButtonState.Pressed)
                {
                    return;
                }
                if (WindowState != WindowState.Maximized)
                {
                    WindowState = WindowState.Maximized;
                }
                else
                {
                    WindowState = WindowState.Normal;
                }
            };

            //讓工具列可以水平捲動
            ((UIElement)dockPanel_功能列.Content).MouseWheel += new MouseWheelEventHandler((object sender, MouseWheelEventArgs e) => {
                int x = e.Delta;
                if (x > 0)
                {
                    dockPanel_功能列.LineLeft();
                }
                else
                {
                    dockPanel_功能列.LineRight();
                }
            });



            but_截圖.Click += (sender, e) => {
                func_截圖();
            };


            but_清空.Click += (sender, e) => {
                func_刪除目前資料夾();
            };


            but_重新整理.Click += (sender, e) => {
                func_重新整理資料夾();
            };

            but_開啟資料夾.Click += (sender, e) => {
                func_開啟資料夾();
            };

            but_設定.Click += (sender, e) => {
                if (w_設定 != null)
                {
                    w_設定.Close();
                    w_設定 = null;
                }
                w_設定         = new W_設定(this);
                w_設定.Topmost = this.Topmost;
                w_設定.Owner   = this;
                w_設定.Show();
            };


            //鎖定視窗在最上層
            but_鎖定視窗.Click += (sender, e) => {
                func_視窗最上層(this, "auto");
            };


            but_縮小至右下角.Click += (sender, e) => {
                func_縮小至右下角(true);
            };

            //分頁容器的右鍵選單
            var u_menu_分頁容器 = new U_menu(this);

            scroll_分頁捲軸容器.MouseRightButtonUp += (sender, e) => {
                if (e.OriginalSource == scroll_分頁捲軸容器)
                {
                    u_menu_分頁容器.func_open_滑鼠旁邊();
                }
            };
            but_分頁_add.MouseRightButtonUp += (sender, e) => {
                u_menu_分頁容器.func_open_滑鼠旁邊();
            };
            u_menu_分頁容器.func_add_menu("重新整理", null, () => {
                func_分頁重新整理();
            });
            u_menu_分頁容器.func_add_menu("開啟資料夾位置", null, () => {
                try {
                    System.Diagnostics.Process.Start("explorer.exe", "\"" + func_取得儲存根目錄().Replace("/", "\\") + "\"");
                } catch { }
            });
            u_menu_分頁容器.func_add_menu("新增", null, () => {
                but_分頁_add_Click(null, null);
            });


            this.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, this.OnCloseWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, this.OnMaximizeWindow, this.OnCanResizeWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, this.OnMinimizeWindow, this.OnCanMinimizeWindow));
            this.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, this.OnRestoreWindow, this.OnCanResizeWindow));



            this.Closing += (sender, e) => {
                if (Directory.Exists(func_exe_path() + "\\data") == false)
                {
                    Directory.CreateDirectory(func_exe_path() + "\\data");
                }
                SET.fun_儲存設定();
            };


            this.Loaded += MainWindow_Loaded;
        }