예제 #1
0
        void richEditControl_InitializeDocument(object sender, EventArgs e)
        {
            Document document = Control.Document;

            document.BeginUpdate();
            try {
                document.DefaultCharacterProperties.FontName = "Courier New";
                document.DefaultCharacterProperties.FontSize = 10;
                document.Sections[0].Page.Width                = Units.InchesToDocumentsF(100);
                document.Sections[0].LineNumbering.CountBy     = 1;
                document.Sections[0].LineNumbering.RestartType = LineNumberingRestart.Continuous;

                SizeF             tabSize = Control.MeasureSingleLineString("    ", document.DefaultCharacterProperties);
                TabInfoCollection tabs    = document.Paragraphs[0].BeginUpdateTabs(true);
                try {
                    for (int i = 1; i <= 30; i++)
                    {
                        DevExpress.XtraRichEdit.API.Native.TabInfo tab = new DevExpress.XtraRichEdit.API.Native.TabInfo();
                        tab.Position = i * tabSize.Width;
                        tabs.Add(tab);
                    }
                }
                finally {
                    document.Paragraphs[0].EndUpdateTabs(tabs);
                }
            }
            finally {
                document.EndUpdate();
            }
        }
예제 #2
0
        static void FormatParagraph(Document document)
        {
            #region #FormatParagraph
            document.BeginUpdate();
            document.AppendText("Modified Paragraph\nNormal\nNormal");
            document.EndUpdate();

            //The target range is the first paragraph
            DocumentPosition pos   = document.Range.Start;
            DocumentRange    range = document.CreateRange(pos, 0);

            // Create and customize an object
            // that sets character formatting for the selected range
            ParagraphProperties pp = document.BeginUpdateParagraphs(range);
            // Center paragraph
            pp.Alignment = ParagraphAlignment.Center;
            // Set triple spacing
            pp.LineSpacingType       = ParagraphLineSpacing.Multiple;
            pp.LineSpacingMultiplier = 3;
            // Set left indent at 0.5".
            // Default unit is 1/300 of an inch (a document unit).
            pp.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f);
            // Set tab stop at 1.5"
            TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
            TabInfo           tbi     = new DevExpress.XtraRichEdit.API.Native.TabInfo();
            tbi.Alignment = TabAlignmentType.Center;
            tbi.Position  = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);
            tbiColl.Add(tbi);
            pp.EndUpdateTabs(tbiColl);

            //Finalize modifications
            // with this method call
            document.EndUpdateParagraphs(pp);
            #endregion #FormatParagraph
        }
        private void FormatTitleParagraph(Document document)
        {
            #region #FormatTitleParagraph
            //The target range is the first paragraph
            DocumentRange titleParagraph = document.Paragraphs[0].Range;

            //Provide access to the paragraph options
            ParagraphProperties titleParagraphFormatting = document.BeginUpdateParagraphs(titleParagraph);

            //Set the paragraph alignment
            titleParagraphFormatting.Alignment = ParagraphAlignment.Center;

            //Set left indent at 0.5".
            //Default unit is 1/300 of an inch (a document unit).
            titleParagraphFormatting.LeftIndent   = Units.InchesToDocumentsF(0.5f);
            titleParagraphFormatting.SpacingAfter = Units.InchesToDocumentsF(0.3f);

            //Set tab stop at 1.5"
            TabInfoCollection tbiColl = titleParagraphFormatting.BeginUpdateTabs(true);
            TabInfo           tbi     = new TabInfo();
            tbi.Alignment = TabAlignmentType.Center;
            tbi.Position  = Units.InchesToDocumentsF(1.5f);
            tbiColl.Add(tbi);
            titleParagraphFormatting.EndUpdateTabs(tbiColl);

            document.EndUpdateParagraphs(titleParagraphFormatting);
            #endregion #FormatTitleParagraph
        }
 private void btnFormatParagraph_Click(object sender, EventArgs e)
 {
     #region #formatparagraph
     Document            doc   = richEditControl1.Document;
     DocumentPosition    pos   = doc.Selection.Start;
     DocumentRange       range = doc.CreateRange(pos, 0);
     ParagraphProperties pp    = doc.BeginUpdateParagraphs(range);
     // Center paragraph
     pp.Alignment = ParagraphAlignment.Center;
     // Set triple spacing
     pp.LineSpacingType       = ParagraphLineSpacing.Multiple;
     pp.LineSpacingMultiplier = 3;
     // Set left indent at 0.5".
     // Default unit is 1/300 of an inch (a document unit).
     pp.LeftIndent = Units.InchesToDocumentsF(0.5f);
     // Set tab stop at 1.5"
     TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
     TabInfo           tbi     = new TabInfo();
     tbi.Alignment = TabAlignmentType.Center;
     tbi.Position  = Units.InchesToDocumentsF(1.5f);
     tbiColl.Add(tbi);
     pp.EndUpdateTabs(tbiColl);
     doc.EndUpdateParagraphs(pp);
     #endregion #formatparagraph
 }
 static void FormatParagraph(RichEditDocumentServer wordProcessor)
 {
     #region #FormatParagraph
     Document document = wordProcessor.Document;
     document.BeginUpdate();
     document.AppendText("Modified Paragraph\nNormal\nNormal");
     document.EndUpdate();
     DocumentPosition    pos   = document.Range.Start;
     DocumentRange       range = document.CreateRange(pos, 0);
     ParagraphProperties pp    = document.BeginUpdateParagraphs(range);
     // Center paragraph
     pp.Alignment = ParagraphAlignment.Center;
     // Set triple spacing
     pp.LineSpacingType       = ParagraphLineSpacing.Multiple;
     pp.LineSpacingMultiplier = 3;
     // Set left indent at 0.5".
     // Default unit is 1/300 of an inch (a document unit).
     pp.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f);
     // Set tab stop at 1.5"
     TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
     TabInfo           tbi     = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     tbi.Alignment = TabAlignmentType.Center;
     tbi.Position  = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);
     tbiColl.Add(tbi);
     pp.EndUpdateTabs(tbiColl);
     document.EndUpdateParagraphs(pp);
     #endregion #FormatParagraph
 }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //richEditControl1.CreateNewDocument();
            #region #tabs
            richEditControl1.Document.Unit = DevExpress.Office.DocumentUnit.Inch;
            TabInfoCollection tabs = richEditControl1.Document.Paragraphs[0].BeginUpdateTabs(true);
            TabInfo           tab1 = new TabInfo();
            // Sets tab stop at 2.5 inch
            tab1.Position  = 2.5f;
            tab1.Alignment = TabAlignmentType.Left;
            tab1.Leader    = TabLeaderType.MiddleDots;
            tabs.Add(tab1);
            TabInfo tab2 = new TabInfo();
            tab2.Position  = 5.5f;
            tab2.Alignment = TabAlignmentType.Decimal;
            tab2.Leader    = TabLeaderType.EqualSign;
            tabs.Add(tab2);
            richEditControl1.Document.Paragraphs[0].EndUpdateTabs(tabs);
            #endregion #tabs
            if (checkEdit1.Checked)
            {
                string s = textEdit1.Text.Replace("\\t", "\t");
                richEditControl1.Options.Behavior.TabMarker = s;
            }

            InsertTabCommand cmd = new InsertTabCommand(richEditControl1);
            cmd.Execute();
            richEditControl1.Document.InsertSingleLineText(richEditControl1.Document.Selection.Start, "Amount");
            cmd.Execute();
            richEditControl1.Document.InsertSingleLineText(richEditControl1.Document.Selection.Start, "222.22");
        }
