예제 #1
0
        private void AddPage(Widget widget)
        {
            HBox hbox = new HBox();
            hbox.PackStart(new Label("Label"));
            Button closeButton = new Button("X");
            closeButton.Relief = ReliefStyle.None;
            closeButton.FocusOnClick = false;
            closeButton.Clicked += delegate {
                hbox.Destroy();
                widget.Destroy();
            };

            hbox.PackStart(closeButton);
            hbox.ShowAll();
            notebook.AppendPage(widget, hbox);
            notebook.ShowAll();
        }
        protected void OnButtonPickDatePeriodClicked(object sender, EventArgs e)
        {
            #region Widget creation
            Window parentWin = (Window)Toplevel;
            var selectDate = new Dialog ("Укажите период", parentWin, DialogFlags.DestroyWithParent);
            selectDate.Modal = true;
            selectDate.AddButton ("Отмена", ResponseType.Cancel);
            selectDate.AddButton ("Ok", ResponseType.Ok);

            periodSummary = new Label();
            selectDate.VBox.Add(periodSummary);

            HBox hbox = new HBox (true, 6);

            StartDateCalendar = new Calendar ();
            StartDateCalendar.DisplayOptions = DisplayOptions;
            StartDateCalendar.Date = StartDateOrNull ?? DateTime.Today;
            StartDateCalendar.DaySelected += StartDateCalendar_DaySelected;

            EndDateCalendar = new Calendar ();
            EndDateCalendar.DisplayOptions = DisplayOptions;
            EndDateCalendar.Date = EndDateOrNull ?? DateTime.Today;
            EndDateCalendar.DaySelected += EndDateCalendar_DaySelected;

            hbox.Add (StartDateCalendar);
            hbox.Add (EndDateCalendar);

            selectDate.VBox.Add (hbox);
            selectDate.ShowAll ();
            #endregion

            int response = selectDate.Run ();
            if (response == (int)ResponseType.Ok) {
                startDate = StartDateCalendar.GetDate ();
                endDate = EndDateCalendar.GetDate ();
                OnPeriodChanged ();
            }

            #region Destroy
            EndDateCalendar.Destroy ();
            StartDateCalendar.Destroy ();
            hbox.Destroy ();
            selectDate.Destroy ();
            #endregion
        }