public void RaisePostBackEvent_IfDirectWriteSetAsFalse_SavesImageToAlternativePath()
        {
            // Arrange
            var toolText = new ToolText();

            _imageEditor.Toolbar.Tools.Add(toolText);
            _imageEditor.DirectWrite = false;

            // RaisePostBackEvent method eventArgument parameter scheme
            // float factor

            // sample args to toolText
            var raisePostBackEventArgs = "lorem ipsum; White; Regular; 20; Arial; false; Near";

            // text starting point
            _imageEditor.Selection.X1 = 10;
            _imageEditor.Selection.Y1 = 10;

            // Act
            toolText.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            var alternativeDirectoryFilesCount = Directory.GetFiles(ToolImagesAlternativeDirectory).Length;

            alternativeDirectoryFilesCount.ShouldBe(1);
        }
Esempio n. 2
0
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (ShowLabel.HasValue)
            {
                writer.WriteAttributeString("showLabel", ShowLabel.GetHashCode().ToString());
            }
            if (ToolText.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("toolText", ToolText);
            }
            if (Label.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("label", Label);
            }

            if (ShowLabelBorder.HasValue)
            {
                writer.WriteAttributeString("showLabelBorder", ShowLabelBorder.GetHashCode().ToString());
            }

            if (LabelPosition.HasValue)
            {
                writer.WriteAttributeString("LabelPosition", LabelPosition.GetHashCode().ToString());
            }
            if (LabelHAlign.HasValue)
            {
                writer.WriteAttributeString("LabelHAlign", LabelHAlign.GetHashCode().ToString());
            }
            if (LabelVAlign.HasValue)
            {
                writer.WriteAttributeString("LabelVAlign", LabelVAlign.GetHashCode().ToString());
            }
        }
        public void RaisePostBackEvent_IfEventArgumentIsInvalid_RegistersStartupScript()
        {
            // Arrange
            var toolText = new ToolText();

            _imageEditor.Toolbar.Tools.Add(toolText);
            _imageEditor.DirectWrite = true;

            var registeredStartupScriptKey   = string.Empty;
            var registeredStartupScriptValue = string.Empty;

            _shimPage.RegisterStartupScriptStringString =
                (key, value) =>
            {
                registeredStartupScriptKey   = key;
                registeredStartupScriptValue = value;
                _registeredScripts[key]      = value;
            };

            // RaisePostBackEvent method eventArgument parameter scheme
            // string text; Color forecolor; FontStyle style; int size; string font; boolean antialias; StringAlignment alignment

            // sample args to toolText
            var raisePostBackEventArgs = "error prone argument to get exception inside";

            // Act
            toolText.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            _registeredScripts[registeredStartupScriptKey].ShouldBe(registeredStartupScriptValue);
        }
        public void RaisePostBackEvent_IfDirectWriteSetAsTrue_SavesImageDirectly()
        {
            // Arrange
            var toolText = new ToolText();

            _imageEditor.Toolbar.Tools.Add(toolText);
            _imageEditor.DirectWrite = true;

            // RaisePostBackEvent method eventArgument parameter scheme
            // string text; Color forecolor; FontStyle style; int size; string font; boolean antialias; StringAlignment alignment

            // sample args to toolText
            var raisePostBackEventArgs = "lorem ipsum; White; Regular; 20; Arial; false; Near";

            // text starting point
            _imageEditor.Selection.X1 = 10;
            _imageEditor.Selection.Y1 = 10;

            // Act
            toolText.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            var imagePath = _shimHttpServerUtility.Instance.MapPath(_imageEditor.ImageURL);

            using (var image = ActivePixToolsTestHelper.LoadImage(imagePath))
            {
                image.ShouldNotBeNull();
            }
        }
        public void Constructor_WithoutId_CreatesObjectWithGeneratedId()
        {
            // Arrange & Act
            var toolText           = new ToolText();
            var expectedToolTextId = string.Format("{0}{1}", ToolIdPrefix, ImageEditor.indexTools - 1);

            // Assert
            toolText.ID.ShouldBe(expectedToolTextId);
        }
        public void ParentToolbarGetter_IfToolIsNotAddedIntoAnImageEditor_ReturnsNull()
        {
            // Arrange
            var toolText = new ToolText();

            // Act
            var returnedToolbar = toolText.ParentToolbar;

            // Assert
            returnedToolbar.ShouldBeNull();
        }
        public void ParentImageEditorGetter_IfToolIsNotAddedIntoAnImageEditor_ThrowsException()
        {
            // Arrange
            var toolText = new ToolText();

            // Act
            var getParentImageEditor = new Action(() => { var returnedImageEditor = toolText.ParentImageEditor; });

            // Assert
            getParentImageEditor.ShouldThrow <NullReferenceException>();
        }
        public void Constructor_WithId_CreatesObjectWithGivenId()
        {
            // Arrange
            var expectedToolTextId = "myToolText";

            // Act
            var toolText = new ToolText(expectedToolTextId);

            // Assert
            toolText.ID.ShouldBe(expectedToolTextId);
        }
        public void ParentToolbarGetter_IfToolIsAddedIntoAnImageEditor_ReturnsToolbarOfImageEditor()
        {
            // Arrange
            var toolText = new ToolText();

            _imageEditor.Toolbar.Tools.Add(toolText);

            // Act
            var returnedToolbar = toolText.ParentToolbar;

            // Assert
            returnedToolbar.ShouldBeSameAs(_imageEditor.Toolbar);
        }
