private void OnButtonPlayClick(Object sender, EventArgs args)
        {
            try
            {
                this.tbbSave.Enabled = false;

                String source = this.source;

                if (String.IsNullOrWhiteSpace(source))
                {
                    source = System.IO.File.ReadAllText(this.txtFilename.Text);
                }

                GeneratorSettings settings = new GeneratorSettings
                {
                    RootClass     = this.txtRootClass.Text,
                    Namespace     = this.txtNamespace.Text,
                    IsAllInOne    = this.chkAllInOne.Checked,
                    SourceType    = (SourceType)this.cmbSourceType.SelectedItem,
                    TargetType    = (TargetType)this.cmbTargetType.SelectedItem,
                    MemberType    = (MemberType)this.cmbMemberType.SelectedItem,
                    AttributeType = (AttributeType)this.cmbAttributeType.SelectedItem
                };

                IEnumerable <ICode> codes = Generators.ModelGenerator.Generate(settings, source);

                this.tbcCode.TabPages.Clear();

                foreach (ICode code in codes)
                {
                    CodeTabPage page = new CodeTabPage(code);

                    this.tbcCode.Controls.Add(page);
                }
            }
            catch (Exception exception)
            {
                this.ShowError(exception);
                return;
            }
            finally
            {
                this.tbbSave.Enabled = this.tbcCode.TabPages.Count > 0;
            }
        }
Exemple #2
0
        /// <summary>
        /// Öffnet Datei.
        /// </summary>
        /// <param name="Path">Pfad der Datei</param>
        private void openFile(string Path)
        {
            if (System.IO.Path.GetExtension(Path) != "")
            {
                bool fileOpened = false;

                foreach (TabPage tp in tabControl.TabPages)
                {
                    if (tp.Text == System.IO.Path.GetFileName(Path))
                    {
                        fileOpened = true;
                    }
                }

                if (fileOpened == false)
                {
                    //Wenn Datei noch nicht geöffnet
                    string      tabPageName = System.IO.Path.GetFileName(Path);
                    CodeTabPage t           = Tabs.Tabs.CreateNewCodeTabPage(tabPageName);

                    System.IO.StreamReader sr = new System.IO.StreamReader(Path);
                    string tcode = "";

                    tcode += sr.ReadToEnd();

                    sr.Close();

                    t.fasColoredTextBox.Text = tcode;

                    tabControl.TabPages.Add(t);
                    tabControl.SelectTab(tabControl.TabPages.IndexOf(t));
                }
                else
                {
                    //Wenn Datei geöffnet
                    foreach (TabPage tp in tabControl.TabPages)
                    {
                        if (tp.Text == System.IO.Path.GetFileName(Path))
                        {
                            tabControl.SelectedTab = tp;
                        }
                    }
                }
            }
        }