public AutoComplete(Form owner, TagsStorage tagsStorage)
        {
            InitializeComponent();

            this.Owner = owner;
            this.Owner.Click += new EventHandler(Generic_LostFocus);
            this.tagsStorage = tagsStorage;
        }
        public AutoComplete_OLD(Form owner, TagsStorage tagsStorage)
        {
            InitializeComponent();
            this.owner = owner;
            this.owner.Click += new EventHandler(control_LostFocus);
            tvList.GotFocus += new EventHandler(listBox1_GotFocus);

            //TagsLoader tagsLoader = new TagsLoader(xmlPath);
            //this.tagsStorage = tagsLoader.LoadTags();
            this.tagsStorage = tagsStorage;
        }
Example #3
0
 // string.substring
 private void GetParentPath(ArrayList list, TagsStorage tagsStorage, bool includeRoot)
 {
     if (tagsStorage.Parent != null)
     {
         list.Add(tagsStorage.Value);
         GetParentPath(list, tagsStorage.Parent, includeRoot);
     }
     else
     {
         if (includeRoot == true)
         {
             list.Add(tagsStorage.Value);
         }
     }
 }
        public SyntaxHighlightingMenager(TagsStorage tagsStorage)
        {
            //
            this.controls = new ControlCollection();
            this.controls.ControlAdded += new EventHandler(controls_ControlAdded);

            //
            TagsShow tagsShow = new TagsShow(tagsStorage);
            tagsShow.ShowOnlyTagsOfObjectType = true;
            // get array list of tags from tagsStorage object
            tagsList = tagsShow.GetTagsList();

            // costum sort
            TagsSortClass tagsSortClass = new TagsSortClass();
            tagsList.Sort(tagsSortClass);
            Log.Write(tagsList, this, "SyntaxHighlightingMenager", Log.LogType.DEBUG);
        }
