Tasque.TaskCalendar.ShowCalendar C# (CSharp) Method

ShowCalendar() public method

public ShowCalendar ( ) : void
return void
        public void ShowCalendar()
        {
            popup = new Window(WindowType.Popup);
            popup.Screen = parent.Screen;

            Frame frame = new Frame();
            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);
            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            //Requisition req = SizeRequest();

            parent.GdkWindow.GetOrigin(out xPos, out yPos);
            //			popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3);
            popup.Move(xPos, yPos);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                     Gdk.EventMask.ButtonPressMask
                                     | Gdk.EventMask.ButtonReleaseMask
                                     | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success) {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success) {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            } else {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelected += OnCalendarDaySelected;
            cal.MonthChanged += OnCalendarMonthChanged;

            cal.Date = date;
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Modify the due date or completion date depending on whether the
        /// task being modified is completed or active.
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/>
        /// </param>
        /// <param name="args">
        /// A <see cref="Gtk.EditedArgs"/>
        /// </param>
        void OnDateEdited(object sender, Gtk.EditedArgs args)
        {
            if (args.NewText == null) {
                Debug.WriteLine ("New date text null, not setting date");
                return;
            }

            Gtk.TreeIter iter;
            Gtk.TreePath path = new TreePath (args.Path);
            if (!Model.GetIter (out iter, path))
                return;

            //  2/11 - Today
            //  2/12 - Tomorrow
            //  2/13 - Wed
            //  2/14 - Thu
            //  2/15 - Fri
            //  2/16 - Sat
            //  2/17 - Sun
            // --------------
            //  2/18 - In 1 Week
            // --------------
            //  No Date
            // ---------------
            //  Choose Date...

            DateTime newDate = DateTime.MinValue;
            DateTime today = DateTime.Now;
            Task task = Model.GetValue (iter, 0) as Task;

            if (args.NewText.CompareTo (
                            today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today") ) == 0)
                newDate = today;
            else if (args.NewText.CompareTo (
                        today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow") ) == 0)
                newDate = today.AddDays (1);
            else if (args.NewText.CompareTo (Catalog.GetString ("No Date")) == 0)
                newDate = DateTime.MinValue;
            else if (args.NewText.CompareTo (
                today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week")	) == 0)
                newDate = today.AddDays (7);
            else if (args.NewText.CompareTo (Catalog.GetString ("Choose Date...")) == 0) {
                TaskCalendar tc = new TaskCalendar(task, this.Parent);
                tc.ShowCalendar();
                return;
            } else {
                for (int i = 2; i <= 6; i++) {
                    DateTime testDate = today.AddDays (i);
                    if (testDate.ToString(Catalog.GetString("M/d - ddd")).CompareTo (
                            args.NewText) == 0) {
                        newDate = testDate;
                        break;
                    }
                }
            }

            Console.WriteLine ("task.State {0}", task.State);

            // Modify the due date
            task.DueDate = newDate;
        }
All Usage Examples Of Tasque.TaskCalendar::ShowCalendar