public TemplateView()
            {
                ShowBorderLine          = true;
                tree                    = new TemplateTreeView();
                tree.Selection.Changed += delegate
                {
                    if (SelectionChanged != null)
                    {
                        SelectionChanged(this, EventArgs.Empty);
                    }
                };
                tree.RowActivated += delegate
                {
                    if (DoubleClicked != null)
                    {
                        DoubleClicked(this, EventArgs.Empty);
                    }
                };

                Add(tree);
                HscrollbarPolicy = PolicyType.Automatic;
                VscrollbarPolicy = PolicyType.Automatic;
                ShadowType       = ShadowType.None;
                ShowAll();
            }
        private void Initialize()
        {
            if (m_TemplateTreeViewState == null)
            {
                m_TemplateTreeViewState = new TreeViewState();
            }

            m_TemplateTreeView = new TemplateTreeView(m_TemplateTreeViewState);
            EditorInputTemplateCache.onRefresh += m_TemplateTreeView.Reload;

            // Expand controls, devices, and products toplevel items.
            m_TemplateTreeView.SetExpanded(1, true);
            m_TemplateTreeView.SetExpanded(2, true);
            m_TemplateTreeView.SetExpanded(3, true);
        }
Exemple #3
0
        private MongoJsonEditor(MongoJsonEditorViewModel viewModel, FunctionDesigner context)
            : this()
        {
            base.DataContext   = viewModel;
            viewModel.Designer = context;
            base.Title         = viewModel.Title;
            foreach (var source in viewModel.TemplateSources)
            {
                var treeView = new TemplateTreeView(source);
                templateTabs.Items.Add(treeView);
            }

            viewModel.InitialiseDocument(this.textEditor.Document);
            Watermark.Visibility    = String.IsNullOrEmpty(textEditor.Text) ? Visibility.Visible : Visibility.Hidden;
            textEditor.TextChanged += (sender, e) => HideWatermark();
            textEditor.GotFocus    += (sender, e) => HideWatermark();
            textEditor.LostFocus   += (sender, e) => HideWatermark();
        }
Exemple #4
0
        /// <summary>
        /// Sélection des templates en prenant ceux du repository et ceux spécifiques à la strategie
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            // Récupération des templates du repository
            List <string> templates = RepositoryManager.Instance.GetT4TemplatesList();

            // Puis ceux local à la stratégie
            StrategyBase strategy = context.Instance as StrategyBase;

            if (strategy != null)
            {
                DirectoryInfo di = new DirectoryInfo(strategy.MapPath(String.Empty));
                if (di.Exists)
                {
                    foreach (FileInfo fi in di.GetFiles("*.t4"))
                    {
                        templates.Add("0\\" + Path.GetFileNameWithoutExtension(fi.Name));
                    }
                }
            }

            FilterTemplates(templates);

            IWindowsFormsEditorService uiService =
                (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            TemplateTreeView tv = new TemplateTreeView(uiService, templates, CurrentCategoryName);

            uiService.DropDownControl(tv);
            if (tv.SelectedName == null)
            {
                return(value);
            }
            string val = tv.SelectedName;

            if (val.StartsWith(CurrentCategoryName) && val.Length > CurrentCategoryName.Length)
            {
                return(val.Substring(CurrentCategoryName.Length + 1));
            }
            return(tv.SelectedName);
        }
			public TemplateView ()
			{
				tree = new TemplateTreeView ();
				tree.Selection.Changed += delegate {
					if (SelectionChanged != null)
						SelectionChanged (this, EventArgs.Empty);
				};
				tree.RowActivated += delegate {
					if (DoubleClicked != null)
						DoubleClicked (this, EventArgs.Empty);
				};
				Add (tree);
				HscrollbarPolicy = PolicyType.Automatic;
				VscrollbarPolicy = PolicyType.Automatic;
				ShadowType = ShadowType.In;
				ShowAll ();
			}
        private void OnMenuClick(object sender, EventArgs e)
        {
            string senderName = ((ToolStripItem)sender).Name;

            switch (senderName)
            {
            case "M_About":
            case "T_About":
                using (AboutForm form = new AboutForm()) form.ShowDialog();
                return;

            case "M_File_New":
            case "T_File_New":
                Template.Clear();
                TreeViewEditor.UpdateAllNodes();
                GenerateMission();
                return;

            case "M_File_Open":
            case "T_File_Open":
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Filter           = "BriefingRoom templates (*.brt)|*.brt";
                    ofd.RestoreDirectory = true;
                    if ((ofd.ShowDialog() == DialogResult.OK) && File.Exists(ofd.FileName))
                    {
                        Template.LoadFromFile(ofd.FileName);
                        TreeViewEditor.UpdateAllNodes();
                        GenerateMission();
                    }
                }
                return;

            case "M_File_SaveAs":
            case "T_File_SaveAs":
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter           = "BriefingRoom templates (*.brt)|*.brt";
                    sfd.RestoreDirectory = true;
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        Template.SaveToFile(sfd.FileName);
                    }
                }
                return;

            case "M_File_Exit": Close(); return;

            case "T_CollapseAll": TemplateTreeView.CollapseAll(); return;

            case "M_Mission_Export":
            case "T_Mission_Export":
                if (Mission == null)
                {
                    return;
                }
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter           = "DCS World missions (*.miz)|*.miz";
                    sfd.FileName         = Mission.MissionName + ".miz";
                    sfd.RestoreDirectory = true;
                    sfd.InitialDirectory = Toolbox.GetDCSMissionPath();
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        ExportToMiz(sfd.FileName);
                    }
                }
                return;

            case "M_Mission_ExportBriefingHTML":
            case "T_Mission_ExportBriefingHTML":
                if (Mission == null)
                {
                    return;
                }
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter           = "HTML pages (*.html)|*.html";
                    sfd.FileName         = Mission.MissionName + ".html";
                    sfd.RestoreDirectory = true;
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllText(sfd.FileName, Mission.BriefingHTML);
                    }
                }
                return;

            case "M_Mission_Generate":
            case "T_Mission_Generate":
                GenerateMission();
                return;

#if DEBUG
            case "M_Mission_DebugExport":
                if (Mission == null)
                {
                    return;                      // No mission to export
                }
                Toolbox.CreateDirectoryIfMissing(BRPaths.DEBUGOUTPUT);
                using (MizFile miz = Mission.ExportToMiz())
                    miz.SaveToDirectory(BRPaths.DEBUGOUTPUT);
                return;
#endif
            case "M_Tools_CampaignCreator":
                using (CampaignCreatorForm campaignForm = new CampaignCreatorForm())
                    campaignForm.ShowDialog();
                return;
            }
        }