Example #5
0
        private void ShowTreeView(TreeNode treeNode, TagsStorage tagsStorage)
        {
            TreeNode newTreeNode;

            foreach (TagsStorage tags in tagsStorage)
            {
                // if showOnlyTagsOfObjectType is true and type is object then skip this tagsStorage
                if ( this.showOnlyTagsOfObjectType == false || (tags.Type == TagsStorage.TagsStorageType.Object && this.showOnlyTagsOfObjectType == true))
                {
                    newTreeNode = new TreeNode(tags.Value);
                    // tag object hold referenc to tags storage object
                    newTreeNode.Tag = tags;
                    newTreeNode.ToolTipText = tags.Desctiption;
                    treeNode.Nodes.Add(newTreeNode);
                    ShowTreeView(newTreeNode, tags);
                }
            }
        }
 //public TagsLoader()
 //{
 //    this.path = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder) + GenericTemplate.constTagsXMLFileName;
 //}
 public TagsStorage LoadTags()
 {
     TagsStorage rootNode = null;
     XmlDocument xmlDoc;
     if (File.Exists(this.path))
     {
         xmlDoc = new XmlDocument();
         try
         {
             rootNode = new TagsStorage("{=", TagsStorage.TagsStorageType.Object);
             xmlDoc.Load(path);
             LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags"));
         }
         catch (XmlException ex)
         {
             Log.Write(ex, this, "LoadTags", Log.LogType.ERROR);
         }
         catch (Exception ex)
         {
             Log.Write(ex, this, "LoadTags", Log.LogType.ERROR);
         }
     }
     return rootNode;
 }
        private void tvList_DoubleClick(object sender, EventArgs e)
        {
            TagsStorage tagsStorage;
            int oldSelectionStart;
            string tagBlock;
            int lastIndexOf;

            if (tvList.SelectedNode != null)
            {
                tagsStorage = (TagsStorage)tvList.SelectedNode.Tag;
                oldSelectionStart = activeControl.SelectionStart;
                tagBlock = GetTagBlock(activeControl.Text, activeControl.SelectionStart);

                if (tagBlock.Length > 2)
                {
                    lastIndexOf = activeControl.Text.LastIndexOf('.', activeControl.SelectionStart - 1, tagBlock.Length);
                    if (lastIndexOf != -1)
                    {
                        activeControl.SelectionStart = lastIndexOf + 1;
                    }
                    else
                    {
                        activeControl.SelectionStart = oldSelectionStart - tagBlock.Length + 2;
                    }
                    activeControl.SelectionLength = oldSelectionStart - activeControl.SelectionStart;

                }

                activeControl.SelectedText = tagsStorage.Value;
                if (tagsStorage.Type == TagsStorage.TagsStorageType.String)
                {
                    activeControl.SelectionStart = activeControl.SelectionStart - 1;
                }
                control_LostFocus(sender, null);
            }
        }
 private void tvList_AfterSelect(object sender, TreeViewEventArgs e)
 {
     TagsStorage tagsStorage;
     tagsStorage = (TagsStorage)e.Node.Tag;
     ttToolTip.Show(tagsStorage.Desctiption, this, this.Width, this.Height / 3);
 }
        private void LoadXMLChild(TagsStorage tagsStorage, XmlNode xmlNode)
        {
            TagsStorage newTagsStorage;
            TagsStorage.TagsStorageType tagsStorageType;
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    if (node.Name == "tag")
                    {
                        tagsStorageType = TagsStorage.GetTypeFromString(node.Attributes["type"].Value);

                        if (node.Attributes["type"] != null)
                        {
                            // check if node is type of object

                            // ovo staviti pod isti i, jer je isto code
                            if (node.Attributes["type"].Value == "object")
                            {
                                if (tagsStorage != null)
                                {
                                    // if TagsStorage is not null then build nodes
                                    newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagsStorageType);
                                    tagsStorage.Add(newTagsStorage);
                                    if (node.HasChildNodes)
                                    {
                                        LoadXMLChild(newTagsStorage, node);
                                    }
                                }
                                else
                                {
                                    Log.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", Log.LogType.WARNING);
                                }
                            }
                            else
                            {
                                if (tagsStorage != null)
                                {
                                    // if TagsStorage is not null then build nodes
                                    newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagsStorageType);
                                    tagsStorage.Add(newTagsStorage);
                                    if (node.HasChildNodes)
                                    {
                                        LoadXMLChild(newTagsStorage, node);
                                    }
                                }
                                else
                                {
                                    Log.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", Log.LogType.WARNING);
                                }
                            }
                        }
                        else
                        {
                            Log.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", Log.LogType.WARNING);
                        }
                    }
                    else if (node.Name == "syntax")
                    {
                        tagsStorage.Syntax = node.InnerText;
                    }
                    else if (node.Name == "result")
                    {
                        //lblResult.Text = "Result: " + node.InnerText;
                    }
                    else if (node.Name == "example")
                    {
                        //lblExample.Text = "Example: " + node.InnerText;
                    }
                    else if (node.Name == "desctiption")
                    {
                        tagsStorage.Desctiption = node.InnerText;
                    }
                    else
                    {
                        if (node.HasChildNodes)
                        {
                            LoadXMLChild(tagsStorage, node);
                        }
                    }
                }
            }
        }
        private void SelectIthem()
        {
            TagsStorage tagsStorage;
            int oldSelectionStart;
            string tagBlock;
            int lastIndexOf;

            if (tvList.SelectedNode != null)
            {
                tagsStorage = (TagsStorage)tvList.SelectedNode.Tag;
                oldSelectionStart = activeControl.SelectionStart;
                tagBlock = GetTagBlock(activeControl.Text, activeControl.SelectionStart);

                if (tagBlock.Length > 2)
                {
                    lastIndexOf = activeControl.Text.LastIndexOf('.', activeControl.SelectionStart - 1, tagBlock.Length);
                    if (lastIndexOf != -1)
                    {
                        activeControl.SelectionStart = lastIndexOf + 1;
                    }
                    else
                    {
                        activeControl.SelectionStart = oldSelectionStart - tagBlock.Length + 2;
                    }
                    activeControl.SelectionLength = oldSelectionStart - activeControl.SelectionStart;

                }

                activeControl.SelectedText = tagsStorage.Value;
                if (tagsStorage.Type == TagsStorage.TagsStorageType.String)
                {
                    activeControl.SelectionStart = activeControl.SelectionStart - 1;
                }
                HideMe();
            }
        }
Example #11
0
 private void TagStorageToList(ArrayList list, TagsStorage tagsStorage, string separator)
 {
     ArrayList parantList = new ArrayList();
     string parentString = "";
     foreach (TagsStorage tags in tagsStorage)
     {
         // if showOnlyTagsOfObjectType is true and type is object then skip this tagsStorage
         if (this.showOnlyTagsOfObjectType == false || (tags.Type == TagsStorage.TagsStorageType.Object && this.showOnlyTagsOfObjectType == true))
         {
             parentString = "";
             parantList.Clear();
             GetParentPath(parantList, tags.Parent, false);
             for (int i = parantList.Count - 1; i >= 0; i--)
             {
                 parentString = i == parantList.Count - 1 ? string.Concat(parentString, parantList[i].ToString()) : string.Concat(parentString, separator, parantList[i].ToString());
             }
             list.Add(parentString.Equals("") ? tags.Value : string.Concat(parentString, separator, tags.Value));
             if (tags.HasChilds)
             {
                 //parentString = parentString.Equals("") ? tags.Value : string.Concat(parentString, separator, tags.Value);
                 TagStorageToList(list, tags, separator);
             }
         }
     }
 }
Example #12
0
 public TagsShow(TagsStorage tagsStorage)
 {
     this.tagsStorage = tagsStorage;
 }
 /// <summary>
 /// Add new object
 /// </summary>
 /// <param name="tagsStorage"></param>
 public void Add(TagsStorage tagsStorage)
 {
     tagsStorage.parent = this;
     if (tagsList == null)
     {
         tagsList = new ArrayList();
     }
     tagsList.Add(tagsStorage);
 }
