Exemple #1
0
        private bool ValidateForm()
        {
            bool isTextFieldsFilled = true;
            this.Height = 255;
            if (tbFilePath.Text.Equals(""))
            {
                lblFilePath.ForeColor = Color.Red;
                isTextFieldsFilled = false;
                lblStatus.Text = "Please fill in the required information.";
            }
            else
                lblFilePath.ForeColor = Color.Black;

            if (tbClusterSize.Text.Equals(""))
            {
                lblClusterSize.ForeColor = Color.Red;
                isTextFieldsFilled = false;
                lblStatus.Text = "Please fill in the required information.";
            }
            else
                lblClusterSize.ForeColor = Color.Black;
            if (!isTextFieldsFilled)
                return false;

            int clusterSize;
            if (!Int32.TryParse(tbClusterSize.Text, out clusterSize))
            {
                lblClusterSize.ForeColor = Color.Red;
                lblStatus.Text = "Cluster size must be an integer.";
                return false;
            }
            try
            {

                if(tbHeader.Text.Equals(""))
                    using ( FileStream file = new FileStream(tbFilePath.Text, FileMode.Open))
                    using (var storage = new IndexedFileStorage(file, clusterSize, checkSafeWrite.Checked))
                    {

                    }
                else
                    using (FileStream file = new FileStream(tbFilePath.Text, FileMode.Open))
                    using (var storage = new IndexedFileStorage(file, clusterSize, checkSafeWrite.Checked, tbHeader.Text))
                    {

                    }
            }
            catch (Exception e)
            {
                ExceptionDialog exDialog = new ExceptionDialog("An exception occured. \nPlease check the inputed parameters.",
                                                                e);

                exDialog.ShowDialog();
                return false;
            }

            if(tbHeader.Text.Equals(""))
                parent.setStorageInformation(tbFilePath.Text, clusterSize, checkSafeWrite.Checked);
            else
                parent.setStorageInformation(tbFilePath.Text, clusterSize, checkSafeWrite.Checked, tbHeader.Text);

            return true;
        }
Exemple #2
0
        private bool ValidateForm()
        {
            bool isTextFieldsFilled = true;

            this.Height = 255;
            if (tbFilePath.Text.Equals(""))
            {
                lblFilePath.ForeColor = Color.Red;
                isTextFieldsFilled    = false;
                lblStatus.Text        = "Please fill in the required information.";
            }
            else
            {
                lblFilePath.ForeColor = Color.Black;
            }

            if (tbClusterSize.Text.Equals(""))
            {
                lblClusterSize.ForeColor = Color.Red;
                isTextFieldsFilled       = false;
                lblStatus.Text           = "Please fill in the required information.";
            }
            else
            {
                lblClusterSize.ForeColor = Color.Black;
            }
            if (!isTextFieldsFilled)
            {
                return(false);
            }

            int clusterSize;

            if (!Int32.TryParse(tbClusterSize.Text, out clusterSize))
            {
                lblClusterSize.ForeColor = Color.Red;
                lblStatus.Text           = "Cluster size must be an integer.";
                return(false);
            }
            try
            {
                if (tbHeader.Text.Equals(""))
                {
                    using (FileStream file = new FileStream(tbFilePath.Text, FileMode.Open))
                        using (var storage = new IndexedFileStorage(file, clusterSize, checkSafeWrite.Checked))
                        {
                        }
                }
                else
                {
                    using (FileStream file = new FileStream(tbFilePath.Text, FileMode.Open))
                        using (var storage = new IndexedFileStorage(file, clusterSize, checkSafeWrite.Checked, tbHeader.Text))
                        {
                        }
                }
            }
            catch (Exception e)
            {
                ExceptionDialog exDialog = new ExceptionDialog("An exception occured. \nPlease check the inputed parameters.",
                                                               e);

                exDialog.ShowDialog();
                return(false);
            }

            if (tbHeader.Text.Equals(""))
            {
                parent.setStorageInformation(tbFilePath.Text, clusterSize, checkSafeWrite.Checked);
            }
            else
            {
                parent.setStorageInformation(tbFilePath.Text, clusterSize, checkSafeWrite.Checked, tbHeader.Text);
            }

            return(true);
        }