Esempio n. 10
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Label.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("label", Label);
            }
            if (DisplayValue.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("displayValue", DisplayValue);
            }
            if (Color.HasValue)
            {
                writer.WriteAttributeString("color", Color.Value.ToHexString());
            }
            if (Alpha.HasValue)
            {
                writer.WriteAttributeString("alpha", Alpha.ToString());
            }

            if (_link != null)
            {
                _link.GenerateXmlAttributes(writer);
            }

            if (ToolText.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("toolText", ToolText);
            }
            if (ShowLabel.HasValue)
            {
                writer.WriteAttributeString("showLabel", ShowLabel.GetHashCode().ToString());
            }
            if (Dashed.HasValue)
            {
                writer.WriteAttributeString("dashed", Dashed.GetHashCode().ToString());
            }

            if (_anchor != null)
            {
                _anchor.GenerateXmlAttributes(writer);
            }
        }
        public void OnPreRender_SetsButtonImages()
        {
            // Arrange
            var toolText = new ToolText();

            toolText.Page         = _shimPage;
            toolText.ImageURL     = string.Empty;
            toolText.OverImageURL = string.Empty;

            _imageEditor.Toolbar.Tools.Add(toolText);

            var toolTextPrivateObject = new MsUnitTesting.PrivateObject(toolText);

            // Act
            toolTextPrivateObject.Invoke("OnPreRender", EventArgs.Empty);

            // Assert
            TestsHelper.AssertNotFX1(ToolImageResourceName, toolText.ImageURL);
            TestsHelper.AssertNotFX1(ToolOverImageResourceName, toolText.OverImageURL);

            TestsHelper.AssertFX1(ToolImageName, toolText.ImageURL);
            TestsHelper.AssertFX1(ToolOverImageName, toolText.OverImageURL);
        }
        /// <summary>
        /// 속성 중 Attribute Node로 표현해야 한다.
        /// </summary>
        /// <param name="writer"></param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Id.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("Id", Id);
            }
            if (X.HasValue)
            {
                writer.WriteAttributeString("x", X.ToString());
            }
            if (Y.HasValue)
            {
                writer.WriteAttributeString("y", Y.ToString());
            }
            if (Alpha.HasValue)
            {
                writer.WriteAttributeString("Alpha", Alpha.ToString());
            }
            if (XScale.HasValue)
            {
                writer.WriteAttributeString("XScale", XScale.ToString());
            }
            if (YScale.HasValue)
            {
                writer.WriteAttributeString("YScale", YScale.ToString());
            }
            if (OrigW.HasValue)
            {
                writer.WriteAttributeString("origW", OrigW.ToString());
            }
            if (OrigH.HasValue)
            {
                writer.WriteAttributeString("origH", OrigH.ToString());
            }
            if (AutoScale.HasValue)
            {
                writer.WriteAttributeString("AutoScale", AutoScale.GetHashCode().ToString());
            }
            if (ConstrainedScale.HasValue)
            {
                writer.WriteAttributeString("ConstrainedScale", ConstrainedScale.GetHashCode().ToString());
            }
            if (ScaleImages.HasValue)
            {
                writer.WriteAttributeString("ScaleImages", ScaleImages.GetHashCode().ToString());
            }
            if (ScaleText.HasValue)
            {
                writer.WriteAttributeString("ScaleText", ScaleText.GetHashCode().ToString());
            }
            if (GrpXShift.HasValue)
            {
                writer.WriteAttributeString("GrpXShift", GrpXShift.ToString());
            }
            if (GrpYShift.HasValue)
            {
                writer.WriteAttributeString("GrpXShift", GrpXShift.ToString());
            }

            if (ShowBelow.HasValue)
            {
                writer.WriteAttributeString("ShowBelow", ShowBelow.GetHashCode().ToString());
            }
            if (Visible.HasValue)
            {
                writer.WriteAttributeString("Visible", Visible.GetHashCode().ToString());
            }

            if (ToolText.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("ToolText", ToolText);
            }

            if (_link != null)
            {
                _link.GenerateXmlAttributes(writer);
            }
        }
