Пример #1
0
        private void Add_Click(object sender, EventArgs e)
        {
            PluginRequestDataStruct NewPluginDataStruct = new PluginRequestDataStruct();

            NewPluginDataStruct.FileName     = FileToUse;
            NewPluginDataStruct.SerialNumber = PluginID.Text;
            PluginCommands PluginCommandsForm = new PluginCommands(NewPluginDataStruct);

            PluginCommandsForm.ShowDialog();
            NewPluginDataStruct = PluginCommandsForm.PluginRequestData;
            if (NewPluginDataStruct.Save)
            {
                PluginRequestData[PluginRequestDataCounter] = NewPluginDataStruct;
                PluginRequestDataCounter++;
                SortColumns(ColumnSorted);
                Save.Enabled = true;
                Changed      = true;
            }
        }
Пример #2
0
        private void SortColumns(int Which)
        {
            int i;
            int j;
            PluginRequestDataStruct temp = new PluginRequestDataStruct();

            if (Which == 0)
            {
                for (i = (PluginRequestDataCounter - 1); i >= 0; i--)
                {
                    for (j = 1; j <= i; j++)
                    {
                        if (Convert.ToInt32(PluginRequestData[j - 1].CommandNumber) > Convert.ToInt32(PluginRequestData[j].CommandNumber))
                        {
                            temp = PluginRequestData[j - 1];
                            PluginRequestData[j - 1] = PluginRequestData[j];
                            PluginRequestData[j]     = temp;
                        }
                    }
                }
                ColumnSorted = 0;
                FillListView();
            }

            if (Which == 1)
            {
                for (i = (PluginRequestDataCounter - 1); i >= 0; i--)
                {
                    for (j = 1; j <= i; j++)
                    {
                        if (string.Compare(PluginRequestData[j - 1].CommandName.ToLower(), PluginRequestData[j].CommandName.ToLower()) > 0)
                        {
                            temp = PluginRequestData[j - 1];
                            PluginRequestData[j - 1] = PluginRequestData[j];
                            PluginRequestData[j]     = temp;
                        }
                    }
                }
                ColumnSorted = 1;
                FillListView();
            }
        }
Пример #3
0
        private void MainListView_DoubleClick(object sender, EventArgs e)
        {
            PluginRequestDataStruct NewPluginDataStruct = new PluginRequestDataStruct();
            ListViewItem            item = MainListView.SelectedItems[0];

            NewPluginDataStruct              = PluginRequestData[(int)item.Tag];
            NewPluginDataStruct.FileName     = FileToUse;
            NewPluginDataStruct.SerialNumber = PluginID.Text;
            NewPluginDataStruct.New          = false;

            PluginCommands PluginCommandsForm = new PluginCommands(NewPluginDataStruct);

            PluginCommandsForm.ShowDialog();
            NewPluginDataStruct = PluginCommandsForm.PluginRequestData;
            if (NewPluginDataStruct.Save)
            {
                PluginRequestData[(int)item.Tag] = NewPluginDataStruct;
                SortColumns(ColumnSorted);
                Save.Enabled = true;
                Changed      = true;
            }
        }
Пример #4
0
        private void PluginCommansGrid_Shown(object sender, EventArgs e)
        {
            PluginRequestData = new PluginRequestDataStruct[99];

            openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory();

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(@"PluginCommands");

                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                {
                    foreach (XmlNode Cnode in node)
                    {
                        if (node.Name == "LastPath")
                        {
                            openFileDialog1.InitialDirectory = node.InnerText;
                        }
                    }
                }
            }
            catch
            {
            }



            DialogResult result = openFileDialog1.ShowDialog();

            if (result != DialogResult.OK)
            {
                Close();
                return;
            }
            FileToUse = openFileDialog1.FileName;
            if (!File.Exists(FileToUse))
            {
                PluginRequestDataStruct NewPluginDataStruct = new PluginRequestDataStruct();
                NewPluginDataStruct.FileName = FileToUse;
                NewPluginDataStruct.New      = true;
                PluginCommands PluginCommandsForm = new PluginCommands(NewPluginDataStruct);
                PluginCommandsForm.ShowDialog();
            }
            XmlDocument Data     = new XmlDocument();
            XmlNode     DataNode = Data.CreateXmlDeclaration("1.0", "UTF-8", null);

            Data.AppendChild(DataNode);

            XmlNode DataNodeRoot;
            XmlNode DataNodeNode;

            DataNodeRoot = Data.CreateElement("PluginCommandsDocumentation");
            Data.AppendChild(DataNodeRoot);

            DataNodeNode = Data.CreateElement("LastPath");
            DataNodeNode.AppendChild(Data.CreateTextNode(Path.GetDirectoryName(FileToUse)));
            DataNodeRoot.AppendChild(DataNodeNode);
            Data.Save("PluginCommands");


            MainListView.Columns.Add("Command Number", -2, HorizontalAlignment.Left);
            MainListView.Columns.Add("Command Name", -2, HorizontalAlignment.Left);
            MainListView.Columns.Add("Comments", -2, HorizontalAlignment.Left);

            LoadandProcessDocumentation();
            SortColumns(ColumnSorted);
            Save.Enabled = false;
        }