예제 #7
0
        public void LoadSettings(NUnit.Util.ISettings settings)
        {
            this.settings = settings;

            TabInfoCollection info    = new TabInfoCollection();
            string            tabList = (string)settings.GetSetting(Prefix + "TabList");

            if (tabList != null)
            {
                string[] tabNames = tabList.Split(new char[] { ',' });
                foreach (string name in tabNames)
                {
                    string prefix = Prefix + name;
                    string text   = (string)settings.GetSetting(prefix + ".Title");
                    if (text == null)
                    {
                        break;
                    }

                    TabInfo tab = new TabInfo(name, text);
                    tab.Content = (TextDisplayContent)settings.GetSetting(prefix + ".Content", TextDisplayContent.Empty);
                    tab.Enabled = settings.GetSetting(prefix + ".Enabled", true);
                    info.Add(tab);
                }
            }

            if (info.Count > 0)
            {
                tabInfo = info;
            }
            else
            {
                LoadDefaults();
            }
        }
예제 #8
0
        void richEditControl_InitializeDocument(object sender, EventArgs e)
        {
            var document = Control.RichEditControl.Document;

            document.BeginUpdate();
            try {
                document.DefaultCharacterProperties.FontName = "Courier New";
                document.DefaultCharacterProperties.FontSize = 10;
                document.Sections[0].Page.Width = Units.InchesToDocumentsF(100);

                SizeF             tabSize = Control.RichEditControl.MeasureSingleLineString("    ", document.DefaultCharacterProperties);
                TabInfoCollection tabs    = document.Paragraphs[0].BeginUpdateTabs(true);
                try {
                    for (int i = 1; i <= 30; i++)
                    {
                        var tab = new TabInfo {
                            Position = i * tabSize.Width
                        };
                        tabs.Add(tab);
                    }
                }
                finally {
                    document.Paragraphs[0].EndUpdateTabs(tabs);
                }
            }
            finally {
                document.EndUpdate();
            }
        }
