コード例 #1
0
        public GlDoc ChosenDoc()
        {
            if (comboDocs.SelectedItem == null)
            {
                return(null);
            }

            DocWrapper chosen_wrapper = (DocWrapper)comboDocs.SelectedItem;

            return(chosen_wrapper._api_doc);
        }
コード例 #2
0
        private void buttonDeleteDoc_Click(object sender, EventArgs e)
        {
            GlDoc current_doc = CurrentSelectedDoc();
            GlDoc ref_doc     = current_doc.IsReferenced();

            if (ref_doc != null)
            {
                MessageBox.Show("Another document (" + DocWrapper.FindDocName(ref_doc) + ") has a reference to this document.");
                return;
            }

            current_doc.Delete();
            RebuildDocList();
        }
コード例 #3
0
ファイル: DocWrapper.cs プロジェクト: amoun00/Contributions
        public string PropertyDisplayStr(string property_name)
        {
            switch (_api_doc.PropertyType(property_name))
            {
            case GlDoc.ValueType.DOCUMENT:
                List <GlDoc> docrefs = _api_doc.GetDocs(property_name);
                if (docrefs == null)
                {
                    return(FindDocName(_api_doc.GetDoc(property_name)));
                }
                else
                {
                    switch (docrefs.Count)
                    {
                    case 0:
                        return("(empty list)");

                    case 1:
                        return(DocWrapper.FindDocName(docrefs[0]));

                    default:
                        return(DocWrapper.FindDocName(docrefs[0]) + ", " + DocWrapper.FindDocName(docrefs[1]) + ", ...");
                    }
                }

            case GlDoc.ValueType.STRING:
                List <string> multivals = _api_doc.GetStrings(property_name);
                if (multivals == null)
                {
                    return(_api_doc.GetString(property_name));
                }
                else
                {
                    switch (multivals.Count)
                    {
                    case 0:
                        return("empty list");

                    case 1:
                        return(multivals[0]);

                    default:
                        return(multivals[0] + ", " + multivals[1] + ", ...");
                    }
                }

            default:
                return("");
            }
        }
コード例 #4
0
        private void buttonNewDoc_Click(object sender, EventArgs e)
        {
            if (CurrentDocSet == null)
            {
                return;
            }
            InputDialog new_name_dlg = new InputDialog();

            new_name_dlg.SetInstr("Name of new document ..."); // in this example we're assuming that "name" will be required for nodes
            new_name_dlg.ShowDialog();
            if (new_name_dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                DocWrapper.CreateDocument(CurrentDocSet, new_name_dlg.TextValue.Trim());
                RebuildDocList();
            }
        }
コード例 #5
0
 private void RebuildDocList()
 {
     treeDocs.Nodes.Clear();
     if (CurrentDocSet != null)
     {
         foreach (GlDoc loop_doc in CurrentDocSet.AllDocs)
         {
             Guid       doc_guid = loop_doc.DocUID;
             DocWrapper doc_wrap = new DocWrapper(loop_doc);
             TreeNode   docnode  = treeDocs.Nodes.Add(doc_guid.ToString(), doc_wrap.DocName);
             foreach (string loop_property in doc_wrap.CustomPropertyNames())
             {
                 docnode.Nodes.Add(doc_guid.ToString() + "-" + loop_property, loop_property + ": " + doc_wrap.PropertyDisplayStr(loop_property));
             }
         }
     }
     treeDocs.Refresh();
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: amoun00/Contributions
 private void RebuildDocList()
 {
     treeDocs.Nodes.Clear();
     if (CurrentDocSet != null)
     {
         foreach (GlDoc loop_doc in CurrentDocSet.AllDocs)
         {
             Guid doc_guid = loop_doc.DocUID;
             DocWrapper doc_wrap = new DocWrapper(loop_doc);
             TreeNode docnode = treeDocs.Nodes.Add(doc_guid.ToString(), doc_wrap.DocName);
             foreach (string loop_property in doc_wrap.CustomPropertyNames())
             {
                 docnode.Nodes.Add(doc_guid.ToString() + "-" + loop_property, loop_property + ": " + doc_wrap.PropertyDisplayStr(loop_property));
             }
         }
     }
     treeDocs.Refresh();
 }
コード例 #7
0
ファイル: frmDocEditor.cs プロジェクト: amoun00/Contributions
        private void DisplayValues()
        {
            labelPropVal.Visible = false;
            panelMulti.Visible   = false;

            string chosen_prop = ChosenPropStr();

            if (chosen_prop == "")
            {
                return;
            }

            switch (chosen_prop)
            {
            case "Address":
            case "Favorite color":
                labelPropVal.Visible = true;
                labelPropVal.Text    = CurrentDoc.GetString(chosen_prop);
                break;

            case "Spouse":
                labelPropVal.Visible = true;
                GlDoc target_doc = CurrentDoc.GetDoc(chosen_prop);
                if (target_doc == null)
                {
                    labelPropVal.Text = "";
                }
                else
                {
                    labelPropVal.Text = DocWrapper.FindDocName(target_doc);
                }
                break;

            case "Children":
                panelMulti.Visible = true;
                List <DocWrapper> children = new List <DocWrapper>();
                foreach (GlDoc child_doc in CurrentDoc.GetDocs(chosen_prop))
                {
                    children.Add(new DocWrapper(child_doc));
                }
                listPropVals.DisplayMember = "DocName";
                listPropVals.DataSource    = new BindingList <DocWrapper>(children);
                break;

            case "Favorite foods":
                panelMulti.Visible = true;
                List <string> yum = CurrentDoc.GetStrings(chosen_prop);
                listPropVals.DisplayMember = "";
                try
                {
                    listPropVals.DataSource = new BindingList <string>(yum);     // ?
                }
                catch { }
                break;

            default:
                MessageBox.Show("oops");
                break;
            }

            buttonEdit.Visible = labelPropVal.Visible;
            //buttonClear.Visible = labelPropVal.Visible;
        }