Example #1
0
 public void Setup()
 {
     _debugTag  = new TextTag("debug");
     _indentTag = new TextTag("indent")
     {
         Indent = 4
     };
     _tagTable = new TextTagTable();
     _tagTable.Add(_debugTag);
     _tagTable.Add(_indentTag);
     _buffer = new TextBuffer(_tagTable);
 }
Example #2
0
        protected void Update()
        {
            List <AlarmData> alarming = Alarm.GetAllAlarming();
            TextBuffer       tb       = tv.Buffer;

            tb.Text = string.Empty;

            foreach (var a in alarming)
            {
                var tag = new TextTag(null);
                if (a.acknowledged)
                {
                    tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                }
                else
                {
                    tag.ForegroundGdk = TouchColor.NewGtkColor("compl");
                }
                TextTagTable ttt = tb.TagTable;
                ttt.Add(tag);

                var ti = tb.EndIter;
                tb.InsertWithTags(ref ti, string.Format("{0:MM/dd hh:mm:ss}: {1}\n", a.postTime, a.name), tag);
            }
        }
Example #3
0
        private void UpdateResults(List <string> results)
        {
            GtkScrolledWindowErrors.Visible = true;
            TextTagTable textResultTags = new TextTagTable();
            var          tagResult      = new TextTag("blue");

            tagResult.Foreground = "blue";
            textResultTags.Add(tagResult);
            TextBuffer tempBuffer = new TextBuffer(textResultTags);
            TextIter   iter       = tempBuffer.EndIter;

            tempBuffer.InsertWithTags(ref iter, String.Join("\n", results), tagResult);
            textviewErrors.Buffer = tempBuffer;
        }
Example #4
0
        private void Export(Export1cMode mode)
        {
            var dateStart = dateperiodpicker1.StartDate;
            var dateEnd   = dateperiodpicker1.EndDate;

            using (var exportOperation = new ExportOperation(new OrderParametersProvider(new ParametersProvider()), mode, dateStart, dateEnd)) {
                this.exportInProgress = true;
                UpdateExportButtonSensitivity();
                LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false);
                this.exportInProgress = false;
                UpdateExportButtonSensitivity();
                exportData = exportOperation.Result;
            }
            this.labelTotalCounterparty.Text = exportData.Objects
                                               .OfType <CatalogObjectNode>()
                                               .Count(node => node.Type == Common1cTypes.ReferenceCounterparty)
                                               .ToString();
            this.labelTotalNomenclature.Text = exportData.Objects
                                               .OfType <CatalogObjectNode>()
                                               .Count(node => node.Type == Common1cTypes.ReferenceNomenclature)
                                               .ToString();
            this.labelTotalSales.Text = exportData.Objects
                                        .OfType <SalesDocumentNode>()
                                        .Count()
                                        .ToString();
            this.labelTotalSum.Text      = exportData.OrdersTotalSum.ToString("C");
            this.labelExportedSum.Markup = String.Format("<span foreground=\"{1}\">{0:C}</span>",
                                                         exportData.ExportedTotalSum,
                                                         exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red");

            this.labelTotalInvoices.Text = exportData.Objects
                                           .OfType <InvoiceDocumentNode>()
                                           .Count()
                                           .ToString();

            GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0;
            if (exportData.Errors.Count > 0)
            {
                TextTagTable textTags = new TextTagTable();
                var          tag      = new TextTag("Red");
                tag.Foreground = "red";
                textTags.Add(tag);
                TextBuffer tempBuffer = new TextBuffer(textTags);
                TextIter   iter       = tempBuffer.EndIter;
                tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag);
                textviewErrors.Buffer = tempBuffer;
            }

            buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0;
        }
