Exemple #1
0
        private void OnChangeTimer(object sender, EventArgs e)
        {
            if (IsDisposed)
            {
                return;
            }

            var page = (PageType)tabControl.SelectedIndex;

            switch (page)
            {
            case PageType.Header:
                m_Template.Header.Text            = this.htmlReportHeaderControl.InnerHtml ?? "";
                m_Template.Header.Enabled         = headerEnabledCheckbox.Checked;
                m_Template.Header.WantDivider     = headerDividerCheckbox.Checked;
                m_Template.Header.BackColor       = this.htmlReportHeaderControl.BackColor;
                m_Template.Header.PixelHeightText = this.headerHeightCombobox.Text;
                break;

            case PageType.Title:
                m_Template.Title.Text         = this.htmlReportTitleControl.InnerHtml ?? "";
                m_Template.Title.Enabled      = titleEnabledCheckbox.Checked;
                m_Template.Title.SeparatePage = this.titleSeparatePageCheckbox.Checked;
                break;

            case PageType.Tasks:
                if (!this.tableHeaderRowCombobox.DroppedDown)
                {
                    // Only update if the header row combo is NOT dropped down
                    // else it's inconsistent with the rest of the updates
                    m_Template.Task.Text           = this.htmlReportTasksControl.InnerHtml ?? "";
                    m_Template.Task.Enabled        = true;                      // always
                    m_Template.Task.TableHeaderRow = this.tableHeaderRowCombobox.SelectedOption;
                }
                break;

            case PageType.Footer:
                m_Template.Footer.Text            = this.htmlReportFooterControl.InnerHtml ?? "";
                m_Template.Footer.Enabled         = footerEnabledCheckbox.Checked;
                m_Template.Footer.WantDivider     = footerDividerCheckbox.Checked;
                m_Template.Footer.BackColor       = this.htmlReportFooterControl.BackColor;
                m_Template.Footer.PixelHeightText = this.footerHeightCombobox.Text;
                break;
            }

            if (!m_Template.Equals(m_PrevTemplate))
            {
                m_ChangeTimer.Stop();

                OnChangeTemplate(page, m_PrevTemplate, m_Template);

                m_PrevTemplate.Copy(m_Template);
                m_EditedSinceLastSave = true;

                m_ChangeTimer.Start();
            }

            // always
            UpdateToolbar();
        }
Exemple #2
0
        // --------------------------------------------------------------

        public HtmlReportTemplateForm(String typeId, Translator trans, TaskList tasks, Preferences prefs, String key)
        {
            m_TypeId   = typeId;
            m_Trans    = trans;
            m_Tasklist = tasks;
            m_Prefs    = prefs;
            m_PrefsKey = key;

            m_Template         = new HtmlReportTemplate();
            m_PrevTemplate     = new HtmlReportTemplate();
            m_CustomAttributes = new Dictionary <String, String>();

            m_EditedSinceLastSave = false;
            m_TemplateFilePath    = prefs.GetProfileString(key, "LastOpenTemplate", "");

            if (!m_Template.Load(m_TemplateFilePath))
            {
                m_TemplateFilePath = String.Empty;
            }
            else
            {
                m_PrevTemplate.Copy(m_Template);
            }

            m_ChangeTimer          = new Timer();
            m_ChangeTimer.Tick    += new EventHandler(OnChangeTimer);
            m_ChangeTimer.Interval = 500;

            InitializeComponent();

            // Build list custom attribute IDs for later use
            if (tasks.HasCustomAttributes())
            {
                var numAttrib = tasks.GetCustomAttributeCount();
                var attribs   = new Dictionary <String, String>();

                for (var attrib = 0; attrib < numAttrib; attrib++)
                {
                    m_CustomAttributes.Add(tasks.GetCustomAttributeID(attrib).ToLower(),
                                           tasks.GetCustomAttributeLabel(attrib));
                }
            }

            this.htmlReportTasksControl.SetCustomAttributes(m_CustomAttributes);

            HtmlEditorControlEx.SizeEditHtmlForm = new Size(prefs.GetProfileInt(key, "HtmlFormWidth", -1),
                                                            prefs.GetProfileInt(key, "HtmlFormHeight", -1));

            var prevSize = new Size(prefs.GetProfileInt(key, "TemplateFormWidth", -1),
                                    prefs.GetProfileInt(key, "TemplateFormHeight", -1));

            if ((prevSize.Width > 0) && (prevSize.Height > 0))
            {
                this.Size = prevSize;
            }
        }
        private void CheckRefreshPreview()
        {
            if (!m_Template.Equals(m_PrevTemplate))
            {
                m_ChangeTimer.Stop();

                m_PrevTemplate.Copy(m_Template);
                RefreshPreview();

                m_ChangeTimer.Start();
            }
        }
        private Size LoadPreferences()
        {
            // Last template
            m_TemplateFilePath = m_Prefs.GetProfileString(m_PrefsKey, "LastOpenTemplate", "");

            if (!m_Template.Load(m_TemplateFilePath))
            {
                m_TemplateFilePath = String.Empty;
            }
            else
            {
                m_PrevTemplate.Copy(m_Template);
            }

            // Template history
            int numHistory = m_Prefs.GetProfileInt(m_PrefsKey, "TemplateHistoryCount", 0);

            for (int nItem = 0; nItem < numHistory; nItem++)
            {
                string path = m_Prefs.GetProfileString(m_PrefsKey, string.Format("History{0}", nItem), "");

                if (!string.IsNullOrEmpty(path) && (path != m_TemplateFilePath))
                {
                    toolStripFileHistory.Items.Add(new TemplateHistoryItem(path));
                }
            }
            AddFileToTopOfHistory(m_TemplateFilePath);

            // Window sizes
            HtmlEditorControlEx.SizeEditHtmlForm = new Size(m_Prefs.GetProfileInt(m_PrefsKey, "HtmlFormWidth", -1),
                                                            m_Prefs.GetProfileInt(m_PrefsKey, "HtmlFormHeight", -1));

            var prevSize = new Size(m_Prefs.GetProfileInt(m_PrefsKey, "TemplateFormWidth", -1),
                                    m_Prefs.GetProfileInt(m_PrefsKey, "TemplateFormHeight", -1));

            return(prevSize);
        }