Beispiel #1
0
        public List <CalendarCell> getList(DateTime date)
        {
            var cells = new List <CalendarCell>();

            if (date.Day != 1)
            {
                date = date.AddDays(-date.Day + 1);
            }
            int dayOfWeek = (int)date.DayOfWeek;

            dayOfWeek = dayOfWeek < 1 ? 6 : dayOfWeek - 1; // Monday is 0 now;

            for (int i = -dayOfWeek; i < 35 - dayOfWeek; i++)
            {
                var          tempDay = date.AddDays(i);
                CalendarCell temp    = new CalendarCell(tempDay, i);
                cells.Add(temp);

                if (isSimilarDate(tempDay, DateTime.Now))
                {
                    temp.ClassName = "today ";
                }
                if (temp.Date.Month != date.Month)
                {
                    temp.ClassName = "wrongMonth ";
                }
            }

            return(cells);
        }
        public async Task InitAsync()
        {
            RefreshTimer.Interval = TimeSpan.FromSeconds(10);
            RefreshTimer.Tick    += RefreshTimer_Tick;

            AutoSaveTimer.Interval = TimeSpan.FromSeconds(5);
            AutoSaveTimer.Tick    += AutoSaveTimer_Tick;

            CurrentDateCell = new CalendarCell();

            Settings = await Task.Run(() => Common.LoadJson <Settings>(DataPath));

            if (Settings == null)
            {
                Settings = new Settings();
            }

            Settings.PropertyChanged             += Settings_PropertyChanged;
            Settings.HabitDays.CollectionChanged += HabitDays_CollectionChanged;

            FillSelectedMonthInfo();

            Update();
            RefreshTimer.Start();
        }
Beispiel #3
0
        private StackPanel GetYearRow(int from, int to)
        {
            var row = new StackPanel();

            row.Orientation = Orientation.Horizontal;
            row.Margin      = new System.Windows.Thickness(15, 0, 15, 0);

            for (int year = from; year <= to; year++)
            {
                var cell = new CalendarCell();
                cell.Width  = 90;
                cell.Height = 90;
                cell.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                cell.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                cell.Content = year;
                cell.Year    = year;
                if (this.Date.Year == year)
                {
                    cell.Background = CommonUtil.ToBrush("#FF4169E1");
                    cell.Foreground = CommonUtil.ToBrush("#FFFFFF");
                }
                else
                {
                    cell.Background = CommonUtil.ToBrush("#FFFFFF");
                    cell.Foreground = CommonUtil.ToBrush("#3b3b3b");
                }
                cell.MouseMove         += Cell_MouseMove;
                cell.MouseLeave        += Cell_MouseLeave;
                cell.MouseLeftButtonUp += btnYear_Click;
                row.Children.Add(cell);
            }

            return(row);
        }
        public async Task <IActionResult> CreateAbsence(Guid guid, string Absencetype, int UsersID, DateTime FromDate, DateTime ToDate, string CommentField, string ApprovalState)
        {
            if (guid != null)
            {
                await DeleteAbsence(guid);
            }

            guid = Guid.NewGuid();
            for (DateTime date = FromDate; date <= ToDate; date = date.AddDays(1))
            {
                var newcell = new CalendarCell {
                    ID = guid, AbsenceName = Absencetype, UsersID = UsersID, Date = date, CommentField = CommentField, Approval = ApprovalState
                };

                if (_context.Calendar.ToList().Any(item => (item.Date == newcell.Date && item.UsersID == newcell.UsersID)))
                {
                    //Not necessary with current fix, may want this later
                    ViewBag.error = "No duplicate absences allowed, please try again!";
                }
                else
                {
                    _context.Calendar.Add(newcell);
                }
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction("/"));
        }
		/// ------------------------------------------------------------------------------------
		public CalendarColumn(Func<DateTime> getDefaultValue, CalendarCell.UserAction whenToUseDefault)
			: base(new CalendarCell(getDefaultValue, whenToUseDefault))
		{
			base.DefaultCellStyle.ForeColor = SystemColors.WindowText;
			base.DefaultCellStyle.BackColor = SystemColors.Window;
			base.DefaultCellStyle.Font = SystemFonts.MenuFont;
			base.CellTemplate.Style = DefaultCellStyle;
		}
Beispiel #6
0
 public static void WaitFilled(this CalendarCell cell, bool filled, string errorMessage = "")
 {
     if (filled)
     {
         cell.Filled.WaitPresence(componentDescription: "заполненный день " + errorMessage);
         cell.Empty.WaitAbsence(componentDescription: "заполненный день " + errorMessage);
     }
     else
     {
         cell.Empty.WaitPresence(componentDescription: "незаполненный день " + errorMessage);
         cell.Filled.WaitAbsence(componentDescription: "незаполненный день " + errorMessage);
     }
 }
        public void Test_SetCellTemplate()
        {
            //---------------Set up test pack-------------------
            DataGridViewDateTimeColumn dtColumn = new DataGridViewDateTimeColumn();
            CalendarCell calendarCell           = new CalendarCell();

            //---------------Assert Precondition----------------
            Assert.AreNotSame(calendarCell, dtColumn.CellTemplate);
            //---------------Execute Test ----------------------
            dtColumn.CellTemplate = calendarCell;

            //---------------Test Result -----------------------
            Assert.AreSame(calendarCell, dtColumn.CellTemplate);
        }
        public void TestCalendarCell_HasCorrectSettings()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            CalendarCell calendarCell = new CalendarCell();

            //---------------Test Result -----------------------
            Assert.AreEqual("d", calendarCell.Style.Format);
            Assert.AreEqual(typeof(CalendarEditingControl), calendarCell.EditType);
            Assert.AreEqual(typeof(DateTime), calendarCell.ValueType);
            Assert.IsInstanceOf(typeof(DateTime), calendarCell.DefaultNewRowValue);

            DateTime newRowValue = (DateTime)calendarCell.DefaultNewRowValue;

            Assert.IsTrue(DateTimeUtilities.CloseToDateTimeNow(newRowValue, 10));
        }