Exemple #3
0
        private void btnCreateGVFile_Click(object sender, EventArgs e)
        {
            disableControls();
            this.Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            try
            {
                string gvContent = null;
                string chosenTypeName = null;
                //Opening the storage
                using (FileStream file = new FileStream(filePath, FileMode.Open))
                using (var storage = new IndexedFileStorage(file, clusterSize, safeWrite, header))
                {
                    TypesVisualisationService typesVisualisationService = new TypesVisualisationService(storage);
                    string rootTypeName = typesVisualisationService.getRootTypeName();
                    if (rbRootType.Checked)
                    {
                        chosenTypeName = rootTypeName;
                        gvContent = typesVisualisationService.GetGraphVizContentFromStorage(storage);

                    }
                    else
                    {
                        //Opening the dialog for choosing a type.
                        ChooseTypeForm chooseTypeForm = new ChooseTypeForm(typesVisualisationService.GetTypeVisualUnits(typesVisualisationService.GetRootTypeId()), rootTypeName);
                        if (chooseTypeForm.ShowDialog() == DialogResult.OK)
                        {
                            chosenTypeName = chooseTypeForm.CurrentType.Name;
                            gvContent = typesVisualisationService.GetGraphVizContentFromStorage(chosenTypeName, storage);
                        }
                    }
                }
                if (gvContent != null)
                {
                    this.Cursor = Cursors.WaitCursor;
                    Application.DoEvents();

                    //creating the filename for the image.
                    string fileLocation = filePath.Substring(0, filePath.LastIndexOf("\\") + 1);
                    string fileName = Path.GetFileNameWithoutExtension(filePath) + "_" + chosenTypeName;
                    string pngExtension = ".png";
                    string newFilePathPng = fileLocation + fileName + pngExtension;
                    int occurance = 0;
                    while (File.Exists(newFilePathPng))
                    {
                        occurance++;
                        newFilePathPng = fileLocation + fileName + occurance + pngExtension;
                    }

                    //Calling dot.exe to generate the image.
                    var getStartProcessQuery = new GetStartProcessQuery();
                    var getProcessStartInfoQuery = new GetProcessStartInfoQuery();
                    var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery,getStartProcessQuery);
                    var wrapper = new GraphVizWrapper.GraphVizWrapper(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand);

                    byte[] output = wrapper.GenerateGraph(gvContent, Enums.GraphReturnType.Png);
                    File.WriteAllBytes(newFilePathPng, output);

                    panStatus.Visible = true;
                    tbStatus.Text = newFilePathPng;

                }

            }
            catch (FileNotFoundException ex)
            {
                String message = "File Path is invalid! The file has probably been moved or removed since opening it.\n Please check the file location.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            catch (Exception ex)
            {
                String message = "An exception has occured. Please consult the exception log below.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            enableControls();
            this.Cursor = Cursors.Default;
            Application.DoEvents();
        }
Exemple #4
0
        private void btnCreateGVFile_Click(object sender, EventArgs e)
        {
            disableControls();
            this.Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            try
            {
                string gvContent      = null;
                string chosenTypeName = null;
                //Opening the storage
                using (FileStream file = new FileStream(filePath, FileMode.Open))
                    using (var storage = new IndexedFileStorage(file, clusterSize, safeWrite, header))
                    {
                        TypesVisualisationService typesVisualisationService = new TypesVisualisationService(storage);
                        string rootTypeName = typesVisualisationService.getRootTypeName();
                        if (rbRootType.Checked)
                        {
                            chosenTypeName = rootTypeName;
                            gvContent      = typesVisualisationService.GetGraphVizContentFromStorage(storage);
                        }
                        else
                        {
                            //Opening the dialog for choosing a type.
                            ChooseTypeForm chooseTypeForm = new ChooseTypeForm(typesVisualisationService.GetTypeVisualUnits(typesVisualisationService.GetRootTypeId()), rootTypeName);
                            if (chooseTypeForm.ShowDialog() == DialogResult.OK)
                            {
                                chosenTypeName = chooseTypeForm.CurrentType.Name;
                                gvContent      = typesVisualisationService.GetGraphVizContentFromStorage(chosenTypeName, storage);
                            }
                        }
                    }
                if (gvContent != null)
                {
                    this.Cursor = Cursors.WaitCursor;
                    Application.DoEvents();

                    //creating the filename for the image.
                    string fileLocation   = filePath.Substring(0, filePath.LastIndexOf("\\") + 1);
                    string fileName       = Path.GetFileNameWithoutExtension(filePath) + "_" + chosenTypeName;
                    string pngExtension   = ".png";
                    string newFilePathPng = fileLocation + fileName + pngExtension;
                    int    occurance      = 0;
                    while (File.Exists(newFilePathPng))
                    {
                        occurance++;
                        newFilePathPng = fileLocation + fileName + occurance + pngExtension;
                    }

                    //Calling dot.exe to generate the image.
                    var getStartProcessQuery        = new GetStartProcessQuery();
                    var getProcessStartInfoQuery    = new GetProcessStartInfoQuery();
                    var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);
                    var wrapper = new GraphVizWrapper.GraphVizWrapper(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand);

                    byte[] output = wrapper.GenerateGraph(gvContent, Enums.GraphReturnType.Png);
                    File.WriteAllBytes(newFilePathPng, output);


                    panStatus.Visible = true;
                    tbStatus.Text     = newFilePathPng;
                }
            }
            catch (FileNotFoundException ex)
            {
                String          message  = "File Path is invalid! The file has probably been moved or removed since opening it.\n Please check the file location.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            catch (Exception ex)
            {
                String          message  = "An exception has occured. Please consult the exception log below.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            enableControls();
            this.Cursor = Cursors.Default;
            Application.DoEvents();
        }