private void DoubleClickOnTable(object sender, MouseButtonEventArgs e)
        {
            var table = sender as DataGrid;

            if (table == null)
            {
                return;
            }
            var selected = table.SelectedItem as IDataObject;

            if (selected == null)
            {
                return;
            }
            var element = selected.GetXElementFromObject();
            var source  = table.ItemsSource as Collection <object>;

            if (source == null)
            {
                return;
            }
            var index  = source.IndexOf(selected);
            var dialog = new XElementDialog(element, false);

            dialog.ShowDialog();
            if (dialog.DialogResult != true)
            {
                return;
            }
            var updated = dialog.GetElement().GetObjectFromXElement();

            source[index]     = updated;
            table.ItemsSource = source;
            DBFactory.GetData().Save(dialog.GetElement());
        }
Beispiel #2
0
        private static TreeViewItem AddNewItemToTree(TreeView tree, XElement xElement)
        {
            var dialog = new XElementDialog(xElement, false);

            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value)
            {
                return(null);
            }
            var xE       = dialog.GetElement();
            var selected = (TreeViewItem)tree.SelectedItem;
            var xParent  = (XElement)selected.DataContext;
            var parentId = xParent.GetAttributeValue(Constants._ID);

            xE.SetAttributeValue(Constants.PARENT_ID, parentId);

            if (!DBFactory.GetData().Save(xE))
            {
                MessageBox.Show("Add Tree item Failed.");
                return(null);
            }
            var ret = xE.GetTreeViewItemFromXElement();

            selected.Items.Add(ret);
            return(ret);
        }
Beispiel #3
0
        private void Settings(object sender, RoutedEventArgs e)
        {
            // generate a XElement from configuration
            var config = new XElement("Configuration");

            Configuration.AddSettingsToXElement(config);
            //show XElementDialog
            var xElementDialog = new XElementDialog(config, false);

            xElementDialog.ShowDialog();
            //if click yes
            if (!xElementDialog.DialogResult.HasValue || !xElementDialog.DialogResult.Value)
            {
                return;
            }
            //set settings back to configuration, to memory and disk
            foreach (XAttribute attr in config.Attributes())
            {
                var name  = attr.Name.ToString();
                var value = attr.Value;
                Configuration.Set(name, value);
            }
            Configuration.SaveSettings();
            _config = Configuration.Clone();
        }
Beispiel #4
0
        private static void Edit(XElement element)
        {
            var dialog = new XElementDialog(element, false);

            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value)
            {
                return;
            }
            var xElement = dialog.GetElement();

            if (!DBFactory.GetData().Save(xElement))
            {
                MessageBox.Show("update Tree item Failed.");
            }
        }
Beispiel #5
0
        private static void Edit(TreeViewItem selected)
        {
            if (selected == null)
            {
                return;
            }
            var element = ((XElement)selected.DataContext);
            var dialog  = new XElementDialog(element, false);

            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value)
            {
                return;
            }
            var xElement = dialog.GetElement();

            if (!DBFactory.GetData().Save(xElement))
            {
                MessageBox.Show("update Tree item Failed.");
                return;
            }
            selected.UpdateTreeViewItem(xElement);
        }
 private void Settings(object sender, RoutedEventArgs e)
 {
     // generate a XElement from configuration
     var config = new XElement("Configuration");
     Configuration.AddSettingsToXElement(config);
     //show XElementDialog
     var xElementDialog = new XElementDialog(config, false);
     xElementDialog.ShowDialog();
     //if click yes
     if (!xElementDialog.DialogResult.HasValue || !xElementDialog.DialogResult.Value) return;
     //set settings back to configuration, to memory and disk
     foreach (XAttribute attr in config.Attributes())
     {
         var name = attr.Name.ToString();
         var value = attr.Value;
         Configuration.Set(name, value);
     }
     Configuration.SaveSettings();
     _config = Configuration.Clone();
 }
        private static void Edit(XElement element)
        {
            var dialog = new XElementDialog(element, false);
            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value) return;
            var xElement = dialog.GetElement();

            if (!DBFactory.GetData().Save(xElement))
            {
                MessageBox.Show("update Tree item Failed.");
            }
        }
        private static void Edit(TreeViewItem selected)
        {
            if (selected == null)
            {
                return;
            }
            var element = ((XElement) selected.DataContext);
            var dialog = new XElementDialog(element, false);
            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value) return;
            var xElement = dialog.GetElement();

            if (!DBFactory.GetData().Save(xElement))
            {
                MessageBox.Show("update Tree item Failed.");
                return;
            }
            selected.UpdateTreeViewItem(xElement);
        }
        private static TreeViewItem AddNewItemToTree(TreeView tree, XElement xElement)
        {
            var dialog = new XElementDialog(xElement, false);
            dialog.ShowDialog();
            if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value) return null;
            var xE = dialog.GetElement();
            var selected = (TreeViewItem) tree.SelectedItem;
            var xParent = (XElement) selected.DataContext;
            var parentId = xParent.GetAttributeValue(Constants._ID);

            xE.SetAttributeValue(Constants.PARENT_ID, parentId);

            if (!DBFactory.GetData().Save(xE))
            {
                MessageBox.Show("Add Tree item Failed.");
                return null;
            }
            var ret = xE.GetTreeViewItemFromXElement();
            selected.Items.Add(ret);
            return ret;
        }
 private void DoubleClickOnTable(object sender, MouseButtonEventArgs e)
 {
     var table = sender as DataGrid;
     if (table == null) return;
     var selected = table.SelectedItem as IDataObject;
     if (selected == null) return;
     var element = selected.GetXElementFromObject();
     var source = table.ItemsSource as Collection<object>;
     if (source == null) return;
     var index = source.IndexOf(selected);
     var dialog = new XElementDialog(element, false);
     dialog.ShowDialog();
     if (dialog.DialogResult != true) return;
     var updated = dialog.GetElement().GetObjectFromXElement();
     source[index] = updated;
     table.ItemsSource = source;
     DBFactory.GetData().Save(dialog.GetElement());
 }