Пример #1
0
        /// <summary>
        /// 横向填充
        /// </summary>
        /// <param name="host"></param>
        public static void HorizontalStrech(ILayoutHost host)
        {
            if (host == null)
            {
                return;
            }
            if (host.LayoutRuntime == null)
            {
                return;
            }
            ILayout layout = host.LayoutRuntime.Layout;

            if (layout == null)
            {
                return;
            }
            List <IElement> elements = layout.Elements;

            if (elements == null || elements.Count == 0)
            {
                return;
            }
            foreach (IElement ele in elements)
            {
                if (ele is IDataFrame)
                {
                    (ele as IDataFrame).ApplyLocation(0 - (ele as IDataFrame).Location.X, 0);
                    (ele as IDataFrame).ApplySize(layout.Size.Width - (ele as IDataFrame).Size.Width, 0);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 纵向填充
        /// </summary>
        /// <param name="host"></param>
        public static void VerticalStrech(ILayoutHost host)
        {
            if (host == null)
            {
                return;
            }
            if (host.LayoutRuntime == null)
            {
                return;
            }
            ILayout layout = host.LayoutRuntime.Layout;

            if (layout == null)
            {
                return;
            }
            List <IElement> elements = layout.Elements;

            if (elements == null || elements.Count == 0)
            {
                return;
            }
            foreach (IElement ele in elements)
            {
                if (ele is IDataFrame)
                {
                    (ele as IDataFrame).ApplyLocation(0, 0 - (ele as IDataFrame).Location.Y);
                    (ele as IDataFrame).ApplySize(0, layout.Size.Height - (ele as IDataFrame).Size.Height);
                }
            }
        }
Пример #3
0
        private void AddDataFrame(LayoutViewer lv)
        {
            // 这里是绘制专题图Frame的,如果需要给专题图增加外边框,一个建议是
            // 将xbank、ybank设置大一些,多出来的部分,可作为外边框,然后增加外边框的
            // 对象,等相关内容,方法类似于 LayoutViewer 的绘制
            // LayoutViewer 在容器中定义了画布,新增加的外框,应该是画布中,
            // 强制绘制的一个多边形对象
            // 新增外边框完成以后,需要至少改进格网的绘制方法,使数字能落在网格和
            // DataFrame 外边框之间
            DataFrame   df    = new DataFrame(lv.LayoutHost);
            ILayoutHost host  = lv.LayoutHost;
            SizeF       sizef = host.LayoutRuntime.Layout.Size;
            float       xbank = 1; //cm
            float       ybank = 1; //cm

            xbank = host.LayoutRuntime.Centimeter2Pixel(xbank);
            ybank = host.LayoutRuntime.Centimeter2Pixel(ybank);
            host.LayoutRuntime.Pixel2Layout(ref xbank, ref ybank);
            sizef       = new SizeF(sizef.Width - 2 * xbank, sizef.Height - 2 * ybank);
            df.Size     = sizef;
            df.Location = new PointF(xbank, ybank);
            df.Update(host);
            AttachVectorHost(df);
            host.LayoutRuntime.Layout.Elements.Add(df);
            //host.ActiveDataFrame = df;
            df.IsLocked = true;
        }
Пример #4
0
        //移除选中层
        void itemLayer_Click(object sender, EventArgs e)
        {
            RadMenuItem item = sender as RadMenuItem;

            if (item == null)
            {
                return;
            }
            ILayoutHost host   = null;
            ICanvas     canvas = GetCanvasFromSession(ref host);

            if (canvas == null)
            {
                return;
            }
            if ((item.Tag as GeoGridLayer) != null)//经纬网格
            {
                RemoveGridLayer(canvas);
            }
            else // 矢量层
            {
                RemoveVectorLayer(canvas, item);
            }
            _removeRef.Items.Clear();
            canvas.Refresh(enumRefreshType.VectorLayer);
            if (host != null)
            {
                host.Render(true);
            }
            RefreshLayerManager();
        }
Пример #5
0
        private TextBox CreatTextbox(ILayoutHost host)
        {
            TextBox box = new TextBox();

            box.Text        = null;
            box.Visible     = true;
            box.Capture     = true;
            box.Font        = new Font(_txtEle.Font.FontFamily, _txtEle.Font.Size * _scale); //_txtEle.Font;
            box.Text        = _txtEle.Text;
            box.BorderStyle = BorderStyle.None;
            float x = _txtEle.Location.X;
            float y = _txtEle.Location.Y;

            host.LayoutRuntime.Layout2Screen(ref x, ref y);
            box.Location = new Point((int)x + LayoutControl.RULER_HEIGHT + 4, (int)y + LayoutControl.RULER_HEIGHT + 2);
            box.Width    = (int)(_txtEle.Size.Width);
            _currentHost.Container.Controls.Add(box);
            box.BringToFront();
            box.Focus();  //必须在其它的属性设置完成之后设置焦点才有作用
            box.KeyDown     += new KeyEventHandler(box_KeyDown);
            box.LostFocus   += new EventHandler(box_LostFocus);
            box.TextChanged += new EventHandler(box_TextChanged); //设置文本框的宽随文本的宽度改变
            _originWid       = box.Width;
            return(box);
        }
Пример #6
0
        public override void Execute(string argument)
        {
            ILayoutViewer viewer = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer;

            if (viewer == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(argument))
            {
                return;
            }
            ILayoutHost host = viewer.LayoutHost;

            if (host == null)
            {
                return;
            }
            if (host.ActiveDataFrame == null)
            {
                return;
            }
            float scale = float.Parse(argument);

            if (scale <= 0)
            {
                return;
            }
            host.ActiveDataFrame.LayoutScale = scale;
            viewer.LayoutHost.Render(true);
        }
Пример #7
0
 private void TrySetDataFrameById(ILayoutHost host)
 {
     if (_dataFrame != null)
     {
         if (string.IsNullOrEmpty(_dataFrameId))
         {
             _dataFrameId = _dataFrame.Name;
         }
         return;
     }
     else if (!string.IsNullOrEmpty(_dataFrameId))
     {
         IElement[] eles = host.LayoutRuntime.QueryElements((ele) =>
         {
             IDataFrame df = ele as IDataFrame;
             return(df != null && df.Name == _dataFrameId);
         },
                                                            true);
         if (eles != null && eles.Length > 0)
         {
             _dataFrame   = eles[0] as IDataFrame;
             _dataFrameId = _dataFrame.Name;
         }
     }
 }
Пример #8
0
 public AVIHelper(ILayoutHost host)
 {
     _host = host;
     _bmps = new List <Bitmap>();
     InitAviLayerInfos();
     InitTimer();
 }
Пример #9
0
 private ISizableElement GetEditedElementFromSelection(ILayoutHost host, CanvasEventArgs e)
 {
     IElement[] selection = host.LayoutRuntime.Selection;
     if (selection == null)
     {
         return(null);
     }
     foreach (IElement ele in selection)
     {
         if (!ele.IsSelected)
         {
             continue;
         }
         _editedBox = host.LayoutRuntime.SelectedEditBoxManager.Get(ele as ISizableElement);
         if (_editedBox != null)
         {
             _anchorIndex = _editedBox.IndexOfAnchor(e.ScreenX, e.ScreenY);
         }
         PreviewKeyDownEventArgs pe = e.E as PreviewKeyDownEventArgs;
         if (pe != null && pe.KeyCode == Keys.ShiftKey && _anchorIndex != -1)
         {
             _isMultiSelect = true;
         }
         if (_anchorIndex != -1 || ele.IsHited(e.LayoutX, e.LayoutY))
         {
             ele.IsSelected = true;
             return(ele as ISizableElement);
         }
     }
     return(null);
 }
Пример #10
0
        private void AddElementCustom()
        {
            if (_session.SmartWindowManager.ActiveCanvasViewer == null)
            {
                return;
            }
            ILayoutViewer viewer = _session.SmartWindowManager.ActiveCanvasViewer as ILayoutViewer;

            if (viewer == null)
            {
                return;
            }
            ILayoutHost host = viewer.LayoutHost;

            if (host == null)
            {
                return;
            }
            ILayoutRuntime runtime = host.LayoutRuntime;

            if (runtime == null)
            {
                return;
            }
            IElement[] eles = runtime.Selection;
            if (eles == null || eles.Length == 0)
            {
                return;
            }
            if (_eleList == null)
            {
                return;
            }
            _eleList.CustomElements = eles;
        }
Пример #11
0
        private void CreatMultlineTextbox(ILayoutHost host, MultlineTextElement multlineTextElement)
        {
            multlineTextElement.Visible = false;
            TextBox txtBox = new TextBox();

            txtBox.Tag         = multlineTextElement;
            txtBox.Multiline   = true;
            txtBox.Capture     = true;
            txtBox.Font        = new Font(multlineTextElement.Font.FontFamily, multlineTextElement.Font.Size * _scale); //_txtEle.Font;
            txtBox.Text        = multlineTextElement.Text;
            txtBox.BorderStyle = BorderStyle.FixedSingle;
            txtBox.ForeColor   = multlineTextElement.Color;
            float x = multlineTextElement.Location.X;
            float y = multlineTextElement.Location.Y;

            host.LayoutRuntime.Layout2Screen(ref x, ref y);
            txtBox.Location = new Point((int)x + LayoutControl.RULER_HEIGHT + 4, (int)y + LayoutControl.RULER_HEIGHT + 2);
            txtBox.Width    = (int)(multlineTextElement.Size.Width * _scale);
            txtBox.Height   = (int)(multlineTextElement.Size.Height * _scale);
            _currentHost.Container.Controls.Add(txtBox);
            txtBox.BringToFront();
            txtBox.Focus();                                             //必须在其它的属性设置完成之后设置焦点才有作用
            //txtBox.KeyDown += new KeyEventHandler(txtBox_KeyDown);
            txtBox.TextChanged += new EventHandler(txtBox_TextChanged); //设置文本框的宽随文本的宽度改变
            txtBox.LostFocus   += new EventHandler(txtBox_LostFocus);
            _originWid          = txtBox.Width;
        }
Пример #12
0
        public static IGxdDocument GenerateFrom(ILayoutHost host)
        {
            if (host == null || host.LayoutRuntime == null || host.LayoutRuntime.Layout == null)
            {
                return(null);
            }
            //
            ILayoutTemplate template    = new LayoutTemplate(host.LayoutRuntime.Layout);
            GxdTemplateHost gxdTemplate = new GxdTemplateHost(template);
            //
            IGxdDocument gxdoc = new GxdDocument(gxdTemplate);

            //
            IElement[] dfs = host.LayoutRuntime.QueryElements((ele) => { return(ele is IDataFrame); }, false);
            if (dfs != null)
            {
                gxdoc.DataFrames.Clear();
                foreach (IDataFrame df in dfs)
                {
                    GxdDataFrame gxdDf = new GxdDataFrame(df.Name, GetDfEnvelope(df),
                                                          GetDfVectorHost(df), df.SpatialRef, df.GetGridXml(), df.GetDocumentableLayersHostXml());
                    if (GxDataFrameRasterItemsSetter != null)
                    {
                        GxDataFrameRasterItemsSetter(df, gxdDf);
                    }
                    gxdoc.DataFrames.Add(gxdDf);
                }
            }
            return(gxdoc);
        }
Пример #13
0
 private void MovingElement(ILayoutHost host, CanvasEventArgs e)
 {
     host.Container.Cursor = Cursors.SizeAll;
     IElement[] selections = host.LayoutRuntime.Selection;
     if (selections == null)
     {
         return;
     }
     _isMoving = true;
     foreach (IElement ele in selections)
     {
         if (!ele.IsSelected)
         {
             continue;
         }
         if (ele is SizableElementGroup)
         {
             (ele as SizableElementGroup).ApplyLocation(e.LayoutX - _beginPoint.X, e.LayoutY - _beginPoint.Y);
         }
         else if (ele is SizableElement)
         {
             IElement group = host.LayoutRuntime.Layout.FindParent(ele);
             if (group != null && group is ISizableElementGroup)
             {
                 (group as ISizableElementGroup).ApplyLocationByItemSelected(e.LayoutX - _beginPoint.X, e.LayoutY - _beginPoint.Y);
             }
             (ele as SizableElement).ApplyLocation(e.LayoutX - _beginPoint.X, e.LayoutY - _beginPoint.Y);
         }
     }
     _beginPoint.X = e.LayoutX;
     _beginPoint.Y = e.LayoutY;
     host.Render();
 }
Пример #14
0
        private void RemoveVectorLayer(string filename)
        {
            try
            {
                ILayoutHost host   = null;
                ICanvas     canvas = GetCanvasFromSession(ref host);
                if (canvas == null)
                {
                    return;
                }
                IVectorHostLayer vectorHost = canvas.LayerContainer.VectorHost;
                if (vectorHost == null)
                {
                    return;
                }
                Map map = vectorHost.Map as Map;
                if (map == null)
                {
                    return;
                }
                CodeCell.AgileMap.Core.ILayer _layer = shps[filename.ToLower()];
                map.LayerContainer.Remove(_layer);

                canvas.Refresh(enumRefreshType.VectorLayer);
                if (host != null)
                {
                    host.Render(true);
                }
                RefreshLayerManager();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #15
0
        public override void Execute(string argument)
        {
            if (String.IsNullOrEmpty(argument))
            {
                return;
            }
            ILayoutViewer viewer = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer;

            if (viewer == null)
            {
                return;
            }
            float angle;
            bool  ok = float.TryParse(argument, out angle);

            if (!ok)
            {
                return;
            }
            ILayoutHost host = viewer.LayoutHost;

            if (host == null)
            {
                return;
            }
            Rotate90(host.LayoutRuntime, angle);
            host.Render();
        }
Пример #16
0
        public override void Execute()
        {
            ILayoutViewer viewer = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer;

            if (viewer == null)
            {
                return;
            }
            ILayoutHost host = viewer.LayoutHost;

            if (host == null)
            {
                return;
            }
            ILayoutTemplate template = host.Template;

            if (template == null || string.IsNullOrEmpty(template.FullPath))
            {
                _smartSession.CommandEnvironment.Get(6006).Execute();
            }
            else
            {
                template.SaveTo(template.FullPath);
                using (System.Drawing.Bitmap bm = viewer.LayoutHost.ExportToBitmap(PixelFormat.Format32bppArgb, new System.Drawing.Size(165, 165)))
                {
                    bm.Save(template.FullPath.ToLower().Replace(".gxt", ".png"), ImageFormat.Png);
                }
            }
        }
Пример #17
0
        /// <summary>
        /// 取消元素组合
        /// </summary>
        /// <param name="elements"></param>
        /// <param name="host"></param>
        public static void ElementsUnGroup(IElement[] elements, ILayoutHost host)
        {
            if (host == null)
            {
                return;
            }
            if (elements == null || elements.Length == 0)
            {
                return;
            }
            if (elements.Length != 1)
            {
                return;
            }
            IElement ele = elements[0];

            if (ele is ISizableElementGroup) //选中的是元素的组合时
            {
                UnGroupSizableGroup(ele as ISizableElementGroup, host);
            }
            else  //选中的是组合中的单个元素时
            {
                UnGroupSizableElement(ele, host);
            }
        }
Пример #18
0
 public LayoutRuntime(ILayout layout, ILayoutHost host)
 {
     _layout = layout;
     _host   = host;
     _selectedEditBoxManager  = host.SelectedEditBoxManager;
     _host.CanvasSizeChanged += new EventHandler(CanvasSizeChanged);
     UpdateMatrix();
 }
Пример #19
0
 public new void Free()
 {
     if (_host != null)
     {
         _host.Dispose();
         _host = null;
     }
 }
Пример #20
0
 private void ExportBitmaps(ILayoutHost host)
 {
     if (host == null)
     {
         return;
     }
     _avi = new AVIHelper(host);
     _avi.OnTimerStopped += new EventHandler(GetBitmaps);
 }
Пример #21
0
 /// <summary>
 /// 左对齐
 /// </summary>
 /// <param name="group"></param>
 public static void ArrangeLeft(IElementGroup group, ILayoutHost host)
 {
     if (group == null)
     {
         return;
     }
     IElement[] eles = group.Elements.ToArray();
     ArrangeLeft(eles, host);
 }
Пример #22
0
 public DataFrame(ILayoutHost host, IDataFrameDataProvider provider)
 {
     _name             = Guid.NewGuid().ToString();
     _host             = host;
     _size             = new System.Drawing.SizeF(300, 300);
     _isInsideProvider = false;
     _provider         = provider;
     TrySetAsyncDataArrivedNotify();
     ReCreateBorderPen();
 }
Пример #23
0
        /// <summary>
        /// 关注区域管理器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _manageBookMarks_Click(object sender, EventArgs e)
        {
            if (_session == null)
            {
                return;
            }
            ILayoutHost host = null;
            frmBookMarkGroupsManager manager = null;
            ICanvas canvas = GetCanvasFromSession(ref host);

            if (canvas == null)
            {
                manager = new frmBookMarkGroupsManager(true);
            }
            else
            {
                CoordEnvelope geoEvp = GetGeoEnvelopeByCanvas(canvas);
                manager = new frmBookMarkGroupsManager(false, geoEvp);
            }
            if (manager.ShowDialog() == DialogResult.OK)
            {
                CoordEnvelope envelope = manager.ApplyEnvelope;
                if (envelope == null)
                {
                    return;
                }
                if (canvas == null)
                {
                    return;
                }
                IRasterDrawing drawing = canvas.PrimaryDrawObject as IRasterDrawing;
                if (drawing == null)
                {
                    return;
                }
                // EnlargeEnvelope(ref envelop);
                CoordEnvelope evp = canvas.CurrentEnvelope.Clone();
                canvas.CoordTransform.Geo2Prj(envelope);
                //当所选的关注区域不在当前的范围内时,给出对话框提示是否定位
                if (evp.MaxY < envelope.MinY || evp.MinY > envelope.MaxY || evp.MaxX < envelope.MinX || evp.MinX > envelope.MaxX)
                {
                    DialogResult dialogRe = MessageBox.Show("选中区域不在当前影像范围内,是否定位到选中区域?", "提示", MessageBoxButtons.YesNo);
                    if (dialogRe == DialogResult.No)
                    {
                        return;
                    }
                }
                canvas.CurrentEnvelope = envelope;
                canvas.Refresh(enumRefreshType.All);
                if (host != null)
                {
                    host.Render(true);
                }
            }
        }
Пример #24
0
 private ICanvas GetCanvasFromSession(ref ILayoutHost host)
 {
     if (_session.SmartWindowManager.ActiveViewer is ICanvasViewer)
     {
         return(GetCanvasByCanvasViewer());
     }
     else if (_session.SmartWindowManager.ActiveViewer is ILayoutViewer)
     {
         return(GetCanvasByLayoutDataFrame(ref host));
     }
     return(null);
 }
Пример #25
0
 private void ApplyWheel(ILayoutHost host, CanvasEventArgs e)
 {
     if (e.WheelDelta > 0)
     {
         host.LayoutRuntime.Scale -= 0.1f;
     }
     else
     {
         host.LayoutRuntime.Scale += 0.1f;
     }
     host.Render();
 }
Пример #26
0
 void Form1_Load(object sender, EventArgs e)
 {
     _host            = new LayoutHost(layoutControl1);
     _txt             = new TextBox();
     _txt.BorderStyle = BorderStyle.None;
     _txt.Location    = new Point(ClientRectangle.Width / 2, ClientRectangle.Height / 2);
     _txt.Visible     = false;
     layoutControl1.Controls.Add(_txt);
     _txt.BringToFront();
     _txt.KeyDown += new KeyEventHandler(txt_KeyDown);
     //_host.LayoutRuntime.Scale = 0.7f;
 }
Пример #27
0
        public override void Execute()
        {
            ILayoutViewer view = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer;

            if (view == null)
            {
                return;
            }
            ILayoutHost host = view.LayoutHost;

            if (host == null)
            {
                return;
            }
            if (host.LayoutRuntime == null)
            {
                return;
            }
            if (host.LayoutRuntime.Layout == null)
            {
                return;
            }
            if (host.LayoutRuntime.Layout.Elements == null || host.LayoutRuntime.Layout.Elements.Count == 0)
            {
                return;
            }
            IDataFrame             df       = new DataFrame(host);
            IDataFrameDataProvider provider = df.Provider as IDataFrameDataProvider;

            if (provider == null)
            {
                return;
            }
            ICanvas c = provider.Canvas;

            if (c != null)
            {
                if (c.CanvasSetting != null)
                {
                    if (c.CanvasSetting.RenderSetting != null)
                    {
                        c.CanvasSetting.RenderSetting.BackColor = Color.White;
                    }
                }
                IVectorHostLayer vhost = new VectorHostLayer(null);
                c.LayerContainer.Layers.Add(vhost as GeoDo.RSS.Core.DrawEngine.ILayer);
            }
            host.LayoutRuntime.Layout.Elements.Insert(1, df);
            host.Render();
            host.ActiveDataFrame = df;
            TryRefreshLayerManager();
        }
Пример #28
0
        /// <summary>
        /// 将元素编组
        /// </summary>
        /// <param name="elements">需要编组的元素</param>
        /// <param name="host">当前的layoutHost</param>
        /// <returns></returns>
        public static IElementGroup ElementsToGroup(IElement[] elements, ILayoutHost host)
        {
            if (elements == null || elements.Length == 0)
            {
                return(null);
            }
            int           count = elements.Length;
            IElementGroup group = new ElementGroup();

            IElement[] parents = new IElement[count];
            IElement   parent;

            //将所选element从其父节点中移除
            for (int i = 0; i < count; i++)
            {
                parent = host.LayoutRuntime.Layout.FindParent(elements[i]);
                //parent = group.FindParent(elements[i]);
                if (parent == null)
                {
                    return(null);
                }
                parents[i] = parent;
                (parents[i] as IElementGroup).Elements.Remove(elements[i]);
                group.Elements.Add(elements[i]);
            }

            //统计所选element的父节点的深度级数
            int[]      levels     = new int[count];
            IElement[] parentClon = parents.Clone() as IElement[];
            for (int i = 0; i < count; i++)
            {
                while (parentClon[i] != null)
                {
                    parentClon[i] = (parentClon[i] as IElementGroup).FindParent(parentClon[i]);
                    levels[i]++;
                }
            }
            //查找深度最大的父节点
            int maxLevelIndex = 0;

            for (int i = 0; i < count - 1; i++)
            {
                if (levels[i] < levels[i + 1])
                {
                    maxLevelIndex = i + 1;
                }
                maxLevelIndex = i;
            }
            //将group加入深度最大的父节点中
            (parents[maxLevelIndex] as IElementGroup).Elements.Add(group);
            return(group);
        }
Пример #29
0
        private static void UnGroupSizableElement(IElement ele, ILayoutHost host)
        {
            if (ele == null)
            {
                return;
            }
            ISizableElementGroup group = host.LayoutRuntime.Layout.FindParent(ele) as ISizableElementGroup;

            if (group == null)
            {
                return;  //选中的元素没有被组合
            }
            UnGroupSizableGroup(group, host);
        }
Пример #30
0
        private float GetDataFrameScale(ILayoutRuntime runtime)
        {
            ILayoutHost host = runtime.GetHost();

            if (host == null)
            {
                return(-1);
            }
            if (host.ActiveDataFrame == null)
            {
                return(-1);
            }
            return(host.ActiveDataFrame.LayoutScale);
        }