コード例 #1
0
        private bool TryCreateShortcut()
        {
            using (FileProtectorContext dbContext = new FileProtectorContext())
            {
                dbContext.Database.Migrate();
            }

            String shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Windows\\Start Menu\\Programs\\File Protector.lnk";

            if (!File.Exists(shortcutPath))
            {
                InstallShortcut(shortcutPath);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        public MainWindow()
        {
            this.Closed += (sender, e) => { Environment.Exit(0); };
            InitializeComponent();
            PopulateFilesList();

            isMonitoringActive            = readFromRegistry("isMonitoring");
            ComboMonitoring.SelectedIndex = isMonitoringActive ? 0 : 1;
            isDefaultBlockingActive       = readFromRegistry("isDefaultBlocking");
            ComboBlock.SelectedIndex      = isDefaultBlockingActive ? 0 : 1;
            showIcons();
            isInitState = false;

            fp = new FileProtectorContext();
            PopulateHistoryList();
            syncCtx = SynchronizationContext.Current;
            worker  = new Thread(NotificationWorker);
            worker.SetApartmentState(ApartmentState.STA);
            worker.Start();
            InitializeLabels();
            createTray();
            Closing        += OnWindowClosing;
            this.ResizeMode = ResizeMode.CanMinimize;
        }