Ejemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //WorkItemWindow myFirstWindow = new WorkItemWindow(WorkItemWindow.Type.Note, "this is a little note");
            //myFirstWindow.Left = 300;

            //WorkItemWindow mySecondWindow = new WorkItemWindow(WorkItemWindow.Type.Image, @"C:\temp\awarepoint-w.jpg");
            //mySecondWindow.Left = 600;

            //myFirstWindow.Show();
            //mySecondWindow.Show();

            workWindowDirectory = Path.Combine(Directory.GetCurrentDirectory(), "WorkItems");
            //Create two test worksurfaces
            myWs1 = new WorkSurface(0, 0, 1680, 1050);
            myWs2 = new WorkSurface(0, 0, 1680, 1050);

            WorkItem myWi1 = new ImageItem(Path.Combine(workWindowDirectory, "finger.jpg"));
            WorkItem myWi2 = new NoteItem("this is a little note");
            WorkItem myWi3 = new NoteItem("this is something else");
            WorkItem myWi4 = new NoteItem("lucy in the sky with diamonds");
            WorkItem myWi5 = new NoteItem("boo is cuddly");

            myWs1.AddItem(myWi1, 5, 5);
            myWs1.AddItem(myWi2, 100, 5);
            myWs1.AddItem(myWi3, 200, 5);

            myWs2.AddItem(myWi4, 500, 200);
            myWs2.AddItem(myWi5, 500, 5);

            XmlDocument myDoc    = new XmlDocument();
            XmlElement  contents = myWs1.SerializeToXML(myDoc);

            myDoc.AppendChild(contents);
            try
            {
                FileStream fileStream =
                    new FileStream("WorkSurfaces.xml", FileMode.Create);
                XmlTextWriter textWriter =
                    new XmlTextWriter(fileStream, Encoding.UTF8);
                textWriter.Formatting = Formatting.Indented;
                myDoc.Save(textWriter);
                fileStream.Close();
            }
            catch (System.IO.DirectoryNotFoundException ex)
            {
                System.ArgumentException argEx = new System.ArgumentException("XMLFile path is not valid", "WorkSurfaces.xml", ex);
                throw argEx;
            }
            catch (System.Exception ex)
            {
                System.ArgumentException argEx = new System.ArgumentException("XML File write failed", "WorkSurfaces.xml", ex);
                throw argEx;
            }



            //1680x1050;
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //WorkItemWindow myFirstWindow = new WorkItemWindow(WorkItemWindow.Type.Note, "this is a little note");
            //myFirstWindow.Left = 300;

            //WorkItemWindow mySecondWindow = new WorkItemWindow(WorkItemWindow.Type.Image, @"C:\temp\awarepoint-w.jpg");
            //mySecondWindow.Left = 600;

            //myFirstWindow.Show();
            //mySecondWindow.Show();

            workWindowDirectory = Path.Combine(Directory.GetCurrentDirectory(), "WorkItems");
            //Create two test worksurfaces
            myWs1 = new WorkSurface(0, 0, 1680, 1050);
            myWs2 = new WorkSurface(0, 0, 1680, 1050);

            WorkItem myWi1 = new ImageItem(Path.Combine(workWindowDirectory, "finger.jpg"));
            WorkItem myWi2 = new NoteItem("this is a little note");
            WorkItem myWi3 = new NoteItem("this is something else");
            WorkItem myWi4 = new NoteItem("lucy in the sky with diamonds");
            WorkItem myWi5 = new NoteItem("boo is cuddly");
            myWs1.AddItem(myWi1, 5, 5);
            myWs1.AddItem(myWi2, 100, 5);
            myWs1.AddItem(myWi3, 200, 5);

            myWs2.AddItem(myWi4, 500, 200);
            myWs2.AddItem(myWi5, 500, 5);

            XmlDocument myDoc = new XmlDocument();
            XmlElement contents = myWs1.SerializeToXML(myDoc);
            myDoc.AppendChild(contents);
            try
            {
                FileStream fileStream =
                  new FileStream("WorkSurfaces.xml", FileMode.Create);
                XmlTextWriter textWriter =
                  new XmlTextWriter(fileStream, Encoding.UTF8);
                textWriter.Formatting = Formatting.Indented;
                myDoc.Save(textWriter);
                fileStream.Close();

            }
            catch (System.IO.DirectoryNotFoundException ex)
            {
                System.ArgumentException argEx = new System.ArgumentException("XMLFile path is not valid", "WorkSurfaces.xml", ex);
                throw argEx;
            }
            catch (System.Exception ex)
            {
                System.ArgumentException argEx = new System.ArgumentException("XML File write failed", "WorkSurfaces.xml", ex);
                throw argEx;
            }

            //1680x1050;
        }