Example #5
0
        /// Parse through and create TextTag objects for every
        /// <a href="TextTagName"> found in the message text.
        private TextTagTable CreateTextTagTable(XmlNode topLevelNode)
        {
            TextTagTable textTagTable = new TextTagTable();

            TextTag smallFontTag = new TextTag("small-font");

            smallFontTag.Scale = Pango.Scale.Small;
            textTagTable.Add(smallFontTag);

            XmlNodeList linkNodes = topLevelNode.SelectNodes("//a");

            if (linkNodes != null)
            {
                foreach (XmlNode linkNode in linkNodes)
                {
                    XmlAttribute href = linkNode.Attributes["href"];
                    if (href != null)
                    {
                        string textTagName = href.Value;

                        if (textTagTable.Lookup(textTagName) != null)
                        {
                            continue;
                        }

                        TextTag textTag = new TextTag(textTagName);
                        textTag.Underline  = Pango.Underline.Single;
                        textTag.Foreground = "blue";
                        textTag.TextEvent +=
                            new TextEventHandler(OnTextEvent);
                        textTagTable.Add(textTag);
                    }
                }
            }

            return(textTagTable);
        }
Example #6
0
 /// <summary>
 /// Если метод вернул true, это значит что есть ошибки.
 /// </summary>
 bool UpdateErrors(List <string> errors)
 {
     GtkScrolledWindowErrors.Visible = errors.Any();
     if (errors.Any())
     {
         TextTagTable textTags = new TextTagTable();
         var          tag      = new TextTag("Red");
         tag.Foreground = "red";
         textTags.Add(tag);
         TextBuffer tempBuffer = new TextBuffer(textTags);
         TextIter   iter       = tempBuffer.EndIter;
         tempBuffer.InsertWithTags(ref iter, String.Join("\n", errors), tag);
         textviewErrors.Buffer = tempBuffer;
         return(true);
     }
     return(false);
 }
Example #7
0
        public Editor(Gtk.Window parent)
        {
            Parent = parent;
            View   = new Box(Orientation.Vertical, 0);

            // Load services
            storage = GlobalDI.GetService <IDocumentsStorage>();

            // Init widgets
            var scrolled = new ScrolledWindow()
            {
                Expand = true
            };

            View.StyleContext.AddClass("view");

            FormatBar      = new FormatBar(Orientation.Horizontal, 6);
            FormatRevealer = new Revealer();
            FormatRevealer.Add(FormatBar);

            FormatRevealer.RevealChild = false;

            TextTagTable tagTable = new TextTagTable();

            foreach (var tag in Tags)
            {
                tagTable.Add(tag.Value);
            }
            TextBuffer        = new TextBuffer(tagTable);
            SerializeFormat   = TextBuffer.RegisterSerializeTagset("text/markdown");
            DeserializeFormat = TextBuffer.RegisterDeserializeTagset("text/markdown");
            EditorView        = new EditorView(TextBuffer);
            scrolled.Add(EditorView);

            View.PackStart(FormatRevealer, false, true, 0);
            View.PackEnd(scrolled, true, true, 0);
        }
