Ejemplo n.º 1
0
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren(Layout);
            CaptionLabel.Dock = DockStyle.Top;
            CaptionLabel.SuspendLayout();

            if (null != dataSource)
            {
            }
            else
            {
                NewMessage.Show(Loc.Instance.GetString("CreateParent: You have a null datasource"));
                lg.Instance.Line("NoteDataXML_Table->CreateParent", ProblemType.WARNING, Loc.Instance.GetString("You have a null table which should not happen. This usually occurs only during UNIT TESTING because proper create constructor is not used"));
                BuildDefaultColumns();
            }
            lg.Instance.Line("NoteDataXML_Table-CreateParent", ProblemType.MESSAGE, String.Format("Passing {0} columns into new TablePanel", Columns.Length));
            Table = new TablePanel(dataSource, HandleCellBeginEdit, Columns, GoToNote, this.Caption, GetRandomTableResults);
            lg.Instance.Line("NoteDataXML_Table->CreateParent", ProblemType.MESSAGE, String.Format("Before HANDLEDATABINING my name is {0}", this.Caption));
            Table.Parent = ParentNotePanel;
            Table.Dock   = DockStyle.Fill;
            Table.BringToFront();
            Table.ReadOnly = this.ReadOnly;



            ToolStripMenuItem TableCaptionLabel =
                LayoutDetails.BuildMenuPropertyEdit(Loc.Instance.GetString("Table Caption: {0}"), TableCaption, Loc.Instance.GetString("When generating random data this caption will be used to present the results."), HandleNoteLinkNameChange);



            ToolStripMenuItem NextTableLabel =
                LayoutDetails.BuildMenuPropertyEdit(Loc.Instance.GetString("Next Table: {0}"), NextTable, Loc.Instance.GetString("Set a value here and if the random results of this table resolve without finding a 'NextTable' in the table itself, it will proceed with randomization on the table specified here."), HandleNextTableKeyDown);

            useHeadingStyleOption              = new ToolStripButton();
            useHeadingStyleOption.Text         = Loc.Instance.GetString("Use Heading Styled Captions");
            useHeadingStyleOption.CheckOnClick = true;
            useHeadingStyleOption.Checked      = useHeadingStyleForCaption;
            useHeadingStyleOption.Click       += (object sender, EventArgs e) =>
            {
                SetSaveRequired(true);
                useHeadingStyleForCaption = useHeadingStyleOption.Checked;
            };



            properties.DropDownItems.Add(new ToolStripSeparator());
            properties.DropDownItems.Add(TableCaptionLabel);
            properties.DropDownItems.Add(NextTableLabel);
            properties.DropDownItems.Add(useHeadingStyleOption);
            CaptionLabel.ResumeLayout();
        }
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren(Layout);
            CaptionLabel.Dock = DockStyle.Top;


            if (TableCreated == false)
            {
                Width  = 500;
                Height = 200;
                ParentNotePanel.Width  = Width;
                ParentNotePanel.Height = Height;

                TimelineStartDate = DateTime.Today;

                // A. Create the Table
                NoteDataXML_Table myTable = new NoteDataXML_Table(100, 100, new ColumnDetails[7] {
                    new ColumnDetails("Date", 50),
                    new ColumnDetails("Type", 50),
                    new ColumnDetails("Data", 50),
                    new ColumnDetails("Data2", 50),
                    new ColumnDetails("Data3", 50),
                    new ColumnDetails("Data4", 50),
                    new ColumnDetails("icon", 50)
                });
                string GuidOfTable = this.GuidForNote + "table";
                myTable.GuidForNote = GuidOfTable;

                myTable.Caption = Loc.Instance.GetStringFmt("Table for Timeline");



                Layout.AddNote(myTable);

                // we do not need to call CreateParent because AddNote does it for us
                //myTable.CreateParent (Layout);
                Save();
                myTable.AddRow(new object[7] {
                    DateTime.Today.ToString(), "100", "Example Description", "Example Title", "", "", 2
                });
                TableCreated = true;
                Save();
                // B. Populate it with example Row
            }
            Timeline      = new NotePanelTimeline(this);
            Timeline.Dock = DockStyle.Fill;
            ParentNotePanel.Controls.Add(Timeline);
            Timeline.dayPanelWidth = DayPanelWidth;
            Timeline.BringToFront();

            RowFilterStrip =
                LayoutDetails.BuildMenuPropertyEdit(Loc.Instance.GetString("Row Filter: {0}"), RowFilter, Loc.Instance.GetString("Filter via the columns on the table associated with this timeline."), HandleRowFilterChange);



            ToolStripSeparator sep = new ToolStripSeparator();


            ToolStripComboBox dropper = new ToolStripComboBox();



            dropper.ToolTipText   = Loc.Instance.GetString("Set the type of timeline you want by selecting an appropriate calendar.");
            dropper.DropDownStyle = ComboBoxStyle.DropDownList;
            foreach (Calendar.calendertype calendertype in Enum.GetValues(typeof(Calendar.calendertype)))
            {
                dropper.Items.Add(calendertype.ToString());
            }
            dropper.Text = MCalendarType.ToString();
            dropper.SelectedIndexChanged += HandleSelectedIndexCalendarPickerChanged;



            // Icons Per Column. We had the edit to a ToolStrip Host and add the Host to the toolstrip
            NumericUpDown numbers = new NumericUpDown();


            Panel numbersPanel = new Panel();

            numbersPanel.BackColor = dropper.BackColor;
            Label numbersLabel = new Label();

            numbersLabel.Left = 0;
            //numbersLabel.Dock = DockStyle.Left;
            numbersLabel.Text     = Loc.Instance.GetString("Icons/Column: ");
            numbersLabel.AutoSize = false;
            numbersLabel.Width    = 85;
            numbers.Left          = 90;
            numbers.Width         = 45;
            //numbersLabel.AutoSize = true;
            //numbers.Dock = DockStyle.Right;

            numbersPanel.Controls.Add(numbersLabel);
            numbersPanel.Controls.Add(numbers);
            numbersLabel.BringToFront();
            //numbersPanel.Dock = DockStyle.Fill;


            numbers.Value         = IconsPerColumn;
            numbers.ValueChanged += HandleIconsPerColumnValueChanged;
            numbers.Minimum       = 1;
            numbers.Maximum       = 20;
            ToolStripControlHost iconsPerColumn = new ToolStripControlHost(numbersPanel);


            // Day Width
            ToolStripControlHost setDayWidth = BuildDayWidth(dropper.BackColor);


            DateTimePicker dates = new DateTimePicker();

            dates.Width = 125;
            try {
                dates.Value = this.TimelineStartDate;
            } catch (Exception) {
                dates.Value = DateTime.Today;
            }
            dates.ValueChanged += HandleValueCurrentdateChanged;
            ToolStripControlHost dateToolStrip = new ToolStripControlHost(dates);

            dateToolStrip.ToolTipText = Loc.Instance.GetString("Select a date to center the timeline on that date.");



            properties.DropDownItems.Add(sep);
            properties.DropDownItems.Add(dropper);
            properties.DropDownItems.Add(iconsPerColumn);
            properties.DropDownItems.Add(setDayWidth);
            properties.DropDownItems.Add(RowFilterStrip);
            properties.DropDownItems.Add(dateToolStrip);


            // add hjistory to RowFilterStrip
            foreach (string history in RowHistory)
            {
                ToolStripMenuItem test = new ToolStripMenuItem(history);
                test.Click += delegate(object sender, EventArgs e){ RowFilter = RowFilterStrip.Text = test.Text; Timeline.Refresh(); };
                RowFilterStrip.DropDownItems.Add(test);
            }

            //
            //
            // Hide ZOom Panel
            //
            //
            ToolStripButton HideMonths = new ToolStripButton();

            HideMonths.Text         = Loc.Instance.GetString("Hide Months Panel");
            HideMonths.CheckOnClick = true;
            HideMonths.Checked      = this.HideZoomOutPanel;
            HideMonths.Click       += HandleHideMonthsClick;

            properties.DropDownItems.Add(HideMonths);
            // Adjust panel as needed; also add this to the menu too
            Timeline.HideZoomPanel(this.HideZoomOutPanel);
        }