Esempio n. 13
0
        void ReleaseDesignerOutlets()
        {
            if (PointInspector != null)
            {
                PointInspector.Dispose();
                PointInspector = null;
            }

            if (ArrowInspector != null)
            {
                ArrowInspector.Dispose();
                ArrowInspector = null;
            }

            if (AttachedStyleInspector != null)
            {
                AttachedStyleInspector.Dispose();
                AttachedStyleInspector = null;
            }

            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BooleanPropertyInspector != null)
            {
                BooleanPropertyInspector.Dispose();
                BooleanPropertyInspector = null;
            }

            if (BorderInspectorsButton != null)
            {
                BorderInspectorsButton.Dispose();
                BorderInspectorsButton = null;
            }

            if (ColorPaletteInspector != null)
            {
                ColorPaletteInspector.Dispose();
                ColorPaletteInspector = null;
            }

            if (ConnectionInspectorsButton != null)
            {
                ConnectionInspectorsButton.Dispose();
                ConnectionInspectorsButton = null;
            }

            if (ConnectionsInspector != null)
            {
                ConnectionsInspector.Dispose();
                ConnectionsInspector = null;
            }

            if (DesignSurface != null)
            {
                DesignSurface.Dispose();
                DesignSurface = null;
            }

            if (DetailsInspectorButton != null)
            {
                DetailsInspectorButton.Dispose();
                DetailsInspectorButton = null;
            }

            if (DocumentScrollView != null)
            {
                DocumentScrollView.Dispose();
                DocumentScrollView = null;
            }

            if (DocumentView != null)
            {
                DocumentView.Dispose();
                DocumentView = null;
            }

            if (DocumentViewHeight != null)
            {
                DocumentViewHeight.Dispose();
                DocumentViewHeight = null;
            }

            if (DocumentViewWidth != null)
            {
                DocumentViewWidth.Dispose();
                DocumentViewWidth = null;
            }

            if (ExportButton != null)
            {
                ExportButton.Dispose();
                ExportButton = null;
            }

            if (FillInspector != null)
            {
                FillInspector.Dispose();
                FillInspector = null;
            }

            if (FillInspectorsButton != null)
            {
                FillInspectorsButton.Dispose();
                FillInspectorsButton = null;
            }

            if (FontInspector != null)
            {
                FontInspector.Dispose();
                FontInspector = null;
            }

            if (FrameInspector != null)
            {
                FrameInspector.Dispose();
                FrameInspector = null;
            }

            if (GeneralInfoInspector != null)
            {
                GeneralInfoInspector.Dispose();
                GeneralInfoInspector = null;
            }

            if (GradientInspector != null)
            {
                GradientInspector.Dispose();
                GradientInspector = null;
            }

            if (GroupInspector != null)
            {
                GroupInspector.Dispose();
                GroupInspector = null;
            }

            if (InspectorScrollView != null)
            {
                InspectorScrollView.Dispose();
                InspectorScrollView = null;
            }

            if (InspectorView != null)
            {
                InspectorView.Dispose();
                InspectorView = null;
            }

            if (LanguageSelector != null)
            {
                LanguageSelector.Dispose();
                LanguageSelector = null;
            }

            if (LibrarySelector != null)
            {
                LibrarySelector.Dispose();
                LibrarySelector = null;
            }

            if (NumberPropertyInspector != null)
            {
                NumberPropertyInspector.Dispose();
                NumberPropertyInspector = null;
            }

            if (OSSelector != null)
            {
                OSSelector.Dispose();
                OSSelector = null;
            }

            if (PolygonInspector != null)
            {
                PolygonInspector.Dispose();
                PolygonInspector = null;
            }

            if (PortfolioInspector != null)
            {
                PortfolioInspector.Dispose();
                PortfolioInspector = null;
            }

            if (PropertyInspector != null)
            {
                PropertyInspector.Dispose();
                PropertyInspector = null;
            }

            if (RectPropertyInspector != null)
            {
                RectPropertyInspector.Dispose();
                RectPropertyInspector = null;
            }

            if (RoundRectInspector != null)
            {
                RoundRectInspector.Dispose();
                RoundRectInspector = null;
            }

            if (ScriptDebuggerInspector != null)
            {
                ScriptDebuggerInspector.Dispose();
                ScriptDebuggerInspector = null;
            }

            if (SketchInspector != null)
            {
                SketchInspector.Dispose();
                SketchInspector = null;
            }

            if (SketchPath != null)
            {
                SketchPath.Dispose();
                SketchPath = null;
            }

            if (SourceList != null)
            {
                SourceList.Dispose();
                SourceList = null;
            }

            if (StarInspector != null)
            {
                StarInspector.Dispose();
                StarInspector = null;
            }

            if (StyleInspector != null)
            {
                StyleInspector.Dispose();
                StyleInspector = null;
            }

            if (TextEditor != null)
            {
                TextEditor.Dispose();
                TextEditor = null;
            }

            if (TextEditorMode != null)
            {
                TextEditorMode.Dispose();
                TextEditorMode = null;
            }

            if (TextEditorTitle != null)
            {
                TextEditorTitle.Dispose();
                TextEditorTitle = null;
            }

            if (TextInspector != null)
            {
                TextInspector.Dispose();
                TextInspector = null;
            }

            if (TextPropertyInspector != null)
            {
                TextPropertyInspector.Dispose();
                TextPropertyInspector = null;
            }

            if (ToolArrow != null)
            {
                ToolArrow.Dispose();
                ToolArrow = null;
            }

            if (ToolBezier != null)
            {
                ToolBezier.Dispose();
                ToolBezier = null;
            }

            if (ToolCursor != null)
            {
                ToolCursor.Dispose();
                ToolCursor = null;
            }

            if (ToolLine != null)
            {
                ToolLine.Dispose();
                ToolLine = null;
            }

            if (ToolOval != null)
            {
                ToolOval.Dispose();
                ToolOval = null;
            }

            if (ToolPolygon != null)
            {
                ToolPolygon.Dispose();
                ToolPolygon = null;
            }

            if (ToolRect != null)
            {
                ToolRect.Dispose();
                ToolRect = null;
            }

            if (ToolRoundRect != null)
            {
                ToolRoundRect.Dispose();
                ToolRoundRect = null;
            }

            if (ToolStar != null)
            {
                ToolStar.Dispose();
                ToolStar = null;
            }

            if (ToolText != null)
            {
                ToolText.Dispose();
                ToolText = null;
            }

            if (ToolTriangle != null)
            {
                ToolTriangle.Dispose();
                ToolTriangle = null;
            }

            if (ToolVector != null)
            {
                ToolVector.Dispose();
                ToolVector = null;
            }
        }