Example #8
0
        private void Export(Export1cMode mode)
        {
            var dateStart = dateperiodpicker1.StartDate;
            var dateEnd   = dateperiodpicker1.EndDate;

            int?organizationId = null;

            if (mode == Export1cMode.BuhgalteriaOOONew)
            {
                organizationId = (comboOrganization.SelectedItem as Organization)?.Id;
            }
            else if (mode == Export1cMode.BuhgalteriaOOO)
            {
                organizationId = new OrganizationParametersProvider(_parametersProvider).VodovozOrganizationId;
            }

            using (var exportOperation = new ExportOperation(
                       mode,
                       new OrderParametersProvider(_parametersProvider),
                       dateStart,
                       dateEnd,
                       organizationId
                       ))
            {
                this.exportInProgress = true;
                UpdateExportSensitivity();
                LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false);
                this.exportInProgress = false;
                UpdateExportSensitivity();
                exportData = exportOperation.Result;
            }

            labelTotalCounterparty.Text = exportData.Objects
                                          .OfType <CatalogObjectNode>()
                                          .Count(node => node.Type == Common1cTypes.ReferenceCounterparty)
                                          .ToString();

            labelTotalNomenclature.Text = exportData.Objects
                                          .OfType <CatalogObjectNode>()
                                          .Count(node => node.Type == Common1cTypes.ReferenceNomenclature)
                                          .ToString();

            labelTotalSales.Text = (exportData.Objects
                                    .OfType <SalesDocumentNode>()
                                    .Count()
                                    + exportData.Objects.OfType <RetailDocumentNode>().Count())
                                   .ToString();

            labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU"));

            labelExportedSum.Markup =
                $"<span foreground=\"{(exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red")}\">" +
                $"{exportData.ExportedTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU"))}</span>";

            labelTotalInvoices.Text = exportData.Objects
                                      .OfType <InvoiceDocumentNode>()
                                      .Count()
                                      .ToString();

            GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0;
            if (exportData.Errors.Count > 0)
            {
                TextTagTable textTags = new TextTagTable();
                var          tag      = new TextTag("Red");
                tag.Foreground = "red";
                textTags.Add(tag);
                TextBuffer tempBuffer = new TextBuffer(textTags);
                TextIter   iter       = tempBuffer.EndIter;
                tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag);
                textviewErrors.Buffer = tempBuffer;
            }

            buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0;
        }
        private void ConfigureDlg()
        {
            ybuttonExport.Clicked += (sender, e) => {
                var parentWindow  = GetParentWindow(this);
                var folderChooser = new FileChooserDialog("Выберите папку выгрузки", parentWindow, FileChooserAction.SelectFolder,
                                                          Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Accept)
                {
                    DoOverwriteConfirmation = true,
                };
                folderChooser.ShowAll();
                if ((ResponseType)folderChooser.Run() == ResponseType.Accept)
                {
                    if (folderChooser.CurrentFolder == null)
                    {
                        folderChooser.Destroy();
                        return;
                    }
                    ViewModel.FolderPath = folderChooser.CurrentFolder;
                    var shortpath = folderChooser.CurrentFolder;
                    if (folderChooser.CurrentFolder.Length > 25)
                    {
                        shortpath = "..." + shortpath.Substring(shortpath.Length - 25);
                    }
                    ybuttonExport.Label = shortpath;
                    folderChooser.Destroy();
                }
                else
                {
                    folderChooser.Destroy();
                }
            };

            enummenubuttonExport.ItemsEnum        = typeof(ExportType);
            enummenubuttonExport.EnumItemClicked += (sender, e) => {
                ViewModel.ExportCommand.Execute(e.ItemEnum);
            };

            enummenubuttonLoadActions.ItemsEnum        = typeof(LoadAction);
            enummenubuttonLoadActions.EnumItemClicked += (sender, e) => {
                ViewModel.LoadActionCommand.Execute(e.ItemEnum);
            };

            enummenubuttonConfirmUpdate.ItemsEnum        = typeof(ConfirmUpdateAction);
            enummenubuttonConfirmUpdate.EnumItemClicked += (sender, e) => {
                ViewModel.ConfirmUpdateDataCommand.Execute(e.ItemEnum);
            };

            ycheckDontChangeSellPrice.Binding.AddBinding(ViewModel, vm => vm.DontChangeSellPrice, w => w.Active);
            ycheckDontChangeSellPrice.Active      = true;
            ycheckDontChangeSellPrice.TooltipText = "При включении у всех заменяемых номенклатур будут удалены все старые цены и будет создана одна новая цена, указанная в файле";

            ybuttonConfirmLoadNew.Clicked += (sender, e) => { ViewModel.ConfirmLoadNewCommand.Execute(); };

            yfilechooserbuttonImport.Binding.AddBinding(ViewModel, vm => vm.FilePath, w => w.Filename);
            var fileFilter = new FileFilter();

            fileFilter.AddPattern("*.csv");
            yfilechooserbuttonImport.Filter = fileFilter;
            yfilechooserbuttonImport.Title  = "Выберите csv файл";

            ytreeviewNomenclatures.ColumnsConfig = FluentColumnsConfig <NomenclatureCatalogNode> .Create()
                                                   .AddColumn("Действие")
                                                   .MinWidth(120)
                                                   .AddComboRenderer(x => x.ConflictSolveAction)
                                                   .SetDisplayFunc(x => x.GetEnumTitle())
                                                   .FillItems(((ConflictSolveAction[])Enum.GetValues(typeof(ConflictSolveAction))).ToList())
                                                   .AddSetter((c, n) => {
                c.Editable = n.Source == Source.File && n.Status == NodeStatus.Conflict && n.DuplicateOf != null && ViewModel.CurrentState == LoadAction.LoadNew;
                switch (ViewModel.CurrentState)
                {
                case LoadAction.LoadNew:
                    if (n.DuplicateOf == null || n.Source == Source.Base || !c.Editable)
                    {
                        c.Text = "";
                    }
                    break;

                case LoadAction.UpdateData:
                    if (n.ConflictSolveAction != ConflictSolveAction.Ignore)
                    {
                        c.Text = "";
                    }
                    break;
                }
            })
                                                   .AddColumn("Источник")
                                                   .AddEnumRenderer((x) => x.Source)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Статус")
                                                   .AddTextRenderer((x) => x.Status.GetEnumTitle())
                                                   .XAlign(0.5f)
                                                   .AddColumn("ID номенклатуры")
                                                   .AddTextRenderer(x => x.Id.ToString())
                                                   .AddSetter((c, n) => { if (n.Id == null)
                                                                          {
                                                                              c.Text = "Новый";
                                                                          }
                                                              })
                                                   .XAlign(0.5f)
                                                   .AddColumn("Наименование")
                                                   .AddTextRenderer(x => x.Name)
                                                   .WrapMode(Pango.WrapMode.WordChar)
                                                   .WrapWidth(400)
                                                   .AddColumn("ID группы товаров")
                                                   .AddNumericRenderer(x => x.GroupId)
                                                   .XAlign(0.5f)
                                                   .AddColumn("ID поставщика")
                                                   .AddNumericRenderer(x => x.ShipperCounterpartyId)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Цена продажи")
                                                   .AddNumericRenderer(x => x.SellPrice).Digits(2).WidthChars(10)
                                                   .XAlign(1)
                                                   .AddColumn("Единицы измерения")
                                                   .AddNumericRenderer(x => x.MeasurementUnit)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Папка 1С")
                                                   .HeaderAlignment(0.5f)
                                                   .AddNumericRenderer(x => x.Folder1cName)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Категория")
                                                   .HeaderAlignment(0.5f)
                                                   .AddTextRenderer(x => x.NomenclatureCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Объем тары")
                                                   .HeaderAlignment(0.5f)
                                                   .AddTextRenderer(x => x.TareVolume)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Вид оборудования")
                                                   .AddTextRenderer(x => x.EquipmentKindName)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Доступность для продажи")
                                                   .AddTextRenderer(x => x.SaleCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Тип залога")
                                                   .AddTextRenderer(x => x.TypeOfDepositCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Тип топлива")
                                                   .AddTextRenderer(x => x.FuelTypeName)
                                                   .XAlign(0.5f)
                                                   .RowCells()
                                                   .AddSetter((CellRendererText c, NomenclatureCatalogNode n) => {
                c.CellBackgroundGdk = GetGdkColor(n.BackgroundColor);
                c.ForegroundGdk     = GetGdkColor(n.ForegroundColor);
            })
                                                   .Finish();

            ViewModel.PropertyChanged += (sender, e) => {
                Application.Invoke((s, args) => {
                    if (e.PropertyName == nameof(ViewModel.ProgressBarValue))
                    {
                        progressbar.Adjustment.Value = ViewModel.ProgressBarValue;
                    }
                    if (e.PropertyName == nameof(ViewModel.ProgressBarUpper))
                    {
                        progressbar.Adjustment.Upper = ViewModel.ProgressBarUpper;
                    }
                    if (e.PropertyName == nameof(ViewModel.Items))
                    {
                        ytreeviewNomenclatures.ItemsDataSource = ViewModel.Items;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmUpdateDataButtonVisible))
                    {
                        enummenubuttonConfirmUpdate.Visible = ViewModel.IsConfirmUpdateDataButtonVisible;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible))
                    {
                        ycheckDontChangeSellPrice.Visible = ViewModel.IsConfirmUpdateDataButtonVisible;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible))
                    {
                        ybuttonConfirmLoadNew.Visible = ViewModel.IsConfirmLoadNewButtonVisible;
                    }
                });
            };

            TextTagTable textTags   = new TextTagTable();
            var          darkredtag = new TextTag("DarkRed");

            darkredtag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkRed);
            textTags.Add(darkredtag);
            var redtag = new TextTag("red");

            redtag.ForegroundGdk = GetGdkColor(ConsoleColor.Red);
            textTags.Add(redtag);
            var greentag = new TextTag("Green");

            greentag.ForegroundGdk = GetGdkColor(ConsoleColor.Green);
            textTags.Add(greentag);
            var darkgreentag = new TextTag("DrakGreen");

            darkgreentag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkGreen);
            textTags.Add(darkgreentag);
            var blackTag = new TextTag("Black");

            blackTag.ForegroundGdk = GetGdkColor(ConsoleColor.Black);
            textTags.Add(blackTag);
            var yellowTag = new TextTag("Yellow");

            yellowTag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkYellow);
            textTags.Add(yellowTag);

            ViewModel.ProgressBarMessagesUpdated += (aList, aIdx) => {
                Application.Invoke((s, args) => {
                    TextBuffer tempBuffer = new TextBuffer(textTags);
                    foreach (ColoredMessage message in ViewModel.ProgressBarMessages)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        switch (message.Color)
                        {
                        case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, blackTag); break;

                        case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkredtag); break;

                        case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, greentag); break;

                        case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, yellowTag); break;

                        case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkgreentag); break;

                        case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, redtag); break;

                        default: throw new NotImplementedException("Цвет не настроен");
                        }
                    }
                    ytextviewProgressStatus.Buffer = tempBuffer;
                    ScrollToEnd();
                });
            };

            ytreeviewNomenclatures.Selection.Changed += (sender, e) => {
                Application.Invoke((s, args) => {
                    ytextviewNodeMessages.Buffer.Clear();
                    TextBuffer tempBuffer = new TextBuffer(textTags);
                    var node = ytreeviewNomenclatures.GetSelectedObject <NomenclatureCatalogNode>();
                    if (node == null)
                    {
                        ytextviewNodeMessages.Buffer.Text = "Выберите запись для просмотра ошибок";
                        return;
                    }
                    foreach (ColoredMessage message in node.ErrorMessages)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        switch (message.Color)
                        {
                        case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", blackTag); break;

                        case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkredtag); break;

                        case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", greentag); break;

                        case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", yellowTag); break;

                        case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkgreentag); break;

                        case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", redtag); break;

                        default: throw new NotImplementedException("Цвет не настроен");
                        }
                    }
                    if (!node.ErrorMessages.Any() && node.Source == Source.File)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        tempBuffer.InsertWithTags(ref iter, "Ошибок нет\n", darkgreentag);
                    }
                    if (node.Source == Source.Base)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        tempBuffer.InsertWithTags(ref iter, "Данные из базы\n", blackTag);
                    }
                    ytextviewNodeMessages.Buffer = tempBuffer;
                    ScrollToEnd();
                });
            };
        }
