Ejemplo n.º 1
0
        public static void ExportRecent()
        {
            BaseDatabase MyDatabase = CreateDatabase();


            // get list of GUIDS changed in the last 12 hours
            List <string> GuidsChanged = GetListOfLayoutsChangedRecently(12);

            // Create Export/Timed, if necessary
            string exportDirectory = Path.Combine(LayoutDetails.Instance.Path, "export");

            exportDirectory = Path.Combine(exportDirectory, "timed");
            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }
            else
            {
                // Delete all files in Export/Timed

                string[] files = Directory.GetFiles(exportDirectory);
                foreach (string s in files)
                {
                    File.Delete(s);
                }
            }
            int count = 0;

            //string temp = "";
            foreach (string guid in GuidsChanged)
            {
                //	temp = temp + Environment.NewLine + guid;
                count++;
                string THISGUID = guid;
                THISGUID = guid.Replace("{", "");
                THISGUID = THISGUID.Replace("}", "");
                string name     = MasterOfLayouts.GetNameFromGuid(THISGUID);
                string filename = String.Format("{0}_{1}{2}", name, THISGUID, ".txt");
                filename = FileUtils.MakeValidFilename(filename);
                ExportLayout(guid, Path.Combine(exportDirectory, filename));
            }
            NewMessage.Show(Loc.Instance.GetStringFmt("Exported {0} files", count));

            //NewMessage.Show (temp);



            MyDatabase.Dispose();
        }
        /// <summary>
        /// Updates the list of layouts.
        /// </summary>
        /// <param name='_CurrentFilter'>
        /// _ current filter.
        /// </param>
        void UpdateListOfLayouts(string _CurrentFilter)
        {
            this.list.DataSource = null;
            this.list.Items.Clear();

//			MasterOfLayouts master = new MasterOfLayouts ();
//			this.list.DataSource = master.GetListOfLayouts ("filternotdone");
            //DataView view = new DataView(MasterOfLayouts.GetListOfLayouts (CurrentFilterName));

            // if we are the system note we need to override this
            // to use ourself because the table lookup is not yet loaded
            LayoutPanelBase OverridePanelToUse = null;            //LayoutDetails.Instance.TableLayout;

            if (LayoutDetails.Instance.TableLayout == null)
            {
                OverridePanelToUse = Layout;
            }

            List <MasterOfLayouts.NameAndGuid> ListOfItems = MasterOfLayouts.GetListOfLayouts(_CurrentFilter, TextEditor.Text, FullTextSearch.Checked, OverridePanelToUse);

//			for (int i = ListOfItems.Count - 1; i >= 0; i--)
//			{
//				if (TextEditor.Text != Constants.BLANK)
//				{
//					if (ListOfItems[i].Caption.IndexOf(TextEditor.Text) > -1)
//					{
//
//					}
//					else
//					{
//						ListOfItems.Remove (ListOfItems[i]);
//					}
//				}
//			}
            this.list.DataSource = ListOfItems;

            this.list.DisplayMember = "Caption";
            this.list.ValueMember   = "Guid";


            ///master.Dispose ();

            count.Text = Loc.Instance.GetStringFmt("Count = {0}", this.list.Items.Count);
        }
Ejemplo n.º 3
0
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren(Layout);
            ReadOnlyButton.CheckOnClick = false;
            string linkfile = GetLink();


            ToolStripButton SetupLinkButton = new ToolStripButton();

            SetupLinkButton.Text   = Loc.Instance.GetString("Paste Link");
            SetupLinkButton.Click += HandleSetupLinkClick;

            ToolStripButton RefreshLinkButton = new ToolStripButton();

            RefreshLinkButton.Text   = Loc.Instance.GetString("Refresh Link");
            RefreshLinkButton.Click += HandleRefreshLinkClick;


            properties.DropDownItems.Add(SetupLinkButton);
            properties.DropDownItems.Add(RefreshLinkButton);



            if (linkfile != Constants.BLANK)
            {
                if (this.richBox.Text == Constants.BLANK)
                {
                    string[] links = linkfile.Split(new char[1] {
                        '.'
                    });
                    if (links.Length == 2)
                    {
                        // we have a valid link
                        LayoutGuid = links[0];
                        ChildGuid  = links[1];
                        if (LayoutGuid != Constants.BLANK && ChildGuid != Constants.BLANK)
                        {
                            // now retrieve parent
                            NoteDataInterface note = MasterOfLayouts.GetNoteFromInsideLayout(LayoutGuid, ChildGuid);

                            // TODO: if null then iterate through all CHILDREN PANELS???
                            if (null == note)
                            {
                                System.Collections.Generic.List <string> children = MasterOfLayouts.GetListOfChildren(LayoutGuid);
                                foreach (string child in children)
                                {
                                    note = MasterOfLayouts.GetNoteFromInsideLayout(child, ChildGuid);
                                    if (note != null)
                                    {
                                        break;
                                    }
                                }
                            }


                            if (note != null)
                            {
                                if (true == note.IsLinkable)
                                {
                                    SetData(note);
                                }
                            }
                            else
                            {
                                string name = MasterOfLayouts.GetNameFromGuid(LayoutGuid);
                                if (Constants.BLANK != name)
                                {
                                    this.richBox.Text = name;
                                }
                                else
                                {
                                    this.richBox.Text = Loc.Instance.GetStringFmt("There is a link but the target does not appear to be imported yet. Guid is {0}", linkfile);
                                }
                            }



                            // now grab child text
                        }
                    }

                    else
                    {
                        this.richBox.Text = Loc.Instance.GetStringFmt("There is a link but the target does not appear to be imported yet. Guid is {0}", linkfile);
                    }
                }
            }
            else
            {
                this.richBox.Text = Loc.Instance.GetString("Start a link by selecting the note you want to link to and select the Link option. Then return here to set the link up");
            }

            Button GoToLayout = new Button();

            GoToLayout.Dock    = DockStyle.Top;
            GoToLayout.Text    = Loc.Instance.GetString("Go To Link");
            GoToLayout.Enabled = false;
            GoToLayout.Click  += HandleGoToLayoutClick;
            if (LayoutGuid != Constants.BLANK)
            {
                GoToLayout.Enabled = true;
            }

            ParentNotePanel.Controls.Add(GoToLayout);
            GoToLayout.BringToFront();
            richBox.BringToFront();
        }
Ejemplo n.º 4
0
 List <string> BuildLinkList()
 {
     return(MasterOfLayouts.ReciprocalLinks(GUID));
 }