// End: Global variables.
        public DotNetFrameworkErrorWindow()
        {
            this.InitializeComponent();

            this.Title = m_ResourceManager.GetString("win_dotNetFrameworkRequirement");

            lblDescription1.Content = m_ResourceManager.GetString("lbl_dotNetFrameworkDescriptionText1");
            lblDescription2.Content = m_ResourceManager.GetString("lbl_dotNetFrameworkDescriptionText2");

            ProgramUpdateChecker dotNetFrameworkUpdateChecker = new ProgramUpdateChecker();
            dotNetFrameworkInfo = dotNetFrameworkUpdateChecker.GetRequiredDotNetInfo();
            lblDownloadLink.Content = m_ResourceManager.GetString("lbl_download") + " " + dotNetFrameworkInfo[0];
        }
示例#2
0
        // End: Global variables.
        public MainWindow()
        {
            this.InitializeComponent();

            //For debugging purpose: Reset language.
            //Properties.Settings.Default.LanguageResx = "";
            //Properties.Settings.Default.Save();

            if ((Properties.Settings.Default.LanguageResx).Equals(""))
            {
                LanguageSelection languageSelection = new LanguageSelection();
                languageSelection.Show();
                this.Hide();
            }
            else
            {
                m_ResourceManager = new ResourceManager(Properties.Settings.Default.LanguageResx,
                                        System.Reflection.Assembly.GetExecutingAssembly());

                string RunningProcess = Process.GetCurrentProcess().ProcessName;
                Process[] processes = Process.GetProcessesByName(RunningProcess);

                RegistryKey installed_versions = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
                string[] version_names = installed_versions.GetSubKeyNames();
                //version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
                double Framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1));
                int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));

                if (processes.Length > 1)
                {
                    //Make sure that there is only one OneSync application running for all the time.
                    MessageBox.Show(m_ResourceManager.GetString("msg_oneInstance"), m_ResourceManager.GetString("msg_oneInstanceTitle"), MessageBoxButton.OK, MessageBoxImage.Stop);
                    Application.Current.Shutdown();
                }
                else if (Framework < 3.5 || (Framework == 3.5 && SP < 1))
                {
                    //Check for the .NET Framework requirement.
                    //Requirement is .NET 3.5 SP1 or later.
                    DotNetFrameworkErrorWindow dotNetFrameworkErrorWindow = new DotNetFrameworkErrorWindow();
                    dotNetFrameworkErrorWindow.Show();
                    this.Hide();
                }
                else
                {
                    trayNotifyIcon = new System.Windows.Forms.NotifyIcon();
                    trayNotifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
                    trayNotifyIcon.Text = m_ResourceManager.GetString("not_name");
                    trayNotifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(trayNotifyIcon_MouseDoubleClick);
                    trayNotifyIcon.Visible = true;

                    //For Run Program context menu item
                    mnuRunProgram = new System.Windows.Forms.ToolStripMenuItem(m_ResourceManager.GetString("not_openName"));
                    mnuRunProgram.Click += new EventHandler(mnuRunProgram_Click);

                    //For Help context menu item
                    mnuHelp = new System.Windows.Forms.ToolStripMenuItem(m_ResourceManager.GetString("not_helpName"));
                    mnuHelp.Click += new EventHandler(mnuHelp_Click);

                    //For Exit context menu item
                    mnuExit = new System.Windows.Forms.ToolStripMenuItem();
                    mnuExit.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    //mnuExit.Size = new System.Drawing.Size(117, 22);
                    mnuExit.Text = m_ResourceManager.GetString("not_exitName");
                    mnuExit.Click += new EventHandler(mnuExit_Click);

                    ctxTrayMenu = new System.Windows.Forms.ContextMenuStrip();
                    ctxTrayMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuRunProgram, mnuHelp, mnuExit });

                    trayNotifyIcon.ContextMenuStrip = ctxTrayMenu;

                    // Get current synchronization directory from command line arguments.
                    // Default sync directory is current directory of app.
                    string[] args = System.Environment.GetCommandLineArgs();

                    jobManager = SyncClient.GetSyncJobManager(STARTUP_PATH);

                    if (args.Length > 1 && Validator.validateDirPath(args[1]) == null)
                    {
                        txtSyncJobName.Text = System.IO.Path.GetFileName(args[1]);
                        txtSource.Text = args[1];
                        txtSource.Focus();
                    }

                    // Tag each browse button to corr TextBox
                    btnBrowse_Source.Tag = txtSource;
                    btnBrowse.Tag = txtIntStorage;

                    // Initialize syncWorker
                    syncWorker = new BackgroundWorker();
                    syncWorker.WorkerSupportsCancellation = true;
                    syncWorker.DoWork += new DoWorkEventHandler(syncWorker_DoWork);
                    syncWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(syncWorker_RunWorkerCompleted);

                    // Configure the timer to check the Dropbox status
                    timerDropbox = new DispatcherTimer();
                    timerDropbox.Tick += new EventHandler((sender, e) => dropboxStatusChecking());
                    timerDropbox.Interval = TimeSpan.FromMilliseconds(1000);

                    // Configure the timer to check the auto sync waiting list
                    //timerAutoSync = new DispatcherTimer();
                    //timerAutoSync.Tick += new EventHandler(timerAutoSync_Tick);
                    //timerAutoSync.Interval = TimeSpan.FromMilliseconds(4000);
                    //timerAutoSync.Start();

                    _SyncJobEntries.CollectionChanged += (sender, e) => refreshCombobox();

                    // Do not show the help button if the help file is not there
                    if (!File.Exists(STARTUP_PATH + @"\OneSync.chm"))
                        btnHelp.Visibility = Visibility.Hidden;

                    // Set-up data bindings
                    listAllSyncJobs.ItemsSource = this.SyncJobEntries;
                    LoadSyncJobs();
                    new ListViewDragDrop<UISyncJobEntry>(listAllSyncJobs);

                    //Check for latest update.
                    //MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    try
                    {
                        ProgramUpdateChecker updateChecker = new ProgramUpdateChecker();
                        string updateURL = updateChecker.GetNewVersion();
                        if (!string.IsNullOrEmpty(updateURL))
                        {
                            MessageBoxResult gettingNewVersion = MessageBox.Show(
                                    m_ResourceManager.GetString("msg_newOneSyncVersion"), m_ResourceManager.GetString("msg_newOneSyncVersionTitle"),
                                        MessageBoxButton.YesNo, MessageBoxImage.Question);

                            if (gettingNewVersion == MessageBoxResult.Yes)
                                Process.Start(updateURL);
                        }
                    }
                    catch (Exception)
                    {
                        //Do nothing
                    }
                    language();
                }
            }
        }