Example #1
0
 public void Close()
 {
     BackgroundThreadContinue = false;
     BackgroundThread.Interrupt();
     BackgroundThread.Abort();
     BackgroundThread.Join();
     Send("Have a nice day!");
     ClientSocket.Close();
     ClientProcess.Close();
     OnExited(this);
 }
Example #2
0
    //-- FILE SEARCH

    public void SearchFiles(string s)
    {
        Searching = s.Length > 0;

        if (!Searching)
        {
            // Search done
            Invoke("HideProgress", 0.01f);
            SourceFolder.Initialize();
        }
        else
        {
            // Reset results
            sDirs  = new List <String> ();
            sFiles = new List <String> ();

            // Dispose current thread
            if (thread != null && thread.IsBusy)
            {
                thread.Abort();
                // thread.Dispose ();
            }

            // Initalize thread
            thread = new BackgroundThread();
            thread.WorkerSupportsCancellation = true;
            thread.DoWork += delegate {
                // Destroy elements
                MainThreadDispatcher.Instance().Enqueue(SourceFolder.DestroyAll);

                // Get search results
                GetResults(s);

                // Display search results
                MainThreadDispatcher.Instance().Enqueue(delegate {
                    SourceFolder.Display(sDirs, sFiles, true);
                });

                // Hide progress
                MainThreadDispatcher.Instance().Enqueue(HideProgress);
            };

            // Run thread
            thread.RunWorkerAsync();
        }
    }
 public new void Dispose()
 {
     BackgroundThread.Abort();
 }
Example #4
0
        public MetroWindow()
        {
            Initialized += delegate
            {
                WindowStyle = WindowStyle.SingleBorderWindow;
            };

            Loaded += delegate
            {
                GoToState();

                switch (SizeToContent)
                {
                case SizeToContent.WidthAndHeight:
                case SizeToContent.Height:
                case SizeToContent.Width:
                    SizeToContent = SizeToContent.Manual;
                    Width         = ActualWidth - 16;
                    Height        = ActualHeight - 32 - 7 + 3;

                    /*
                     *  // 解决何必DLL到EXE中之后残留的Bug
                     *  if (!File.Exists(Path.StartPath + @"\Arthas.dll"))
                     *  {
                     *      // Height = Height + 10;
                     *      // Width = Width + 10; // 可能某些情况下不需要,但是无法获取到这些情况,所以全部加10像素,一般来说不会有问题
                     *  }
                     */
                    break;

                default:
                    Height = ActualHeight + 32;
                    break;
                }

                MinWidth  = MinWidth == 0.0 ? Width : MinWidth;
                MinHeight = MinHeight == 0.0 ? Height : MinHeight;
                if (ResizeMode == ResizeMode.CanMinimize || ResizeMode == ResizeMode.NoResize)
                {
                    MaxWidth  = Width;
                    MaxHeight = Height;
                }
                Left = (Screen.ScreenWidthLogic - Width) / 2;
                Top  = (Screen.ScreenHeightLogic - Height) / 3;
            };
            KeyUp += delegate(object sender, KeyEventArgs e)
            {
                if (e.Key == Key.Escape && EscClose)
                {
                    Close();
                }
            };

            Closing += delegate
            {
                if (BackgroundThread != null)
                {
                    BackgroundThread.Abort();
                }
            };
            StateChanged += delegate
            {
                if (ResizeMode == ResizeMode.CanMinimize || ResizeMode == ResizeMode.NoResize)
                {
                    if (WindowState == WindowState.Maximized)
                    {
                        WindowState = WindowState.Normal;
                    }
                }
            };
#if DEBUG
            ContentRendered += delegate
            {
                if (Debugger.IsAttached)
                {
                    Title += " 编译器调试模式";
                }
                else
                {
                    Title += " 调试模式";
                }
                Debug.WriteLine("当前处于调试版本,请勿发布!!!");
            };
#endif
            Utility.Refresh(this);
        }