Пример #1
0
        /// <summary>
        /// Checks the chapter and multimedia (stylesheet) selection, generates the HTML page by arrayList function call and loads the page.
        /// </summary>
        /// <param name="sender">Event Sender, unused.</param>
        /// <param name="e">Event Arguments, unused.</param>
        /// <remarks>Documented by Dev01, 2007-07-19</remarks>
        /// <remarks>Documented by Dev02, 2007-11-23</remarks>
        private void btnPreview_Click(object sender, EventArgs e)
        {
            // Only start the query when at least one chapter and box has been selected
            if (Chapters.GetItemCount() < 1 || (listViewBoxesSelection.CheckedItems.Count < 1 && !checkBoxAllBoxes.Checked))
            {
                MessageBox.Show(Resources.PRINT_SELECT_TEXT, Resources.PRINT_SELECT_CAPTION,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                this.Enabled = false;

                statusDialog = new LoadStatusMessage(Properties.Resources.PRINT_STATUS_FETCHINGCARDS, 100, false);
                statusDialog.Show();
                statusDialog.SetProgress(0);

                BackgroundWorker worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;
                worker.ProgressChanged      += new ProgressChangedEventHandler(worker_ProgressChanged);

                BackgroundWorker prepareworker = new BackgroundWorker();
                prepareworker.WorkerReportsProgress = true;
                prepareworker.ProgressChanged      += new ProgressChangedEventHandler(prepareworker_ProgressChanged);

                System.Collections.Generic.List <int> boxes;
                QueryOrder     cardorder;
                QueryOrderDir  cardorderdir;
                QueryCardState cardstate;
                GetGUISelection(out boxes, out cardorder, out cardorderdir, out cardstate);

                List <QueryStruct> querystructs = GetQueryStructs(Chapters.SelChapters, boxes, cardstate);

                string stylesheet = ((StyleInfo)comboBoxPrintStyle.SelectedItem).Path;

                List <ICard> cards = Dictionary.GetPrintOutCards(querystructs, cardorder, cardorderdir);

                string htmlContent = Dictionary.GeneratePrintOut(
                    cards,
                    stylesheet,
                    worker,
                    prepareworker);

                statusDialog.InfoMessage       = Resources.PRINT_STATUS_RENDERING;
                statusDialog.EnableProgressbar = false;

                Browser.DocumentText = htmlContent;
            }
        }
Пример #2
0
        /// <summary>
        /// Fills the browser with the current print material.
        /// </summary>
        /// <param name="sender">The sender button.</param>
        /// <remarks>Documented by Dev02, 2008-01-03</remarks>
        private void FillBrowser(object sender)
        {
            this.Enabled = false;
            if (this.ParentWizard is Wizard)
                this.ParentWizard.Enabled = false;

            statusDialog = new LoadStatusMessage(Properties.Resources.PRINT_STATUS_FETCHINGCARDS, 100, false);
            statusDialog.Show();
            statusDialog.SetProgress(0);

            dictionary.PreloadCardCache();

            BackgroundWorker worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);

            BackgroundWorker prepareworker = new BackgroundWorker();
            prepareworker.WorkerReportsProgress = true;
            prepareworker.ProgressChanged += new ProgressChangedEventHandler(prepareworker_ProgressChanged);

            QueryOrder cardorder;
            QueryOrderDir cardorderdir;

            GetSelection(out cardorder, out cardorderdir);

            List<QueryStruct> querystructs = new List<QueryStruct>();
            List<ICard> cards = new List<ICard>();

            switch (settings.Type)
            {
                case PrintType.All:
                    querystructs.Add(new QueryStruct(QueryCardState.All));
                    break;
                case PrintType.Wrong:
                    querystructs.Add(new QueryStruct(-1, 1));
                    break;
                case PrintType.Chapter:
                    foreach (int id in settings.IDs)
                        querystructs.Add(new QueryStruct(id, -1));
                    break;
                case PrintType.Boxes:
                    foreach (int id in settings.IDs)
                        querystructs.Add(new QueryStruct(-1, id));
                    break;
                case PrintType.Individual:
                    cards = dictionary.GetPrintOutCards(settings.IDs, cardorder, cardorderdir);
                    break;
                default:
                    break;
            }

            if (settings.Type != PrintType.Individual)
                cards = dictionary.GetPrintOutCards(querystructs, cardorder, cardorderdir);

            if (cards == null || cards.Count < 1)
            {
                statusDialog.Close();
                MessageBox.Show(MLifter.Controls.Properties.Resources.PRINT_NOCARDS_TEXT, MLifter.Controls.Properties.Resources.PRINT_NOCARDS_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Enabled = true;
                if (this.ParentWizard is Wizard)
                    this.ParentWizard.Enabled = true;
                return;
            }

            string stylesheet = ((StyleInfo)comboBoxStyle.SelectedItem).Path;

            string htmlContent = dictionary.GeneratePrintOut(
                cards,
                stylesheet,
                worker,
                prepareworker);

            #if DEBUG
            try
            {
                System.IO.StreamWriter writer = new System.IO.StreamWriter(System.IO.Path.Combine(Application.StartupPath, "Print.htm"));
                writer.Write(htmlContent);
                writer.Close();
            }
            catch { }
            #endif

            statusDialog.InfoMessage = Properties.Resources.PRINT_STATUS_RENDERING;
            statusDialog.EnableProgressbar = false;

            Browser.Tag = sender;
            Browser.DocumentText = htmlContent;
            //now we must wait for the webbrowser to complete loading [ML-63]
        }
Пример #3
0
        /// <summary>
        /// Fills the browser with the current print material.
        /// </summary>
        /// <param name="sender">The sender button.</param>
        /// <remarks>Documented by Dev02, 2008-01-03</remarks>
        private void FillBrowser(object sender)
        {
            this.Enabled = false;
            if (this.ParentWizard is Wizard)
            {
                this.ParentWizard.Enabled = false;
            }

            statusDialog = new LoadStatusMessage(Properties.Resources.PRINT_STATUS_FETCHINGCARDS, 100, false);
            statusDialog.Show();
            statusDialog.SetProgress(0);

            dictionary.PreloadCardCache();

            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress = true;
            worker.ProgressChanged      += new ProgressChangedEventHandler(worker_ProgressChanged);

            BackgroundWorker prepareworker = new BackgroundWorker();

            prepareworker.WorkerReportsProgress = true;
            prepareworker.ProgressChanged      += new ProgressChangedEventHandler(prepareworker_ProgressChanged);

            QueryOrder    cardorder;
            QueryOrderDir cardorderdir;

            GetSelection(out cardorder, out cardorderdir);

            List <QueryStruct> querystructs = new List <QueryStruct>();
            List <ICard>       cards        = new List <ICard>();

            switch (settings.Type)
            {
            case PrintType.All:
                querystructs.Add(new QueryStruct(QueryCardState.All));
                break;

            case PrintType.Wrong:
                querystructs.Add(new QueryStruct(-1, 1));
                break;

            case PrintType.Chapter:
                foreach (int id in settings.IDs)
                {
                    querystructs.Add(new QueryStruct(id, -1));
                }
                break;

            case PrintType.Boxes:
                foreach (int id in settings.IDs)
                {
                    querystructs.Add(new QueryStruct(-1, id));
                }
                break;

            case PrintType.Individual:
                cards = dictionary.GetPrintOutCards(settings.IDs, cardorder, cardorderdir);
                break;

            default:
                break;
            }

            if (settings.Type != PrintType.Individual)
            {
                cards = dictionary.GetPrintOutCards(querystructs, cardorder, cardorderdir);
            }

            if (cards == null || cards.Count < 1)
            {
                statusDialog.Close();
                MessageBox.Show(MLifter.Controls.Properties.Resources.PRINT_NOCARDS_TEXT, MLifter.Controls.Properties.Resources.PRINT_NOCARDS_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Enabled = true;
                if (this.ParentWizard is Wizard)
                {
                    this.ParentWizard.Enabled = true;
                }
                return;
            }

            string stylesheet = ((StyleInfo)comboBoxStyle.SelectedItem).Path;

            string htmlContent = dictionary.GeneratePrintOut(
                cards,
                stylesheet,
                worker,
                prepareworker);

#if DEBUG
            try
            {
                System.IO.StreamWriter writer = new System.IO.StreamWriter(System.IO.Path.Combine(Application.StartupPath, "Print.htm"));
                writer.Write(htmlContent);
                writer.Close();
            }
            catch { }
#endif

            statusDialog.InfoMessage       = Properties.Resources.PRINT_STATUS_RENDERING;
            statusDialog.EnableProgressbar = false;

            Browser.Tag          = sender;
            Browser.DocumentText = htmlContent;
            //now we must wait for the webbrowser to complete loading [ML-63]
        }