Esempio n. 14
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 15
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Id.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("Id", Id);
            }
            if (Value.HasValue)
            {
                writer.WriteAttributeString("Value", Value.ToString());
            }

            if (ShowValue.HasValue)
            {
                writer.WriteAttributeString("ShowValue", ShowValue.GetHashCode().ToString());
            }
            if (ValueX.HasValue)
            {
                writer.WriteAttributeString("ValueX", ValueX.ToString());
            }
            if (ValueY.HasValue)
            {
                writer.WriteAttributeString("ValueY", ValueY.ToString());
            }
            if (EditMode.HasValue)
            {
                writer.WriteAttributeString("EditMode", EditMode.GetHashCode().ToString());
            }

            if (_border != null)
            {
                _border.GenerateXmlAttributes(writer);
            }

            if (BgColor.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("BgColor", BgColor);
            }
            if (Radius.HasValue)
            {
                writer.WriteAttributeString("Radius", Radius.ToString());
            }
            if (BaseWidth.HasValue)
            {
                writer.WriteAttributeString("BaseWidth", BaseWidth.ToString());
            }
            if (TopWidth.HasValue)
            {
                writer.WriteAttributeString("TopWidth", TopWidth.ToString());
            }
            if (RearExtension.HasValue)
            {
                writer.WriteAttributeString("RearExtension", RearExtension.ToString());
            }
            if (ToolText.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("ToolText", ToolText);
            }

            if (_link != null)
            {
                _link.GenerateXmlAttributes(writer);
            }
        }