DepartmentProject/DepartmentPortal/AcademicProgressWindowsDesktop/SpecialControls/ControlReportPlanDisciplines.cs

141 lines
4.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.Enums;
using System;
using System.Xml.Linq;
using System.Windows.Forms;
using DesktopTools.BaseControls;
using DepartmentWindowsDesktop.EntityControls;
using DepartmentBusinessLogic.Enums;
namespace AcademicProgressWindowsDesktop.SpecialControls
{
public partial class ControlReportPlanDisciplines : UserControl, IControl
{
/// <summary>
/// Событие, вызываемое при закрытии контрола
/// </summary>
private event Action<Guid> CloseEvent;
public ControlReportPlanDisciplines()
{
InitializeComponent();
Title = "План сдачи";
//что за цифры тут откуда брать...
ControlId = new Guid("cc2234e6-5d92-4c89-b817-4c17ec382bc1");
AccessOperation = AccessOperation.План_сдачи;
toolStripButtonClose.Click += (object sender, EventArgs e) =>
{
CloseEvent?.Invoke(ControlId);
Dispose();
};
LoadGroupBoxReportInfo();
}
#region IControl
public Guid ControlId { get; private set; }
public string Title { get; private set; }
public AccessOperation AccessOperation { get; private set; }
public IControl GetInstance() => new ControlReportPlanDisciplines() { ControlId = Guid.NewGuid() };
public void Open(ControlOpenModel model)
{
if (model.CloseList != null)
{
CloseEvent += model.CloseList;
}
Dock = DockStyle.Fill;
}
public string SaveToXml() => new XElement("Control",
new XAttribute("Type", GetType().FullName),
new XAttribute("ControlId", ControlId),
new XAttribute("Title", Title),
new XAttribute("AccessOperation", AccessOperation)).ToString();
public void LoadFromXml(string xml)
{
var control = XElement.Parse(xml);
ControlId = new Guid(control.Attribute("ControlId").Value.ToString());
Title = control.Attribute("Title").Value.ToString();
AccessOperation = (AccessOperation)Enum.Parse(typeof(AccessOperation), control.Attribute("AccessOperation").Value.ToString());
}
#endregion
private void buttonSave_Click(object sender, EventArgs e)
{
}
private void buttonSaveSelectFolder_Click(object sender, EventArgs e)
{
}
private void LoadGroupBoxReportInfo()
{
int positionY = 40;
int interval = 15;
var controlStudent = new BaseControlGuid("StudentId", true, false, new ControlStudentList(), null)
{
Location = new System.Drawing.Point(100, positionY),
Size = new System.Drawing.Size(545, 23)
};
controlStudent.SetTitleWidth(controlStudent.SetTitle("Cтудент:"));
groupBoxReportInfo.Controls.Add(controlStudent);
positionY += controlStudent.Height + interval;
var controlEducationDirectionUpTo = new BaseControlGuid("EducationDirectionViewModelId", true, false, new ControlEducationDirectionList(), null)
{
Location = new System.Drawing.Point(37, positionY),
Size = new System.Drawing.Size(356, 23)
};
controlEducationDirectionUpTo.SetTitleWidth(controlEducationDirectionUpTo.SetTitle("Направление до:"));
groupBoxReportInfo.Controls.Add(controlEducationDirectionUpTo);
var controlSemesterUpTo = new BaseControlEnum("Semester", true, false, typeof(Semester))
{
Location = new System.Drawing.Point(425, positionY),
Size = new System.Drawing.Size(220, 23)
};
controlSemesterUpTo.SetTitleWidth(controlSemesterUpTo.SetTitle("Семестр до:"));
groupBoxReportInfo.Controls.Add(controlSemesterUpTo);
positionY += controlEducationDirectionUpTo.Height + interval;
var controlEducationDirectionAfter = new BaseControlGuid("EducationDirectionViewModelId", true, false, new ControlEducationDirectionList(), null)
{
Location = new System.Drawing.Point(13, positionY),
Size = new System.Drawing.Size(380, 23)
};
controlEducationDirectionAfter.SetTitleWidth(controlEducationDirectionAfter.SetTitle("Направление после:"));
groupBoxReportInfo.Controls.Add(controlEducationDirectionAfter);
var controlSemesterAfter = new BaseControlEnum("Semester", true, false, typeof(Semester))
{
Location = new System.Drawing.Point(401, positionY),
Size = new System.Drawing.Size(245, 23)
};
controlSemesterAfter.SetTitleWidth(controlSemesterAfter.SetTitle("Семестр после:"));
groupBoxReportInfo.Controls.Add(controlSemesterAfter);
}
}
}