Пример #1
0
        public MainWindow()
        {
            InitializeComponent();


            bool isFirst;

            mtx = new System.Threading.Mutex
                      (true, "zjdd ", out isFirst);

            #region Background color
            this.Background              = new SolidColorBrush(Color.FromRgb(188, 99, 163));
            this.mainPanel.Background    = this.Background;
            this.fileListView.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.about.Background        = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcBox.Background       = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcList.Background      = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.directoryTreeView.TreeViewBackground = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            #endregion

            #region Initialize directory treeview contexmenu
            dirViewContextMenu = new ContextMenu();
            MenuItem menu = new MenuItem();
            menu.Header = "Add This Folder";
            menu.Click += new RoutedEventHandler(menu_Click);
            dirViewContextMenu.Items.Add(menu);
            MenuItem open = new MenuItem();
            open.Header = "Open Folder in Windows Explorer";
            open.Click += new RoutedEventHandler(open_Click);
            dirViewContextMenu.Items.Add(open);
            MenuItem properties = new MenuItem();
            properties.Header = "Properties";
            properties.Click += new RoutedEventHandler(properties_Click);
            dirViewContextMenu.Items.Add(properties);
            this.directoryTreeView.TreeViewContextMenu = dirViewContextMenu;
            #endregion

            #region Initialize mainwindow icon
            defaultPath = Settings.Settings.Default.lrcDirectory;//
            if ("" == defaultPath.Trim())
            {
                defaultPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "ZDLRC\\";
                Settings.Settings.Default.lrcDirectory = defaultPath;
            }
            MemoryStream stream = new MemoryStream();
            Properties.Resources.lrc.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
            this.Icon = (ImageSource)imageSourceConverter.ConvertFrom(stream);



            Image image = new Image();
            image.Source = ImageHelper.ToBitmapSource(Properties.Resources.lrc);
            image.Height = image.Width = 64;


            #endregion

            #region delegate and thread
            fileList                             = new List <MusicFile>();
            lrcDownload                          = new LRCDownload();
            updateStatus                         = new UpdateStatus(UpdateSearchStatus);
            addLrcSelect                         = new AddLrcSelect(AddSearchLrc);
            addLrc                               = new AddLrc(AddDownloadLRC);
            failedList                           = new List <MusicFile>();
            searchLrcByZLP                       = new SearchLrcByZPL(SearchFromZLP);
            listViewFileList                     = new List <MusicFile>();
            fileList                             = new List <MusicFile>();
            lrcDownload                          = new LRCDownload();
            selectLRCBase                        = new LRCBase();
            scanComplete                         = new ScanComplete(ScanFinish);
            addFileToListView                    = new AddFileToListView(UpdateScanResult);
            backgroundWorker                     = new BackgroundWorker();
            backgroundWorker.DoWork             += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            #endregion

            #region Initialize aboutBox and load settings
            autoSelect.IsChecked = Settings.Settings.Default.autoSave;

            about.AppendText("LRC Download 1.0.0.1\n\n");
            about.AppendText("This is a free soft made by ZJ.\n");
            about.AppendText("If you have questions,please send me email:[email protected].\n");
            about.AppendText("Copyright© 2010-2012 of ZJSoft\n");
            new InlineUIContainer(image, about.Document.ContentEnd);
            #endregion

            #region Initialize lrcBox contexmenu
            InitLrcBoxContextMenu();
            #endregion

            #region Initialize fileListViewContextmenu
            fileListViewContextMenu = new ContextMenu();
            MenuItem clear = new MenuItem();
            clear.Header = "Remove All Files";
            clear.Click += new RoutedEventHandler(clear_Click);
            fileListViewContextMenu.Items.Add(clear);
            fileListViewContextMenu.Opened += new RoutedEventHandler(fileListViewContextMenu_Opened);
            fileListView.ContextMenu        = fileListViewContextMenu;
            #endregion

            ps    = new PipeServer(this);
            psSer = new Thread(new ThreadStart(ps.StartPipeServer));
            psSer.Start();
            //MessageBox.Show(App.args);
            if (!String.IsNullOrEmpty(App.args))
            {
                string[] pas = App.args.Split('|');
                if (pas.Length >= 3)
                {
                    if (pas[0].Trim() == "0xFFFF")
                    {
                        pas[0] = "";
                    }
                    if (pas[1].Trim() == "0xFFFF")
                    {
                        pas[1] = "";
                    }

                    SearchFromZLP(pas[0], pas[1], pas[2]);
                }
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            bool isFirst;
            mtx  = new System.Threading.Mutex
                                                               (true, "zjdd ", out   isFirst);

            #region Background color
            this.Background = new SolidColorBrush(Color.FromRgb(188, 99, 163));
            this.mainPanel.Background = this.Background;
            this.fileListView.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.about.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcBox.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcList.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.directoryTreeView.TreeViewBackground = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            #endregion

            #region Initialize directory treeview contexmenu
            dirViewContextMenu = new ContextMenu();
            MenuItem menu = new MenuItem();
            menu.Header = "Add This Folder";
            menu.Click += new RoutedEventHandler(menu_Click);
            dirViewContextMenu.Items.Add(menu);
            MenuItem open = new MenuItem();
            open.Header = "Open Folder in Windows Explorer";
            open.Click += new RoutedEventHandler(open_Click);
            dirViewContextMenu.Items.Add(open);
            MenuItem properties = new MenuItem();
            properties.Header = "Properties";
            properties.Click += new RoutedEventHandler(properties_Click);
            dirViewContextMenu.Items.Add(properties);
            this.directoryTreeView.TreeViewContextMenu = dirViewContextMenu;
            #endregion

            #region Initialize mainwindow icon
            defaultPath = Settings.Settings.Default.lrcDirectory;//
            if ("" == defaultPath.Trim())
            {
                defaultPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "ZDLRC\\";
                Settings.Settings.Default.lrcDirectory = defaultPath;
            }
            MemoryStream stream = new MemoryStream();
            Properties.Resources.lrc.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
            this.Icon = (ImageSource)imageSourceConverter.ConvertFrom(stream);

            Image image = new Image();
            image.Source = ImageHelper.ToBitmapSource(Properties.Resources.lrc);
            image.Height = image.Width = 64;

            #endregion

            #region delegate and thread
            fileList = new List<MusicFile>();
            lrcDownload = new LRCDownload();
            updateStatus = new UpdateStatus(UpdateSearchStatus);
            addLrcSelect = new AddLrcSelect(AddSearchLrc);
            addLrc = new AddLrc(AddDownloadLRC);
            failedList = new List<MusicFile>();
            searchLrcByZLP = new SearchLrcByZPL(SearchFromZLP);
            listViewFileList = new List<MusicFile>();
            fileList = new List<MusicFile>();
            lrcDownload = new LRCDownload();
            selectLRCBase = new LRCBase();
            scanComplete = new ScanComplete(ScanFinish);
            addFileToListView = new AddFileToListView(UpdateScanResult);
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            #endregion

            #region Initialize aboutBox and load settings
            autoSelect.IsChecked = Settings.Settings.Default.autoSave;

            about.AppendText("LRC Download 1.0.0.1\n\n");
            about.AppendText("This is a free soft made by ZJ.\n");
            about.AppendText("If you have questions,please send me email:[email protected].\n");
            about.AppendText("Copyright© 2010-2012 of ZJSoft\n");
            new InlineUIContainer(image, about.Document.ContentEnd);
            #endregion

            #region Initialize lrcBox contexmenu
            InitLrcBoxContextMenu();
            #endregion

            #region Initialize fileListViewContextmenu
            fileListViewContextMenu = new ContextMenu();
            MenuItem clear = new MenuItem();
            clear.Header="Remove All Files";
            clear.Click += new RoutedEventHandler(clear_Click);
            fileListViewContextMenu.Items.Add(clear);
            fileListViewContextMenu.Opened += new RoutedEventHandler(fileListViewContextMenu_Opened);
            fileListView.ContextMenu = fileListViewContextMenu;
            #endregion

            ps = new PipeServer(this);
            psSer = new Thread(new ThreadStart(ps.StartPipeServer));
            psSer.Start();
            //MessageBox.Show(App.args);
            if (!String.IsNullOrEmpty(App.args))
            {
                string[] pas = App.args.Split('|');
                if (pas.Length >= 3)
                {
                    if (pas[0].Trim() == "0xFFFF")
                        pas[0] = "";
                    if (pas[1].Trim() == "0xFFFF")
                        pas[1] = "";

                    SearchFromZLP(pas[0], pas[1], pas[2]);
                }
            }
        }