Example #10
0
		public MainWindow() : base(Gtk.WindowType.Toplevel)
		{
			Build();

			// Be sure to start with a consistent window title.
			InfoTitle = null;

			// Prepare using status bar.
			_SbCtxActivity = this.statusbar1.GetContextId("Activity like loading or cleaning up");
			_SbCtxState = this.statusbar1.GetContextId("State of affairs");
			_SbCtxError = this.statusbar1.GetContextId("Error message, should stay visible");

			// Prepare using TextView.
			TextTagTable tagTable = this.textviewText.Buffer.TagTable;

			// Current notes element
			_TagCurrentNotesElement = new TextTag("current_notes_element");
			_TagCurrentNotesElement.Background = "lightgreen";
			_TagCurrentNotesElement.BackgroundSet = true;
			tagTable.Add(_TagCurrentNotesElement);

			_TagCurrentNotesElementLinewise = new TextTag("current_notes_element_linewise");
			_TagCurrentNotesElementLinewise.ParagraphBackground = "lightgreen";
			tagTable.Add(_TagCurrentNotesElementLinewise);

			// Error parse issue
			_TagErrorParseIssue = new TextTag("error_parse_issue");
			_TagErrorParseIssue.Background = "red";
			_TagErrorParseIssue.BackgroundSet = true;
			tagTable.Add(_TagErrorParseIssue);

			_TagErrorParseIssueLinewise = new TextTag("error_parse_issue_linewise");
			_TagErrorParseIssueLinewise.ParagraphBackground = "red";
			tagTable.Add(_TagErrorParseIssueLinewise);

			// Warning parse issue
			_TagWarningParseIssue = new TextTag("warning_parse_issue");
			_TagWarningParseIssue.Background = "orange";
			_TagWarningParseIssue.BackgroundSet = true;
			tagTable.Add(_TagWarningParseIssue);

			_TagWarningParseIssueLinewise = new TextTag("warning_parse_issue_linewise");
			_TagWarningParseIssueLinewise.ParagraphBackground = "orange";
			tagTable.Add(_TagWarningParseIssueLinewise);

			// Semantic types:
			_TagsSemanticType = new Dictionary<SemanticType, TextTag>();

			// Type
			var typeSemanticTypeTag = new TextTag("syntax_type");
			typeSemanticTypeTag.Foreground = "green";
			typeSemanticTypeTag.ForegroundSet = true;
			tagTable.Add(typeSemanticTypeTag);
			this._TagsSemanticType.Add(SemanticType.Type, typeSemanticTypeTag);

			// Identifier
			var identifierSemanticTypeTag = new TextTag("syntax_identifier");
			identifierSemanticTypeTag.Foreground = "darkcyan";
			identifierSemanticTypeTag.ForegroundSet = true;
			tagTable.Add(identifierSemanticTypeTag);
			this._TagsSemanticType.Add(SemanticType.Identifier, identifierSemanticTypeTag);

			// Constant
			var constantSemanticTypeTag = new TextTag("syntax_constant");
			constantSemanticTypeTag.Foreground = "darkred";
			constantSemanticTypeTag.ForegroundSet = true;
			tagTable.Add(constantSemanticTypeTag);
			this._TagsSemanticType.Add(SemanticType.Constant, constantSemanticTypeTag);

			// Keyword
			var keywordSemanticTypeTag = new TextTag("syntax_keyword");
			keywordSemanticTypeTag.Foreground = "darkorange";
			keywordSemanticTypeTag.ForegroundSet = true;
			tagTable.Add(keywordSemanticTypeTag);
			this._TagsSemanticType.Add(SemanticType.Keyword, keywordSemanticTypeTag);


			// Set up NodeView.
			this.nodeviewNotes.NodeStore = new NodeStore(typeof(NotesElementTreeNode));

			this.nodeviewNotes.AppendColumn("Summary", new CellRendererText(), "text", 0, "foreground", 3);

			var cellRendererLine = new CellRendererText();
			cellRendererLine.Alignment = Pango.Alignment.Right;
			this.nodeviewNotes.AppendColumn("Line", cellRendererLine, "text", 1, "foreground", 3);

			var cellRendererTotalLines = new CellRendererText();
			cellRendererTotalLines.Alignment = Pango.Alignment.Right;
			this.nodeviewNotes.AppendColumn("# Lines", cellRendererTotalLines, "text", 2, "foreground", 3);

			var cellRendererParseIssues = new CellRendererText();
			cellRendererParseIssues.Alignment = Pango.Alignment.Right;
			cellRendererParseIssues.Foreground = "red";
			this.nodeviewNotes.AppendColumn("# Issues", cellRendererParseIssues, "text", 4);

			this.nodeviewNotes.NodeSelection.Changed += NodeviewNotes_NodeSelection_Changed;
			this.nodeviewNotes.KeyReleaseEvent += NodeviewNotes_KeyReleaseEvent;

			// Set up recent menu.
			Debug.Print("[MainWindow] ctor: Searching for 'Recent' menu...");
			foreach (Widget widget in this.menubar1) {
				Debug.Print("[MainWindow] ctor: Examining widget: {0}", widget);
				var menuItem = widget as MenuItem;
				if (object.ReferenceEquals(menuItem, null)) {
					Debug.Print("[MainWindow] ctor: Widget is not a MenuItem. Skipping.");
					continue;
				}

				var menu = menuItem.Submenu as Menu;
				if (object.ReferenceEquals(menu, null)) {
					Debug.Print("[MainWindow] ctor: MenuItem's submenu is not a Menu. Skipping.");
					continue;
				}

				if (object.ReferenceEquals(menu.Action, this.FileAction)) {
					Debug.Print("[MainWindow] ctor: Menu is not the 'File' menu. Skipping.");
					continue;
				}

				Debug.Print("[MainWindow] ctor: Found 'File' menu.");

				foreach (Widget widget2 in menu) {
					Debug.Print("[MainWindow] ctor: File menu: Examining widget: {0}", widget2);
					var menuItem2 = widget2 as MenuItem;
					if (object.ReferenceEquals(menuItem2, null)) {
						Debug.Print("[MainWindow] ctor: File menu: Widget is not a MenuItem. Skipping.");
						continue;
					}

					if (object.ReferenceEquals(menuItem2.Action, this.RecentAction)) {
						Debug.Print("[MainWindow] ctor: File menu: Found 'Recent' menu item.");
						this.RecentMenu = menuItem2.Submenu as Menu;
						if (object.ReferenceEquals(this.RecentMenu, null)) {
							Debug.Print("[MainWindow] ctor: File menu: Can't handle 'Recent' submenu. Breaking out.");
							break;
						}
						break;
					}
				}

				if (!object.ReferenceEquals(this.RecentMenu, null))
					break;
			}

			if (object.ReferenceEquals(this.RecentMenu, null))
				Debug.Print("[MainWindow] ctor: Couldn't find 'Recent' menu.");

			UpdateRecentMenu();

			// Set up signals. Doing this manually should be cleaner
			// than an association getting lost in the auto-generated code...
			RecentManager.Default.Changed += (sender, e) =>
				UpdateRecentMenu();
			this.openAction.Activated += OpenAction_Activated;
			this.closeAction.Activated += (object sender, EventArgs e) =>
				CloseFile();
			this.quitAction.Activated += (object sender, EventArgs e) =>
				Application.Quit();
		}