Beispiel #9
0
        /// <summary>
        /// 判断节假日情况,设置单元格颜色
        /// </summary>
        /// <param name="currCell"></param>
        /// <param name="currDayInfo"></param>
        /// <param name="currMonth"></param>
        private void SetCellColor(CalendarCell currCell)
        {
            DayInfo currDayInfo = (DayInfo)currCell.Tag;

            currCell.BGColor    = Color.Transparent;
            currCell.DateColor  = Color.Black;
            currCell.LunarColor = Color.DimGray;

            if (currDayInfo.date.Month != displayDate.Month)
            {
                currCell.BGColor         = Color.Transparent;
                currCell.DateColor       = Color.FromArgb(0xF0F0F0);
                currCell.LunarColor      = Color.FromArgb(0xF0F0F0);
                currCell.HoverBGColor    = Color.Transparent;
                currCell.HoverDateColor  = currCell.DateColor = Color.FromArgb(0xF0F0F0);
                currCell.HoverLunarColor = currCell.LunarColor = Color.FromArgb(0xF0F0F0);
            }
            else
            {
                currCell.HoverBGColor    = Color.FromArgb(128, Color.PeachPuff);
                currCell.HoverDateColor  = Color.Gray;
                currCell.HoverLunarColor = Color.Gray;
                if (currDayInfo.lunarHoliday != null && currDayInfo.lunarHoliday != "")
                {
                    currCell.LunarColor = Color.DarkGreen;
                }
                if (currDayInfo.holiday != null && currDayInfo.holiday != "")
                {
                    currCell.LunarColor = Color.DarkGreen;
                }
                if (currDayInfo.holiday != null && currDayInfo.holiday != "" && currDayInfo.isHoliday == false)
                {
                    currCell.DateColor = Color.DarkGreen;
                }
                if (currDayInfo.term != "")
                {
                    currCell.LunarColor = Color.Purple;
                }
                if (currDayInfo.isLunarHoliday || currDayInfo.isHoliday)
                {
                    currCell.LunarColor = Color.Red;
                    currCell.DateColor  = Color.Red;
                }
            }
        }
            public void Apply(Java.Lang.Object p0)
            {
                CalendarCell calendarCell = p0.JavaCast <CalendarCell>();

                if (calendarCell.CellType != CalendarCellType.Date)
                {
                    return;
                }
                calendar.TimeInMillis = calendarCell.Date;
                if (calendar.Get(Java.Util.CalendarField.DayOfMonth) == 21 &&
                    calendar.Get(Java.Util.CalendarField.Month) ==
                    Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Month))
                {
                    calendarCell.SetBackgroundColor(
                        Android.Graphics.Color.ParseColor("#FF00A1"),
                        Android.Graphics.Color.ParseColor("#F988CF"));
                }
            }
        private void DataGridViewFilters_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            if (dataGridViewFilters["FieldFilterTableColumn", e.RowIndex] ==
                dataGridViewFilters[e.ColumnIndex, e.RowIndex])
            {
                var cellValue    = dataGridViewFilters[e.ColumnIndex, e.RowIndex].Value.ToString();
                var propertyType = ((BindingSource)currentDisplayDataGrid.DataSource).DataSource
                                   .GetType()
                                   .GetGenericArguments()[0]
                                   .GetProperty(cellValue)
                                   .PropertyType;

                var conditionsCell = new DataGridViewComboBoxCell();

                conditionsCell.Items.AddRange(dataGridViewFilters.NumberConditionValues);
                dataGridViewFilters["ConditionFilterTableColumn", e.RowIndex]       = conditionsCell;
                dataGridViewFilters["ConditionFilterTableColumn", e.RowIndex].Value =
                    dataGridViewFilters.NumberConditionValues.First();
                dataGridViewFilters["ValueFilterTableColumn", e.RowIndex] = new DataGridViewTextBoxCell();

                if (propertyType == typeof(int) || propertyType == typeof(int?))
                {
                    dataGridViewFilters["ValueFilterTableColumn", e.RowIndex].Value = "1";
                }
                else if (propertyType == typeof(DateTime))
                {
                    var calendarCell = new CalendarCell();
                    calendarCell.Value = DateTime.Now;
                    dataGridViewFilters["ValueFilterTableColumn", e.RowIndex] = calendarCell;
                }
                else
                {
                    conditionsCell.Items.Clear();
                    conditionsCell.Items.AddRange(dataGridViewFilters.StringConditionValues);
                    dataGridViewFilters["ConditionFilterTableColumn", e.RowIndex].Value =
                        dataGridViewFilters.StringConditionValues.First();
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// 设置画面
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        private void SetCalendar(int year, int month)
        {
            pnlDate.Children.Clear();
            var list = GetDayOfMonth(year, month);

            foreach (var item in list)
            {
                var row = new StackPanel();
                row.Orientation = Orientation.Horizontal;
                row.Margin      = new System.Windows.Thickness(10, 0, 10, 0);

                for (int i = 1; i <= 7; i++)
                {
                    var subItem = item[i];
                    var cell    = new CalendarCell();
                    cell.Width  = 40;
                    cell.Height = 40;
                    cell.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                    cell.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                    cell.Content    = subItem.Day;
                    cell.Year       = subItem.Year;
                    cell.Month      = subItem.Month;
                    cell.Day        = subItem.Day;
                    cell.Background = CommonUtil.ToBrush("#FFFFFF");
                    if (year == subItem.Year && month == subItem.Month)
                    {
                        cell.Foreground = CommonUtil.ToBrush("#3b3b3b");
                    }
                    else
                    {
                        cell.Foreground = CommonUtil.ToBrush("#CCC");
                    }
                    cell.MouseMove         += Cell_MouseMove;
                    cell.MouseLeave        += Cell_MouseLeave;
                    cell.MouseLeftButtonUp += btnDay_Click;
                    row.Children.Add(cell);
                }

                pnlDate.Children.Add(row);
            }
            SelectDate();
        }
Beispiel #13
0
 /// <summary>
 /// 设置显示文字和TAG
 /// </summary>
 /// <param name="cell"></param>
 /// <param name="info"></param>
 private void SetCellText(CalendarCell cell, DayInfo info)
 {
     cell.label1.Text = info.date.Day.ToString();
     cell.label2.Text = info.lunarMS + info.lunarDS;
     if (info.holiday != null && info.holiday.Trim() != "")
     {
         cell.label2.Text = info.holiday;
     }
     if (info.term != "")
     {
         cell.label2.Text = info.term;
     }
     if (info.lunarHoliday != null && info.lunarHoliday != "")
     {
         cell.label2.Text = info.lunarHoliday;
     }
     cell.Tag = (object)info;
     if (cell.label2.Text.IndexOf("\n") > 0)
     {
         cell.label2.Text = cell.label2.Text.Remove(cell.label2.Text.Length - (cell.label2.Text.Length - cell.label2.Text.IndexOf("\n")));
     }
 }
Beispiel #14
0
        /// <summary>
        /// 有单元格被点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CellClicked(object sender, EventArgs e)
        {
            CalendarCell cell     = (CalendarCell)sender;
            DayInfo      cellInfo = new DayInfo();

            cellInfo = (DayInfo)cell.Tag;
            if (cellInfo.date.Month != displayDate.Month)
            {
                displayDate = cellInfo.date;
                CheckDateChange();
                return;
            }
            else
            {
                DisplayCellInfo(cellInfo);
            }
            displayDate = cellInfo.date;

            foreach (CalendarCell cCell in MainPanel.Controls)
            {
                try
                {
                    if (cCell == cell)
                    {
                        cCell.Clicked = true;
                    }
                    else
                    {
                        cCell.Clicked = false;
                    }
                    cCell.ResetColor();
                }
                catch
                { }
            }
            cell.ResetColor();
            cColumn = MainPanel.GetColumn(cell);
            cRow    = MainPanel.GetRow(cell);
        }
Beispiel #15
0
        /// <summary>
        /// 设置月份日历
        /// </summary>
        /// <param name="year"></param>
        private void SetMonthCalendar(int year)
        {
            pnlMonth.Children.Clear();
            for (int i = 0; i < 4; i++)
            {
                var row = new StackPanel();
                row.Orientation = Orientation.Horizontal;
                row.Margin      = new System.Windows.Thickness(15, 0, 15, 0);

                for (int j = 1; j <= 3; j++)
                {
                    int month = i * 3 + j;
                    var cell  = new CalendarCell();
                    cell.Width  = 90;
                    cell.Height = 70;
                    cell.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                    cell.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                    cell.Content = string.Format("{0}月\n\r{1}", month, DicMonth[month]);
                    cell.Year    = year;
                    cell.Month   = month;
                    if (this.Date.Year == year && this.Date.Month == month)
                    {
                        cell.Background = CommonUtil.ToBrush("#FF4169E1");
                        cell.Foreground = CommonUtil.ToBrush("#FFFFFF");
                    }
                    else
                    {
                        cell.Background = CommonUtil.ToBrush("#FFFFFF");
                        cell.Foreground = CommonUtil.ToBrush("#3b3b3b");
                    }
                    cell.MouseMove         += Cell_MouseMove;
                    cell.MouseLeave        += Cell_MouseLeave;
                    cell.MouseLeftButtonUp += btnMonth_Click;
                    row.Children.Add(cell);
                }

                pnlMonth.Children.Add(row);
            }
        }
Beispiel #16
0
        //Обновляет таблицу всех Юзеров делает запросы Данных через Контроллер
        public void UpdateSheet()
        {
            usersTableGrid.Rows.Clear();


            users = Controller.getAllUsersFromDatabase();
            foreach (User user in users)
            {
                DataGridViewRow row = new DataGridViewRow();

                DataGridViewCell nameCell       = new DataGridViewTextBoxCell();
                DataGridViewCell secondnameCell = new DataGridViewTextBoxCell();
                CalendarCell     birthdayCell   = new CalendarCell();
                DataGridViewCell agesCell       = new DataGridViewTextBoxCell();
                DataGridViewCell occupationCell = new DataGridViewTextBoxCell();
                DataGridViewCell remoteCell     = new DataGridViewCheckBoxCell();
                DataGridViewCell addressCell    = new DataGridViewTextBoxCell();
                DataGridViewCell personNumCell  = new DataGridViewTextBoxCell();
                DataGridViewCell departmentCell = new DataGridViewTextBoxCell();

                nameCell.Value       = user.firstName;
                secondnameCell.Value = user.secondName;
                birthdayCell.Value   = user.birthData;
                occupationCell.Value = user.occupation.ToString();
                remoteCell.Value     = user.remoteWork;
                addressCell.Value    = user.address;
                agesCell.Value       = user.age;
                departmentCell.Value = user.department;


                personNumCell.Value = user.personNum;
                row.Cells.AddRange(nameCell, secondnameCell, agesCell, occupationCell, remoteCell, addressCell, personNumCell, birthdayCell, departmentCell);


                usersTableGrid.Rows.Add(row);
            }
        }
Beispiel #17
0
        public static void CreateImage(bool darkMode, DateTime currentDate, CalendarCell currentDateCell, List <MonthDay> selectedMonthDays, List <DateTime> habitDays)
        {
            MainWindow.log.Info("Drawing calendar bitmap");
            Color  color1, color2, color3;
            String baseImageFile, highlightFile, crossoutFile, crossoutDimmedFile;

            if (darkMode)
            {
                color1             = color1Dark;
                color2             = color2Dark;
                color3             = color3Dark;
                baseImageFile      = baseImageFileDark;
                highlightFile      = highlightFileDark;
                crossoutFile       = crossoutFileDark;
                crossoutDimmedFile = crossoutDimmedFileDark;
            }
            else
            {
                color1             = color1Light;
                color2             = color2Light;
                color3             = color3Light;
                baseImageFile      = baseImageLight;
                highlightFile      = highlightLight;
                crossoutFile       = crossoutLight;
                crossoutDimmedFile = crossoutDimmedLight;
            }

            //Init
            //
            CalendarVariables calVars = new CalendarVariables();

            int textw = 70;
            int texth = 45;

            FontCollection collection = new FontCollection();
            FontFamily     family     = collection.Install(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "Fonts", "OldStandard-Bold.ttf"));


            Font            numbersFont        = family.CreateFont(60, FontStyle.Italic);
            RendererOptions numbersFontOptions = new RendererOptions(numbersFont, dpi: 72)
            {
                ApplyKerning = true
            };

            using (Image <Rgba32> baseImage = Image.Load <Rgba32>(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", baseImageFile))) // load up source images
                using (Image <Rgba32> highlightImage = Image.Load <Rgba32>(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", highlightFile)))
                    using (Image <Rgba32> crossoutImage = Image.Load <Rgba32>(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", crossoutFile)))
                        using (Image <Rgba32> crossoutDisabledImage = Image.Load <Rgba32>(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", crossoutDimmedFile)))
                            using (Image <Rgba32> outputImage = new Image <Rgba32>(baseImage.Width, baseImage.Height)) // create output image of the correct dimensions
                            {
                                #region Highlight current day on calendar
                                //Highlight current day on calendar
                                //
                                Point highlightPosition = new Point(
                                    calVars.canvasStartX + (currentDateCell.X - 1) * calVars.calendarCellW
                                    + (currentDateCell.X * calVars.calendarCellBorder)
                                    + (calVars.calendarCellW / 2 - calVars.currentDayHighlightImageW / 2),
                                    calVars.canvasStartY - 2 + ((currentDateCell.Y - 1) * calVars.calendarCellH)
                                    + (currentDateCell.Y * calVars.calendarCellBorder)
                                    + (calVars.calendarCellH / 2 - calVars.currentDayHighlightImageH / 2));
                                //Y calc -> (CanvasStart Y px + CurrentDayCell row number * cellheight) + (CurrentDayCell row number * border size) + (cellheight / 2 - imageheight / 2)

                                outputImage.Mutate(o => o
                                                   .DrawImage(baseImage, new Point(0, 0), 1f)
                                                   .DrawImage(highlightImage, highlightPosition, 1f)
                                                   );
                                #endregion

                                #region Draw Calendar numbers
                                //Draw Calendar numbers
                                //
                                for (int i = 0; i < 6; i++)
                                {
                                    for (int j = 0; j < 7; j++)
                                    {
                                        float posx = calVars.canvasStartX + ((j + 1) - 1) * calVars.calendarCellW + ((j + 1) * calVars.calendarCellBorder) + (calVars.calendarCellW / 2 - textw / 2);
                                        float posy = calVars.canvasStartY - 20 + (((i + 1) - 1) * calVars.calendarCellH) + ((i + 1) * calVars.calendarCellBorder) + (calVars.calendarCellH / 2 - texth / 2);

                                        Color textcolor = color1;

                                        if (!selectedMonthDays[(i * 7) + j].FromCurrentMonth)
                                        {
                                            textcolor = color3;
                                        }

                                        outputImage.Mutate(x => x.DrawText(selectedMonthDays[(i * 7) + j].Date.Day.ToString("D2"), numbersFont, textcolor, new PointF(posx, posy)));

                                        //Crossout completed habit days
                                        //
                                        var habitDay = habitDays.FindIndex(s => s.ToString("MM/dd/yyyy") == selectedMonthDays[(i * 7) + j].Date.ToString("MM/dd/yyyy"));
                                        if (habitDay != -1)
                                        {
                                            int posx2 = calVars.canvasStartX - 10 + ((j + 1) - 1) * calVars.calendarCellW + ((j + 1) * calVars.calendarCellBorder) + (calVars.calendarCellW / 2 - textw / 2);
                                            int posy2 = calVars.canvasStartY - 22 + ((i + 1) - 1) * calVars.calendarCellH + ((i + 1) * calVars.calendarCellBorder) + (calVars.calendarCellH / 2 - texth / 2);

                                            if (selectedMonthDays[(i * 7) + j].FromCurrentMonth)
                                            {
                                                outputImage.Mutate(x => x.DrawImage(crossoutImage, new Point(posx2, posy2), 1f));
                                            }
                                            else
                                            {
                                                outputImage.Mutate(x => x.DrawImage(crossoutDisabledImage, new Point(posx2, posy2), 1f));
                                            }
                                        }
                                    }
                                }
                                #endregion

                                #region Draw month name text
                                //Draw month name text
                                //
                                PathBuilder pathBuilder = new PathBuilder();
                                pathBuilder.AddLine(new PointF(1930, 1008), new PointF(1930, 73));

                                IPath path = pathBuilder.Build();

                                var textGraphicsOptions = new TextGraphicsOptions() // draw the text along the path wrapping at the end of the line
                                {
                                    TextOptions =
                                    {
                                        WrapTextWidth       = path.Length,
                                        HorizontalAlignment = HorizontalAlignment.Center
                                    }
                                };

                                Font            monthFontBase    = family.CreateFont(242, FontStyle.Italic);
                                RendererOptions monthFontOptions = new RendererOptions(monthFontBase, dpi: 72)
                                {
                                    ApplyKerning = true
                                };

                                string MonthText = Common.GetMonthNameFromNumber(currentDate.Month).ToUpper();

                                // measure the text size
                                FontRectangle size          = TextMeasurer.Measure(MonthText, new RendererOptions(monthFontBase));
                                int           w             = 934;
                                int           h             = 278;
                                float         scalingFactor = Math.Min(w / size.Width, h / size.Height);
                                Font          monthFont     = new Font(monthFontBase, scalingFactor * monthFontBase.Size);

                                var glyphs = TextBuilder.GenerateGlyphs(MonthText, path, new RendererOptions(monthFont, textGraphicsOptions.TextOptions.DpiX, textGraphicsOptions.TextOptions.DpiY)
                                {
                                    HorizontalAlignment = textGraphicsOptions.TextOptions.HorizontalAlignment,
                                    TabWidth            = textGraphicsOptions.TextOptions.TabWidth,
                                    VerticalAlignment   = textGraphicsOptions.TextOptions.VerticalAlignment,
                                    WrappingWidth       = textGraphicsOptions.TextOptions.WrapTextWidth,
                                    ApplyKerning        = textGraphicsOptions.TextOptions.ApplyKerning
                                });

                                outputImage.Mutate(ctx => ctx
                                                   .Fill(color1, glyphs));
                                #endregion


                                #region Draw year text
                                //Draw year text
                                //
                                PathBuilder pathBuilder2 = new PathBuilder();
                                pathBuilder2.AddLine(new PointF(-10, 267), new PointF(-10, 829));

                                IPath path2 = pathBuilder2.Build();

                                var textGraphicsOptions2 = new TextGraphicsOptions() // draw the text along the path wrapping at the end of the line
                                {
                                    TextOptions =
                                    {
                                        WrapTextWidth = path2.Length
                                    }
                                };

                                Font            yearFont        = family.CreateFont(242);
                                RendererOptions yearFontOptions = new RendererOptions(yearFont, dpi: 72)
                                {
                                    ApplyKerning = true
                                };

                                var glyphs2 = TextBuilder.GenerateGlyphs(currentDate.Year.ToString(), path2, new RendererOptions(yearFont, textGraphicsOptions2.TextOptions.DpiX, textGraphicsOptions2.TextOptions.DpiY)
                                {
                                    HorizontalAlignment = textGraphicsOptions2.TextOptions.HorizontalAlignment,
                                    TabWidth            = textGraphicsOptions2.TextOptions.TabWidth,
                                    VerticalAlignment   = textGraphicsOptions2.TextOptions.VerticalAlignment,
                                    WrappingWidth       = textGraphicsOptions2.TextOptions.WrapTextWidth,
                                    ApplyKerning        = textGraphicsOptions2.TextOptions.ApplyKerning
                                });

                                outputImage.Mutate(ctx => ctx
                                                   .Fill(color1, glyphs2));
                                #endregion

                                MainWindow.log.Info("Saving image as output.png");
                                //Save output image
                                //
                                try
                                {
                                    outputImage.SaveAsPngAsync(IOPath.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "output.png"));
                                    MainWindow.log.Info("Image saved successfully");
                                }
                                catch (Exception e)
                                {
                                    MainWindow.log.Error(e.InnerException.Message);
                                }
                            }
        }
Beispiel #18
0
 public static void CreateCalendar(bool darkMode, DateTime currentDate, CalendarCell currentDateCell, List <MonthDay> selectedMonthDays, List <DateTime> habitDays)
 {
     CreateImage(darkMode, currentDate, currentDateCell, selectedMonthDays, habitDays);
 }
        public static void Initialize(UsersContext context)
        {
            context.Database.EnsureCreated();

            // Look for any roles.
            if (context.Roles.Any())
            {
                return;   // DB has been seeded
            }

            var users = new Users[] {};

            foreach (Users s in users)
            {
                context.Users.Add(s);
            }
            context.SaveChanges();

            var calendars = new CalendarCell[]
            {
                //Removed test data because of GUID ID change
            };

            foreach (CalendarCell c in calendars)
            {
                context.Calendar.Add(c);
            }
            context.SaveChanges();


            var roles = new Roles[]
            {
                new Roles {
                    RoleID = "Antura Developers", RoleName = "Developer"
                },
                new Roles {
                    RoleID = "Antura Development Architects", RoleName = "Development Architect"
                },
                new Roles {
                    RoleID = "Antura Testers", RoleName = "Tester"
                },
                new Roles {
                    RoleID = "Antura Support Engineers", RoleName = "Support Engineer"
                },
            };

            foreach (Roles r in roles)
            {
                context.Roles.Add(r);
            }
            context.SaveChanges();

            var userRoles = new UserRoles[]
            {
            };

            foreach (UserRoles ur in userRoles)
            {
                var userRolesInDataBase = context.UserRole.Where(
                    s =>
                    s.User.ID == ur.UsersID &&
                    s.Role.ID == ur.RolesID).SingleOrDefault();
                if (userRolesInDataBase == null)
                {
                    context.UserRole.Add(ur);
                }
            }

            context.SaveChanges();

            var department = new Department[]
            {
                new Department {
                    DepartmentName = "ProductDevelopment"
                },
                new Department {
                    DepartmentName = "SalesDepartment"
                },
                new Department {
                    DepartmentName = "TestDepartment"
                },
            };

            foreach (Department d in department)
            {
                context.Department.Add(d);
            }
            context.SaveChanges();


            var userDepartment = new UserDepartment[]
            {
            };

            foreach (UserDepartment ud in userDepartment)
            {
                var userDepartmentInDataBase = context.UserDepartment.Where(
                    s =>
                    s.User.ID == ud.UsersID &&
                    s.Departments.ID == ud.DepartmentID).SingleOrDefault();
                if (userDepartmentInDataBase == null)
                {
                    context.UserDepartment.Add(ud);
                }
            }
            context.SaveChanges();


            var teams = new Team[]
            {
                new Team {
                    TeamName = "A-Team"
                },
                new Team {
                    TeamName = "GoldTeam"
                },
                new Team {
                    TeamName = "Wombats"
                },
            };

            foreach (Team t in teams)
            {
                context.Team.Add(t);
            }
            context.SaveChanges();

            var userTeam = new UserTeam[]
            {
            };

            foreach (UserTeam ut in userTeam)
            {
                var userTeamInDataBase = context.UserTeam.Where(
                    s =>
                    s.User.ID == ut.UsersID &&
                    s.Teams.ID == ut.TeamID).SingleOrDefault();
                if (userTeamInDataBase == null)
                {
                    context.UserTeam.Add(ut);
                }
            }
            context.SaveChanges();
        }
Beispiel #20
0
        /// <summary>
        /// 方向键被按下
        /// </summary>
        /// <param name="direction">方向:1.上;2.右;3.下;4.左</param>
        private void ArrowKeyPressed(int direction)
        {
            DayInfo      info = new DayInfo();
            CalendarCell cell = new CalendarCell();

            switch (direction)
            {
            case 1:
                if (cRow == 0)
                {
                    cell        = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                    info        = (DayInfo)cell.Tag;
                    displayDate = info.date.Date.AddDays(-7);
                    CheckDateChange();
                    return;
                }
                else
                {
                    cRow--;
                }
                break;

            case 2:
                if (cColumn == 6)
                {
                    if (cRow == 5)
                    {
                        cell        = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                        info        = (DayInfo)cell.Tag;
                        displayDate = info.date.Date.AddDays(1);
                        CheckDateChange();
                        return;
                    }
                    else
                    {
                        cColumn = 0; cRow++;
                    }
                }
                else
                {
                    cColumn++;
                }
                break;

            case 3:
                if (cRow == 5)
                {
                    cell        = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                    info        = (DayInfo)cell.Tag;
                    displayDate = info.date.Date.AddDays(7);
                    CheckDateChange();
                    return;
                }
                else
                {
                    cRow++;
                }
                break;

            case 4:
                if (cColumn == 0)
                {
                    if (cRow == 0)
                    {
                        cell        = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                        info        = (DayInfo)cell.Tag;
                        displayDate = info.date.Date.AddDays(-1);
                        CheckDateChange();
                        return;
                    }
                    else
                    {
                        cColumn = 6; cRow--;
                    }
                }
                else
                {
                    cColumn--;
                }
                break;
            }
            cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
            CellClicked(cell, new EventArgs());
        }
Beispiel #21
0
        /// <summary>
        /// 重新设置单元格
        /// </summary>
        private void InitCells()
        {
            int column = 0; int row = 0;
            MainPanel.RowCount = 6;
            DateTime currMonth = new DateTime(displayDate.Year, displayDate.Month, 1);
            DateTime currDay = new DateTime();
            currDay = currMonth.AddDays((double)(0 - currMonth.DayOfWeek));
            CalendarCell currCell = new CalendarCell();
            #region 填充单元格
            while (column<7 && row<6)
            {

                HFDate lunarProcessor = new HFDate(currDay);
                DayInfo currDayInfo = new DayInfo();
                currDayInfo.date = currDay;
                currDayInfo.animal = animalNames[lunarProcessor.LunarYear.Zhi.IntValue - 1];
                currDayInfo.lunarM = lunarProcessor.LunarCalendarMonth;
                currDayInfo.lunarD = lunarProcessor.LunarCalendarDay;
                currDayInfo.ganZhi = lunarProcessor.LunarYear.Name + "年";
                currDayInfo.ganZhiM = lunarProcessor.LunarMonth.Name + "月";
                currDayInfo.ganZhiD = lunarProcessor.LunarDay.Name + "日";
                currDayInfo.lunarMS = lunarProcessor.LunarCalendarMonthString;
                currDayInfo.lunarDS = lunarProcessor.LunarCalendarDayString;
                currDayInfo.term = lunarProcessor.SolarTermInfo;

                currDayInfo.isHoliday = IsHoliday(ref currDayInfo); //加入节假日判断
                currDayInfo.isLunarHoliday = IsLunarHoliday(ref currDayInfo);

                currCell = (CalendarCell)MainPanel.GetControlFromPosition(column, row);
                currCell.Visible = true;

                SetCellText(currCell, currDayInfo);
                SetCellColor(currCell);
                if (currDayInfo.date.Date==displayDate.Date)
                {
                    cColumn = column; cRow = row;
                    CellClicked(currCell, new EventArgs());
                }

                column++;
                if (column > 6)
                {
                    column = 0;
                    row++;
                }

                currDay = currDay.AddDays(1);
            }

            CalendarCell tmpCell = (CalendarCell)MainPanel.GetControlFromPosition(0, 5);
            if (((DayInfo)tmpCell.Tag).date.Month != displayDate.Date.Month)
            {

                for (int i = 0; i < 7; i++)
                {
                    tmpCell = (CalendarCell)MainPanel.GetControlFromPosition(i, 5);
                    tmpCell.Visible = false;
                }

            }

            #endregion
            oldDate = displayDate;
            return;
        }
        private CalendarCellStyle SetStyleForCell(CalendarCell cell)
        {
            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("EEEEEE"),
                    BorderColor = Color.Transparent,
                    FontSize = Device.OnPlatform <double>(10, 16, 16),
                    FontWeight = Telerik.XamarinForms.Common.FontWeight.Bold,
                    ForegroundColor = Color.FromHex("999999")
                });
            }

            if (cell.Type == CalendarCellType.WeekNumber)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("E5E5E5"),
                    BorderColor = Color.Transparent,
                    FontSize = Device.OnPlatform <double>(13, 24, 13),
                    ForegroundColor = Color.FromHex("A9A9A9")
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = Color.FromHex("EEEEEE"),
                BorderColor     = Color.FromHex("CCCCCC"),
                BorderThickness = Device.OnPlatform <Thickness>(new Thickness(0, 0, 0, 1), 1, 0),
                FontSize        = Device.OnPlatform <double>(15, 16, 0),

                ForegroundColor = Color.FromHex("333333")
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    defaultStyle.ForegroundColor = Color.FromHex("D42A28");
                }

                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.FontWeight = Telerik.XamarinForms.Common.FontWeight.Bold;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(115, 174, 239);
                    }
                    else
                    {
                        defaultStyle.ForegroundColor = Color.FromHex("999999");
                        defaultStyle.BackgroundColor = Color.FromHex("E5E5E5");
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.ForegroundColor = Color.White;
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
Beispiel #23
0
        private async void Calendar_CellTapped(object sender, CalendarCell e)
        {
            var x = e as CalendarDateCell;

            if (x != null)
            {
                if (lastdateselected.Date != x.Date)
                {
                    lastdateselected = x.Date;
                    return;
                }

                var loading = new LoadingPopup();
                await Navigation.PushPopupAsync(loading);

                var      data  = Application.Current.Properties;
                DateTime start = (calendar as RadCalendar).MinDate;
                var      num   = (x.Date - start.Date).TotalDays + 1;
                var      food  = "";

                if (x.Date == DateTime.Now.Date)
                {
                    food = data["todayspressedlist"].ToString();

                    if (food.Length == 0)
                    {
                        var alert1 = new PopupAlert("No data for selected date.");
                        await Navigation.RemovePopupPageAsync(loading);

                        await Navigation.PushPopupAsync(alert1);

                        return;
                    }
                }
                else
                {
                    //   var num = (DateTime.Now.Date - x.Date).TotalDays;


                    bool exists = data.Any(p => p.Key == num + "day");
                    if (!exists)
                    {
                        var alert1 = new PopupAlert("No data for selected date.");
                        await Navigation.RemovePopupPageAsync(loading);

                        await Navigation.PushPopupAsync(alert1);

                        return;
                    }
                    else
                    {
                        food = data[num + "day"].ToString();
                    }
                }
                var list = new List <int>();
                int inde = 0;

                if (x.Date == DateTime.Now.Date)
                {
                    if (food == "")
                    {
                        var alert1 = new PopupAlert("No data for selected date.");
                        await Navigation.RemovePopupPageAsync(loading);

                        await Navigation.PushPopupAsync(alert1);

                        return;
                    }
                    do
                    {
                        //if(food[inde] == ',')
                        //{
                        //    inde += 1;
                        //    continue;
                        //}

                        var q = "";// + ",";
                        do
                        {
                            q    += food[inde].ToString();// + ",";
                            inde += 1;
                        } while (food[inde].ToString() != ",");
                        inde = 0;
                        if (!list.Contains(Convert.ToInt32(q.ToString())))
                        {
                            list.Add(Convert.ToInt32(q.ToString()));
                        }

                        q += ",";
                        // food = food.Replace(q, "");
                        int    qLength   = q.Length;
                        int    chRemoved = 0;
                        int    tempInt   = 0;
                        string temp      = "";
                        for (int ii = 0; ii < food.Length; ii++)
                        {
                            if (tempInt != qLength)
                            {
                                temp    += food[ii - chRemoved];
                                tempInt += 1;
                            }
                            if (temp == q)
                            {
                                food       = food.Remove(ii - tempInt + 1 - chRemoved, tempInt);
                                chRemoved += tempInt;
                                tempInt    = 0;
                                temp       = "";
                            }
                            else if (temp.Contains(","))
                            {
                                temp    = "";
                                tempInt = 0;
                            }
                        }

                        if (food.Length == 0)
                        {
                            break;
                        }
                        // inde += 1;
                    } while (true);
                }
                string show = "";
                inde = 0;
                if (x.Date == DateTime.Now.Date)
                {
                    foreach (var y in list)
                    {
                        if (data["removedClassIds"].ToString().Contains(list[inde].ToString() + ","))
                        {
                            inde += 1;
                            continue;
                        }
                        var q = JsonConvert.DeserializeObject <FoodModel>(data[list[inde] + "food"].ToString());
                        if (x.Date == DateTime.Now.Date)
                        {
                            show += q.Name + " : " + q.TimesPressed + ". \n";
                        }

                        //kyr edw prepei na mpei check an einai simera h oxi.
                        //an einai pairnei to q.TimesPressed. alliws prepei na apothikeyw st telos tis meras ta TimesPressed kapou.
                        inde += 1;
                    }
                }
                else
                {
                    try
                    {
                        show = data[num + "day"].ToString();
                    }
                    catch
                    {
                        var alert1 = new PopupAlert("No data for selected date.");
                        await Navigation.RemovePopupPageAsync(loading);

                        await Navigation.PushPopupAsync(alert1);

                        return;
                    }
                }
                var alert = new PopupAlert(show);
                await Navigation.RemovePopupPageAsync(loading);

                await Navigation.PushPopupAsync(alert);
            }
        }
        public frmWarranty(Warranty warranty)
        {
            InitializeComponent();
            this.Text      = "Изменение наряда.";
            this._Warranty = warranty;
            List <Position> positions = warranty.Positions.ToList();
            List <Executor> executors = warranty.Executors.ToList();
            List <Labor>    labors    = warranty.Labors.ToList();

            this.tbCustomer.Text = warranty.Customer;
            this.mtbOrder.Text   = warranty.Order.ToString("D4");
            Brigade brigade = Databases.Tables.Brigades[warranty.BrigadeId];

            this.bBrigade.Tag  = brigade;
            this.bBrigade.Text = String.Format("{0} / {1}", brigade.Area.Code.ToString("D2"), brigade.Code.ToString("D2"));

            foreach (Executor executor in executors)
            {
                DataGridViewRow  row              = new DataGridViewRow();
                DataGridViewCell ExecutorId       = new DataGridViewTextBoxCell();
                DataGridViewCell PersonCode       = new DataGridViewButtonCell();
                DataGridViewCell PersonLastName   = new DataGridViewTextBoxCell();
                DataGridViewCell PersonFirstName  = new DataGridViewTextBoxCell();
                DataGridViewCell PersonMiddleName = new DataGridViewTextBoxCell();
                DataGridViewCell ProfessionCode   = new DataGridViewButtonCell();
                DataGridViewCell Rank             = new DataGridViewTextBoxCell();

                ExecutorId.Value       = executor.Id;
                PersonCode.Value       = executor.Person.Code;
                PersonCode.Tag         = executor.Person;
                PersonLastName.Value   = executor.Person.LastName;
                PersonFirstName.Value  = executor.Person.FirstName;
                PersonMiddleName.Value = executor.Person.MiddleName;
                ProfessionCode.Tag     = Databases.Tables.PersonProfessions.First(r => r.Profession.Code == executor.Profession.Code);
                ProfessionCode.Value   = executor.Profession.Code;
                Rank.Value             = executor.Rank;

                row.Cells.Add(ExecutorId);
                row.Cells.Add(PersonCode);
                row.Cells.Add(PersonLastName);
                row.Cells.Add(PersonFirstName);
                row.Cells.Add(PersonMiddleName);
                row.Cells.Add(ProfessionCode);
                row.Cells.Add(Rank);

                this.ctrlExecutors.dgvItems.Rows.Add(row);
            }
            foreach (Labor labor in labors)
            {
                DataGridViewRow row = new DataGridViewRow();

                DataGridViewCell LaborId   = new DataGridViewTextBoxCell();
                DataGridViewCell LaborDate = new CalendarCell();
                DataGridViewCell Hours     = new DataGridViewTextBoxCell();

                LaborId.Value   = labor.Id;
                LaborDate.Value = labor.LaborDate;
                Hours.Value     = labor.Hours;

                row.Cells.Add(LaborId);
                row.Cells.Add(LaborDate);
                row.Cells.Add(Hours);
                this.ctrlLabors.dgvItems.Rows.Add(row);
            }
            foreach (Position position in positions)
            {
                this.ctrlPositions.dgvItems.Rows
                .Add(position.Id, position.Title, position.Draw, position.Matherial, position.Number, position.Mass, position.Norm, position.Price);
            }
            Sinc();
            CalculatePrice();
        }
Beispiel #25
0
 /// <summary>
 /// 设置显示文字和TAG
 /// </summary>
 /// <param name="cell"></param>
 /// <param name="info"></param>
 private void SetCellText(CalendarCell cell,DayInfo info)
 {
     cell.label1.Text = info.date.Day.ToString();
     cell.label2.Text = info.lunarMS+info.lunarDS;
     if (info.holiday!=null && info.holiday.Trim()!="")
     {
         cell.label2.Text = info.holiday;
     }
     if (info.term != "")
     {
         cell.label2.Text = info.term;
     }
     if (info.lunarHoliday!=null && info.lunarHoliday!="")
     {
         cell.label2.Text = info.lunarHoliday;
     }
     cell.Tag = (object)info;
     if (cell.label2.Text.IndexOf("\n")>0)
     {
         cell.label2.Text = cell.label2.Text.Remove(cell.label2.Text.Length - (cell.label2.Text.Length - cell.label2.Text.IndexOf("\n")));
     }
 }
Beispiel #26
0
        /// <summary>
        /// 判断节假日情况,设置单元格颜色
        /// </summary>
        /// <param name="currCell"></param>
        /// <param name="currDayInfo"></param>
        /// <param name="currMonth"></param>
        private void SetCellColor(CalendarCell currCell)
        {
            DayInfo currDayInfo = (DayInfo)currCell.Tag;
            currCell.BGColor = Color.Transparent;
            currCell.DateColor = Color.Black;
            currCell.LunarColor = Color.DimGray;

            if (currDayInfo.date.Month!=displayDate.Month)
            {
                currCell.BGColor = Color.Transparent;
                currCell.DateColor = Color.FromArgb(0xF0F0F0);
                currCell.LunarColor = Color.FromArgb(0xF0F0F0);
                currCell.HoverBGColor = Color.Transparent;
                currCell.HoverDateColor = currCell.DateColor = Color.FromArgb(0xF0F0F0);
                currCell.HoverLunarColor = currCell.LunarColor = Color.FromArgb(0xF0F0F0) ;
            }
            else
            {
                currCell.HoverBGColor = Color.FromArgb(128, Color.PeachPuff);
                currCell.HoverDateColor = Color.Gray;
                currCell.HoverLunarColor = Color.Gray;
                if (currDayInfo.lunarHoliday != null && currDayInfo.lunarHoliday != "")
                { currCell.LunarColor = Color.DarkGreen; }
                if (currDayInfo.holiday != null && currDayInfo.holiday != "")
                { currCell.LunarColor = Color.DarkGreen; }
                if (currDayInfo.holiday != null && currDayInfo.holiday != "" && currDayInfo.isHoliday==false)
                { currCell.DateColor = Color.DarkGreen; }
                if (currDayInfo.term!="")
                { currCell.LunarColor = Color.Purple; }
                if (currDayInfo.isLunarHoliday || currDayInfo.isHoliday)
                {
                    currCell.LunarColor = Color.Red;
                    currCell.DateColor = Color.Red;
                }
            }
        }
        private CalendarCellStyle SetStyleForCell(CalendarCell cell)
        {
            double    dayNameFontSize    = 0;
            double    weekNumberFontSize = 0;
            double    defaultFontSize    = 0;
            Thickness defaultThickness   = new Thickness(1);

            switch (Device.RuntimePlatform)
            {
            case Device.UWP:
            {
                dayNameFontSize    = 16;
                weekNumberFontSize = 13;
                defaultFontSize    = 0;
                defaultThickness   = new Thickness(0);
            }
            break;

            case Device.Android:
            {
                dayNameFontSize    = 16;
                weekNumberFontSize = 24;
                defaultFontSize    = 16;
                defaultThickness   = new Thickness(1);
            }
            break;

            case Device.iOS:
            {
                dayNameFontSize    = 10;
                weekNumberFontSize = 13;
                defaultFontSize    = 15;
                defaultThickness   = new Thickness(0, 0, 0, 1);
            }
            break;
            }

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("EEEEEE"),
                    BorderColor = Color.Transparent,
                    FontSize = dayNameFontSize,
                    FontAttributes = FontAttributes.Bold,
                    TextColor = Color.FromHex("999999")
                });
            }

            if (cell.Type == CalendarCellType.WeekNumber)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("E5E5E5"),
                    BorderColor = Color.Transparent,
                    FontSize = weekNumberFontSize,
                    TextColor = Color.FromHex("A9A9A9")
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = Color.FromHex("EEEEEE"),
                BorderColor     = Color.FromHex("CCCCCC"),
                BorderThickness = defaultThickness,
                FontSize        = defaultFontSize,

                TextColor = Color.FromHex("333333")
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    defaultStyle.TextColor = Color.FromHex("D42A28");
                }

                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.FontAttributes = FontAttributes.Bold;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor = Color.FromRgb(115, 174, 239);
                    }
                    else
                    {
                        defaultStyle.TextColor       = Color.FromHex("999999");
                        defaultStyle.BackgroundColor = Color.FromHex("E5E5E5");
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.TextColor = Color.White;
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
Beispiel #28
0
        /// <summary>
        /// 重新设置单元格
        /// </summary>
        private void InitCells()
        {
            int column = 0; int row = 0;

            MainPanel.RowCount = 6;
            DateTime currMonth = new DateTime(displayDate.Year, displayDate.Month, 1);
            DateTime currDay   = new DateTime();

            currDay = currMonth.AddDays((double)(0 - currMonth.DayOfWeek));
            CalendarCell currCell = new CalendarCell();

            #region 填充单元格
            while (column < 7 && row < 6)
            {
                HFDate  lunarProcessor = new HFDate(currDay);
                DayInfo currDayInfo    = new DayInfo();
                currDayInfo.date    = currDay;
                currDayInfo.animal  = animalNames[lunarProcessor.LunarYear.Zhi.IntValue - 1];
                currDayInfo.lunarM  = lunarProcessor.LunarCalendarMonth;
                currDayInfo.lunarD  = lunarProcessor.LunarCalendarDay;
                currDayInfo.ganZhi  = lunarProcessor.LunarYear.Name + "年";
                currDayInfo.ganZhiM = lunarProcessor.LunarMonth.Name + "月";
                currDayInfo.ganZhiD = lunarProcessor.LunarDay.Name + "日";
                currDayInfo.lunarMS = lunarProcessor.LunarCalendarMonthString;
                currDayInfo.lunarDS = lunarProcessor.LunarCalendarDayString;
                currDayInfo.term    = lunarProcessor.SolarTermInfo;

                currDayInfo.isHoliday      = IsHoliday(ref currDayInfo); //加入节假日判断
                currDayInfo.isLunarHoliday = IsLunarHoliday(ref currDayInfo);

                currCell         = (CalendarCell)MainPanel.GetControlFromPosition(column, row);
                currCell.Visible = true;

                SetCellText(currCell, currDayInfo);
                SetCellColor(currCell);
                if (currDayInfo.date.Date == displayDate.Date)
                {
                    cColumn = column; cRow = row;
                    CellClicked(currCell, new EventArgs());
                }

                column++;
                if (column > 6)
                {
                    column = 0;
                    row++;
                }

                currDay = currDay.AddDays(1);
            }

            CalendarCell tmpCell = (CalendarCell)MainPanel.GetControlFromPosition(0, 5);
            if (((DayInfo)tmpCell.Tag).date.Month != displayDate.Date.Month)
            {
                for (int i = 0; i < 7; i++)
                {
                    tmpCell         = (CalendarCell)MainPanel.GetControlFromPosition(i, 5);
                    tmpCell.Visible = false;
                }
            }

            #endregion
            oldDate = displayDate;
            return;
        }
Beispiel #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a calendar control grid column that hosts calendar (date) cells.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static DataGridViewColumn CreateCalendarControlColumn(string name, string headerText,
			Func<DateTime> getDefaultValue, CalendarCell.UserAction whenToUseDefault)
		{
			var col = new CalendarColumn(getDefaultValue, whenToUseDefault);
			col.HeaderCell.Style.Font = SystemFonts.MenuFont;
			col.Name = name;
			col.HeaderText = headerText;

			return col;
		}
Beispiel #30
0
        // >> calendar-features-cellstyling-evaluatecellstyle
        private CalendarCellStyle EvaluateCellStyle(CalendarCell cell)
        {
            var background = Device.OnPlatform(Color.White, Color.White, Color.FromRgb(30, 30, 30));
            var selectedCellForegroundColor = Device.OnPlatform(Color.White, Color.FromRgb(139, 209, 0), Color.White);
            var dayNamesFontSize            = Device.OnPlatform(14, 15, 17);
            var fontSize             = Device.OnPlatform(14, 15, 17);
            var todayBorderThickness = Device.OnPlatform(new Thickness(2), new Thickness(1), new Thickness(2));
            var todayBorderColor     = Color.FromRgb(115, 174, 239);

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.LightGray,
                    FontSize = dayNamesFontSize,
                    FontWeight = FontWeight.Bold,
                    ForegroundColor = Color.FromRgb(0, 122, 255)
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = background,
                FontSize        = fontSize,
                FontWeight      = FontWeight.Normal,
                ForegroundColor = Color.FromRgb(139, 209, 0)
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(0, 122, 255);
                        defaultStyle.FontWeight      = FontWeight.Bold;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = todayBorderColor;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                    else
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(166, 181, 137);
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.ForegroundColor = selectedCellForegroundColor;
                    defaultStyle.BorderColor     = Color.FromHex("FF0066CC");
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
Beispiel #31
0
 /// <summary>
 /// 方向键被按下
 /// </summary>
 /// <param name="direction">方向:1.上;2.右;3.下;4.左</param>
 private void ArrowKeyPressed(int direction)
 {
     DayInfo info = new DayInfo();
     CalendarCell cell = new CalendarCell();
     switch (direction)
     {
         case 1:
             if (cRow == 0)
             {
                 cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                 info = (DayInfo)cell.Tag;
                 displayDate = info.date.Date.AddDays(-7);
                 CheckDateChange();
                 return;
             }
             else { cRow--; }
             break;
         case 2:
             if (cColumn == 6)
             {
                 if (cRow == 5)
                 {
                     cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                     info = (DayInfo)cell.Tag;
                     displayDate = info.date.Date.AddDays(1);
                     CheckDateChange();
                     return;
                 }
                 else
                 { cColumn = 0; cRow++; }
             }
             else
             { cColumn++; }
             break;
         case 3:
             if (cRow == 5)
             {
                 cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                 info = (DayInfo)cell.Tag;
                 displayDate = info.date.Date.AddDays(7);
                 CheckDateChange();
                 return;
             }
             else
             { cRow++; }
             break;
         case 4:
             if (cColumn == 0)
             {
                 if (cRow == 0)
                 {
                     cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
                     info = (DayInfo)cell.Tag;
                     displayDate = info.date.Date.AddDays(-1);
                     CheckDateChange();
                     return;
                 }
                 else
                 { cColumn = 6; cRow--; }
             }
             else
             { cColumn--; }
             break;
     }
     cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow);
     CellClicked(cell, new EventArgs());
 }
        /// <summary>
        /// This method will create a date drop downin the specified cell.
        /// </summary>
        public void CreateDateDropDownInCell(DataGridViewCell Cell)
        {
            CalendarCell DateEditor = new CalendarCell();

            ReplaceCell(Cell, DateEditor);
        }
Beispiel #33
0
 public static void Click(this CalendarCell cell)
 {
     cell.Container.Click();
 }
Beispiel #34
0
 public static void WaitNotFilled(this CalendarCell cell, string errorMessage = "") => cell.WaitFilled(false, errorMessage);
Beispiel #35
0
		private void GetReportArgs(ReportParameterInfoCollection rpic)
		{
			int i = 0;

			dgvParameters.Rows.Clear();
			foreach (ReportParameterInfo rp in rpic)
			{
				try
				{
					Object customCell = null;

					if (rp.ValidValues != null)
					{
						DataGridViewComboBoxCell cbCell = new DataGridViewComboBoxCell();

						int ii = 0;
						string[] vals = new string[rp.ValidValues.Count];
						foreach (object o in rp.ValidValues)
							vals[ii++] = ((Microsoft.Reporting.WinForms.ValidValue)o).Value;

						cbCell.Items.AddRange(vals);
						customCell = cbCell;
					}
					else if (rp.DataType.Equals(ParameterDataType.DateTime))
					{
						CalendarCell calCell = new CalendarCell();
						customCell = calCell;
					}
					else
					{
						DataGridViewTextBoxCell dgt = new DataGridViewTextBoxCell();
						customCell = dgt;
					}

					if (    !rp.Name.Equals("Portfolio") &&
							!rp.Name.Equals("Consolidate") &&
							!rp.Name.Equals("AccountingFilters"))
						continue;

					dgvParameters.Rows.Add();

					DataGridViewTextBoxCell dgtLabel = new DataGridViewTextBoxCell();
					dgtLabel.Value = rp.Name;
					dgvParameters[0, i] = dgtLabel;

					((DataGridViewCell)customCell).Value = argLookup[rp.Name];
					dgvParameters[1, i] = (DataGridViewCell)customCell;
					i++;
				}
				catch (Exception ex)
				{
					Console.Write(ex);
				}
			}
		}
        // >> calendar-features-cellstyling-evaluatecellstyle
        private CalendarCellStyle EvaluateCellStyle(CalendarCell cell)
        {
            Color     background = default(Color);
            Color     selectedCellForegroundColor = default(Color);
            Color     todayBorderColor            = Color.FromRgb(115, 174, 239);
            double    dayNamesFontSize            = default(double);
            double    fontSize             = default(double);
            Thickness todayBorderThickness = default(Thickness);

            switch (Device.RuntimePlatform)
            {
            case "iOS":
                background = Color.White;
                selectedCellForegroundColor = Color.White;
                fontSize             = 14;
                dayNamesFontSize     = 14;
                todayBorderThickness = new Thickness(2);
                break;

            case "Android":
                background = Color.White;
                selectedCellForegroundColor = Color.FromRgb(139, 209, 0);
                fontSize             = 15;
                dayNamesFontSize     = 15;
                todayBorderThickness = new Thickness(1);
                break;

            case "UWP":
                background = Color.FromRgb(30, 30, 30);
                selectedCellForegroundColor = Color.White;
                fontSize             = 17;
                dayNamesFontSize     = 17;
                todayBorderThickness = new Thickness(2);
                break;
            }

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.LightGray,
                    FontSize = dayNamesFontSize,
                    FontAttributes = FontAttributes.Bold,
                    TextColor = Color.FromRgb(0, 122, 255)
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = background,
                FontSize        = fontSize,
                FontAttributes  = FontAttributes.None,
                TextColor       = Color.FromRgb(139, 209, 0)
            };

            if (cell is CalendarDayCell dayCell)
            {
                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor       = Color.FromRgb(0, 122, 255);
                        defaultStyle.FontAttributes  = FontAttributes.Bold;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor       = todayBorderColor;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                    else
                    {
                        defaultStyle.TextColor = Color.FromRgb(166, 181, 137);
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.TextColor   = selectedCellForegroundColor;
                    defaultStyle.BorderColor = Color.FromHex("FF0066CC");
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
        // GET: Calendar
        public async Task <ActionResult> Index()
        {
            var client = new MeetingClient(_config);

            var meetings = await client.GetPlanning();

            var x        = meetings.Count + 1;
            var y        = meetings[0].Attendees.Count() + 2;
            var calendar = new Calendar(x, y);

            // Add roles
            int m = meetings[0].Attendees.Count();

            calendar[0, 0] = new CalendarCell {
                AttendeeId = 0, Value = string.Empty
            };
            calendar[0, 1] = new CalendarCell {
                AttendeeId = 0, Value = string.Empty
            };

            int k = 0;

            foreach (var attendee in meetings[0].Attendees)
            {
                calendar[0, k + 2] = new CalendarCell {
                    AttendeeId = 0, Value = attendee.Role.Name
                };

                k++;
            }

            int    i = 0, j = 0;
            string value;

            CalendarCell cell;

            foreach (var meeting in meetings)
            {
                i++;
                j = 0;

                // Add Date
                value          = meeting.Date.ToLocalTime().ToString("yyyy-MM-dd");
                calendar[i, 0] = new CalendarCell {
                    MeetingId = meeting.Id, AttendeeId = 0, Value = value
                };

                // Add subject
                calendar[i, 1] = new CalendarCell {
                    MeetingId = meeting.Id, AttendeeId = 0, Value = meeting.Name
                };

                j = 2;

                // Add member
                foreach (var attendee in meeting.Attendees)
                {
                    value = attendee.Member?.Name ?? string.Empty;
                    cell  = new CalendarCell {
                        MeetingId = meeting.Id, AttendeeId = attendee.Id, Value = value
                    };

                    if (null == attendee.Member)
                    {
                        cell.CanAccept = true;
                    }
                    else
                    {
                        cell.CanRefuse = true;
                    }

                    calendar[i, j] = cell;

                    j++;
                }
            }

            return(View(calendar));
        }