Example #14
0
        public ModuleMainForm()
        {
            string templateFolder;
            InitializeComponent();

            try
            {
                // init mode settings
                Settings.Init();
                Settings.Setting.LoadFromFile(Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder) + Settings.FILE_NAME);

                // init and load tagsStorage object
                TagsLoader tagsLoader = new TagsLoader(Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder) + GenericTemplate.constTagsXMLFileName);
                this.tagsStorage = tagsLoader.LoadTags();

                // WindwosTools controls
                twtToolsWindowsTemplates = new ToolsWindowsTemplates();
                twttoolsWindowsTags = new ToolsWindowsTags(this.tagsStorage);
                twttoolsWindowsTags.AddControl(tbtemplateHeader);
                twttoolsWindowsTags.AddControl(tbtemplateBody);
                twttoolsWindowsTags.AddControl(tbtemplateFooter);
                twttoolsWindowsTags.AddControl(tbTemplateVariables);
                twttoolsWindowsTags.AddControl(tbTemplateComment);
                twttoolsWindowsTags.AddControl(tbFileDestinationFolder);
                twttoolsWindowsTags.AddControl(tbFileDestinationFile);

                // general default settings
                cbDataDestination.SelectedIndex = 0;

                // set icon
                this.Icon = global::UberTools.Modules.GenericTemplate.Properties.Resources.WindowsTable;

                // create settings menager object and add all controls
                templateFolder = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder, GenericTemplate.constTemplateFolder);
                settingsMenager = new SettingsMenager();
                settingsMenager.Add(tbtemplateBody);
                settingsMenager.Add(tbtemplateHeader);
                settingsMenager.Add(tbtemplateFooter);
                settingsMenager.Add(tbTemplateVariables);
                settingsMenager.Add(tbTemplateComment);
                settingsMenager.Add(tbFileDestinationFolder);
                settingsMenager.Add(tbFileDestinationFile);
                settingsMenager.Add(chbDestinationFileAppend);
                settingsMenager.Add(cbDataDestination);
                settingsMenager.Add(cbEncoding);

                //// create settings menager version 2 object and add all controls
                settingsMenager2 = new SettingsMenager2(GenericTemplate.constModuleName, "UberToolsModule", "1.0.0.0");
                //settingsMenager2.Items.Add(new SettingsMenagerStructure2(tbtemplateBody, "tbtemplateBody", SettingsMenager2.Type.Textbox));
                settingsMenager2.Refresh += new EventHandler(settingsMenager2_Refresh);
                settingsMenager2.Update += new EventHandler(settingsMenager2_Update);

                // new instance template menager
                templatesMenager = new TemplatesManager(twtToolsWindowsTemplates.TreeViewControl, templateFolder, settingsMenager, settingsMenager2);
                this.twtToolsWindowsTemplates.ImageListControl = this.ilGeneral;
                templatesMenager.LoadAll();

                // set templateMenager to templateControl
                twtToolsWindowsTemplates.TemplatesMenager = templatesMenager;
                this.twtToolsWindowsTemplates.ImageListControl = this.ilGeneral;

                // Create new rowCollection object and bound it to container
                rowCollectionMenager = new RowCollectionMenager(panel1, this.settingsMenager2);
                foreach (EncodingMenager encoding in EncodingMenager.GetEnumerator())
                {
                    cbEncoding.Items.Add(encoding);
                }
                cbEncoding.SelectedIndex = cbEncoding.Items.Count - 2;

                // new instance of hoveringwindows
                autoComplete = new AutoComplete(this, this.tagsStorage);
                autoComplete.AddControl(tbtemplateHeader);
                autoComplete.AddControl(tbtemplateBody);
                autoComplete.AddControl(tbtemplateFooter);
                autoComplete.AddControl(tbTemplateVariables);
                autoComplete.AddControl(tbTemplateComment);
                autoComplete.AddControl(tbFileDestinationFolder);
                autoComplete.AddControl(tbFileDestinationFile);

                //// syntax color init
                //colorMenager = new ColorMenager_old();
                //colorMenager.Controls.Add(tbTemplateVariables);

                // SyntaxHighlightingMenager settings
                syntaxHighlightingMenager = new SyntaxHighlightingMenager(tagsStorage);
                syntaxHighlightingMenager.Controls.Add(tbTemplateVariables);
                syntaxHighlightingMenager.Controls.Add(tbtemplateBody);
                syntaxHighlightingMenager.Controls.Add(tbtemplateHeader);
                syntaxHighlightingMenager.Controls.Add(tbtemplateFooter);
                syntaxHighlightingMenager.Controls.Add(tbFileDestinationFolder);
                syntaxHighlightingMenager.Controls.Add(tbFileDestinationFile);

                // load last loadet template
                if (Settings.Setting.LoadSetting(Settings.SettingName.ActiveTemplateName.ToString(), "") != "")
                {
                    templatesMenager.Load(Settings.Setting.LoadSetting(Settings.SettingName.ActiveTemplateName.ToString(), ""));
                }

            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "ModuleMainForm", ModuleLog.LogType.ERROR);
            }
        }