Example #11
0
        private TextTagTable buildTagTable()
        {
            TextTagTable textTags = new TextTagTable();
            var          tag      = new TextTag("date");

            tag.Justification = Justification.Center;
            tag.Weight        = Pango.Weight.Bold;
            textTags.Add(tag);
            tag            = new TextTag("user1");
            tag.Foreground = "#FF00FF";
            textTags.Add(tag);
            tag            = new TextTag("user2");
            tag.Foreground = "#9400D3";
            textTags.Add(tag);
            tag            = new TextTag("user3");
            tag.Foreground = "#191970";
            textTags.Add(tag);
            tag            = new TextTag("user4");
            tag.Foreground = "#7F0000";
            textTags.Add(tag);
            tag            = new TextTag("user5");
            tag.Foreground = "#FF8C00";
            textTags.Add(tag);
            tag            = new TextTag("user6");
            tag.Foreground = "#FFA500";
            textTags.Add(tag);
            tag            = new TextTag("user7");
            tag.Foreground = "#32CD32";
            textTags.Add(tag);
            tag            = new TextTag("user8");
            tag.Foreground = "#3CB371";
            textTags.Add(tag);
            tag            = new TextTag("user9");
            tag.Foreground = "#007F00";
            textTags.Add(tag);
            tag            = new TextTag("user10");
            tag.Foreground = "#FFFF00";
            textTags.Add(tag);
            return(textTags);
        }
