private void rrdDbTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //importDataToolStripMenuItem1.Enabled = false;
            //editToolStripMenuItem1.Enabled = false;
            object           selectedObject;
            SelectedNodeType selectedNodeType = GetSelectedNodeObject(e.Node, out selectedObject);

            switch (selectedNodeType)
            {
            case SelectedNodeType.database:
                controller.DatabaseSelected((DatabaseData)selectedObject);
                return;

            case SelectedNodeType.datasources:
                controller.DatasourcesSelected((DatabaseData)selectedObject);
                return;

            case SelectedNodeType.archives:
                selectedObject = e.Node.Parent.Tag;
                controller.ArchivesSelected(selectedObject as DatabaseData);
                return;

            case SelectedNodeType.datasource:
                return;

            case SelectedNodeType.datasourcearchive:
                Application.UseWaitCursor = true;
                DatabaseData databaseData = e.Node.Parent.Parent.Parent.Tag as DatabaseData;
                controller.DatasourceArchiveSelected(databaseData, e.Node.Parent.Tag, e.Node.Tag);
                Application.UseWaitCursor = false;
                return;
            }
        }
        private void removeFromProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object           nodeData;
            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            if (nodeType == SelectedNodeType.database)
            {
                if (controller.DatabaseUnsaved(nodeData as DatabaseData))
                {
                    DialogResult res = MessageBox.Show(this, "Database not saved!\nSave before continue?\n", "Unsaved data", MessageBoxButtons.YesNoCancel);
                    if (res == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }

                    if (res == DialogResult.Yes)
                    {
                        saveFileDialog1.CheckFileExists = false;
                        if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }
                        try
                        {
                            controller.CreateDatabase(saveFileDialog1.FileName);
                        }
                        catch (ArgumentException ex)
                        {
                            MessageBox.Show(ex.Message, "Fail to save database");
                        }
                    }
                }
                controller.RemoveDatabase(nodeData as DatabaseData);
            }
        }
        private void copyDatabasedefToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object           selectedObject;
            SelectedNodeType nodeType = GetSelectedNodeObject(rrdDbTreeView.SelectedNode, out selectedObject);

            Clipboard.SetText(controller.DumpDatabaseDefinition(selectedObject as DatabaseData));
        }
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object           nodeData;
            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            if (nodeType != SelectedNodeType.database)
            {
                return;
            }

            DatabaseData databaseData = nodeData as DatabaseData;
        }
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            object           selectedObject = new object();
            SelectedNodeType nodeType       = GetSelectedNodeObject(rrdDbTreeView.SelectedNode, out selectedObject);

            if (nodeType == SelectedNodeType.database)
            {
                copyDatabasedefToClipboardToolStripMenuItem.Enabled = true;
            }
            else
            {
                copyDatabasedefToClipboardToolStripMenuItem.Enabled = false;
            }
        }
        private void importDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object nodeData;

            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            //if (nodeType == SelectedNodeType.datasource)
            //{
            //   DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;
            //   dsController.DataSourceDef = nodeData as DsDef;
            //   DatabaseData srcDatabaseData = GetSrcDatabase();
            //   dsController.SrcDatabase = srcDatabaseData;
            //   if (dsController.Run())
            //      controller.DatabaseUpdated(srcDatabaseData);
            //   return;

            //}
            //if (nodeType == SelectedNodeType.datasourcearchive)
            //{
            //   ArchiveController archController = kernel[typeof(ArchiveController)] as ArchiveController;
            //   archController.ArchiveDef = nodeData as ArcDef;
            //   if (archController.Run())
            //      controller.DatabaseUpdated(GetSrcDatabase());
            //   return;
            //}

            if (nodeType == SelectedNodeType.database)
            {
                openFileDialog1.DefaultExt = "csv";
                openFileDialog1.FileName   = "*.csv";
                //            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (openFileDialog1.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    DatabaseData dd = nodeData as DatabaseData;
                    controller.ImportData(openFileDialog1.FileName, dd, new TimeSpan(7, 0, 0, 0));
                }
                catch (ApplicationException ex)
                {
                    MessageBox.Show("Fail to import data." + ex.Message);
                }
            }
        }
Exemple #7
0
        private void editToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            object           selectedObject;
            SelectedNodeType selectedNodeType = GetSelectedNodeObject(out selectedObject);

            switch (selectedNodeType)
            {
            case SelectedNodeType.datasource:
                DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;
                dsController.DataSourceDef = selectedObject as DsDef;
                dsController.Run();
                return;

            case SelectedNodeType.datasourcearchive:
                ArchiveController archController = kernel[typeof(ArchiveController)] as ArchiveController;
                archController.ArchiveDef = selectedObject as ArcDef;
                archController.Run();
                return;
            }
        }
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object           nodeData;
            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            if (nodeType != SelectedNodeType.database)
            {
                return;
            }

            DatabaseData databaseData = nodeData as DatabaseData;

            saveFileDialog1.CheckFileExists = false;
            saveFileDialog1.DefaultExt      = "xml";
            saveFileDialog1.FileName        = Path.GetFileNameWithoutExtension(databaseData.Definition.Path) + ".xml";
            //            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (saveFileDialog1.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
            controller.ExportDatabase(databaseData.Definition.Path, saveFileDialog1.FileName);
        }
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object nodeData;

            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            if (nodeType == SelectedNodeType.datasource)
            {
                DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;
                dsController.DataSourceDef = nodeData as DsDef;
                DatabaseData srcDatabaseData = GetSrcDatabase();
                controller.StartEditDatabase(srcDatabaseData);
                dsController.SrcDatabase = srcDatabaseData;
                if (dsController.Run())
                {
                    controller.DatabaseUpdated(srcDatabaseData);
                }
                return;
            }
            if (nodeType == SelectedNodeType.datasourcearchive)
            {
                ArchiveController archController = kernel[typeof(ArchiveController)] as ArchiveController;
                archController.ArchiveDef = nodeData as ArcDef;
                if (archController.Run())
                {
                    controller.DatabaseUpdated(GetSrcDatabase());
                }
                return;
            }

            if (nodeType == SelectedNodeType.database)
            {
                if (!CheckIfUnsaved())
                {
                    return;
                }
                controller.StartEditDatabase(nodeData as DatabaseData);
            }
        }
Exemple #10
0
        private void rrdDbTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            importDataToolStripMenuItem1.Enabled = false;
            editToolStripMenuItem1.Enabled       = false;
            object           selectedObject;
            SelectedNodeType selectedNodeType = GetSelectedNodeObject(e.Node, out selectedObject);

            switch (selectedNodeType)
            {
            case SelectedNodeType.database:
                propertiesGroupBox.Text = "Database";
                //controller.DatabaseSelected();
                return;

            case SelectedNodeType.datasources:
                propertiesGroupBox.Text = "Datasources";
                //controller.DatasourcesSelected();
                return;

            case SelectedNodeType.archives:
                propertiesGroupBox.Text = "Archives";
                controller.ArchivesSelected(selectedObject as DatabaseData);
                return;

            case SelectedNodeType.datasource:
                importDataToolStripMenuItem1.Enabled = true;
                editToolStripMenuItem1.Enabled       = true;
                return;

            case SelectedNodeType.datasourcearchive:
                editToolStripMenuItem1.Enabled = true;
                Application.UseWaitCursor      = true;
                //controller.DatasourceArchiveSelected(e.Node.Parent.Tag, e.Node.Tag);
                Application.UseWaitCursor = false;
                return;
            }
        }