示例#1
0
        private void addGoogleSpreadsheetReferenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!GoogleAuthManager.CheckGoogleCredentials(this))
            {
                return;
            }

            var zDialog = new GoogleSpreadsheetBrowser(GoogleReferenceReader.APP_NAME, GoogleReferenceReader.CLIENT_ID,
                                                       CardMakerInstance.GoogleAccessToken, true);

            if (DialogResult.OK == zDialog.ShowDialog(this))
            {
                var bNewDefault = 0 == treeView.SelectedNode.Nodes.Count;
                var zLayout     = (ProjectLayout)treeView.SelectedNode.Tag;
                var tnReference = AddReferenceNode(
                    treeView.SelectedNode,
                    CardMakerConstants.GOOGLE_REFERENCE + CardMakerConstants.GOOGLE_REFERENCE_SPLIT_CHAR +
                    zDialog.SelectedSpreadsheet.Title.Text + CardMakerConstants.GOOGLE_REFERENCE_SPLIT_CHAR +
                    zDialog.SelectedSheet.Title.Text,
                    bNewDefault,
                    zLayout);
                if (null == tnReference)
                {
                    MessageBox.Show(this, "The specified reference is already associated with this layout.", "Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (bNewDefault)
                {
                    tnReference.Parent.Expand();
                    LayoutManager.Instance.RefreshActiveLayout();
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                }
                ProjectManager.Instance.FireProjectUpdated(true);
            }
        }
示例#2
0
        public static void ShowProjectSettings(Form parentForm)
        {
            const string TRANSLATOR = "translator";
            const string DEFAULT_DEFINE_REFERENCE_TYPE = "default_define_reference_type";
            const string OVERRIDE_DEFINE_REFRENCE_NAME = "override_define_reference_name";
            const string JS_ESCAPE_SINGLE_QUOTES       = "js_escape_single_quotes";
            const string JS_TILDE_CODE     = "js_tilde_code";
            const string JS_KEEP_FUNCTIONS = "js_keep_functions";

            var zQuery = new QueryPanelDialog("Project Settings", 550, 300, true);

            zQuery.SetIcon(Resources.CardMakerIcon);

            TranslatorType eTranslator = ProjectManager.Instance.LoadedProjectTranslatorType;
            ReferenceType  eDefaultDefineReferenceType = ProjectManager.Instance.LoadedProjectDefaultDefineReferenceType;

            zQuery.ChangeToTab("Base");

            zQuery.AddPullDownBox("Translator",
                                  Enum.GetNames(typeof(TranslatorType)), (int)eTranslator, TRANSLATOR);

            zQuery.AddPullDownBox("Default Define Reference Type", Enum.GetNames(typeof(ReferenceType)), (int)eDefaultDefineReferenceType, DEFAULT_DEFINE_REFERENCE_TYPE);
            zQuery.AddSelectorBox(
                "Google Project define spreadsheet override",
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName,
                () =>
            {
                if (GoogleAuthManager.CheckGoogleCredentials(parentForm))
                {
                    return(new GoogleSpreadsheetBrowser(new GoogleSpreadsheet(CardMakerInstance.GoogleInitializerFactory), false));
                }
                return(null);
            },
                (zGoogleSpreadsheetBrowser, txtOverride) =>
            {
                txtOverride.Text = new GoogleSpreadsheetReference(zGoogleSpreadsheetBrowser.SelectedSpreadsheet)
                                   .generateSpreadsheetReference();
            },
                OVERRIDE_DEFINE_REFRENCE_NAME);

            zQuery.ChangeToTab("Javascript");
            zQuery.AddCheckBox("Escape Single Quotes", ProjectManager.Instance.LoadedProject.jsEscapeSingleQuotes, JS_ESCAPE_SINGLE_QUOTES);
            zQuery.AddCheckBox("~ Means Code", ProjectManager.Instance.LoadedProject.jsTildeMeansCode, JS_TILDE_CODE);
            zQuery.AddCheckBox("Keep Functions", ProjectManager.Instance.LoadedProject.jsKeepFunctions, JS_KEEP_FUNCTIONS);

            if (DialogResult.OK == zQuery.ShowDialog(parentForm))
            {
                ProjectManager.Instance.LoadedProject.translatorName              = ((TranslatorType)zQuery.GetIndex(TRANSLATOR)).ToString();
                ProjectManager.Instance.LoadedProject.defaultDefineReferenceType  = ((ReferenceType)zQuery.GetIndex(DEFAULT_DEFINE_REFERENCE_TYPE)).ToString();
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName =
                    zQuery.GetString(OVERRIDE_DEFINE_REFRENCE_NAME).Trim();
                ProjectManager.Instance.LoadedProject.jsEscapeSingleQuotes = zQuery.GetBool(JS_ESCAPE_SINGLE_QUOTES);
                ProjectManager.Instance.LoadedProject.jsTildeMeansCode     = zQuery.GetBool(JS_TILDE_CODE);
                ProjectManager.Instance.LoadedProject.jsKeepFunctions      = zQuery.GetBool(JS_KEEP_FUNCTIONS);
                ProjectManager.Instance.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }
示例#3
0
        private void addGoogleSpreadsheetReferenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!GoogleAuthManager.CheckGoogleCredentials(this))
            {
                return;
            }

            var zDialog = new GoogleSpreadsheetBrowser(new GoogleSpreadsheet(CardMakerInstance.GoogleInitializerFactory), true);

            if (DialogResult.OK == zDialog.ShowDialog(this))
            {
                var zGoogleSpreadsheetReference = new GoogleSpreadsheetReference(zDialog.SelectedSpreadsheet)
                {
                    SheetName = zDialog.SelectedSheet
                };
                tryToAddReferenceNode(zGoogleSpreadsheetReference.generateFullReference());
            }
        }
