Ejemplo n.º 1
0
        private void OnSvgSuitePathTextChanged(object sender, TextChangedEventArgs e)
        {
            if (!this.IsLoaded)
            {
                return;
            }

            string selectePath = txtSvgSuitePath.Text;

            if (selectePath != null)
            {
                selectePath = selectePath.Trim();
            }
            if (string.IsNullOrWhiteSpace(selectePath) || !Directory.Exists(selectePath))
            {
                btnPathLocate.IsEnabled = false;

                return;
            }

            btnPathLocate.IsEnabled = true;

            if (OptionSettings.IsTestSuiteAvailable(selectePath))
            {
                _isGeneralModified             = true;
                _optionSettings.LocalSuitePath = selectePath;
            }
        }
Ejemplo n.º 2
0
        public OptionSettings Clone()
        {
            OptionSettings clonedSettings = new OptionSettings(this);

            if (_webSuitePath != null)
            {
                clonedSettings._webSuitePath = new string(_webSuitePath.ToCharArray());
            }
            if (_localSuitePath != null)
            {
                clonedSettings._localSuitePath = new string(_localSuitePath.ToCharArray());
            }
            if (_testSuites != null)
            {
                int itemCount = _testSuites.Count;
                List <SvgTestSuite> clonedTestSuites = new List <SvgTestSuite>(itemCount);
                for (int i = 0; i < itemCount; i++)
                {
                    clonedTestSuites.Add(_testSuites[i].Clone());
                }
                clonedSettings._testSuites = clonedTestSuites;
            }

            return(clonedSettings);
        }
Ejemplo n.º 3
0
        private void OnOpenSvgSuitePath(object sender, RoutedEventArgs e)
        {
            var filePath = txtSvgSuitePath.Text;

            if (string.IsNullOrWhiteSpace(filePath) || Directory.Exists(filePath) == false)
            {
                return;
            }

            OptionSettings.OpenFolderAndSelectItem(filePath, null);
        }
Ejemplo n.º 4
0
 public OptionSettings(OptionSettings source)
 {
     if (source == null)
     {
         return;
     }
     _hidePathsRoot  = source._hidePathsRoot;
     _webSuitePath   = source._webSuitePath;
     _localSuitePath = source._localSuitePath;
     _testSuites     = source._testSuites;
 }
Ejemplo n.º 5
0
        private void OnTestSuitesSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!this.IsLoaded || _isInitialising || _optionSettings == null)
            {
                return;
            }

            var selectedItem = cboTestSuites.SelectedItem as ComboBoxItem;

            if (selectedItem == null || selectedItem.Tag == null)
            {
                return;
            }
            var testSuite = selectedItem.Tag as SvgTestSuite;

            if (testSuite == null)
            {
                return;
            }
            string localSuitePath = testSuite.LocalSuitePath;

            if (OptionSettings.IsTestSuiteAvailable(localSuitePath) == false)
            {
                PromptDialog dlg = new PromptDialog();
                dlg.Owner          = _mainWindow;
                dlg.OptionSettings = _optionSettings;

                var dialogResult = dlg.ShowDialog();

                if (dialogResult == null || dialogResult.Value == false)
                {
                    return;
                }
            }

            _isInitialising = true;

            txtSvgSuitePath.Text    = _optionSettings.GetPath(testSuite.LocalSuitePath);
            txtSvgSuitePathWeb.Text = testSuite.WebSuitePath;

            _optionSettings.LocalSuitePath = testSuite.LocalSuitePath;
            _optionSettings.WebSuitePath   = testSuite.WebSuitePath;

            testSuite.SetSelected(_optionSettings.TestSuites);

            _isGeneralModified = true;

            _isInitialising = false;
        }
Ejemplo n.º 6
0
        private void OnPageLoaded(object sender, RoutedEventArgs e)
        {
            if (_mainWindow == null || _mainWindow.OptionSettings == null)
            {
                return;
            }
            _optionSettings = _mainWindow.OptionSettings;

            _isInitialising = true;

            txtSvgSuitePath.Text    = _optionSettings.GetPath(_optionSettings.LocalSuitePath);
            txtSvgSuitePathWeb.Text = _optionSettings.WebSuitePath;

            txtSvgSuitePath.IsReadOnly = _optionSettings.HidePathsRoot;

            chkHidePathsRoot.IsChecked = _optionSettings.HidePathsRoot;

            var testSuites = _optionSettings.TestSuites;

            if (testSuites != null && testSuites.Count != 0)
            {
                cboTestSuites.Items.Clear();

                int selectedIndex = 0;

                for (int i = 0; i < testSuites.Count; i++)
                {
                    var          testSuite  = testSuites[i];
                    ComboBoxItem comboxItem = new ComboBoxItem();
                    comboxItem.Content = testSuite.Description;
                    comboxItem.Tag     = testSuite;

                    cboTestSuites.Items.Add(comboxItem);

                    if (testSuite.IsSelected)
                    {
                        selectedIndex = i;
                    }
                }

                cboTestSuites.SelectedIndex = selectedIndex;
            }

            _isInitialising = false;
        }
Ejemplo n.º 7
0
        public bool LoadDocument(string documentFilePath, SvgTestInfo testInfo, object extraInfo = null)
        {
            this.UnloadDocument();

            if (string.IsNullOrWhiteSpace(documentFilePath) || testInfo == null)
            {
                return(false);
            }

            if (extraInfo != null)
            {
                _optionSettings = extraInfo as OptionSettings;
            }
            _svgFilePath = documentFilePath;

            bool isLoaded = false;

            string fileExt = Path.GetExtension(documentFilePath);

            if (string.Equals(fileExt, ".svgz", StringComparison.OrdinalIgnoreCase))
            {
                using (FileStream fileStream = File.OpenRead(documentFilePath))
                {
                    using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Decompress))
                    {
                        // Text Editor does not work with this stream, so we read the data to memory stream...
                        MemoryStream memoryStream = new MemoryStream();
                        // Use this method is used to read all bytes from a stream.
                        int    totalCount = 0;
                        int    bufferSize = 512;
                        byte[] buffer     = new byte[bufferSize];
                        while (true)
                        {
                            int bytesRead = zipStream.Read(buffer, 0, bufferSize);
                            if (bytesRead == 0)
                            {
                                break;
                            }

                            memoryStream.Write(buffer, 0, bytesRead);
                            totalCount += bytesRead;
                        }

                        if (totalCount > 0)
                        {
                            memoryStream.Position = 0;
                        }

                        isLoaded = this.LoadFile(memoryStream, testInfo);

                        memoryStream.Close();
                    }
                }
            }
            else
            {
                using (FileStream stream = File.OpenRead(documentFilePath))
                {
                    isLoaded = this.LoadFile(stream, testInfo);
                }
            }

            btnFilePath.IsEnabled = isLoaded;

            return(isLoaded);
        }