Example #12
0
        // Constructors

        public SqlEditorSharp() : base(false, 4)
        {
            scroll = new ScrolledWindow(
                new Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
                new Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
            scroll.HscrollbarPolicy = Gtk.PolicyType.Automatic;
            scroll.VscrollbarPolicy = Gtk.PolicyType.Automatic;
            scroll.ShadowType       = Gtk.ShadowType.In;
            this.PackStart(scroll, true, true, 0);

            // default font famly for SQL editor
            family = "courier";

            // other default settings
            use_hi_lighting = false;

            // create text tag table
            TextTagTable textTagTable = new TextTagTable();

            // anything else is normaltext
            normaltext_tag            = new TextTag("normaltext");
            normaltext_tag.Family     = family;
            normaltext_tag.Foreground = "black";
            normaltext_tag.Style      = Pango.Style.Normal;
            textTagTable.Add(normaltext_tag);

            // SQL Keywords - SELECT FROM WHERE, etc
            sql_tag            = new TextTag("sql");
            sql_tag.Family     = family;
            sql_tag.Foreground = "blue";
            sql_tag.Style      = Pango.Style.Normal;
            textTagTable.Add(sql_tag);

            // c like free comment - used within a SQL statement
            freecomment_tag            = new TextTag("freecomment");
            freecomment_tag.Family     = family;
            freecomment_tag.Foreground = "darkgreen";
            freecomment_tag.Style      = Pango.Style.Italic;
            textTagTable.Add(freecomment_tag);

            // c++ like line comment, but using two hyphens
            linecomment_tag            = new TextTag("linecomment");
            linecomment_tag.Family     = family;
            linecomment_tag.Foreground = "darkgreen";
            linecomment_tag.Style      = Pango.Style.Italic;
            textTagTable.Add(linecomment_tag);

            /* single quoted constant - WHERE COL1 = 'ABC' */
            singlequotedconstant_tag            = new TextTag("singlequotedconstant");
            singlequotedconstant_tag.Family     = family;
            singlequotedconstant_tag.Foreground = "red";
            singlequotedconstant_tag.Style      = Pango.Style.Normal;
            textTagTable.Add(singlequotedconstant_tag);

            // create TextBuffer and TextView
            sqlTextBuffer = new TextBuffer(textTagTable);
            sqlTextView   = new TextView(sqlTextBuffer);

            // allow it to be edited
            sqlTextView.Editable = true;

            //line_last_changed = -1;
            //last_freecomment_count = -1;

            // attach OnTextChanged callback function
            // to "changed" signal so we can do something
            // when the text has changed in the buffer
            sqlTextBuffer.Changed += new EventHandler(OnTextChanged);

            // add the TextView to the ScrolledWindow
            scroll.Add(sqlTextView);
        }