private void tvTree_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode sourceNode;
            TreeNode destinationNode;
            bool     result;

            // Get the tree.
            TreeView tree = (TreeView)sender;

            // Get the screen point.
            Point pt = new Point(e.X, e.Y);

            // Convert to a point in the TreeView's coordinate system.
            pt = tree.PointToClient(pt);

            // Get the node underneath the mouse.
            destinationNode = tree.GetNodeAt(pt);
            sourceNode      = (TreeNode)e.Data.GetData(typeof(TreeNode));

            result = templatesMenager.Copy(sourceNode, destinationNode);

            if (result == true)
            {
                // Add a child node.
                destinationNode.Nodes.Add((TreeNode)sourceNode.Clone());

                // Show the newly added node if it is not already visible.
                destinationNode.Expand();
                tvTree.Nodes.Remove(sourceNode);
                templatesMenager.LoadAll();
            }
        }
Example #2
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);
            }
        }