Ejemplo n.º 1
0
        /// <summary>
        /// Handles the click event by opening the text tool dialog.
        /// </summary>
        /// <param name="e">EventArgs.</param>
        /// <param name="position">Mouse position.</param>
        /// <returns>The mouse state handler for handling the next mouse events.</returns>
        public override void OnClick(PointD3D position, MouseButtonEventArgs e)
        {
            base.OnClick(position, e);

            _cachedActiveLayer = _grac.ActiveLayer;
            _cachedActiveLayerTransformation = _cachedActiveLayer.TransformationFromRootToHere();
            GetHitPointOnActiveLayerPlaneFacingTheCamera(_grac.Doc, _grac.ActiveLayer, position, out var hitPointOnLayerPlaneInLayerCoordinates, out var rotationsRadian);

            var tgo = new TextGraphic(_grac.Doc.GetPropertyContext());

            tgo.SetParentSize(_cachedActiveLayer.Size, false);
            tgo.Position = hitPointOnLayerPlaneInLayerCoordinates;

            tgo.RotationX = (rotationsRadian.X / Math.PI) * 180;
            tgo.RotationY = (rotationsRadian.Y / Math.PI) * 180;
            tgo.RotationZ = (rotationsRadian.Z / Math.PI) * 180;

            tgo.ParentObject = _grac.ActiveLayer;

            // deselect the text tool
            _grac.CurrentGraphTool = GraphToolType.ObjectPointer;

            object tgoo = tgo;

            if (Current.Gui.ShowDialog(ref tgoo, "Text", false))
            {
                tgo = (TextGraphic)tgoo;
                if (tgo != null && !tgo.Empty)
                {
                    _grac.ActiveLayer.GraphObjects.Add(tgo);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 頂点のダーティをマークします
 /// </summary>
 protected void SetVerticesDirty()
 {
     if (TextGraphic != null)
     {
         TextGraphic.SetVerticesDirty();
     }
 }
Ejemplo n.º 3
0
 protected sealed override void Awake()
 {
     if (TextGraphic != null)
     {
         TextGraphic.SetVerticesDirty();
     }
     BeforAwake();
 }
Ejemplo n.º 4
0
        public PlayerUnitframe(InterfaceManager manager)
            : base(manager)
        {
            unitFramePlate = new Form(manager)
            {
                Size = new Vector2(160, 54),
                Background = new BorderGraphic(manager.GlyphCache) { Border = manager.DefaultSlimBorder }
            };

            namePlate = new TextGraphic(manager.GlyphCache)
            {
                Overflow = TextOverflow.Ignore,
                Anchor = Orientation.Left,
                Font = manager.DefaultFont
            };

            teamClassBox = new TeamClassBox(InterfaceManager)
            {
                Position = new Vector3(1, 1, 0),
                Anchor = Orientation.TopRight
            };

            hpBar = new ProgressBar(InterfaceManager)
            {
                Text = "$value$ / $maxvalue$",
                Font = Font,
                Background = null,
                Position = new Vector3(0, 18, 0)
            };
            ((StretchingImageGraphic)hpBar.ProgressGraphic).Texture = manager.View.content.Get<Texture>("hpbar.tga");
            manaBar = new ProgressBar(InterfaceManager)
            {
                Text = "$value$ / $maxvalue$",
                Font = Font,
                Background = null,
                Position = new Vector3(0, 18*2, 0)
            };
            ((StretchingImageGraphic)manaBar.ProgressGraphic).Texture = manager.View.content.Get<Texture>("manabar.tga");

            activeBuffs = new ActiveBuffsPanel(manager)
            {
                Size = new Vector2(Size.X, 12+2*buffOffset),
                Position = new Vector3(0, 18*3+buffOffset, -1),
                BuffIconSize = 12,
                BuffsAnchor = Orientation.TopLeft
            };
            IsClickable = true;

            unitFramePlate.AddChild(teamClassBox);
            unitFramePlate.AddChild(hpBar);
            unitFramePlate.AddChild(manaBar);
            AddChild(unitFramePlate);
            AddChild(activeBuffs);

            namePlate.Construct(InterfaceManager.Device);
            Models["Nameplate"] = namePlate.Model;
        }
Ejemplo n.º 5
0
        private IEnumerator SetVerticesDirtyAsync()
        {
            yield return(null);

            if (TextGraphic != null)
            {
                TextGraphic.SetVerticesDirty();
            }
        }
Ejemplo n.º 6
0
        protected override void OnConstruct()
        {
            if (AutoSize != AutoSizeMode.None)
            {
                AutoAdjustSize();
            }
            base.OnConstruct();

            if (Caption == null && Text != null)
            {
                Caption = new TextGraphic {
                    Anchor = textAnchor
                }
            }
            ;

            if (Caption != null)
            {
                if (Caption is TextGraphic)
                {
                    if (Clickable && !Disabled)
                    {
                        ((TextGraphic)Caption).Font = font;
                    }
                    else
                    {
                        if (disabledFont != null)
                        {
                            ((TextGraphic)Caption).Font = disabledFont;
                        }
                        else
                        {
                            ((TextGraphic)Caption).Font = new Graphics.Content.Font(font.SystemFont, System.Drawing.Color.Gray, font.Backdrop);
                        }
                    }
                    ((TextGraphic)Caption).Text = text;
                }

                caption.Size     = InnerSize;
                caption.Position = Common.Math.ToVector3(InnerOffset);

                SetGraphic("Button.Caption", Caption);

                /*caption.Model.World = Matrix.Translation(-Size.X / 2, -Size.Y / 2, 0);
                 * caption.Model.World *= Matrix.Scaling(captionScale, captionScale, 0);
                 * caption.Model.World *= Matrix.Translation(Size.X / 2, Size.Y / 2, 0);*/
            }

            if (HotkeyCaption != null)
            {
                SetGraphic("Button.HotkeyCaption", HotkeyCaption);
                //HotkeyCaption.Model.World = Matrix.Translation(2, 0, -1);
            }
        }

        Content.Font font = InterfaceScene.DefaultFont;
Ejemplo n.º 7
0
 /// <summary>
 /// Tries to remove a child object of this collection.
 /// </summary>
 /// <param name="go">The object to remove.</param>
 /// <returns> If the provided object is a child object and
 /// the child object could be removed, the return value is true.</returns>
 public bool Remove(GraphicBase go)
 {
     // test our own objects for removal (only that that _are_ removable)
     if (object.ReferenceEquals(go, this._axisTitle))
     {
         _axisTitle = null;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 8
0
 public void ShowTitle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
 {
     if (_axisTitle == null)
     {
         Title = new TextGraphic(context)
         {
             Text = "axis title"
         };
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Tries to remove a child object of this collection.
 /// </summary>
 /// <param name="go">The object to remove.</param>
 /// <returns> If the provided object is a child object and
 /// the child object could be removed, the return value is true.</returns>
 public bool Remove(IGraphicBase go)
 {
     // test our own objects for removal (only that that _are_ removable)
     if (object.ReferenceEquals(go, _axisTitle))
     {
         _axisTitle = null;
         EhSelfChanged(EventArgs.Empty);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 10
0
 public bool InitializeDocument(params object[] args)
 {
     if (args.Length == 0 || !(args[0] is TextGraphic))
     {
         return(false);
     }
     _originalDoc = (TextGraphic)args[0];
     _doc         = _useDocumentCopy == UseDocument.Directly ? _originalDoc : (TextGraphic)_originalDoc.Clone();
     Initialize(true); // initialize always because we have to update the temporary variables
     return(true);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Handles the click event by opening the text tool dialog.
        /// </summary>
        /// <param name="e">EventArgs.</param>
        /// <param name="position">Mouse position.</param>
        /// <returns>The mouse state handler for handling the next mouse events.</returns>
        public override void OnClick(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnClick(position, e);

            _cachedActiveLayer = _grac.ActiveLayer;
            _cachedActiveLayerTransformation    = _cachedActiveLayer.TransformationFromRootToHere();
            _cachedActiveLayerTransformationGdi = _cachedActiveLayerTransformation;

            // get the page coordinates (in Point (1/72") units)
            var rootLayerCoord = _grac.ConvertMouseToRootLayerCoordinates(_positionLastMouseDownInMouseCoordinates);
            // with knowledge of the current active layer, calculate the layer coordinates from them
            var layerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(rootLayerCoord);

            var tgo = new TextGraphic(_grac.Doc.GetPropertyContext());

            tgo.SetParentSize(_grac.ActiveLayer.Size, false);
            tgo.Position     = layerCoord;
            tgo.ParentObject = _grac.ActiveLayer;

            // deselect the text tool
            _grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);

            object tgoo = tgo;

            if (Current.Gui.ShowDialog(ref tgoo, "Text", false))
            {
                tgo = (TextGraphic)tgoo;
                if (tgo != null && !tgo.Empty)
                {
                    _grac.ActiveLayer.GraphObjects.Add(tgo);
                }
            }

            /*
             *                TextControlDialog dlg = new TextControlDialog(_grac.Layers[_grac.CurrentLayerNumber],tgo);
             *                if(DialogResult.OK==dlg.ShowDialog(_grac.View.Window))
             *                {
             *                        // add the resulting textgraphobject to the layer
             *                        if(!dlg.SimpleTextGraphics.Empty)
             *                        {
             *                                _grac.Layers[_grac.CurrentLayerNumber].GraphObjects.Add(dlg.SimpleTextGraphics);
             *                                _grac.RefreshGraph();
             *                        }
             *                }
             */
            _grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);
        }
Ejemplo n.º 12
0
        void AutoAdjustSize()
        {
            if (IsRemoved)
            {
                return;
            }
            var ms = maxSize;

            if (Dock == DockStyle.Top || Dock == DockStyle.Bottom || Dock == DockStyle.Fill)
            {
                ms.X = base.Size.X;
            }
            if (Dock == DockStyle.Left || Dock == DockStyle.Right || Dock == DockStyle.Fill)
            {
                ms.Y = base.Size.Y;
            }
            Size = TextGraphic.AutoSize(autoSize, Scene.View.Content, base.Size, ms, Padding);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the click event by opening the text tool dialog.
        /// </summary>
        /// <param name="e">EventArgs.</param>
        /// <returns>The mouse state handler for handling the next mouse events.</returns>
        public override void OnClick(System.EventArgs e)
        {
            base.OnClick(e);

            // get the page coordinates (in Point (1/72") units)
            PointF printAreaCoord = _grac.WinFormsController.PixelToPrintableAreaCoordinates(m_LastMouseDown);
            // with knowledge of the current active layer, calculate the layer coordinates from them
            PointF layerCoord = _grac.ActiveLayer.GraphToLayerCoordinates(printAreaCoord);

            TextGraphic tgo = new TextGraphic();

            tgo.Position     = layerCoord;
            tgo.ParentObject = _grac.ActiveLayer.GraphObjects;

            // deselect the text tool
            _grac.SetGraphToolFromInternal(Altaxo.Gui.Graph.Viewing.GraphToolType.ObjectPointer);

            object tgoo = tgo;

            if (Current.Gui.ShowDialog(ref tgoo, "Text", false))
            {
                tgo = (TextGraphic)tgoo;
                if (tgo != null && !tgo.Empty)
                {
                    _grac.ActiveLayer.GraphObjects.Add(tgo);
                    _grac.WinFormsController.RefreshGraph();
                }
            }

            /*
             * TextControlDialog dlg = new TextControlDialog(_grac.Layers[_grac.CurrentLayerNumber],tgo);
             * if(DialogResult.OK==dlg.ShowDialog(_grac.View.Window))
             * {
             * // add the resulting textgraphobject to the layer
             * if(!dlg.SimpleTextGraphics.Empty)
             * {
             *  _grac.Layers[_grac.CurrentLayerNumber].GraphObjects.Add(dlg.SimpleTextGraphics);
             *  _grac.RefreshGraph();
             * }
             * }
             */
            _grac.SetGraphToolFromInternal(Altaxo.Gui.Graph.Viewing.GraphToolType.ObjectPointer);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles the double click event onto a plot item.
        /// </summary>
        /// <param name="hit">Object containing information about the double clicked object.</param>
        /// <returns>True if the object should be deleted, false otherwise.</returns>
        protected static bool EhEditTextGraphics(IHitTestObject hit)
        {
            XYPlotLayer layer = hit.ParentLayer;
            TextGraphic tg    = (TextGraphic)hit.HittedObject;

            bool shouldDeleted = false;

            object tgoo = tg;

            if (Current.Gui.ShowDialog(ref tgoo, "Edit text", true))
            {
                tg = (TextGraphic)tgoo;
                if (tg == null || tg.Empty)
                {
                    if (null != hit.Remove)
                    {
                        shouldDeleted = hit.Remove(hit);
                    }
                    else
                    {
                        shouldDeleted = false;
                    }
                }
                else
                {
                    if (tg.ParentObject is Main.IChildChangedEventSink)
                    {
                        ((Main.IChildChangedEventSink)tg.ParentObject).EhChildChanged(tg, EventArgs.Empty);
                    }
                }
            }



            return(shouldDeleted);
        }
Ejemplo n.º 15
0
		/// <summary>
		/// Tries to remove a child object of this collection.
		/// </summary>
		/// <param name="go">The object to remove.</param>
		/// <returns> If the provided object is a child object and
		/// the child object could be removed, the return value is true.</returns>
		public bool Remove(IGraphicBase go)
		{
			// test our own objects for removal (only that that _are_ removable)
			if (object.ReferenceEquals(go, this._axisTitle))
			{
				_axisTitle = null;
				EhSelfChanged(EventArgs.Empty);
				return true;
			}
			return false;
		}
Ejemplo n.º 16
0
    private void SetAxisTitleString(CSLineID id, string value)
    {
      AxisStyle style = _axisStyles[id];
      string oldtitle = (style == null || style.Title == null) ? null : style.Title.Text;
      string newtitle = (value == null || value == String.Empty) ? null : value;

      if (newtitle != oldtitle)
      {
        if (newtitle == null)
        {
          if (style != null)
            style.Title = null;
        }
        else if (_axisStyles.AxisStyleEnsured(id).Title != null)
        {
          _axisStyles[id].Title.Text = newtitle;
        }
        else
        {
          TextGraphic tg = new TextGraphic();
          CSAxisInformation info = CoordinateSystem.GetAxisStyleInformation(id);

          // find out the position and orientation of the item
          double rx0 = 0, rx1 = 1, ry0 = 0, ry1 = 1;
          if (id.ParallelAxisNumber == 0)
            ry0 = ry1 = id.LogicalValueOtherFirst;
          else
            rx0 = rx1 = id.LogicalValueOtherFirst;

          PointF normDirection;
          Logical3D tdirection = CoordinateSystem.GetLogicalDirection(info.Identifier.ParallelAxisNumber, info.PreferedLabelSide);
          PointF location = CoordinateSystem.GetNormalizedDirection(new Logical3D(rx0, ry0), new Logical3D(rx1, ry1), 0.5, tdirection, out normDirection);
          double angle = Math.Atan2(normDirection.Y, normDirection.X) * 180 / Math.PI;

          float distance = 0;
          AxisStyle axisStyle = _axisStyles[id];
          if (null != axisStyle.AxisLineStyle)
            distance += axisStyle.AxisLineStyle.GetOuterDistance(info.PreferedLabelSide);
          float labelFontSize = 0;
          if (axisStyle.ShowMajorLabels)
            labelFontSize = Math.Max(labelFontSize, axisStyle.MajorLabelStyle.FontSize);
          if (axisStyle.ShowMinorLabels)
            labelFontSize = Math.Max(labelFontSize, axisStyle.MinorLabelStyle.FontSize);
          const float scaleFontWidth = 4;
          const float scaleFontHeight = 1.5f;

          if (-45<= angle && angle <= 45)
          {
            //case EdgeType.Right:
            tg.Rotation = 90;
            tg.XAnchor = XAnchorPositionType.Center;
            tg.YAnchor = YAnchorPositionType.Top;
            distance += scaleFontWidth * labelFontSize;
          }
          else if (-135 <= angle && angle <= -45)
          {
            //case Top:
            tg.Rotation = 0;
            tg.XAnchor = XAnchorPositionType.Center;
            tg.YAnchor = YAnchorPositionType.Bottom;
            distance += scaleFontHeight * labelFontSize;
          }
          else if (45 <= angle && angle <= 135)
          {
            //case EdgeType.Bottom:
            tg.Rotation = 0;
            tg.XAnchor = XAnchorPositionType.Center;
            tg.YAnchor = YAnchorPositionType.Top;
            distance += scaleFontHeight * labelFontSize;
          }
          else
          {
            //case EdgeType.Left:

            tg.Rotation = 90;
            tg.XAnchor = XAnchorPositionType.Center;
            tg.YAnchor = YAnchorPositionType.Bottom;
            distance += scaleFontWidth * labelFontSize;
          }

          tg.Position = new PointF(location.X + distance * normDirection.X, location.Y + distance * normDirection.Y);
          tg.Text = newtitle;
          _axisStyles.AxisStyleEnsured(id).Title = tg;
        }
      }
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Creates a new legend, removing the old one.
    /// </summary>
    /// <remarks>The position of the old legend is <b>only</b> used for the new legend if the old legend's position is
    /// inside the layer. This prevents a "stealth" legend in case it is not visible by accident.
    /// </remarks>
    public void CreateNewLayerLegend()
    {
      // remove the legend if there are no plot curves on the layer
      if (PlotItems.Flattened.Length == 0)
      {
        _legends.Clear();
        OnChanged();
        return;
      }

      TextGraphic tgo;

      if (Legend != null)
        tgo = new TextGraphic(Legend);
      else
        tgo = new TextGraphic();


      System.Text.StringBuilder strg = new System.Text.StringBuilder();
      for (int i = 0; i < this.PlotItems.Flattened.Length; i++)
      {
        strg.AppendFormat("{0}\\L({1}) \\%({2})", (i == 0 ? "" : "\r\n"), i, i);
      }
      tgo.Text = strg.ToString();

      // if the position of the old legend is outside, use a new position
      if (null == Legend || Legend.Position.X < 0 || Legend.Position.Y < 0 ||
        Legend.Position.X > this.Size.Width || Legend.Position.Y > this.Size.Height)
        tgo.SetPosition(new PointF(0.1f * this.Size.Width, 0.1f * this.Size.Height));
      else
        tgo.SetPosition(Legend.Position);

      Legend = tgo;

      OnChanged();
    }
Ejemplo n.º 18
0
        private void khs2xml(AxMap pMap, ref XmlTextWriter wr)
        {
            wr.WriteStartElement("KyHieus");
            wr.WriteAttributeString("CX", pMap.CenterX.ToString("#.0000"));
            wr.WriteAttributeString("CY", pMap.CenterY.ToString("#.0000"));
            wr.WriteAttributeString("Zoom", pMap.Zoom.ToString());
            checked
            {
                try
                {
                    IEnumerator enumerator = this.List.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        CSymbol mKH = (CSymbol)enumerator.Current;
                        wr.WriteStartElement("KyHieu");
                        bool flag = mKH.Description.Length > 0;
                        if (flag)
                        {
                            wr.WriteAttributeString("Desc", mKH.Description);
                        }
                        flag = mKH.Blinking;
                        if (flag)
                        {
                            wr.WriteAttributeString("Blink", mKH.Blinking.ToString());
                        }
                        wr.WriteAttributeString("Zoom", mKH.Zoom.ToString());
                        wr.WriteAttributeString("MWi", mKH.MWidth.ToString());
                        wr.WriteAttributeString("GocX", mKH.GocX.ToString("#.0000"));
                        wr.WriteAttributeString("GocY", mKH.GocY.ToString("#.0000"));
                        try
                        {
                            IEnumerator enumerator2 = mKH.GObjs.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                GraphicObject mPart = (GraphicObject)enumerator2.Current;
                                wr.WriteStartElement("Part");
                                OBJECTTYPE mType = mPart.GetObjType();
                                wr.WriteAttributeString("Type", mType.ToString());
                                flag = (mType == OBJECTTYPE.Text);
                                if (flag)
                                {
                                    TextGraphic mTextObj = (TextGraphic)mPart;
                                    wr.WriteAttributeString("Text", mTextObj.Text);
                                    wr.WriteAttributeString("FName", mTextObj.Font.Name);
                                    wr.WriteAttributeString("FSize", mTextObj.Font.Size.ToString());
                                    wr.WriteAttributeString("FStyle", mTextObj.Font.Style.ToString());
                                    wr.WriteAttributeString("FColor", Conversions.ToString(mTextObj.Color.ToArgb()));
                                    wr.WriteStartElement("Pos");
                                    wr.WriteAttributeString("X", mTextObj.X.ToString());
                                    wr.WriteAttributeString("Y", mTextObj.Y.ToString());
                                    wr.WriteAttributeString("A", mTextObj.Rotation.ToString());
                                    wr.WriteEndElement();
                                }
                                else
                                {
                                    flag = (mType == OBJECTTYPE.Table);
                                    if (flag)
                                    {
                                        TableGraphic mTableObj = (TableGraphic)mPart;
                                        wr.WriteStartElement("TBL");
                                        wr.WriteAttributeString("X", mTableObj.X.ToString());
                                        wr.WriteAttributeString("Y", mTableObj.Y.ToString());
                                        wr.WriteAttributeString("W", mTableObj.Width.ToString());
                                        wr.WriteAttributeString("H", mTableObj.Height.ToString());
                                        wr.WriteAttributeString("A", mTableObj.Rotation.ToString());
                                        wr.WriteAttributeString("Cols", mTableObj.ColsNo.ToString());
                                        wr.WriteAttributeString("Rows", mTableObj.RowsNo.ToString());
                                        wr.WriteAttributeString("BColor", Conversions.ToString(mTableObj.BorderColor.ToArgb()));
                                        wr.WriteAttributeString("BWidth", mTableObj.BorderWidth.ToString());
                                        wr.WriteAttributeString("LColor", Conversions.ToString(mTableObj.LineColor.ToArgb()));
                                        wr.WriteAttributeString("LWidth", mTableObj.LineWidth.ToString());
                                        wr.WriteAttributeString("FiColor", Conversions.ToString(mTableObj.FiColor.ToArgb()));
                                        string str       = Conversions.ToString(mTableObj.AWidth[0]);
                                        int    arg_47A_0 = 1;
                                        int    num       = mTableObj.ColsNo - 1;
                                        int    i         = arg_47A_0;
                                        while (true)
                                        {
                                            int arg_4A4_0 = i;
                                            int num2      = num;
                                            if (arg_4A4_0 > num2)
                                            {
                                                break;
                                            }
                                            str = str + "|" + Conversions.ToString(mTableObj.AWidth[i]);
                                            i++;
                                        }
                                        wr.WriteAttributeString("AWS", str);
                                        str = Conversions.ToString(mTableObj.AHeight[0]);
                                        int arg_4CF_0 = 1;
                                        int num3      = mTableObj.RowsNo - 1;
                                        i = arg_4CF_0;
                                        while (true)
                                        {
                                            int arg_4F9_0 = i;
                                            int num2      = num3;
                                            if (arg_4F9_0 > num2)
                                            {
                                                break;
                                            }
                                            str = str + "|" + Conversions.ToString(mTableObj.AHeight[i]);
                                            i++;
                                        }
                                        wr.WriteAttributeString("AHS", str);
                                        i = 0;
                                        try
                                        {
                                            IEnumerator enumerator3 = mTableObj.Cells.GetEnumerator();
                                            while (enumerator3.MoveNext())
                                            {
                                                CCell mCell = (CCell)enumerator3.Current;
                                                i++;
                                                wr.WriteStartElement("Cell");
                                                wr.WriteAttributeString("iR", mCell.iRow.ToString());
                                                wr.WriteAttributeString("iC", mCell.iCol.ToString());
                                                wr.WriteAttributeString("RNo", mCell.RowsNo.ToString());
                                                wr.WriteAttributeString("CNo", mCell.ColsNo.ToString());
                                                wr.WriteAttributeString("Text", mCell.Text);
                                                wr.WriteAttributeString("FName", mCell.Font.Name);
                                                wr.WriteAttributeString("FSize", mCell.Font.Size.ToString());
                                                wr.WriteAttributeString("FStyle", mCell.Font.Style.ToString());
                                                wr.WriteAttributeString("Color", Conversions.ToString(mCell.Color.ToArgb()));
                                                wr.WriteElementString("i", i.ToString());
                                                wr.WriteEndElement();
                                            }
                                        }
                                        finally
                                        {
                                            IEnumerator enumerator3;
                                            flag = (enumerator3 is IDisposable);
                                            if (flag)
                                            {
                                                (enumerator3 as IDisposable).Dispose();
                                            }
                                        }
                                        wr.WriteEndElement();
                                    }
                                    else
                                    {
                                        flag = (mType == OBJECTTYPE.EmbeddedImage);
                                        if (flag)
                                        {
                                            EmbeddedImageGraphic mImageObj = (EmbeddedImageGraphic)mPart;
                                            wr.WriteAttributeString("ITYPE", mImageObj.ImageType);
                                            wr.WriteAttributeString("IMAGEW", mImageObj.Width.ToString());
                                            wr.WriteAttributeString("IMAGEH", mImageObj.Height.ToString());
                                            string strImage  = "";
                                            string imageType = mImageObj.ImageType;
                                            if (Operators.CompareString(imageType, "wmf", false) == 0 || Operators.CompareString(imageType, "emf", false) == 0)
                                            {
                                                goto IL_74D;
                                            }
                                            if (Operators.CompareString(imageType, "kro", false) == 0)
                                            {
                                                goto IL_74D;
                                            }
                                            bool arg_74E_0 = false;
IL_74E:
                                            flag = arg_74E_0;
                                            if (flag)
                                            {
                                                try
                                                {
                                                    object mFileName = "tmp2.kro";
                                                    Image  mMetaFile = mImageObj.Image;
                                                    mMetaFile.Save(Conversions.ToString(mFileName));
                                                    byte[] arrImageByte = this.GetarrImage(Conversions.ToString(mFileName));
                                                    strImage = Convert.ToBase64String(arrImageByte);
                                                }
                                                catch (Exception expr_78D)
                                                {
                                                    ProjectData.SetProjectError(expr_78D);
                                                    Exception ex = expr_78D;
                                                    Interaction.MsgBox("kro sai: " + ex.Message, MsgBoxStyle.OkOnly, null);
                                                    ProjectData.ClearProjectError();
                                                }
                                            }
                                            else
                                            {
                                                MemoryStream memStream = new MemoryStream();
                                                mImageObj.Image.Save(memStream, ImageFormat.Bmp);
                                                strImage = Convert.ToBase64String(memStream.ToArray());
                                            }
                                            wr.WriteAttributeString("IMAGE", strImage);
                                            wr.WriteStartElement("Pos");
                                            wr.WriteAttributeString("X", mImageObj.X.ToString());
                                            wr.WriteAttributeString("Y", mImageObj.Y.ToString());
                                            wr.WriteAttributeString("A", mImageObj.Rotation.ToString());
                                            wr.WriteEndElement();
                                            goto IL_CDF;
IL_74D:
                                            arg_74E_0 = true;
                                            goto IL_74E;
                                        }
                                        ShapeGraphic mShapeObj = (ShapeGraphic)mPart;
                                        wr.WriteAttributeString("Color", Conversions.ToString(mShapeObj.LineColor.ToArgb()));
                                        wr.WriteAttributeString("Width", mShapeObj.LineWidth.ToString());
                                        flag = (mShapeObj.LineStyle > 0);
                                        if (flag)
                                        {
                                            wr.WriteAttributeString("Style", mShapeObj.LineStyle.ToString());
                                            wr.WriteAttributeString("SWidth", mShapeObj.StyleWidth.ToString());
                                        }
                                        flag = (mShapeObj.Line2Width > 0f);
                                        if (flag)
                                        {
                                            wr.WriteAttributeString("Color2", Conversions.ToString(mShapeObj.Line2Color.ToArgb()));
                                            wr.WriteAttributeString("Width2", mShapeObj.Line2Width.ToString());
                                        }
                                        flag = (mShapeObj.DValues.Length > 6);
                                        if (flag)
                                        {
                                            wr.WriteAttributeString("DV", mShapeObj.DValues);
                                        }
                                        flag = mShapeObj.Fill;
                                        if (flag)
                                        {
                                            wr.WriteAttributeString("Fill", mShapeObj.Fill.ToString());
                                            wr.WriteAttributeString("FColor", Conversions.ToString(mShapeObj.FillColor.ToArgb()));
                                            wr.WriteAttributeString("HColor", Conversions.ToString(mShapeObj.HatchColor.ToArgb()));
                                            wr.WriteAttributeString("HStyle", mShapeObj.HatchStyle.ToString());
                                        }
                                        flag = (mType == OBJECTTYPE.Ellipse);
                                        if (flag)
                                        {
                                            EllipseGraphic mEllipseObj = (EllipseGraphic)mShapeObj;
                                            wr.WriteStartElement("Rect");
                                            wr.WriteAttributeString("X", mEllipseObj.X.ToString());
                                            wr.WriteAttributeString("Y", mEllipseObj.Y.ToString());
                                            wr.WriteAttributeString("W", mEllipseObj.Width.ToString());
                                            wr.WriteAttributeString("H", mEllipseObj.Height.ToString());
                                            wr.WriteAttributeString("A", mEllipseObj.Rotation.ToString());
                                            wr.WriteEndElement();
                                        }
                                        else
                                        {
                                            flag = (mType == OBJECTTYPE.Pie);
                                            if (flag)
                                            {
                                                PieGraphic mPieObj = (PieGraphic)mShapeObj;
                                                wr.WriteStartElement("Pie");
                                                wr.WriteAttributeString("X", mPieObj.X.ToString());
                                                wr.WriteAttributeString("Y", mPieObj.Y.ToString());
                                                wr.WriteAttributeString("W", mPieObj.Width.ToString());
                                                wr.WriteAttributeString("H", mPieObj.Height.ToString());
                                                wr.WriteAttributeString("ST", mPieObj.StartAngle.ToString());
                                                wr.WriteAttributeString("SW", mPieObj.SweepAngle.ToString());
                                                flag = mPieObj.IsArc;
                                                if (flag)
                                                {
                                                    wr.WriteAttributeString("ARC", mPieObj.IsArc.ToString());
                                                }
                                                wr.WriteAttributeString("A", mPieObj.Rotation.ToString());
                                                wr.WriteEndElement();
                                            }
                                            else
                                            {
                                                int i = 0;
                                                NodesShapeGraphic mNodesShapeObj = (NodesShapeGraphic)mShapeObj;
                                                try
                                                {
                                                    IEnumerator enumerator4 = mNodesShapeObj.Nodes.GetEnumerator();
                                                    while (enumerator4.MoveNext())
                                                    {
                                                        CNODE mNode = (CNODE)enumerator4.Current;
                                                        i++;
                                                        wr.WriteStartElement("Node");
                                                        wr.WriteAttributeString("X", mNode.Pt.X.ToString());
                                                        wr.WriteAttributeString("Y", mNode.Pt.Y.ToString());
                                                        flag = mNode.IsControl;
                                                        if (flag)
                                                        {
                                                            wr.WriteAttributeString("Type", mNode.IsControl.ToString());
                                                        }
                                                        wr.WriteElementString("i", i.ToString());
                                                        wr.WriteEndElement();
                                                    }
                                                }
                                                finally
                                                {
                                                    IEnumerator enumerator4;
                                                    flag = (enumerator4 is IDisposable);
                                                    if (flag)
                                                    {
                                                        (enumerator4 as IDisposable).Dispose();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
IL_CDF:
                                wr.WriteEndElement();
                            }
                        }
                        finally
                        {
                            IEnumerator enumerator2;
                            flag = (enumerator2 is IDisposable);
                            if (flag)
                            {
                                (enumerator2 as IDisposable).Dispose();
                            }
                        }
                        wr.WriteEndElement();
                    }
                }
                finally
                {
                    IEnumerator enumerator;
                    bool        flag = enumerator is IDisposable;
                    if (flag)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                wr.WriteEndElement();
            }
        }
Ejemplo n.º 19
0
		private void SetDefaultAxisTitlePositionAndOrientation(TextGraphic axisTitle, CSLineID id, CSAxisInformation info)
		{
			// find out the position and orientation of the item
			double rx0 = 0, rx1 = 1, ry0 = 0, ry1 = 1, rz0 = 0, rz1 = 1;
			double relOnAxis = 0.5; // where on the axis is the label positioned
			if (id.ParallelAxisNumber == 0)
			{
				ry0 = ry1 = id.LogicalValueOtherFirst;
				rz0 = rz1 = id.LogicalValueOtherSecond;
			}
			else if (id.ParallelAxisNumber == 1)
			{
				rx0 = rx1 = id.LogicalValueOtherFirst;
				rz0 = rz1 = id.LogicalValueOtherSecond;
				relOnAxis = 0.4;
			}
			else if (id.ParallelAxisNumber == 2)
			{
				rx0 = rx1 = id.LogicalValueOtherFirst;
				ry0 = ry1 = id.LogicalValueOtherSecond;
				relOnAxis = 0.4;
			}
			else
			{
				throw new NotImplementedException();
			}

			VectorD3D normDirection;
			Logical3D tdirection = CoordinateSystem.GetLogicalDirection(info.Identifier.ParallelAxisNumber, info.PreferredLabelSide);
			var location = CoordinateSystem.GetPositionAndNormalizedDirection(new Logical3D(rx0, ry0, rz0), new Logical3D(rx1, ry1, rz1), relOnAxis, tdirection, out normDirection);

			axisTitle.Location.ParentAnchorX = RADouble.NewRel(location.X / this.Size.X); // set the x anchor of the parent
			axisTitle.Location.ParentAnchorY = RADouble.NewRel(location.Y / this.Size.Y); // set the y anchor of the parent
			axisTitle.Location.ParentAnchorZ = RADouble.NewRel(location.Z / this.Size.Z); // set the z anchor of the parent

			double distance = 0;
			AxisStyle axisStyle = _axisStyles[id];
			if (null != axisStyle.AxisLineStyle)
				distance += axisStyle.AxisLineStyle.GetOuterDistance(info.PreferredLabelSide);
			double labelFontSize = 0;
			if (axisStyle.AreMajorLabelsEnabled)
				labelFontSize = Math.Max(labelFontSize, axisStyle.MajorLabelStyle.FontSize);
			if (axisStyle.AreMinorLabelsEnabled)
				labelFontSize = Math.Max(labelFontSize, axisStyle.MinorLabelStyle.FontSize);

			axisTitle.RotationX = 90; // Font height now is z, Font depth is y and x remains x

			axisTitle.Location.LocalAnchorX = normDirection.X == 0 ? RADouble.NewRel(0.5) : normDirection.X < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0);
			axisTitle.Location.LocalAnchorY = normDirection.Z == 0 ? RADouble.NewRel(0.5) : normDirection.Z < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0);
			axisTitle.Location.LocalAnchorZ = normDirection.Y == 0 ? RADouble.NewRel(0.5) : normDirection.Y < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0);

			VectorD3D scaleFont = new VectorD3D(1, 1, 1.4);

			distance += Math.Abs(scaleFont.X * normDirection.X) * labelFontSize;
			distance += Math.Abs(scaleFont.Y * normDirection.Y) * labelFontSize;
			distance += Math.Abs(scaleFont.Z * normDirection.Z) * labelFontSize;

			axisTitle.Location.PositionX = RADouble.NewAbs(distance * normDirection.X); // because this is relative to the reference point, we don't need to take the location into account here, it is set above
			axisTitle.Location.PositionY = RADouble.NewAbs(distance * normDirection.Y);
			axisTitle.Location.PositionZ = RADouble.NewAbs(distance * normDirection.Z);
		}
Ejemplo n.º 20
0
        protected override void OnConstruct()
        {
            if (AutoSize != AutoSizeMode.None)
                AutoAdjustSize();
            base.OnConstruct();

            if (Caption == null && Text != null)
                Caption = new TextGraphic { Anchor = textAnchor };

            if(Caption != null)
            {
                if (Caption is TextGraphic)
                {
                    if (Clickable && !Disabled)
                        ((TextGraphic)Caption).Font = font;
                    else
                    {
                        if (disabledFont != null)
                            ((TextGraphic)Caption).Font = disabledFont;
                        else
                            ((TextGraphic)Caption).Font = new Graphics.Content.Font(font.SystemFont, System.Drawing.Color.Gray, font.Backdrop);
                    }
                    ((TextGraphic)Caption).Text = text;
                }

                caption.Size = InnerSize;
                caption.Position = Common.Math.ToVector3(InnerOffset);

                SetGraphic("Button.Caption", Caption);

                /*caption.Model.World = Matrix.Translation(-Size.X / 2, -Size.Y / 2, 0);
                caption.Model.World *= Matrix.Scaling(captionScale, captionScale, 0);
                caption.Model.World *= Matrix.Translation(Size.X / 2, Size.Y / 2, 0);*/
            }

            if (HotkeyCaption != null)
            {
                SetGraphic("Button.HotkeyCaption", HotkeyCaption);
                //HotkeyCaption.Model.World = Matrix.Translation(2, 0, -1);
            }
        }
Ejemplo n.º 21
0
		/// <summary>
		/// Creates a new legend, removing the old one.
		/// </summary>
		/// <remarks>The position of the old legend is <b>only</b> used for the new legend if the old legend's position is
		/// inside the layer. This prevents a "stealth" legend in case it is not visible by accident.
		/// </remarks>
		public void CreateNewLayerLegend()
		{
			// remove the legend if there are no plot curves on the layer
			if (PlotItems.Flattened.Length == 0)
			{
				ClearLegends();
				EhSelfChanged(EventArgs.Empty);

				return;
			}

			TextGraphic tgo;

			var existingLegendIndex = GraphObjects.IndexOfFirst(x => x is LegendText);
			var existingLegend = existingLegendIndex >= 0 ? (LegendText)GraphObjects[existingLegendIndex] : null;

			if (existingLegend != null)
				tgo = new TextGraphic(existingLegend);
			else
				tgo = new TextGraphic(this.GetPropertyContext());

			System.Text.StringBuilder strg = new System.Text.StringBuilder();
			for (int i = 0; i < this.PlotItems.Flattened.Length; i++)
			{
				strg.AppendFormat("{0}\\L({1}) \\%({2})", (i == 0 ? "" : "\r\n"), i, i);
			}
			tgo.Text = strg.ToString();

			// if the position of the old legend is outside, use a new position
			if (null == existingLegend || existingLegend.Position.X < 0 || existingLegend.Position.Y < 0 ||
				existingLegend.Position.X > this.Size.X || existingLegend.Position.Y > this.Size.Y)
				tgo.Position = new PointD3D(0.1 * this.Size.X, 0.1 * this.Size.Y, 0.1 * this.Size.Z);
			else
				tgo.Position = existingLegend.Position;

			if (existingLegendIndex >= 0)
				GraphObjects[existingLegendIndex] = tgo;
			else
				GraphObjects.Add(tgo);

			EhSelfChanged(EventArgs.Empty);
		}
Ejemplo n.º 22
0
		private void SetAxisTitleString(CSLineID id, string value)
		{
			AxisStyle style = _axisStyles[id];
			string oldtitle = (style == null || style.Title == null) ? null : style.Title.Text;
			string newtitle = (value == null || value == String.Empty) ? null : value;

			if (newtitle != oldtitle)
			{
				if (newtitle == null)
				{
					if (style != null)
						style.Title = null;
				}
				else if (_axisStyles.AxisStyleEnsured(id).Title != null)
				{
					_axisStyles[id].Title.Text = newtitle;
				}
				else
				{
					TextGraphic tg = new TextGraphic(this.GetPropertyContext());

					CSAxisInformation info = CoordinateSystem.GetAxisStyleInformation(id);

					tg.SetParentSize(this.Size, false);
					SetDefaultAxisTitlePositionAndOrientation(tg, id, info);
					tg.Text = newtitle;
					_axisStyles.AxisStyleEnsured(id).Title = tg;
				}
			}
		}
Ejemplo n.º 23
0
		public void ShowTitle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			if (_axisTitle == null)
			{
				Title = new TextGraphic(context);
				Title.Text = "axis title";
			}
		}
Ejemplo n.º 24
0
			public LegendText(TextGraphic from)
				: base(from)
			{
			}