예제 #1
0
        protected Dictionary <string, int> m_fileNames; // Dictionary to maintain the unicity of each file of a dialog

        public FileExporter(Config config)
        {
            m_config    = config;
            m_archiver  = config.Archiver;
            m_messages  = new StringBuilder();
            m_links     = new StringBuilder();
            m_logs      = new StringBuilder();
            m_fileNames = new Dictionary <string, int>();
        }
예제 #2
0
        public FormTLArchiver()
        {
            InitializeComponent();
            m_config = new Config();
            Config.Load(m_config);
            m_archiver        = new TLAArchiver(m_config);
            m_orderColumnName = "";
            // Grid configuration
            m_dialogSource.DataSource                = m_dialogView;   // m_dialogSource.SupportsFiltering: true
            m_dgvDialogs.DataSource                  = m_dialogSource; // Initialize the grid
            m_dgvDialogs.RowHeadersVisible           = false;
            m_dgvDialogs.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            m_dgvDialogs.SelectionMode               = DataGridViewSelectionMode.FullRowSelect;
            m_dgvDialogs.AllowUserToAddRows          = false;
            // The grid is readonly except for the 1st column which is the selection
            foreach (DataGridViewColumn col in m_dgvDialogs.Columns)
            {
                col.ReadOnly = true;
            }
            DataGridViewColumn selectedCol = m_dgvDialogs.Columns["Selected"];

            selectedCol.ReadOnly = false;
            selectedCol.Width    = 50;
            if (m_config.CountMessagesAtLaunch)
            {
                // Fill the last column to match the resize of the form
                m_dgvDialogs.Columns["Total"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
            else
            {
                m_dgvDialogs.Columns["Total"].Visible       = false;                               // Hide the 'Total' column
                m_dgvDialogs.Columns["Closed"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; // Become the last column
                Width -= 50;
            }
            m_dgvDialogs.Columns["AccessHash"].Visible = false; // Hide the 'AccessHash' column
            m_dgvDialogs.Columns["Title"].Width        = 200;   // Enlarge the 'Title' column
            // Add an event on the header cell to sort the grid
            m_dgvDialogs.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(m_dgvDialogs_ColumnHeaderMouseClick);
            // CheckBox event handler walkaround https://stackoverflow.com/questions/11843488/datagridview-checkbox-event
            m_dgvDialogs.CellContentClick += new DataGridViewCellEventHandler(m_dgvDialogs_CellContentClick);
            m_dgvDialogs.CellValueChanged += new DataGridViewCellEventHandler(m_dgvDialogs_CellValueChanged);
            // Checkbox header
            m_cbHeader                    = new DatagridViewCheckBoxHeaderCell();
            m_cbHeader.Value              = "";
            m_cbHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(m_cbHeader_CheckBoxClicked);
        }
예제 #3
0
        private void FormExport_Shown(object sender, System.EventArgs e)
        {
            // Prepare arguments
            FormTLArchiver arg = this.Owner as FormTLArchiver;

            if (arg == null)
            {
                throw new TLUIException("Owner is not a FormTLArchiveMedia");
            }
            Config                  config     = arg.GetConfig();
            TLAArchiver             archiver   = arg.Archiver;
            ICollection <TLADialog> dialogList = arg.Dialogs.Where(d => d.Selected).ToList(); // Process selected dialogs only

            // How to: Create and Terminate Threads
            // https://msdn.microsoft.com/en-us/library/7a2f3ay4(v=vs.100).aspx

            // Create the worker thread object. This does not start the thread.
            m_exporter = new TLAExporter(config, dialogList);
            if (config.ExportText)
            {
                m_exporter.AddExporter(new TxtExporter(config, m_exporter.ExportDirectory));
            }
            if (config.ExportHtml)
            {
                m_exporter.AddExporter(new HtmlExporter(config, m_exporter.ExportDirectory));
            }
            m_exporter.AddExporter(this);
            m_exporterThread      = new Thread(m_exporter.Start);
            m_exporterThread.Name = "Export Thread";

            // Start the worker thread.
            m_exporterThread.Start();

            // Loop until the worker thread activates.
            while (!m_exporterThread.IsAlive)
            {
                ;
            }
        }