/// <summary> /// Gets the table for this timeline. /// </summary> /// <returns> /// The table for this timeline. /// </returns> /// <param name='TimelineTableGuid'> /// We pass in the GUID to allow other tables to be found (i.e., if you have made a list of tables to associate with this timeline) /// </param> public NoteDataXML_Table GetTableForThisTimeline(string TimelineTableGuid) { NoteDataXML_Table FoundTable = (NoteDataXML_Table)Layout.FindNoteByGuid(TimelineTableGuid); // April 1 2013 - this may make things TOO SLOW // but only way to guarantee al ive connection when the TIMELINE is not in the same panel as the TABLES FoundTable = (NoteDataXML_Table)Layout.GoToNote(FoundTable); if (null == FoundTable && false == errorthrown) { // just throw message once. NewMessage.Show(Loc.Instance.GetString("The table for this Timeline was not found. Probably the guid of it needs to be set to its caption.")); errorthrown = true; //throw new Exception("The table for this Timeline was not found"); } return(FoundTable); }
private static NoteDataXML_Table LoadStringAsTable(string data) { // Loading existing table System.IO.StringReader LinkTableReader = new System.IO.StringReader(data); System.Xml.Serialization.XmlSerializer LinkTableXML = new System.Xml.Serialization.XmlSerializer(typeof(NoteDataXML_Table)); NoteDataXML_Table table = new NoteDataXML_Table(); table = (NoteDataXML_Table)LinkTableXML.Deserialize(LinkTableReader); // if (table != null) // { // MyLinkTable.SetTable (table.dataSource); // } //NewMessage.Show("Loading a link table with GUID = " + table.GuidForNote); LinkTableXML = null; LinkTableReader.Close(); LinkTableReader.Dispose(); return(table); }
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); }
public static System.Collections.Generic.List <string> ReciprocalLinks(string myLayoutGuid) { NoteDataXML_Table table = BuildLinMasterLinkTable(); // returns a list of (Page Names.Guids) which will be links to Layouts // that are linked to me or notes inside me // if (combinedResult != Constants.BLANK) { // // Loading existing table // System.IO.StringReader LinkTableReader = new System.IO.StringReader (combinedResult); // System.Xml.Serialization.XmlSerializer LinkTableXML = new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML_Table)); // // // // table = (NoteDataXML_Table)LinkTableXML.Deserialize (LinkTableReader); // // if (table != null) // // { // // MyLinkTable.SetTable (table.dataSource); // // } // //NewMessage.Show("Loading a link table with GUID = " + table.GuidForNote); // LinkTableXML = null; // LinkTableReader.Close (); // LinkTableReader.Dispose (); // // } // if (table != null) { // // } //NewMessage.Show("Combined row count " + table.RowCount().ToString()); // 2 - search the parent.child column where child=myGuid // and retrieve the (group) column this list is a list of guids in form parent.child (the LinkNote) List <string> result = new List <string>(); if (table != null) { DataView dataView = ((DataTable)table.dataSource).DefaultView; //dataView.Tables.Add(); // ((DataTable)table.dataSource).RowFilter=""; // The GUID we have is the LayoutGuid, so the Parent.* of the eqution dataView.RowFilter = String.Format("linkid Like '{0}.%'", myLayoutGuid); foreach (DataRowView row in dataView) { // if linkid is equal // add group AFTER translating string doubleguid = row[CoreUtilities.Links.LinkTable.GROUP].ToString(); // this will be in parent.child form string[] guids = doubleguid.Split(new char[1] { '.' }); if (guids != null && guids.Length == 2) { string guid = guids[0]; string name = GetNameFromGuid(guid); if (IsSubpanel(guid) == true) { // if we are a subpanel string parentGuid = GetSubpanelsParent(guid); if (ExistsByGUID(parentGuid) == true) { name = GetNameFromGuid(parentGuid); } } result.Add(String.Format("{0}.{1}", name, guid)); } } } // 3 - go through and parse the parent. part of the parent.child guids and return a list of // Name.parentguid return(result); }
protected static NoteDataXML_Table BuildLinMasterLinkTable() { NoteDataXML_Table table = null; BaseDatabase MyDatabase = CreateDatabase(); // 0 - GetValues (all linktable columns) easy List <object[]> results = MyDatabase.GetValues(dbConstants.table_name, new string[1] { dbConstants.LINKTABLE }, "any", "*"); string combinedResult = Constants.BLANK; //int record = 0; //NoteDataXML_Table table = null; if (results != null && results.Count > 0) { foreach (object[] row in results) { if (row.Length > 0) { if (row [0].ToString() != Constants.BLANK) { if (table != null) { // now load secondtable and copy rows over NoteDataXML_Table secondTable = LoadStringAsTable(row [0].ToString()); foreach (DataRow drow in secondTable.GetRows()) { object[] values = drow.ItemArray; values [0] = null; //DBNull.Value;//DBNull.Value; table.AddRow(values); } } else { table = LoadStringAsTable(row [0].ToString()); } // if (row[0].ToString ().IndexOf("<DocumentElement>") > -1) // { // record++; // if (1 == record) // { // // combinedResult = row[0].ToString (); // // the first time we add it in a special way // // int index_of_end = combinedResult.IndexOf("</DocumentElement>"); // if (index_of_end > -1) // { // // chop string // combinedResult = combinedResult.Substring (0, index_of_end); // } // else // { // throw new Exception("Invalid table passed in"); // } // // cut the bottom part off // // // //NewMessage.Show (row[0].ToString()); // // } // }//DocumentElement exists // else // { // // now we add each row // } } } } // we rebuild the text to be a proper table // string END_TEXT = " </DocumentElement></diffgr:diffgram> </dataSource> </NoteDataXML_Table>"; // combinedResult = combinedResult + END_TEXT; } // 1 - Consolidage all LinkTables hard --> requires: MyDatabase.Dispose(); return(table); }
/// <summary> /// will go through each "next" table from the source one /// the calling object /// and generateresults /// /// /// /// /// </summary> /// <returns></returns> public static string GenerateAllResults(ref string nextTable, DataTable currentTable, string Title, string Core_Table, LayoutPanelBase Layout, bool useHeadingStyle) { // probably should save first too but not sure // how to integrate that string sOriginalNextTable = nextTable; if (null == Layout) { throw new Exception("You must have a valid Layout loaded when doing a random table traversal."); } // do first table System.Collections.ArrayList notelist = Layout.GetAllNotes(); NoteDataInterface[] notes = new NoteDataInterface[notelist.Count]; notelist.CopyTo(notes); resultReturn sResult = GenerateResult(0, currentTable, ref nextTable, Title, notes, useHeadingStyle); // now, if there are more tables //classPageTable tables = this; if (sResult.sResult == " \n") { sResult.sResult = Constants.BLANK; } while (nextTable != null && nextTable != Constants.BLANK) { // looks for the note called start NoteDataXML_Table table = null; bool LINEAR_MODE = false; if (nextTable[0] == '-') { // Linear table system. // a -X (any number, with a minus preceding it) represents a row // basically we want to stay on the current table but go to the next row table = (NoteDataXML_Table)Layout.FindNoteByName(Core_Table); LINEAR_MODE = true; } else { // Grab the next table NoteDataInterface potentialTable = Layout.FindNoteByName(nextTable); if (potentialTable is NoteDataXML_Table) { table = (NoteDataXML_Table)potentialTable; // sep 28 2011 // linear table system // if we encounter a 'real table' reference that means // to set the Core Table to that Core_Table = nextTable; } } //NotePanelTable table = (NotePanelTable)desktop.GetPanelByName(nextTable); resultReturn newResult; if (table != null) { string old_next_table = nextTable; string _caption = ""; // table.Caption; if (table.TableCaption != "") { _caption = table.TableCaption; } // see note A below for why we have this check if (LINEAR_MODE == true && table.NextTable == "") { // leave nextable alone in Lienar mode // needed for when we call a linear table from another table (instead of calling the linear table directly) } else { nextTable = table.NextTable; // this is clearing the row field! } newResult = GenerateResult(sResult.nModifier, (DataTable)table.dataSource, ref nextTable, _caption, notes, useHeadingStyle); /* NOTE A September 28 2011 * There is a WEIRD pointer thing happening and working in my favor * Basically because AppearanceClass.NextTable is passed as a ref into GenerateAllResults it is modified directly * when we set Generate the next result * basically we continue to setting this value (not sure why the breakpoint never succeeded though) * * So... I don't want to mess everything, so if we are in LINEAR mode then we * manualy set the table. */ // if (nextTable == old_next_table) //{ // nextTable = Header.Blank; // } // nextTable = table.NextTable; if (newResult.sResult == " \n") { newResult.sResult = Constants.BLANK; } sResult.sResult = sResult.sResult + newResult.sResult; sResult.nModifier = newResult.nModifier; } else { // if we hit a null then we hit user error // abort nextTable = Constants.BLANK; } } nextTable = sOriginalNextTable; return(sResult.sResult); }