private void ButtonUpdateItem_Click(object sender, RoutedEventArgs e)
        {
            if ((ListViewElements.SelectedItem != null) && (ListViewElements.SelectedItem is ToolBoxItem))
            {
                ToolBoxItem item = ListViewElements.SelectedItem as ToolBoxItem;
                if (item != null)
                {
                    //Находим группу которой принадлежит выделенный элемент
                    ExpanderData selectedGroup = null;
                    foreach (ExpanderData data in expanderList)
                    {
                        if (data.Items.Contains(item))
                        {
                            selectedGroup = data;
                            break;
                        }
                    }

                    ToolBoxItemProperty tprop = new ToolBoxItemProperty(item);
                    if (tprop.ShowDialog() == true)
                    {
                        ListViewElements.ItemsSource = null;
                        selectedGroup.Items.Remove(item);
                        selectedGroup.Items.Add(tprop.ToolBoxItem);
                        ListViewElements.ItemsSource = selectedGroup.Items;
                    }
                }
            }
        }
 public ToolBoxItemProperty(ExpanderData expanderData)
 {
     ToolBoxItem = new ToolBoxItem(expanderData);
     InitializeComponent();
     Title = "New ToolboxItem Data";
     LoadIcons();
     ComboBoxIconPath.SelectedIndex = 0;
 }
示例#3
0
        private void ToggleButtonMouseDown(object sender, MouseButtonEventArgs e)
        {
            UncheckAllButtons();
            System.Windows.Controls.Primitives.ToggleButton selected_button = (sender as System.Windows.Controls.Primitives.ToggleButton);
            selected_button.IsChecked = true;

            foreach (ExpanderData data in sortedList)
            {
                foreach (ToolBoxItem item in data.Items)
                {
                    if (item.ToggleButton == selected_button)
                    {
                        selectedToolBoxItem = item;
                        break;
                    }
                }
            }
            e.Handled = true;
        }
        public ToolBoxItemProperty(ToolBoxItem ToolBoxItem)
        {
            this.ToolBoxItem = ToolBoxItem;
            InitializeComponent();

            Title = "Update ToolboxItem Data";

            TextBoxCaption.Text     = ToolBoxItem.Caption;
            TextBoxDescription.Text = ToolBoxItem.Description;
            TextBoxCommand.Text     = ToolBoxItem.Command;

            LoadIcons();
            for (int i = 0; i < ExpanderData.Icons.Length; i++)
            {
                if (ExpanderData.Icons[i].Equals(ToolBoxItem.GetOriginalIconPath()))
                {
                    ComboBoxIconPath.SelectedIndex = i;
                    break;
                }
            }
        }
示例#5
0
        public static List <ExpanderData> LoadDatafromXml(System.IO.Stream stream)
        {
            List <ExpanderData> res = new List <ExpanderData>();

            try
            {
                XmlDocument _doc = new XmlDocument();
                _doc.Load(stream);

                XmlNodeList nodes = _doc.SelectNodes("/ExpanderList/ExpanderData");
                foreach (XmlNode node in nodes)
                {
                    ExpanderData data = new ExpanderData();
                    data.Caption        = node.SelectSingleNode("Caption").InnerText;
                    data.IconPath       = node.SelectSingleNode("IconPath").InnerText;
                    data.Description    = node.SelectSingleNode("Description").InnerText;
                    data.TypeOfElements = node.SelectSingleNode("TypeOfElements").InnerText;

                    XmlNodeList EdpanderDataItems = node.SelectNodes("ToolBoxItem");
                    foreach (XmlNode nodeitem in EdpanderDataItems)
                    {
                        ToolBoxItem item = new ToolBoxItem(data);
                        item.Caption     = nodeitem.SelectSingleNode("Caption").InnerText;
                        item.Command     = nodeitem.SelectSingleNode("Command").InnerText;
                        item.Description = nodeitem.SelectSingleNode("Description").InnerText;
                        item.IconPath    = nodeitem.SelectSingleNode("IconPath").InnerText;
                        data.items.Add(item);
                    }

                    res.Add(data);
                }
            }
            catch (Exception ex)
            {
                Schematix.Core.Logger.Log.Error("Load ToolBox data error.", ex);
                return(res);
            }

            return(res);
        }