Example #1
0
        public OptionSettings Clone()
        {
            OptionSettings clonedSettings = new OptionSettings(this);

            if (_wpfSettings != null)
            {
                clonedSettings._wpfSettings = _wpfSettings.Clone();
            }
            if (_webSuitePath != null)
            {
                clonedSettings._webSuitePath = string.Copy(_webSuitePath);
            }
            if (_localSuitePath != null)
            {
                clonedSettings._localSuitePath = string.Copy(_localSuitePath);
            }
            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);
        }
Example #2
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;
            }
        }
 public OptionSettings(OptionSettings source)
 {
     _hidePathsRoot  = source._hidePathsRoot;
     _webSuitePath   = source._webSuitePath;
     _localSuitePath = source._localSuitePath;
     _wpfSettings    = source._wpfSettings;
 }
Example #4
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);
        }
 public OptionSettings(OptionSettings source)
 {
     if (source == null)
     {
         return;
     }
     _hidePathsRoot  = source._hidePathsRoot;
     _webSuitePath   = source._webSuitePath;
     _localSuitePath = source._localSuitePath;
     _wpfSettings    = source._wpfSettings;
 }
Example #6
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;
        }
        public OptionSettings Clone()
        {
            OptionSettings optSettings = new OptionSettings(this);

            if (_wpfSettings != null)
            {
                optSettings._wpfSettings = _wpfSettings.Clone();
            }
            if (_webSuitePath != null)
            {
                optSettings._webSuitePath = string.Copy(_webSuitePath);
            }
            if (_localSuitePath != null)
            {
                optSettings._localSuitePath = string.Copy(_localSuitePath);
            }

            return(optSettings);
        }
Example #8
0
        private void OnPageLoaded(object sender, RoutedEventArgs e)
        {
            if (_mainWindow == null || _mainWindow.OptionSettings == null)
            {
                return;
            }
            _optionSettings = _mainWindow.OptionSettings;

            var wpfSettings = _optionSettings.ConversionSettings;

            if (wpfSettings != null)
            {
                _wpfSettings = wpfSettings.Clone();
            }
            if (_wpfSettings == null)
            {
                return;
            }

            _isInitialising = true;

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

            txtSvgSuitePath.IsReadOnly = _optionSettings.HidePathsRoot;

            chkHidePathsRoot.IsChecked = _optionSettings.HidePathsRoot;

            chkTextAsGeometry.IsChecked = _wpfSettings.TextAsGeometry;
            chkIncludeRuntime.IsChecked = _wpfSettings.IncludeRuntime;

            chkIgnoreRootViewbox.IsChecked     = _wpfSettings.IgnoreRootViewbox;
            chkEnsureViewboxSize.IsChecked     = _wpfSettings.EnsureViewboxSize;
            chkEnsureViewboxPosition.IsChecked = _wpfSettings.EnsureViewboxPosition;

            _isConversionModified = false;

            _isInitialising = false;
        }
Example #9
0
        private void OnPageLoaded(object sender, RoutedEventArgs e)
        {
            if (_mainWindow == null || _mainWindow.OptionSettings == null)
            {
                return;
            }
            _optionSettings = _mainWindow.OptionSettings;

            var wpfSettings = _optionSettings.ConversionSettings;

            if (wpfSettings != null)
            {
                _wpfSettings = wpfSettings.Clone();
            }
            if (_wpfSettings == null)
            {
                return;
            }

            _isInitialising = true;

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

            txtSvgSuitePath.IsReadOnly = _optionSettings.HidePathsRoot;

            chkHidePathsRoot.IsChecked = _optionSettings.HidePathsRoot;

            chkTextAsGeometry.IsChecked = _wpfSettings.TextAsGeometry;
            chkIncludeRuntime.IsChecked = _wpfSettings.IncludeRuntime;

            chkIgnoreRootViewbox.IsChecked     = _wpfSettings.IgnoreRootViewbox;
            chkEnsureViewboxSize.IsChecked     = _wpfSettings.EnsureViewboxSize;
            chkEnsureViewboxPosition.IsChecked = _wpfSettings.EnsureViewboxPosition;

            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;
            }

            _isConversionModified = false;

            _isInitialising = false;
        }
Example #10
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);
        }