1201 lines
43 KiB
C#
1201 lines
43 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using Data.BusinessService;
|
|
using Data.DataModel;
|
|
using Make3UI;
|
|
using ChildForms;
|
|
using Projects;
|
|
using ControlLibrary;
|
|
using ClassLibrary;
|
|
|
|
|
|
namespace Make3
|
|
{
|
|
public partial class frmMake3 : Form
|
|
{
|
|
#region Local Data
|
|
|
|
Project _projectObj;
|
|
Layer _layerObj;
|
|
ColorProfile _colorProfileObj;
|
|
|
|
private frmChildSequrity childSequrity;
|
|
private frmChildProject childProject;
|
|
private FrmChildTreko3D childTreko3D;
|
|
private frmChildTreko childTreko;
|
|
private frmChildColorProfile childColorProfile;
|
|
private frmChildAngles childAngles;
|
|
private TrekoControl trekoControl1;
|
|
private Treko3DControl treko3DControl1;
|
|
|
|
private IProjectService projectService;
|
|
private ILayerService layerService;
|
|
private IColorProfileService colorProfileService;
|
|
private LayerModel layerModel;
|
|
private ColorProfileModel colorProfileModel;
|
|
|
|
private List<LayerControl> _layers = new List<LayerControl>();
|
|
|
|
#endregion
|
|
|
|
#region Getters-Setters
|
|
|
|
public ControlLibrary.TitleBar TitleBar
|
|
{
|
|
get { return titleBar1; }
|
|
}
|
|
|
|
public ControlLibrary.StatusBar StatusBar
|
|
{
|
|
get { return statusBar1; }
|
|
}
|
|
|
|
public ProjectControl projectControl
|
|
{
|
|
get
|
|
{
|
|
Control[] cnt = this.Controls.Find("newProjectControl1", true);
|
|
return (ProjectControl)cnt[0];
|
|
}
|
|
}
|
|
|
|
public ColorProfileControl colorProfileControl
|
|
{
|
|
get
|
|
{
|
|
return this.childColorProfile.ColorProfileControl;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public frmMake3()
|
|
{
|
|
InitializeComponent();
|
|
this.projectService = new ProjectService();
|
|
this.layerService = new LayerService();
|
|
this.colorProfileService = new ColorProfileService();
|
|
this.layerModel = new LayerModel();
|
|
this.colorProfileModel = new ColorProfileModel();
|
|
InitializeMenuRecentProjects();
|
|
statusBar1.Clear();
|
|
this.projectControl.OnLoadedDefault += projectControl_OnLoadedDefault;
|
|
this.projectControl.OnOkClicked += projectControl_OkClicked;
|
|
this.projectControl.OnDeleteClicked += projectControl_DeleteClicked;
|
|
this.projectControl.OnDeleteClicked += projectControl_SaveAsDefaultClicked;
|
|
this.projectControl.OnPreviewClicked += projectControl_PreviewClicked;
|
|
|
|
this.projectControl.LoadProjectByNameDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to show general error message on any system level exception
|
|
/// </summary>
|
|
private void ShowErrorMessage(Exception ex)
|
|
{
|
|
MessageBox.Show(
|
|
ex.Message,
|
|
"Exception!",
|
|
//Resources.System_Error_Message_Title,
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
|
|
|
|
private void InitializeMenuRecentProjects()
|
|
{
|
|
try
|
|
{
|
|
DataTable data = this.projectService.GetAllProjects();
|
|
DataRow[] drowpar = data.Select(); // ("ParentID=" + 0);
|
|
ToolStripItem[] toolStripItems = new ToolStripItem[drowpar.Length - 1];
|
|
|
|
int i = 0;
|
|
foreach (DataRow dr in drowpar)
|
|
{
|
|
string id = dr["Id"].ToString();
|
|
string projectName = dr["ProjectName"].ToString();
|
|
|
|
if (projectName != Resources.Default_Project_Name)
|
|
{
|
|
toolStripItems[i] = new ToolStripMenuItem(id + " " + projectName);
|
|
toolStripItems[i].Click += new System.EventHandler(this.OnUpdateProjectClick);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
this.recentProjectsMenuItem.DropDownItems.Clear();
|
|
this.recentProjectsMenuItem.DropDownItems.AddRange(toolStripItems);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.ShowErrorMessage(ex);
|
|
}
|
|
}
|
|
|
|
void Child_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
childSequrity = null;
|
|
childProject = null;
|
|
childTreko3D = null;
|
|
childTreko = null;
|
|
//Close();
|
|
}
|
|
|
|
public int GetCountOfLayers(int projectId)
|
|
{
|
|
int nLayers = this.projectService.GetCountOfLayers(projectId);
|
|
return nLayers;
|
|
}
|
|
|
|
private void ClearObjects()
|
|
{
|
|
_projectObj = null;
|
|
_layerObj = null;
|
|
_colorProfileObj = null;
|
|
}
|
|
|
|
private void ClearBarsInfo()
|
|
{
|
|
//projectControl.LoadProjectByNameDefault();
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
|
|
//// Default values
|
|
//int HologramWidth = 30;
|
|
//int HologramHeight = 30;
|
|
//int ResolutionX = 1024;
|
|
//int ResolutionY = 768;
|
|
//int GrayRangeLow = 50;
|
|
//int GrayRangeHigh = 255;
|
|
|
|
//this.TitleBar.TitleBarCaption = "Make3";
|
|
|
|
//string HologramSize = Convert.ToInt16(HologramWidth).ToString() + "x" + Convert.ToInt16(HologramHeight).ToString();
|
|
//string HologramResolution = ResolutionX.ToString() + "x" + ResolutionY.ToString();
|
|
//string grayRange = GrayRangeLow + ".." + GrayRangeHigh;
|
|
//int nLayers = 0; // GetCountOfLayers(project.ProjectId);
|
|
//string outPath = "";
|
|
|
|
//StatusBar.Clear();
|
|
//StatusBar.HologramSize = "Hologram size " + HologramSize + " mm";
|
|
//StatusBar.HologramResolution = HologramResolution;
|
|
//StatusBar.GrayRange = grayRange + " gray range";
|
|
//StatusBar.NLayers = nLayers.ToString() + " layers";
|
|
//StatusBar.OutPath = outPath;
|
|
|
|
InitializeMenuRecentProjects();
|
|
|
|
this.Invalidate();
|
|
}
|
|
|
|
|
|
private void RefreshBarsInfo(Project project)
|
|
{
|
|
this.TitleBar.TitleBarCaption = "Make3 - " + project.ProjectName;
|
|
|
|
string HologramSize = Convert.ToInt16(project.HologramWidth).ToString() + "x" + Convert.ToInt16(project.HologramHeight).ToString();
|
|
string HologramResolution = project.ResolutionX.ToString() + "x" + project.ResolutionY.ToString();
|
|
string grayRange = project.GrayRangeLow + ".." + project.GrayRangeHigh;
|
|
int nLayers = GetCountOfLayers(project.ProjectId);
|
|
string outPath = project.OutPath;
|
|
|
|
StatusBar.Clear();
|
|
StatusBar.HologramSize = "Hologram size " + HologramSize + " mm";
|
|
StatusBar.HologramResolution = HologramResolution;
|
|
StatusBar.GrayRange = grayRange + " gray range";
|
|
StatusBar.NLayers = nLayers.ToString() + " layers";
|
|
StatusBar.OutPath = outPath;
|
|
|
|
InitializeMenuRecentProjects();
|
|
|
|
this.Invalidate();
|
|
}
|
|
|
|
private void RefreshLayersBar()
|
|
{
|
|
flowLayoutPanel1.Controls.Clear();
|
|
Size s = new Size(flowLayoutPanel1.Width, 68);
|
|
LayerControl pgb;
|
|
|
|
if (_projectObj != null)
|
|
{
|
|
projectControl.LoadProject(_projectObj.ProjectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
if (_projectObj != null && _projectObj.Layers != null && _projectObj.Layers.Count > 0)
|
|
{
|
|
foreach (Layer layer in _projectObj.Layers)
|
|
{
|
|
pgb = new LayerControl();
|
|
pgb.LayerService = layerService;
|
|
pgb.LayerModel = layerModel;
|
|
pgb.Padding = new Padding(5);
|
|
pgb.LayerName = layer.LayerName;
|
|
pgb.LayerObj = layer;
|
|
pgb.StatusBarColor = 0;
|
|
pgb.Size = s;
|
|
pgb.Anchor = AnchorStyles.Left | AnchorStyles.Right;
|
|
pgb.OnArrowUpClicked += LayerControl_ArrowUpClicked;
|
|
pgb.OnArrowDownClicked += LayerControl_ArrowDownClicked;
|
|
pgb.OnDoubleClicked += LayerControl_DoubleClicked;
|
|
pgb.OnCancelClicked += LayerControl_CancelClicked;
|
|
|
|
this._layers.Add(pgb);
|
|
this.flowLayoutPanel1.Controls.Add(pgb);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void LayerControl_ArrowUpClicked(object sender, EventArgs e)
|
|
{
|
|
UpdateLayersTable();
|
|
}
|
|
|
|
private void LayerControl_ArrowDownClicked(object sender, EventArgs e)
|
|
{
|
|
UpdateLayersTable();
|
|
}
|
|
|
|
private void LayerControl_DoubleClicked(object sender, EventArgs e)
|
|
{
|
|
LayerControl layerControl = (LayerControl)sender;
|
|
|
|
layerControl.ReloadControl();
|
|
|
|
_layerObj = layerControl.LayerObj;
|
|
|
|
//DataRow row = layerService.GetLayerById(_layerObj.Id);
|
|
|
|
//_layerObj.Id = layerModel.Id = Convert.ToInt16(row["Id"]);
|
|
//_layerObj.Order = layerModel.Order = Convert.ToInt16(row["Order"]);
|
|
//_layerObj.LayerName = layerModel.LayerName = row["LayerName"].ToString();
|
|
//_layerObj.OpticalSchema = layerModel.OpticalSchema = row["OpticalSchema"].ToString();
|
|
//_layerObj.ProjectId = layerModel.ProjectId = Convert.ToInt16(row["ProjectId"]);
|
|
//_layerObj.TechnologyName = layerModel.TechnologyName = row["TechnologyName"].ToString();
|
|
//_layerObj.ArcWidth = layerModel.ArcWidth = Convert.ToInt16(row["ArcWidth"]);
|
|
//_layerObj.RadiusMax = layerModel.RadiusMax = Convert.ToSingle(row["RadiusMax"]);
|
|
//_layerObj.Step = layerModel.Step = Convert.ToSingle(row["Step"]);
|
|
//_layerObj.SourceFilePath = layerModel.SourceFilePath = row["SourceFilePath"].ToString();
|
|
//_layerObj.AnglesFilePath = layerModel.AnglesFilePath = row["AnglesFilePath"].ToString();
|
|
|
|
DataRow rowProfileColor = layerService.GetColorProfileByLayerId(_layerObj.Id);
|
|
colorProfileModel.Id = Convert.ToInt16(rowProfileColor["Id"]);
|
|
colorProfileModel.LayerId = Convert.ToInt16(rowProfileColor["LayerId"]);
|
|
colorProfileModel.ProfileName = rowProfileColor["ProfileName"].ToString();
|
|
colorProfileModel.ArcWidth = Convert.ToInt16(rowProfileColor["ArcWidth"]);
|
|
this._colorProfileObj = new ColorProfile(colorProfileModel);
|
|
|
|
string TraceProfileString = rowProfileColor["TraceProfile"].ToString();
|
|
_layerObj.TraceProfile = layerModel.TraceProfile = TraceProfileString.Split(',').Select(int.Parse).ToArray();
|
|
_layerObj.ArcWidth = Convert.ToInt16(rowProfileColor["ArcWidth"]);
|
|
|
|
//layerControl.RefreshControl(layerModel);
|
|
|
|
bool editMode = true;
|
|
//layerControl.LayerObj;
|
|
if (layerControl.LayerObj.TechnologyName == "Treko")
|
|
{
|
|
ShowTrekoDialog(editMode);
|
|
}
|
|
else if (layerControl.LayerObj.TechnologyName == "Treko3D")
|
|
{
|
|
ShowTreko3DDialog(editMode);
|
|
}
|
|
}
|
|
|
|
private void LayerControl_CancelClicked(object sender, EventArgs e)
|
|
{
|
|
LayerControl layerControl = (LayerControl)sender;
|
|
Layer layerObj = layerControl.LayerObj;
|
|
layerModel.Id = layerObj.Id;
|
|
|
|
layerService.DeleteColorProfile(layerModel);
|
|
|
|
layerService.DeleteLayer(layerModel);
|
|
RefreshLayersBar();
|
|
}
|
|
|
|
public void OpenSplitterPanel(int splitterDistance)
|
|
{
|
|
Control[] cnt = this.Controls.Find("splitContainer1", true);
|
|
SplitContainer splitContainer = (SplitContainer)cnt[0];
|
|
|
|
if (splitContainer.Panel1Collapsed == true)
|
|
{
|
|
splitContainer.Panel1Collapsed = false;
|
|
}
|
|
splitContainer.SplitterDistance = splitterDistance;
|
|
|
|
}
|
|
|
|
public void OpenSplitterPanel()
|
|
{
|
|
Control[] cnt = this.Controls.Find("splitContainer1", true);
|
|
SplitContainer splitContainer = (SplitContainer)cnt[0];
|
|
|
|
if (splitContainer.Panel1Collapsed == true)
|
|
{
|
|
splitContainer.Panel1Collapsed = false;
|
|
}
|
|
splitContainer.SplitterDistance = 230;
|
|
|
|
}
|
|
|
|
public void CloseSplitterPanel()
|
|
{
|
|
Control[] cnt = this.Controls.Find("splitContainer1", true);
|
|
SplitContainer splitContainer = (SplitContainer)cnt[0];
|
|
|
|
splitContainer.SplitterDistance = 630;
|
|
|
|
//if (splitContainer.Panel1Collapsed == false)
|
|
// splitContainer.Panel1Collapsed = true;
|
|
|
|
}
|
|
|
|
private void DisposeControl(UserControl control)
|
|
{
|
|
if (control != null)
|
|
{
|
|
Type type = control.GetType();
|
|
|
|
if (type.Name == "TrekoControl")
|
|
{
|
|
this.trekoControl1.Dispose();
|
|
this.trekoControl1 = null;
|
|
}
|
|
else if (type.Name == "Treko3DControl")
|
|
{
|
|
this.treko3DControl1.Dispose();
|
|
this.treko3DControl1 = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static Pen _dashedPen = new Pen(Color.DarkRed, 1);
|
|
|
|
private void splitContainer1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
SplitContainer s = sender as SplitContainer;
|
|
if (s != null)
|
|
{
|
|
_dashedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
|
|
int gripLineWidth = 9;
|
|
// Fill Splitter rectangle
|
|
e.Graphics.FillRectangle(SystemBrushes.ControlDark,
|
|
s.SplitterRectangle.X, s.SplitterDistance, s.SplitterRectangle.Width, s.SplitterWidth);
|
|
// Draw Single Line Border on Top and Bottom
|
|
e.Graphics.DrawLine(Pens.LightSlateGray,
|
|
s.SplitterRectangle.X, s.SplitterDistance, s.SplitterRectangle.Width, s.SplitterDistance);
|
|
e.Graphics.DrawLine(Pens.LightSlateGray,
|
|
s.SplitterRectangle.X, s.SplitterDistance + s.SplitterWidth - 1, s.SplitterRectangle.Width, s.SplitterDistance + s.SplitterWidth - 1);
|
|
// Draw gripper dots in center
|
|
e.Graphics.DrawLine(_dashedPen,
|
|
((s.SplitterRectangle.Width / 2) - (gripLineWidth / 2)),
|
|
s.SplitterDistance + s.SplitterWidth / 2,
|
|
((s.SplitterRectangle.Width / 2) + (gripLineWidth / 2)),
|
|
s.SplitterDistance + s.SplitterWidth / 2);
|
|
}
|
|
}
|
|
|
|
#region Events
|
|
|
|
private void OnNewProjectClick(object sender, EventArgs e)
|
|
{
|
|
//CloseSplitterPanel();
|
|
projectControl.LoadProjectByNameDefault();
|
|
|
|
projectControl.Caption = "New Project";
|
|
projectControl.EditMode = false;
|
|
//projectControl.ProjectName = "";
|
|
//projectControl.OutPath = "";
|
|
//projectControl.HologramWidth = "30";
|
|
//projectControl.HologramHeight = "30";
|
|
////projectControl.ResolutionX = 1024;
|
|
////projectControl.ResolutionY = 768;
|
|
//projectControl.GrayHigh = 255;
|
|
//projectControl.GrayLow = 50;
|
|
projectControl.Visible = true;
|
|
|
|
ClearObjects();
|
|
ClearBarsInfo();
|
|
RefreshLayersBar();
|
|
OpenSplitterPanel(630);
|
|
}
|
|
|
|
private void OnOpenProjectClick(object sender, EventArgs e)
|
|
{
|
|
//CloseSplitterPanel();
|
|
if (_projectObj == null || _projectObj.ProjectId == 0)
|
|
{
|
|
projectControl.Caption = "New Project";
|
|
projectControl.EditMode = false;
|
|
projectControl.HologramWidth = "30";
|
|
projectControl.HologramHeight = "30";
|
|
//projectControl.ResolutionX = 1024; !!!!
|
|
//projectControl.ResolutionY = 768;
|
|
projectControl.GrayHigh = 255;
|
|
projectControl.GrayLow = 50;
|
|
projectControl.Visible = true;
|
|
|
|
ClearObjects();
|
|
ClearBarsInfo();
|
|
RefreshLayersBar();
|
|
}
|
|
else
|
|
{
|
|
projectControl.Caption = "Update Project";
|
|
projectControl.EditMode = true;
|
|
|
|
//string itemText = (sender as ToolStripMenuItem).Text;
|
|
//string[] words = itemText.Split('(', ')');
|
|
//string[] words1 = words[0].Split(' ');
|
|
|
|
//int projectId = int.Parse(words1[0]);
|
|
//string projectName = words1[1];
|
|
//if (words1.Length > 3)
|
|
//{
|
|
// for (int i = 1; i < words1.Length; i++)
|
|
// {
|
|
// projectName += words1[i];
|
|
// }
|
|
//}
|
|
|
|
projectControl.LoadProject(_projectObj.ProjectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
|
|
projectControl.Visible = true;
|
|
}
|
|
|
|
OpenSplitterPanel(630);
|
|
|
|
}
|
|
|
|
|
|
private void OnUpdateProjectClick(object sender, EventArgs e)
|
|
{
|
|
CloseSplitterPanel();
|
|
projectControl.Caption = "Update Project";
|
|
projectControl.EditMode = true;
|
|
string itemText = (sender as ToolStripMenuItem).Text;
|
|
string[] words = itemText.Split('(', ')');
|
|
string[] words1 = words[0].Split(' ');
|
|
|
|
int projectId = int.Parse(words1[0]);
|
|
string projectName = words1[1];
|
|
if (words1.Length > 3)
|
|
{
|
|
for (int i = 1; i < words1.Length; i++)
|
|
{
|
|
projectName += words1[i];
|
|
}
|
|
}
|
|
|
|
projectControl.LoadProject(projectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
|
|
projectControl.Visible = true;
|
|
}
|
|
|
|
private void projectControl_OnLoadedDefault(object sender, EventArgs e)
|
|
{
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
|
|
//if (projectControl.Project != null)
|
|
//{
|
|
// projectControl.LoadProject(projectControl.Project.ProjectId);
|
|
// _projectObj = projectControl.Project;
|
|
|
|
// RefreshBarsInfo(projectControl.Project);
|
|
// RefreshLayersBar();
|
|
//}
|
|
|
|
CloseSplitterPanel();
|
|
//projectControl.Visible = true;
|
|
|
|
}
|
|
|
|
private void projectControl_OkClicked(object sender, EventArgs e)
|
|
{
|
|
|
|
if (projectControl.Project != null)
|
|
{
|
|
projectControl.LoadProject(projectControl.Project.ProjectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
}
|
|
|
|
projectControl.Visible = false;
|
|
|
|
}
|
|
|
|
private int GetFirstProjectId()
|
|
{
|
|
int projectId = 0;
|
|
|
|
try
|
|
{
|
|
DataTable data = this.projectService.GetAllProjects();
|
|
DataRow[] drowpar = data.Select(); // ("ParentID=" + 0);
|
|
DataRow dr = drowpar[0];
|
|
projectId = Convert.ToInt32(dr["Id"]);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.ShowErrorMessage(ex);
|
|
}
|
|
|
|
return projectId;
|
|
}
|
|
|
|
private void projectControl_DeleteClicked(object sender, EventArgs e)
|
|
{
|
|
projectControl.Visible = false;
|
|
|
|
int projectId = GetFirstProjectId();
|
|
|
|
projectControl.LoadProject(projectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
|
|
}
|
|
|
|
private void projectControl_SaveAsDefaultClicked(object sender, EventArgs e)
|
|
{
|
|
//projectControl.Visible = false;
|
|
|
|
//int projectId = GetFirstProjectId();
|
|
|
|
//projectControl.LoadProject(projectId);
|
|
//_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
|
|
}
|
|
|
|
private void projectControl_PreviewClicked(object sender, EventArgs e)
|
|
{
|
|
//Treko3D.Treko3D tr3DObj = treko3DControl1.treko3DObj;
|
|
//_projectObj = projectControl.Project;
|
|
|
|
//string dirName = treko3DControl1.SourceFilePath;
|
|
//string outDirName = _projectObj.OutPath; // dirName + "\\TEST\\";
|
|
|
|
//if (outDirName == "" || !Directory.Exists(outDirName))
|
|
// outDirName = Helper.CreateOutDir(dirName);
|
|
//if (outDirName == "")
|
|
// return;
|
|
//else
|
|
//{
|
|
// projectControl.UpdateProjectOutPath(outDirName);
|
|
// _projectObj = projectControl.Project;
|
|
//}
|
|
|
|
if (childProject == null || childProject.IsDisposed)
|
|
{
|
|
childProject = new frmChildProject();
|
|
childProject.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childProject.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
|
|
childProject.ProjectControl = projectControl;
|
|
childProject.LayerObj = _layerObj;
|
|
childProject.ProjectObj = _projectObj;
|
|
|
|
childProject.RefreshLayersPicBoxes();
|
|
//childTreko3D.GenerateAndSaveStrips(tr3DObj, _projectObj); //, treko3DControl1.RakurseFiles);
|
|
//int decimate = 4;
|
|
|
|
//childTreko3D.GenerateAndSaveStrips(tr3DObj, _projectObj); //, treko3DControl1.RakurseFiles);
|
|
|
|
//childProject.DrawImage();
|
|
|
|
childProject.Show();
|
|
|
|
}
|
|
|
|
private void OnSequrityClick(object sender, EventArgs e)
|
|
{
|
|
if (childSequrity == null)
|
|
{
|
|
childSequrity = new frmChildSequrity();
|
|
childSequrity.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childSequrity.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
childSequrity.Show();
|
|
//child.MergeImagesVertically(StripFiles, resultFilePath, nFileStart, nFileEnd);
|
|
}
|
|
|
|
private void OnExitClick(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
|
|
#endregion
|
|
|
|
void ChildAnglesClicked(object sender, EventArgs e)
|
|
{
|
|
if (childAngles == null || childAngles.IsDisposed)
|
|
{
|
|
childAngles = new frmChildAngles();
|
|
//frmChildAngles.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childAngles.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
|
|
//childColorProfile.ColorProfileControl.ObjSender = sender; // Sender - TrekoControl, Treko3DControl
|
|
|
|
//Type objType = sender.GetType();
|
|
|
|
//TrekoControl trekoControl;
|
|
//Treko3DControl treko3DControl;
|
|
//Layer layerObj;
|
|
//Project projectObj;
|
|
|
|
//if (objType.Name == "TrekoControl")
|
|
//{
|
|
// trekoControl = (TrekoControl)sender;
|
|
// Treko.Treko trekoObj = trekoControl.trekoObj;
|
|
|
|
// projectObj = trekoControl.ProjectObj;
|
|
// layerObj = trekoControl.LayerObj;
|
|
|
|
// childColorProfile.ColorProfileControl.LoadColorProfile(layerObj.Id);
|
|
// childColorProfile.ColorProfileControl.EditMode = trekoControl.EditMode;
|
|
|
|
|
|
//}
|
|
//else if (objType.Name == "Treko3DControl")
|
|
//{
|
|
// treko3DControl = (Treko3DControl)sender;
|
|
// //Treko.Treko3D treko3DObj = treko3DControl..trekoObj;
|
|
|
|
// projectObj = treko3DControl.ProjectObj;
|
|
// layerObj = treko3DControl.LayerObj;
|
|
|
|
// childColorProfile.ColorProfileControl.LoadColorProfile(layerObj.Id);
|
|
// childColorProfile.ColorProfileControl.EditMode = treko3DControl.EditMode;
|
|
//}
|
|
|
|
childAngles.Show();
|
|
}
|
|
|
|
void ChildColorProfileClicked(object sender, EventArgs e)
|
|
{
|
|
if (childColorProfile == null || childColorProfile.IsDisposed)
|
|
{
|
|
childColorProfile = new frmChildColorProfile();
|
|
childColorProfile.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childColorProfile.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
|
|
childColorProfile.ColorProfileControl.ObjSender = sender; // Sender - TrekoControl, Treko3DControl
|
|
|
|
Type objType = sender.GetType();
|
|
|
|
TrekoControl trekoControl;
|
|
Treko3DControl treko3DControl;
|
|
Layer layerObj;
|
|
Project projectObj;
|
|
|
|
if (objType.Name == "TrekoControl")
|
|
{
|
|
trekoControl = (TrekoControl)sender;
|
|
//Treko.Treko trekoObj = trekoControl.trekoObj;
|
|
|
|
projectObj = trekoControl.ProjectObj;
|
|
layerObj = trekoControl.LayerObj;
|
|
|
|
if (layerObj != null && layerObj.Id != 0)
|
|
childColorProfile.ColorProfileControl.LoadColorProfile(layerObj.Id);
|
|
else
|
|
childColorProfile.ColorProfileControl.LoadColorProfileDefault("Treko");
|
|
|
|
childColorProfile.ColorProfileControl.CallerTechnologyName = "Treko";
|
|
childColorProfile.ColorProfileControl.EditMode = trekoControl.EditMode;
|
|
}
|
|
else if (objType.Name == "Treko3DControl")
|
|
{
|
|
treko3DControl = (Treko3DControl)sender;
|
|
//Treko.Treko3D treko3DObj = treko3DControl.trekoObj;
|
|
|
|
projectObj = treko3DControl.ProjectObj;
|
|
layerObj = treko3DControl.LayerObj;
|
|
|
|
if (layerObj != null && layerObj.Id != 0)
|
|
childColorProfile.ColorProfileControl.LoadColorProfile(layerObj.Id);
|
|
else
|
|
childColorProfile.ColorProfileControl.LoadColorProfileDefault("Treko3D");
|
|
|
|
childColorProfile.ColorProfileControl.CallerTechnologyName = "Treko3D";
|
|
childColorProfile.ColorProfileControl.EditMode = treko3DControl.EditMode;
|
|
}
|
|
|
|
childColorProfile.Show();
|
|
}
|
|
|
|
void ChildTreko_PreviewClicked(object sender, EventArgs e)
|
|
{
|
|
Treko.Treko trekoObj = trekoControl1.trekoObj;
|
|
Project projectObj = projectControl.Project;
|
|
|
|
string dirName = Path.GetDirectoryName(trekoControl1.SourceFilePath); //!!!!Nick
|
|
string outDirName = _projectObj.OutPath; // dirName + "\\TEST\\";
|
|
|
|
if (outDirName == "" || !Directory.Exists(outDirName))
|
|
outDirName = Helper.CreateOutDir(dirName);
|
|
if (outDirName == "")
|
|
return;
|
|
else
|
|
{
|
|
projectControl.UpdateProjectOutPath(outDirName);
|
|
projectControl.OutPath = outDirName;
|
|
}
|
|
|
|
if (childTreko == null || childTreko.IsDisposed)
|
|
{
|
|
childTreko = new frmChildTreko();
|
|
childTreko.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childTreko.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
|
|
childTreko.TrekoControl = trekoControl1;
|
|
childTreko.LayerObj = _layerObj;
|
|
childTreko.ProjectObj = _projectObj;
|
|
|
|
childTreko.RefreshChildForm();
|
|
|
|
childTreko.GenerateAndSaveStrips(trekoObj, projectObj);
|
|
|
|
childTreko.DrawImage();
|
|
|
|
childTreko.Show();
|
|
}
|
|
|
|
// Create new layer
|
|
void Treko_OkClicked(object sender, EventArgs e)
|
|
{
|
|
ColorProfileControl colorProfileControl = null;
|
|
TrekoControl trekoControl = (TrekoControl)sender;
|
|
trekoControl.ProjectObj = _projectObj = projectControl.Project;
|
|
|
|
// Treko3D.Treko3D tr3DObj = treko3DControl1.treko3DObj;
|
|
bool success = false;
|
|
|
|
if (trekoControl.EditMode == true) //control for update project
|
|
{
|
|
success = trekoControl.UpdateTrekoLayer();
|
|
}
|
|
else
|
|
{
|
|
// We try to create new layer without project
|
|
// So we need to create default project first
|
|
if (_projectObj == null || _projectObj.ProjectName == ""
|
|
|| _projectObj.ProjectName == Resources.Default_Project_Name)
|
|
{
|
|
projectControl.RegisterDefaultProject();
|
|
_projectObj = projectControl.Project;
|
|
trekoControl.ProjectObj = _projectObj;
|
|
}
|
|
success = trekoControl.RegisterNewTrekoLayer();
|
|
}
|
|
|
|
string dirName = Path.GetDirectoryName(trekoControl.SourceFilePath);
|
|
string outDirName = _projectObj.OutPath; // dirName + "\\TEST\\";
|
|
|
|
if (outDirName == "" || !Directory.Exists(outDirName))
|
|
outDirName = Helper.CreateOutDir(dirName);
|
|
if (outDirName == "")
|
|
return;
|
|
|
|
_layerObj = trekoControl.LayerObj;
|
|
DataRow row = layerService.GetColorProfileByLayerId(_layerObj.Id);
|
|
|
|
if (childColorProfile != null && childColorProfile.IsDisposed == false)
|
|
{
|
|
colorProfileControl = (ColorProfileControl)childColorProfile.Controls[0];
|
|
colorProfileControl.LayerId = _layerObj.Id;
|
|
if (row == null)
|
|
{
|
|
success = colorProfileControl.RegisterNewColorProfile();
|
|
}
|
|
else
|
|
{
|
|
success = colorProfileControl.UpdateColorProfile();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (row == null)
|
|
{
|
|
// Color Profile record is mandatory for layer
|
|
trekoControl.LoadColorProfileDefault();
|
|
// Color Profile record is mandatory for layer
|
|
success = trekoControl.RegisterNewColorProfileDefault();
|
|
}
|
|
else
|
|
{
|
|
trekoControl.LoadColorProfile(_layerObj.Id);
|
|
}
|
|
}
|
|
|
|
Project projectObj = projectControl.Project;
|
|
|
|
projectControl.LoadProject(projectObj.ProjectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
}
|
|
|
|
public void ShowTrekoDialog(bool editMode)
|
|
{
|
|
if (this.trekoControl1 == null)
|
|
{
|
|
DisposeControl(treko3DControl1);
|
|
|
|
this.trekoControl1 = new TrekoControl()
|
|
{
|
|
Dock = DockStyle.Right,
|
|
Location = new Point(0, 0),
|
|
Name = "trekoControl1",
|
|
Size = new System.Drawing.Size(355, 599),
|
|
TabIndex = 10,
|
|
ProjectObj = _projectObj,
|
|
LayerObj = _layerObj,
|
|
EditMode = editMode,
|
|
Resolution = projectControl.Resolution,
|
|
};
|
|
|
|
if (_layerObj != null && _layerObj.Id != 0)
|
|
this.trekoControl1.RefreshControl(_layerObj);
|
|
else
|
|
this.trekoControl1.LoadTrekoByNameDefault();
|
|
|
|
this.trekoControl1.OnOkClicked += Treko_OkClicked;
|
|
this.trekoControl1.OnPreviewClicked += ChildTreko_PreviewClicked;
|
|
this.trekoControl1.OnColorProfileClicked += ChildColorProfileClicked;
|
|
this.trekoControl1.OnAnglesClicked += ChildAnglesClicked;
|
|
|
|
this.splitContainer1.Panel2.Controls.Add(this.trekoControl1);
|
|
}
|
|
else
|
|
{
|
|
if (_layerObj != null && _layerObj.Id != 0)
|
|
{
|
|
this.trekoControl1.EditMode = editMode;
|
|
this.trekoControl1.RefreshControl(_layerObj);
|
|
}
|
|
else
|
|
{
|
|
this.trekoControl1.EditMode = editMode;
|
|
this.trekoControl1.LoadTrekoByNameDefault();
|
|
}
|
|
|
|
this.trekoControl1.Visible = true;
|
|
//CloseSplitterPanel();
|
|
//DisposeControl(trekoControl1);
|
|
}
|
|
|
|
OpenSplitterPanel();
|
|
|
|
if (this.projectControl != null && this.projectControl.Visible == true)
|
|
this.projectControl.Visible = false;
|
|
|
|
}
|
|
|
|
void ChildTreko3D_PreviewClicked(object sender, EventArgs e)
|
|
{
|
|
//int i = 0;
|
|
Treko3D.Treko3D tr3DObj = treko3DControl1.treko3DObj;
|
|
_projectObj = projectControl.Project;
|
|
|
|
string dirName = treko3DControl1.SourceFilePath;
|
|
string outDirName = _projectObj.OutPath; // dirName + "\\TEST\\";
|
|
|
|
if (outDirName == "" || !Directory.Exists(outDirName))
|
|
outDirName = Helper.CreateOutDir(dirName);
|
|
if (outDirName == "")
|
|
return;
|
|
else
|
|
{
|
|
projectControl.UpdateProjectOutPath(outDirName);
|
|
_projectObj = projectControl.Project;
|
|
}
|
|
|
|
if (childTreko3D == null || childTreko3D.IsDisposed)
|
|
{
|
|
childTreko3D = new FrmChildTreko3D();
|
|
childTreko3D.FormClosed += new FormClosedEventHandler(Child_FormClosed);
|
|
childTreko3D.Location = new Point(Location.X, Location.Y + Height + 20);
|
|
}
|
|
|
|
childTreko3D.Treko3DControl = treko3DControl1;
|
|
childTreko3D.LayerObj = _layerObj;
|
|
childTreko3D.ProjectObj = _projectObj;
|
|
|
|
childTreko3D.RefreshChildForm();
|
|
//childTreko3D.GenerateAndSaveStrips(tr3DObj, _projectObj); //, treko3DControl1.RakurseFiles);
|
|
//int decimate = 4;
|
|
|
|
childTreko3D.GenerateAndSaveStrips(tr3DObj, _projectObj); //, treko3DControl1.RakurseFiles);
|
|
|
|
childTreko3D.DrawImage();
|
|
|
|
childTreko3D.Show();
|
|
}
|
|
|
|
void Treko3D_OkClicked(object sender, EventArgs e)
|
|
{
|
|
ColorProfileControl colorProfileControl = null;
|
|
Treko3DControl treko3DControl = (Treko3DControl)sender;
|
|
treko3DControl.ProjectObj = _projectObj = projectControl.Project;
|
|
|
|
// Treko3D.Treko3D tr3DObj = treko3DControl1.treko3DObj;
|
|
bool success = false;
|
|
|
|
if (treko3DControl.EditMode == true) //control for update project
|
|
{
|
|
success = treko3DControl.UpdateTreko3DLayer();
|
|
}
|
|
else
|
|
{
|
|
// We try to create new layer without project
|
|
// So we need to create default project first
|
|
if (_projectObj == null || _projectObj.ProjectName == ""
|
|
|| _projectObj.ProjectName == Resources.Default_Project_Name)
|
|
{
|
|
projectControl.RegisterDefaultProject();
|
|
_projectObj = projectControl.Project;
|
|
treko3DControl.ProjectObj = _projectObj;
|
|
}
|
|
success = treko3DControl.RegisterNewTreko3DLayer();
|
|
}
|
|
|
|
string dirName = treko3DControl.SourceFilePath;
|
|
string outDirName = _projectObj.OutPath; // dirName + "\\TEST\\";
|
|
|
|
if (outDirName == "" || !Directory.Exists(outDirName))
|
|
outDirName = Helper.CreateOutDir(dirName);
|
|
if (outDirName == "")
|
|
return;
|
|
|
|
_layerObj = treko3DControl.LayerObj;
|
|
DataRow row = layerService.GetColorProfileByLayerId(_layerObj.Id);
|
|
|
|
if (childColorProfile != null && childColorProfile.IsDisposed == false)
|
|
{
|
|
colorProfileControl = (ColorProfileControl)childColorProfile.Controls[0];
|
|
colorProfileControl.LayerId = _layerObj.Id;
|
|
if (row == null)
|
|
{
|
|
success = colorProfileControl.RegisterNewColorProfile();
|
|
}
|
|
else
|
|
{
|
|
success = colorProfileControl.UpdateColorProfile();
|
|
}
|
|
} else
|
|
{
|
|
if (row == null)
|
|
{
|
|
// Color Profile record is mandatory for layer
|
|
treko3DControl.LoadColorProfileDefault();
|
|
// Color Profile record is mandatory for layer
|
|
success = treko3DControl.RegisterNewColorProfileDefault();
|
|
}
|
|
else
|
|
{
|
|
treko3DControl.LoadColorProfile(_layerObj.Id);
|
|
}
|
|
|
|
}
|
|
|
|
Project projectObj = projectControl.Project;
|
|
|
|
projectControl.LoadProject(projectObj.ProjectId);
|
|
_projectObj = projectControl.Project;
|
|
|
|
RefreshBarsInfo(projectControl.Project);
|
|
RefreshLayersBar();
|
|
}
|
|
|
|
public void ShowTreko3DDialog(bool editMode)
|
|
{
|
|
if (this.treko3DControl1 == null)
|
|
{
|
|
DisposeControl(trekoControl1);
|
|
|
|
this.treko3DControl1 = new Treko3DControl()
|
|
{
|
|
Dock = DockStyle.Right,
|
|
Location = new Point(0, 0),
|
|
Name = "treko3DControl1",
|
|
Size = new Size(355, 599),
|
|
TabIndex = 10,
|
|
ProjectObj = _projectObj,
|
|
LayerObj = _layerObj,
|
|
EditMode = editMode,
|
|
Resolution = projectControl.Resolution,
|
|
};
|
|
|
|
if (_layerObj != null && _layerObj.Id != 0)
|
|
this.treko3DControl1.RefreshControl(_layerObj);
|
|
else
|
|
this.treko3DControl1.LoadTreko3DByNameDefault();
|
|
|
|
this.treko3DControl1.OnOkClicked += Treko3D_OkClicked;
|
|
this.treko3DControl1.OnPreviewClicked += ChildTreko3D_PreviewClicked;
|
|
this.treko3DControl1.OnColorProfileClicked += ChildColorProfileClicked;
|
|
|
|
this.splitContainer1.Panel2.Controls.Add(this.treko3DControl1);
|
|
}
|
|
else
|
|
{
|
|
if (_layerObj != null && _layerObj.Id != 0)
|
|
{
|
|
this.treko3DControl1.EditMode = editMode;
|
|
this.treko3DControl1.RefreshControl(_layerObj);
|
|
} else
|
|
{
|
|
this.treko3DControl1.EditMode = editMode;
|
|
this.treko3DControl1.LoadTreko3DByNameDefault();
|
|
}
|
|
|
|
this.treko3DControl1.Visible = true;
|
|
|
|
//CloseSplitterPanel();
|
|
//DisposeControl(treko3DControl1);
|
|
}
|
|
|
|
OpenSplitterPanel();
|
|
|
|
if (this.projectControl != null && this.projectControl.Visible == true)
|
|
this.projectControl.Visible = false;
|
|
|
|
}
|
|
|
|
public void ShowCrystalDialog()
|
|
{
|
|
|
|
}
|
|
|
|
private void BtnTreko_Click(object sender, EventArgs e)
|
|
{
|
|
if (_layerObj != null)
|
|
_layerObj.Clear();
|
|
|
|
bool editMode = false;
|
|
ShowTrekoDialog(editMode);
|
|
}
|
|
|
|
private void btnTreko3D_Click(object sender, EventArgs e)
|
|
{
|
|
if (_layerObj != null)
|
|
_layerObj.Clear();
|
|
|
|
bool editMode = false;
|
|
ShowTreko3DDialog(editMode);
|
|
}
|
|
|
|
private void btnCrystal_Click(object sender, EventArgs e)
|
|
{
|
|
ShowCrystalDialog();
|
|
}
|
|
|
|
private void UpdateLayersTable()
|
|
{
|
|
int ii = 0;
|
|
foreach (LayerControl layerControl in this.flowLayoutPanel1.Controls)
|
|
{
|
|
Layer layerObj = layerControl.LayerObj;
|
|
layerModel.Id = layerObj.Id;
|
|
layerModel.Order = layerObj.Order = ii;
|
|
layerModel.LayerName = layerObj.LayerName;
|
|
layerModel.OpticalSchema = layerObj.OpticalSchema;
|
|
layerModel.TechnologyName = layerObj.TechnologyName;
|
|
layerModel.ProjectId = layerObj.ProjectId;
|
|
layerModel.AnglesFilePath = layerObj.AnglesFilePath; //!!!!Nick
|
|
layerModel.SourceFilePath = layerObj.SourceFilePath; //!!!!Nick
|
|
layerModel.LayerLeft = layerObj.LayerLeft;
|
|
layerModel.LayerTop = layerObj.LayerTop;
|
|
layerModel.LayerWidth = layerObj.LayerWidth;
|
|
layerModel.LayerHeight = layerObj.LayerHeight;
|
|
layerModel.ArcWidth = layerObj.ArcWidth;
|
|
layerModel.RadiusMax = layerObj.RadiusMax;
|
|
layerModel.Step = layerObj.Step;
|
|
|
|
layerService.UpdateLayer(layerModel);
|
|
ii++;
|
|
}
|
|
|
|
}
|
|
|
|
private void flowLayoutPanel1_DragDrop(object sender, DragEventArgs e)
|
|
{
|
|
ControlLibrary.LayerControl data = (ControlLibrary.LayerControl)e.Data.GetData(typeof(ControlLibrary.LayerControl));
|
|
FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
|
|
FlowLayoutPanel _source = (FlowLayoutPanel)data.Parent;
|
|
|
|
if (_source != _destination)
|
|
{
|
|
// Add control to panel
|
|
_destination.Controls.Add(data);
|
|
data.Size = new Size(_destination.Width, 50);
|
|
|
|
// Reorder
|
|
Point p = _destination.PointToClient(new Point(e.X, e.Y));
|
|
var item = _destination.GetChildAtPoint(p);
|
|
int index = _destination.Controls.GetChildIndex(item, false);
|
|
_destination.Controls.SetChildIndex(data, index);
|
|
|
|
// Invalidate to paint!
|
|
_destination.Invalidate();
|
|
_source.Invalidate();
|
|
|
|
// Update database with new layers order
|
|
UpdateLayersTable();
|
|
}
|
|
else
|
|
{
|
|
// Just add the control to the new panel.
|
|
// No need to remove from the other panel, this changes the Control.Parent property.
|
|
Point p = _destination.PointToClient(new Point(e.X, e.Y));
|
|
var item = _destination.GetChildAtPoint(p);
|
|
int index = _destination.Controls.GetChildIndex(item, false);
|
|
_destination.Controls.SetChildIndex(data, index);
|
|
_destination.Invalidate();
|
|
// Update database with new layers order
|
|
UpdateLayersTable();
|
|
}
|
|
}
|
|
|
|
private void flowLayoutPanel1_DragEnter(object sender, DragEventArgs e)
|
|
{
|
|
e.Effect = DragDropEffects.All;
|
|
}
|
|
|
|
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
|
|
{
|
|
}
|
|
}
|
|
}
|