Example #1
0
        //private ResourceManager Appresources=new ResourceManager(WebLogViewver.
        public MainForm()
        {
            InitializeComponent();
            this.PathHasChanged=false;

            ConfigFileFullName=Path.GetFullPath(Path.Combine(Application.StartupPath,  @"..\resources\config.csv")) ;

            try
            {
                this.CurrentConfig =new WblvConfig(ConfigFileFullName);
            }
            catch(FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message+"\nUne configuration par défaut va être générée.","Fichier introuvable",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1,MessageBoxOptions.DefaultDesktopOnly);
                this.CurrentConfig =new WblvConfig(5, appsettings.default_directory,"*.log",false);

                this.CurrentConfig.SaveToFile(ConfigFileFullName);
            }

            tabConfig.ToolTipText=ConfigFileFullName;

            this.WatchedFilesList = new Dictionary<string, WatchedFileInfo>();

            if(!this.CurrentConfig.StartTimerAuto || this.CurrentConfig.UseFileSystemWatcher )
                StopTimer();
            else
                StartTimer();

            ApplyConfig(null);

            UpdateFilesList();
            if(cb_AutoStart.Checked)
                    StartTimer();
        }
Example #2
0
        private void ApplyConfig(WblvConfig wlb)
        {
            StopTimer();

            if(wlb == null)
                wlb=this.CurrentConfig;

            fileSystemWatcher1.Path=wlb.WatchedDirectory;
            tb_Filtre.Text=wlb.FileFilter;
            num_Freq.Value = wlb.TimerFrequency;
            timer1.Interval =wlb.TimerFrequency * 1000;
            cb_Path.Items.Clear();

            cb_Path.Items.AddRange(wlb.WatchedDirList());
            cb_Path.Text=wlb.WatchedDirectory;

            this.Text="WLB-"+wlb.WatchedDirectory;

            if(this.CurrentConfig.StartTimerAuto)
            {
                cb_AutoStart.Checked=true;
            }

            if(wlb.UseFileSystemWatcher)
            {
                gp_Timer.Enabled=false;
                fileSystemWatcher1.EnableRaisingEvents=true;
                rb_isFsWatch.Checked=true;
                rb_isTimer.Checked=false;
                b_TimerButton.Enabled=false;
            }
            else
            {
                gp_Timer.Enabled=true;
                fileSystemWatcher1.EnableRaisingEvents=false;
                rb_isFsWatch.Checked=false;
                rb_isTimer.Checked=true;
                b_TimerButton.Enabled=true;
            }
        }