コード例 #1
0
        public PersonalMonthForm(TagObject tagObject, bool isLocal)
        {
            tag   = tagObject;
            local = isLocal;

            InitializeComponent();
            this.Text         = "Отображён расчет для: " + "Год: " + tag.TargetYear + ". Месяц: " + tag.TargetMonthName;
            this.DialogResult = DialogResult.OK;
            ShowDateToUI(tag);
            AllocateDays(tag);
            if (!local)
            {
                saveForPrint.Visible = false;
            }
        }
コード例 #2
0
        private void Panel_Click(object sender, EventArgs e)
        {
            TagObject tag   = null;
            var       panel = sender as Panel;
            var       label = sender as Label;

            if (panel != null)
            {
                tag = panel.Tag as TagObject;
            }
            else if (label != null)
            {
                tag = label.Tag as TagObject;
            }
            else
            {
                MessageBox.Show("Sender is not a Panel or Label.");
            }

            if (tag != null)
            {
                using (PersonalMonthForm personalMonth = new PersonalMonthForm(tag, this.local))
                {
                    personalMonth.WindowState   = FormWindowState.Normal;
                    personalMonth.StartPosition = FormStartPosition.CenterParent;

                    if (personalMonth.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Tag object is missing.");
            }
        }
コード例 #3
0
        private void AllocateDays(TagObject tag)
        {
            var firstPanelBorderWidth = 1;
            var firstPanelSize        = GetDaysFirstPanelSize(pnlPersonalDayBase.Size, firstPanelBorderWidth);
            var secondTopPanelSize    = GetDaysSecondTopPanelSize(firstPanelSize);
            var secondBottomPanelSize = GetDaysSecondBottomPanelSize(firstPanelSize);

            var   fontFamilyName         = "";
            float secondTopPanelFontSize = 14;

            var days = DateTime.DaysInMonth(tag.TargetYear, tag.TargetMonthNumber);

            for (int i = 1; i <= days; i++)
            {
                // 5 x 7
                var row         = GetRow(i);    // y
                var col         = GetColumn(i); // x
                var simpleDay   = Int32.Parse(NarrowToOneNumber((int.Parse(NarrowToOneNumber(i.ToString())) + tag.MonthSimple).ToString()));
                var extendedDay = i + tag.MonthExtended;

                var secondTopPanel = new Label();
                secondTopPanel.Size      = secondTopPanelSize;
                secondTopPanel.Location  = new Point(0, 0);
                secondTopPanel.BackColor = Color.White;
                secondTopPanel.ForeColor = Color.Black;
                secondTopPanel.TextAlign = ContentAlignment.MiddleCenter;
                secondTopPanel.Font      = new Font(fontFamilyName, secondTopPanelFontSize, FontStyle.Bold);
                secondTopPanel.Text      = i.ToString();

                var secondBottomSimplePanel = new Label();
                secondBottomSimplePanel.Size      = secondBottomPanelSize;
                secondBottomSimplePanel.Location  = GetSecondBottomSimpleLocation(firstPanelSize, secondBottomPanelSize, local);
                secondBottomSimplePanel.BackColor = Color.White;
                secondBottomSimplePanel.ForeColor = Color.Black;
                secondBottomSimplePanel.TextAlign = ContentAlignment.MiddleCenter;
                secondBottomSimplePanel.Font      = new Font(fontFamilyName, secondTopPanelFontSize, FontStyle.Bold);
                secondBottomSimplePanel.Text      = simpleDay.ToString();

                var secondBottomExtendedPanel = new Label();
                secondBottomExtendedPanel.Size      = secondBottomPanelSize;
                secondBottomExtendedPanel.Location  = GetSecondBottomExtendedLocation(firstPanelSize);
                secondBottomExtendedPanel.BackColor = Color.White;
                secondBottomExtendedPanel.ForeColor = Color.Red;
                secondBottomExtendedPanel.TextAlign = ContentAlignment.MiddleCenter;
                secondBottomExtendedPanel.Font      = new Font(fontFamilyName, secondTopPanelFontSize, FontStyle.Bold);
                secondBottomExtendedPanel.Text      = extendedDay.ToString();

                var firstPanelLocation = GetDaysFirstPanelLocation(col, row, firstPanelSize, firstPanelBorderWidth);

                var firstPanel = new Panel();
                firstPanel.Size      = firstPanelSize;
                firstPanel.Location  = firstPanelLocation;
                firstPanel.BackColor = Color.White;
                firstPanel.Controls.Add(secondTopPanel);
                firstPanel.Controls.Add(secondBottomSimplePanel);
                if (local)
                {
                    firstPanel.Controls.Add(secondBottomExtendedPanel);
                }

                pnlPersonalDayBase.Controls.Add(firstPanel);
            }
        }
コード例 #4
0
 private void ShowDateToUI(TagObject tag)
 {
     lblDateValue.Text  = DateOfBirthObject.GetString(tag.SourceDayNumber, 2);
     lblMonthValue.Text = tag.SourceMonthName;
     lblYearValue.Text  = DateOfBirthObject.GetString(tag.TargetYear, 4);
 }