예제 #9
0
        public moregadgets()
        {
            if (this.userid < 1)
            {
                HttpContext.Current.Response.Redirect(forumurlnopage + "/login.aspx?reurl=space");
                return;
            }
            GetOnlineUserInfo();

#if NET1
            TabInfoCollection tc = Spaces.GetTabInfoCollectionByUserID(this.userid);
#else
            Discuz.Common.Generic.List <TabInfo> tc = Spaces.GetTabInfoCollectionByUserID(this.userid);
#endif

            currentUserSpaceConfig = Spaces.GetSpaceConfigByUserId(this.userid);
            int            defaultTabId = Spaces.GetDefaultTabId(currentUserSpaceConfig, tc);
            string         html         = StaticFileProvider.GetContent(templatePath + "moregadgets.htm");
            TemplateEngine te           = new TemplateEngine();
            te.Init(html, templatePath);
            te.Put("tabid", defaultTabId);
            te.Put("forumpath", BaseConfigs.GetForumPath);
            te.Put("config", currentUserSpaceConfig);
            te.Put("username", this.olusername);
            te.Put("userid", this.oluserid);
            te.Put("userkey", oluserkey);
            te.Put("forumurlnopage", forumurlnopage);
            double processtime = new TimeSpan(DateTime.Now.Ticks).Subtract(begints).Duration().TotalSeconds;
            te.Put("processtime", processtime);
            html = te.MergeTemplate();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(html);
            HttpContext.Current.Response.End();
        }
		public void LoadSettings(NUnit.Util.ISettings settings)
		{
			this.settings = settings;

			TabInfoCollection info = new TabInfoCollection();
			string tabList = (string)settings.GetSetting( Prefix + "TabList" );

			if ( tabList != null ) 
			{
				string[] tabNames = tabList.Split( new char[] { ',' } );
				foreach( string name in tabNames )
				{
					string prefix = Prefix + name;
					string text = (string)settings.GetSetting(prefix + ".Title");
					if ( text == null )
						break;

					TabInfo tab = new TabInfo( name, text );
					tab.Content = (TextDisplayContent)settings.GetSetting(prefix + ".Content", TextDisplayContent.Empty );
					tab.Enabled = settings.GetSetting( prefix + ".Enabled", true );
					info.Add( tab );
				}
			}

			if ( info.Count > 0 )		
				tabInfo = info;
			else 
				LoadDefaults();
		}
예제 #11
0
        public void LoadDefaults()
        {
            tabInfo = new TabInfoCollection();

            // Get any legacy settings
            bool mergeErrorOutput = settings.GetSetting( "Gui.ResultTabs.MergeErrorOutput", false );
            bool mergeTraceOutput = settings.GetSetting( "Gui.ResultTabs.MergeTraceOutput", false );

            TabInfo tab0 = tabInfo.AddNewTab( "Console.Out" );
            tab0.Content = TextDisplayContent.Out;
            if ( mergeErrorOutput )
                tab0.Content |= TextDisplayContent.Error;
            if ( mergeTraceOutput )
                tab0.Content |= TextDisplayContent.Trace;
            if ( settings.GetSetting( "Gui.ResultTabs.DisplayTestLabels", false ) )
                tab0.Content |= TextDisplayContent.Labels;
            tab0.Enabled = settings.GetSetting( "Gui.ResultTabs.DisplayConsoleOutputTab", true );

            TabInfo tab1 = tabInfo.AddNewTab( "Console.Error" );
            tab1.Content = mergeErrorOutput ? TextDisplayContent.Empty : TextDisplayContent.Error;
            tab1.Enabled = settings.GetSetting( "Gui.ResultTabs.DisplayConsoleErrorTab", true );

            TabInfo tab2 = tabInfo.AddNewTab( "Trace" );
            tab2.Content = mergeTraceOutput ? TextDisplayContent.Empty : TextDisplayContent.Trace;
            tab2.Enabled = settings.GetSetting( "Gui.ResultTabs.DisplayTraceTab", true );

            TabInfo tab3 = tabInfo.AddNewTab( "Log" );
            tab3.Content = TextDisplayContent.Log;
            tab3.Enabled = settings.GetSetting( "Gui.ResultTabs.DisplayLoggingTab", true );
        }
예제 #12
0
        public void LoadDefaults()
        {
            tabInfo = new TabInfoCollection();

            TabInfo tab = tabInfo.AddNewTab("Text Output");

            tab.Content        = new TextDisplayContent();
            tab.Content.Out    = true;
            tab.Content.Error  = true;
            tab.Content.Labels = TestLabelLevel.On;
            tab.Enabled        = true;
        }
		public void LoadDefaults()
		{
			tabInfo = new TabInfoCollection();

            TabInfo tab = tabInfo.AddNewTab("Text Output");
		    tab.Content =
		        TextDisplayContent.Out |
		        TextDisplayContent.Error |
		        TextDisplayContent.Trace |
		        TextDisplayContent.Log |
		        TextDisplayContent.Labels |
		        TextDisplayContent.LabelOnlyOnOutput;
		    tab.Enabled = true;
        }
예제 #14
0
        public void LoadDefaults()
        {
            tabInfo = new TabInfoCollection();

            TabInfo tab = tabInfo.AddNewTab("Text Output");

            tab.Content =
                TextDisplayContent.Out |
                TextDisplayContent.Error |
                TextDisplayContent.Trace |
                TextDisplayContent.Log |
                TextDisplayContent.Labels |
                TextDisplayContent.LabelOnlyOnOutput;
            tab.Enabled = true;
        }
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     #region #measuresinglelinestring
     Document          document = richEditControl1.Document;
     SizeF             tabSize  = richEditControl1.MeasureSingleLineString(new String(' ', 4), document.DefaultCharacterProperties);
     TabInfoCollection tabs     = document.Paragraphs[0].BeginUpdateTabs(true);
     try {
         for (int i = 1; i <= 30; i++)
         {
             DevExpress.XtraRichEdit.API.Native.TabInfo tab = new DevExpress.XtraRichEdit.API.Native.TabInfo();
             tab.Position = i * tabSize.Width;
             tabs.Add(tab);
         }
     }
     finally {
         document.Paragraphs[0].EndUpdateTabs(tabs);
     }
     #endregion #measuresinglelinestring
 }
