//
// Copyright (c) PlaceholderCompany. All rights reserved.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Docking;
using GeoSigma.UCDraw;
namespace PcgDrawR
{
///
/// The frm doc.
///
public partial class FrmDoc : DevExpress.XtraBars.Ribbon.RibbonForm
{
///
/// Gets or sets the new file saved event.
///
public NewFileSavedHandler NewFileSavedEvent
{
get
{
return this.DrawEditor.NewFileSavedEvent;
}
set
{
this.DrawEditor.NewFileSavedEvent = value;
}
}
///
/// Gets or sets the z color width.
///
public double ZColorWidth
{
get
{
return this.DrawEditor.ZColorWidth;
}
set
{
this.DrawEditor.ZColorWidth = value;
}
}
///
/// Gets or sets the file full path.
///
public string FileFullPath { get; set; }
///
/// 图层面板
///
public DockPanel LayerPanel
{
get
{
return this.DrawEditor.LayerPanel;
}
set
{
this.DrawEditor.LayerPanel = value;
}
}
///
/// Gets or sets the property panel.
///
public DockPanel PropertyPanel
{
get
{
return this.DrawEditor.PropertyPanel;
}
set
{
this.DrawEditor.PropertyPanel = value;
}
}
///
/// Gets or sets the statistic panel.
///
public DockPanel StatisticPanel { get; set; }
private bool setZColor;
///
/// Initializes a new instance of the class.
///
public FrmDoc()
{
InitializeComponent();
this.DoubleBuffered = true;
}
///
/// Initializes a new instance of the class.
///
/// 文件路径
/// 是否散点显示为色卡
public FrmDoc(string fileFullPath, bool setZColor = false)
: this()
{
this.FileFullPath = fileFullPath;
this.setZColor = setZColor;
}
///
/// Frms the doc_ load.
///
/// The sender.
/// The e.
private void FrmDoc_Load(object sender, EventArgs e)
{
// 窗口加载
this.DrawEditor.LayerSelected += SetCurrentLayer;
this.DrawEditor.ShowStatisticResult += ShowStatic;
this.DrawEditor.FileModifiedEvent += (object editor, bool isModified) => { this.Text = this.DrawEditor.Text; };
// this.DrawEditor.FileClosedEvent +=
}
///
/// Docs the float.
///
public void DocFloat()
{
this.ribbonControl1.Visible = true;
this.DrawEditor.ribbonMain.MergeOwner = this.ribbonControl1;
if (!object.ReferenceEquals(this.ribbonControl1.MergedRibbon, this.DrawEditor.ribbonMain))
{
this.DrawEditor.ribbonMain.Visible = true;
this.ribbonControl1.MergeRibbon(this.DrawEditor.ribbonMain);
}
}
///
/// Uns the merge control.
///
public void UnMergeControl()
{
this.SuspendLayout();
//this.Controls.Add(this.ribbonControl1);
//this.ribbonControl1.SendToBack();
//this.Ribbon = this.ribbonControl1;
this.ResumeLayout();
this.PerformLayout();
//if (this.LayerPanel.ControlContainer.Controls.Count > 0)
//{
// this.LayerPanel.ControlContainer.Controls.Clear();
//}
//if (this.PropertyPanel.ControlContainer.Controls.Count > 0)
//{
// this.PropertyPanel.ControlContainer.Controls.Clear();
//}
//if (this.StatisticPanel.ControlContainer.Controls.Count > 0)
//{
// this.StatisticPanel.ControlContainer.Controls.Clear();
//}
}
///
/// Merges the control.
///
public void MergeControl()
{
//this.Controls.Remove(this.ribbonControl1);
//this.Ribbon = null;
//// 图层树控件的处理
//UCDraw.LayerTree layerTree = this.DrawEditor.LayerControl;
//if (layerTree != null)
//{
// this.LayerPanel.ControlContainer.Controls.Add(layerTree);
// layerTree.Dock = DockStyle.Fill;
//}
//// 属性控件的处理
//UCDraw.PanelProperty propertyControl = this.DrawEditor.PropertyControl;
//if (propertyControl != null)
//{
// this.PropertyPanel.ControlContainer.Controls.Add(propertyControl);
// propertyControl.Dock = DockStyle.Fill;
//}
//// 统计面板
//DataGridView dgvStatistic = this.DrawEditor.StatisticControl;
//if (dgvStatistic != null)
//{
// this.StatisticPanel.ControlContainer.Controls.Add(dgvStatistic);
// dgvStatistic.Dock = DockStyle.Fill;
//}
}
///
/// 创建新文件
///
/// 文件名称
public void CreateNewFile(string fileName)
{
this.DrawEditor.CreateNewFile(fileName);
this.Text = this.DrawEditor.Text;
}
///
/// 打开文件
///
/// 文件全路径
/// Z块显示的颜色
/// 是否成功
public bool OpenFile(string fileFullPath, bool setZColor = false)
{
this.FileFullPath = fileFullPath;
this.setZColor = setZColor;
try
{
this.SuspendLayout();
// 打开文件
this.DrawEditor.ZColorWidth = this.ZColorWidth;
bool bOpend = this.DrawEditor.OpenFile(this.FileFullPath, this.setZColor);
if (bOpend == false)
{
return false;
}
// this.DrawEditor.InitDrawerView();
this.Text = this.DrawEditor.Text;
// MergeControl();
return true;
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
return false;
}
finally
{
this.ResumeLayout();
}
}
///
/// 保存文件
///
/// 是否成功
public bool SaveFile()
{
return this.DrawEditor.SaveFile();
}
///
/// 另存为
///
/// 是否成功
public bool SaveAs()
{
return this.DrawEditor.SaveAs();
}
///
/// Sets the current layer.
///
/// The sender.
/// The e.
private void SetCurrentLayer(object sender, PropertyChangedEventArgs e)
{
if (this.LayerPanel != null)
{
this.LayerPanel.Text = e.PropertyName;
}
}
///
/// 显示统计面板.
///
/// The sender.
/// The instance containing the event data.
private void ShowStatic(object sender, EventArgs e)
{
try
{
this.StatisticPanel.Visibility = DockVisibility.Visible;
}
finally
{
}
}
///
/// Frms the doc_ form closing.
///
/// The sender.
/// The e.
private void FrmDoc_FormClosing(object sender, FormClosingEventArgs e)
{
this.DrawEditor.UCDrawEdit_FormClosing(this.DrawEditor, e);
}
}
}