예제 #1
0
 void btnNewTemplate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Utility.lstElements = null;
         BaseSchema doc = new BaseSchema();
         if (CenterContent.Children.Count > 0)
             CenterContent.Children.RemoveAt(0);
         brdMain.Width = App.Current.MainWindow.Width - 100;
         brdMain.Height = App.Current.MainWindow.Height - 190;
         doc.scrollMain.Width = brdMain.Width - 65;
         doc.scrollMain.Height = brdMain.Height - 90;
         doc.dgUserRolesToDelete.Width = brdMain.Width - 65;
         CenterContent.Children.Add(doc);
         this.controlheader.btnAddElement.IsEnabled = true;
         this.controlheader.dockSearch.Visibility = System.Windows.Visibility.Visible;
         Utility.elementCount = Utility.lstElements.Count;
         doc.BtnSaveEnabler -= new EventHandler(doc_BtnSaveEnabler);
         doc.BtnSaveEnabler += new EventHandler(doc_BtnSaveEnabler);
         this.controlheader.btnSave.Content = "Save Template";
         this.controlheader.btnSave.Tag = "0";
         ButtonEnabler();
     }
     catch
     {
         MessageBox.Show("ADI_Master.xml", "Invalid Schema", MessageBoxButton.OKCancel);
         return;
     }
 }
예제 #2
0
 void controlheader_AddElement(object sender, EventArgs e)
 {
     var linqResults = from lst in Utility.lstElements
                       orderby lst.Type descending
                       select lst;
     Utility.lstElements = new ObservableCollection<Element>(linqResults);
     if (CenterContent.Children.Count > 0)
         CenterContent.Children.RemoveAt(0);
     BaseSchema doc = new BaseSchema();
     brdMain.Width = gridFormBuilder.ActualWidth - 100;
     brdMain.Height = gridFormBuilder.ActualHeight - 190;
     doc.dgUserRolesToDelete.Width = brdMain.Width - 65;
     doc.scrollMain.Width = brdMain.Width - 65;
     doc.scrollMain.Height = brdMain.Height - 90;
     CenterContent.Children.Add(doc);
     this.controlheader.btnAddElement.IsEnabled = true;
 }
예제 #3
0
        void btnLoadSchema_Click(object sender, RoutedEventArgs e)
        {
            //Displays a SaveFileDialog so the user can save the xml template
            // assigned to Save Button.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "Xml file|*.xml";
            if (!string.IsNullOrEmpty(Utility.lastDir))
               openFileDialog1.InitialDirectory = Utility.lastDir;

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = openFileDialog1.ShowDialog();

             if (result == true)
            {

                Utility.lastDir = openFileDialog1.File.FullName;
                var xElem = (XElement.Load(openFileDialog1.File.OpenRead())).Elements();
                var serializer = new XmlSerializer(typeof(Element));
                Utility.lstElements = new ObservableCollection<Element>();
                foreach (var item in xElem)
                {
                    try
                    {
                        var test = (Element)serializer.Deserialize(item.CreateReader());
                        XElement xn = (XElement)item.LastNode;
                        if (xn.HasElements)
                        {
                            var elements = (from element in xn.Elements("Name")
                                            select element.Value).ToList();
                            test.Combo = elements;
                        }
                        Utility.lstElements.Add(test);
                    }
                    catch
                    {
                        MessageBox.Show("Invalid Schema file", "Invalid Schema", MessageBoxButton.OK);
                        break;
                    }
                }

                if (CenterContent.Children.Count > 0)
                    CenterContent.Children.RemoveAt(0);
                BaseSchema doc = new BaseSchema();
                brdMain.Width = App.Current.MainWindow.Width - 100;
                brdMain.Height = App.Current.MainWindow.Height - 190;
                doc.scrollMain.Width = brdMain.Width - 65;
                doc.scrollMain.Height = brdMain.Height - 90;
                doc.dgUserRolesToDelete.Width = brdMain.Width - 65;
                //doc.scrollMain.Height = brdMain.Height - 175;
                CenterContent.Children.Add(doc);
                this.controlheader.btnAddElement.IsEnabled = true;
                this.controlheader.dockSearch.Visibility = System.Windows.Visibility.Visible;
                Utility.elementCount = Utility.lstElements.Count;
                ButtonEnabler();
                doc.BtnSaveEnabler -= new EventHandler(doc_BtnSaveEnabler);
                doc.BtnSaveEnabler += new EventHandler(doc_BtnSaveEnabler);
             }
        }