示例#4
0
        public static void ShowProjectSettings(Form parentForm)
        {
            const string TRANSLATOR = "translator";
            const string DEFAULT_DEFINE_REFERENCE_TYPE = "default_define_reference_type";
            const string OVERRIDE_DEFINE_REFRENCE_NAME = "override_define_reference_name";

            var zQuery = new QueryPanelDialog("Project Settings", 550, 300, false);

            zQuery.SetIcon(Resources.CardMakerIcon);

            TranslatorType eTranslator = ProjectManager.Instance.LoadedProjectTranslatorType;
            ReferenceType  eDefaultDefineReferenceType = ProjectManager.Instance.LoadedProjectDefaultDefineReferenceType;

            zQuery.AddPullDownBox("Translator",
                                  Enum.GetNames(typeof(TranslatorType)), (int)eTranslator, TRANSLATOR);

            zQuery.AddPullDownBox("Default Define Reference Type", Enum.GetNames(typeof(ReferenceType)), (int)eDefaultDefineReferenceType, DEFAULT_DEFINE_REFERENCE_TYPE);
            zQuery.AddSelectorBox(
                "Google Project define spreadsheet override",
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName,
                () =>
            {
                if (GoogleAuthManager.CheckGoogleCredentials(parentForm))
                {
                    return(new GoogleSpreadsheetBrowser(GoogleReferenceReader.APP_NAME, GoogleReferenceReader.CLIENT_ID,
                                                        CardMakerInstance.GoogleAccessToken, false));
                }
                return(null);
            },
                (zGoogleSpreadsheetBrowser, txtOverride) => { txtOverride.Text = zGoogleSpreadsheetBrowser.SelectedSpreadsheet.Title.Text; },
                OVERRIDE_DEFINE_REFRENCE_NAME);

            if (DialogResult.OK == zQuery.ShowDialog(parentForm))
            {
                ProjectManager.Instance.LoadedProject.translatorName              = ((TranslatorType)zQuery.GetIndex(TRANSLATOR)).ToString();
                ProjectManager.Instance.LoadedProject.defaultDefineReferenceType  = ((ReferenceType)zQuery.GetIndex(DEFAULT_DEFINE_REFERENCE_TYPE)).ToString();
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName =
                    zQuery.GetString(OVERRIDE_DEFINE_REFRENCE_NAME).Trim();
                ProjectManager.Instance.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }