Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem of Deployment c# Application Pin
Member 104764987-Jan-14 2:44
professionalMember 104764987-Jan-14 2:44 
AnswerRe: problem of Deployment c# Application Pin
Marco Bertschi7-Jan-14 23:14
protectorMarco Bertschi7-Jan-14 23:14 
QuestionMaster Detail report using Crystal Report in Visual C# 2010 Pin
ahmed_one7-Jan-14 0:47
ahmed_one7-Jan-14 0:47 
AnswerRe: Master Detail report using Crystal Report in Visual C# 2010 Pin
thatraja7-Jan-14 1:29
professionalthatraja7-Jan-14 1:29 
QuestionRe: Master Detail report using Crystal Report in Visual C# 2010 Pin
ahmed_one7-Jan-14 18:18
ahmed_one7-Jan-14 18:18 
AnswerRe: Master Detail report using Crystal Report in Visual C# 2010 Pin
thatraja8-Jan-14 4:05
professionalthatraja8-Jan-14 4:05 
GeneralRe: Master Detail report using Crystal Report in Visual C# 2010 Pin
ahmed_one8-Jan-14 17:08
ahmed_one8-Jan-14 17:08 
QuestionChanging text in Glyphs in XpsDocument Pin
defjef6-Jan-14 21:41
defjef6-Jan-14 21:41 
I have made code that iterates through a XpsDocument (fixeddocument). It will change the text of glyphs when certains criteria is matched. In visual studio I can see that the UnicodeString is changed. When I close the document the changes are not saved.

C#
/// <summary>
/// Parses the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns></returns>
public bool Parse(params object[] args)
{
    if ((args.Length > 0) && (args[0] is Dictionary<String, object>))
    {
        _values = args[0] as Dictionary<String, object>;
        //Package destPackage = Package.Open(DestinationPath, FileMode.Create, FileAccess.ReadWrite);
        File.Copy(SourcePath, DestinationPath);
        XpsDocument source = new XpsDocument(SourcePath, FileAccess.ReadWrite);
        XpsDocument destination = new XpsDocument(DestinationPath,FileAccess.ReadWrite);
        XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(destination);

        //SerializerWriterCollator vxpsd = writer.CreateVisualsCollator();
        //vxpsd.BeginBatchWrite();

        FixedDocumentSequence sequence = destination.GetFixedDocumentSequence();
        foreach (DocumentReference r in sequence.References)
        {
            FixedDocument d = r.GetDocument(false);
            foreach (PageContent content in d.Pages)
            {
                ContainerVisual visual = new ContainerVisual();
                FixedPage page = content.GetPageRoot(false);
                double width = page.Width;
                double height = page.Height;
                Size size = new Size(page.Width, page.Height);

                visual.Children.Add(page);

                foreach(UIElement test in (page.Children[0] as Canvas).Children)
                {
                    if (test is Glyphs)
                    {
                        String glyphContent = processGlyph(test as Glyphs);
                    }
                    if (test is Canvas)
                    {
                        Canvas address = test as Canvas;
                        foreach (UIElement row in address.Children)
                        {
                            if (row is Canvas)
                            {
                                String addres_text = processGlyph((row as Canvas).Children[0] as Glyphs);
                            }
                        }
                    }
                }
            }
        }
        //vxpsd.EndBatchWrite();
        source.Close();
        destination.Close();
        //container.Close();
        return true;
    }
    else
    {
        return false;
    }
}
#endregion

#region Private Methods
/// <summary>
/// Processes the glyph.
/// </summary>
/// <param name="glyph">The glyph.</param>
/// <returns></returns>
private String processGlyph(Glyphs glyph)
{
    String content="";
    String glyphContent = (glyph as Glyphs).UnicodeString.Trim();
    if ((glyphContent.StartsWith("«")) && (glyphContent.EndsWith("»")))
    {
        //Debug.WriteLine(glyphContent);
        String key = glyphContent.Trim(new Char[] { '«', '»' });
        if (_values.ContainsKey(key))
        {
            Glyphs item = (glyph as Glyphs);
            content = item.UnicodeString.Replace(glyphContent, _values[key].ToString());
            item.UnicodeString = content;
            item.Indices = null;
        }
        else
        {
            Glyphs item = (glyph as Glyphs);
            content = item.UnicodeString.Replace(glyphContent, "test");
            item.UnicodeString = content;
            item.ApplyTemplate();
        }
    }
    return content;
}


Anyone has an idea on how to save the changes that were made to the glyphs?
QuestionRe: Changing text in Glyphs in XpsDocument Pin
Richard MacCutchan6-Jan-14 22:14
mveRichard MacCutchan6-Jan-14 22:14 
AnswerRe: Changing text in Glyphs in XpsDocument Pin
defjef6-Jan-14 23:13
defjef6-Jan-14 23:13 
GeneralRe: Changing text in Glyphs in XpsDocument Pin
Richard MacCutchan6-Jan-14 23:28
mveRichard MacCutchan6-Jan-14 23:28 
GeneralRe: Changing text in Glyphs in XpsDocument Pin
defjef6-Jan-14 23:39
defjef6-Jan-14 23:39 
GeneralRe: Changing text in Glyphs in XpsDocument Pin
Richard MacCutchan6-Jan-14 23:58
mveRichard MacCutchan6-Jan-14 23:58 
GeneralRe: Changing text in Glyphs in XpsDocument Pin
defjef7-Jan-14 0:03
defjef7-Jan-14 0:03 
GeneralRe: Changing text in Glyphs in XpsDocument Pin
Richard MacCutchan7-Jan-14 0:26
mveRichard MacCutchan7-Jan-14 0:26 
QuestionIssues with using C# library in Excel 2007 VBA Pin
Wheels0126-Jan-14 5:45
Wheels0126-Jan-14 5:45 
AnswerRe: Issues with using C# library in Excel 2007 VBA Pin
Dave Kreskowiak6-Jan-14 7:52
mveDave Kreskowiak6-Jan-14 7:52 
GeneralRe: Issues with using C# library in Excel 2007 VBA Pin
Wheels0126-Jan-14 8:46
Wheels0126-Jan-14 8:46 
GeneralRe: Issues with using C# library in Excel 2007 VBA Pin
Chris Quinn6-Jan-14 21:35
Chris Quinn6-Jan-14 21:35 
AnswerRe: Issues with using C# library in Excel 2007 VBA Pin
TnTinMn6-Jan-14 12:03
TnTinMn6-Jan-14 12:03 
Questionwpf prompbox Pin
Member 93270026-Jan-14 3:40
Member 93270026-Jan-14 3:40 
AnswerRe: wpf prompbox Pin
Pete O'Hanlon6-Jan-14 3:59
mvePete O'Hanlon6-Jan-14 3:59 
QuestionPopulate a DVG from a csv file Pin
JOHNNYDEMICHAEL5-Jan-14 7:45
JOHNNYDEMICHAEL5-Jan-14 7:45 
AnswerRe: Populate a DVG from a csv file Pin
Dave Kreskowiak5-Jan-14 8:27
mveDave Kreskowiak5-Jan-14 8:27 
GeneralRe: Populate a DVG from a csv file Pin
JOHNNYDEMICHAEL5-Jan-14 12:13
JOHNNYDEMICHAEL5-Jan-14 12:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.