예제 #16
0
 static void TabStops(Document document)
 {
     #region #TabStops
     document.Unit = DevExpress.Office.DocumentUnit.Inch;
     TabInfoCollection tabs = document.Paragraphs[0].BeginUpdateTabs(true);
     DevExpress.XtraRichEdit.API.Native.TabInfo tab1 = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     // Sets tab stop at 2.5 inch.
     tab1.Position  = 2.5f;
     tab1.Alignment = TabAlignmentType.Left;
     tab1.Leader    = TabLeaderType.MiddleDots;
     tabs.Add(tab1);
     DevExpress.XtraRichEdit.API.Native.TabInfo tab2 = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     tab2.Position  = 5.5f;
     tab2.Alignment = TabAlignmentType.Decimal;
     tab2.Leader    = TabLeaderType.EqualSign;
     tabs.Add(tab2);
     document.Paragraphs[0].EndUpdateTabs(tabs);
     #endregion #TabStops
 }
 static void TabStops(RichEditDocumentServer wordProcessor)
 {
     #region #TabStops
     Document document = wordProcessor.Document;
     wordProcessor.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
     document.Unit = DevExpress.Office.DocumentUnit.Inch;
     TabInfoCollection tabs = document.Paragraphs[0].BeginUpdateTabs(true);
     TabInfo           tab1 = new TabInfo();
     // Sets tab stop at 2.5 inch
     tab1.Position  = 2.5f;
     tab1.Alignment = TabAlignmentType.Left;
     tab1.Leader    = TabLeaderType.MiddleDots;
     tabs.Add(tab1);
     TabInfo tab2 = new TabInfo();
     tab2.Position  = 5.5f;
     tab2.Alignment = TabAlignmentType.Decimal;
     tab2.Leader    = TabLeaderType.EqualSign;
     tabs.Add(tab2);
     document.Paragraphs[0].EndUpdateTabs(tabs);
     #endregion #TabStops
 }
        public void LoadDefaults()
        {
            tabInfo = new TabInfoCollection();

            // Get any legacy settings
            bool mergeErrorOutput = settings.GetSetting("Gui.ResultTabs.MergeErrorOutput", false);
            bool mergeTraceOutput = settings.GetSetting("Gui.ResultTabs.MergeTraceOutput", false);

            TabInfo tab0 = tabInfo.AddNewTab("Console.Out");

            tab0.Content = TextDisplayContent.Out;
            if (mergeErrorOutput)
            {
                tab0.Content |= TextDisplayContent.Error;
            }
            if (mergeTraceOutput)
            {
                tab0.Content |= TextDisplayContent.Trace;
            }
            if (settings.GetSetting("Gui.ResultTabs.DisplayTestLabels", false))
            {
                tab0.Content |= TextDisplayContent.Labels;
            }
            tab0.Enabled = settings.GetSetting("Gui.ResultTabs.DisplayConsoleOutputTab", true);

            TabInfo tab1 = tabInfo.AddNewTab("Console.Error");

            tab1.Content = mergeErrorOutput ? TextDisplayContent.Empty : TextDisplayContent.Error;
            tab1.Enabled = settings.GetSetting("Gui.ResultTabs.DisplayConsoleErrorTab", true);

            TabInfo tab2 = tabInfo.AddNewTab("Trace");

            tab2.Content = mergeTraceOutput ? TextDisplayContent.Empty : TextDisplayContent.Trace;
            tab2.Enabled = settings.GetSetting("Gui.ResultTabs.DisplayTraceTab", true);

            TabInfo tab3 = tabInfo.AddNewTab("Log");

            tab3.Content = TextDisplayContent.Log;
            tab3.Enabled = settings.GetSetting("Gui.ResultTabs.DisplayLoggingTab", true);
        }
예제 #19
0
        protected override void  OnInit(EventArgs e)
        {
            //tabid先取config,找到defaulttab,检测defaulttab是否属于这个用户,是就用,不是就取这个用户的tab的最后一个,module必须==1

            int module = DNTRequest.GetQueryInt("module", 0);

            if (module != 1)
            {
                return;
            }
            string          url         = DNTRequest.GetQueryString("url");
            SpaceConfigInfo spaceconfig = Spaces.GetSpaceConfigByUserId(this.userid);

            //改为始终为第一是默认,因此需要传递tabid
            int tabid = DNTRequest.GetInt("tab", 0);

#if NET1
            TabInfoCollection usertabs = Spaces.GetTabInfoCollectionByUserID(this.userid);
#else
            List <TabInfo> usertabs = Spaces.GetTabInfoCollectionByUserID(this.userid);
#endif
            tabid = IsUserTab(tabid, usertabs) ? tabid : 0;

            if (tabid == 0)
            {
                tabid = usertabs[usertabs.Count - 1].TabID;
            }

            TabInfo tab = Spaces.GetTabById(tabid, this.userid);
            if (tab == null || tab.UserID != this.userid)
            {
                return;
            }
            int    moduledef  = 0;
            string modulepath = BaseConfigs.GetForumPath + "/space/modules/";
            if (url.StartsWith("builtin_"))
            {
                string file = Utils.GetMapPath(modulepath + url);
                if (File.Exists(file))
                {
                    moduledef = Spaces.GetModuleDefIdByUrl(url);
                }
                else
                {
                    string errmsg = "alert(\"模块文件不存在\")";
                    ResponseXML(errmsg);
                    return;
                }
            }
            if (moduledef > 0)
            {
                ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(url);                //异常或者远程,返回xml说未知模块或不支持的模块
                if (mt == ModuleType.Error || mt == ModuleType.Remote)
                {
                    string errmsg = "alert(\"未知模块或不支持的模块\")";
                    ResponseXML(errmsg);
                    return;
                }
            }
            ResponseXML(string.Format("_add_m(\"x={0}&action=addmodule&t={1}\")", Utils.UrlEncode(url), tabid));
        }
예제 #20
0
        /// <summary>
        /// 是不是用户的Tab
        /// </summary>
        /// <param name="tabid"></param>
        /// <param name="usertabs"></param>
        /// <returns></returns>
#if NET1
        private bool IsUserTab(int tabid, TabInfoCollection usertabs)