Ejemplo n.º 1
0
        private void listRegistros_SelectedIndexChanged(object sender, EventArgs e)
        {
            listObjetos.Clear();
            tabs.TabPages.Clear();

            if (listRegistros.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItemCustom registroClicked = (ListViewItemCustom)listRegistros.SelectedItems[0];
            string guid = registroClicked.guid;
            if (guid == GUID_NUEVO_REGISTRO)
                return;
            Registro registro = registros.First(item => item.guid == guid);
            foreach (Objeto obj in registro.objetos)
            {

                Codigo cod = new Codigo() ;
                if (obj.codigos.Count>0)
                {

                    //Cogemos el que tenga versión mayor
                    cod = obj.codigos[0];
                    foreach (Codigo item in obj.codigos)
                    {
                        if (item.version > cod.version)
                            cod = item;
                    }
                    HLCode code = new HLCode();

                    code.guidCodigo = cod.guid;
                    code.guidObjeto = obj.guid;
                    code.guidRegistro = registro.guid;
                    code.nombreObjeto = obj.nombre_objeto;

                    iniciarConfiguracionCodigo(code);
                    bool encontrado = false;

                    foreach (CodigoModificado item in codigosModificados)
                    {
                        if (item.guidCodigo == code.guidCodigo && item.guidObjeto == code.guidObjeto && item.guidRegistro == code.guidRegistro)
                        {
                            code.Text = item.codigo;
                            encontrado = true;
                        }

                    }
                    if (!encontrado)
                        code.Text = cod.codigo;
                    actualizarLineasMostradas(code, 0);
                    code.Leave += code_Leave;
                    code.TextChanged += code_TextChanged;
                    code.Insert += code_Insert;
                    code.Delete += code_Delete;
                    code.Click += code_Click;
                    string nombreTab = obj.nombre_objeto;
                    if (encontrado)
                        nombreTab =  nombreTab + "*" ;

                    TabPageCustom tab = new TabPageCustom(nombreTab);

                    tab.guidCodigo = cod.guid;
                    tab.guidObjeto = obj.guid;
                    tab.guidRegistro = registro.guid;
                    tab.nombreObjeto = obj.nombre_objeto;
                    int indexLenguaje = lenguajes.First(item => item.guid == obj.lenguaje).indexImageList;

                    tab.ImageIndex = indexLenguaje;
                    code.Left = 0;
                    code.Top = 0;
                    code.Dock = DockStyle.Fill;
                    //code.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                    tab.Controls.Add(code);
                    tabs.Controls.Add(tab);
                    tabs_Click(tab, null);
                }
            }

            try
            {
                Objeto objSeleccionado = (Objeto)sender;
                foreach (TabPageCustom item in tabs.TabPages)
                {
                    if (item.guidObjeto == objSeleccionado.guid)
                    {
                        tabs.SelectedTab = item;
                        tabs_Click(null, null);
                        break;
                    }
                }
            }
            catch (Exception)
            {

            }

            TabPageCustom tabNueva = new TabPageCustom("Nuevo");
            tabNueva.ImageIndex = 0;
            tabNueva.guidCodigo = GUID_NUEVO_OBJETO;
            tabNueva.guidObjeto = GUID_NUEVO_OBJETO;
            tabNueva.guidRegistro = registro.guid;

            tabs.Controls.Add(tabNueva);

            ultimoRegistroSeleccionado = registro;
        }
Ejemplo n.º 2
0
        private void iniciarConfiguracionCodigo(HLCode code)
        {
            code.StyleResetDefault();
                code.Styles[Style.Default].Font = "Consolas";
                code.Styles[Style.Default].Size = 10;
                code.StyleClearAll();
                code.Styles[Style.Cpp.Default].ForeColor = Color.Silver;
                code.Styles[Style.Cpp.Comment].ForeColor = Color.FromArgb(0, 128, 0); // Green
                code.Styles[Style.Cpp.CommentLine].ForeColor = Color.FromArgb(0, 128, 0); // Green
                code.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
                code.Styles[Style.Cpp.Number].ForeColor = Color.Olive;
                code.Styles[Style.Cpp.Word].ForeColor = Color.Blue;
                code.Styles[Style.Cpp.Word2].ForeColor = Color.Blue;
                code.Styles[Style.Cpp.String].ForeColor = Color.FromArgb(163, 21, 21); // Red
                code.Styles[Style.Cpp.Character].ForeColor = Color.FromArgb(163, 21, 21); // Red
                code.Styles[Style.Cpp.Verbatim].ForeColor = Color.FromArgb(163, 21, 21); // Red
                code.Styles[Style.Cpp.StringEol].BackColor = Color.Pink;
                code.Styles[Style.Cpp.Operator].ForeColor = Color.Purple;
                code.Styles[Style.Cpp.Preprocessor].ForeColor = Color.Maroon;
                code.Lexer = Lexer.Cpp;

                //code.Margins[0].Width = 16;
                code.Margins[0].Type = MarginType.RightText;
                code.Margins[0].Width = 16;
                code.Styles[Style.BraceLight].BackColor = Color.LightGray;
                code.Styles[Style.BraceLight].ForeColor = Color.BlueViolet;
                code.Styles[Style.BraceBad].ForeColor = Color.Red;
                //code.Margins[0].Width = 16;
                code.SetProperty("fold", "1");
                code.SetProperty("fold.compact", "1");

                code.Margins[2].Type = MarginType.Symbol;
                code.Margins[2].Mask = Marker.MaskFolders;
                code.Margins[2].Sensitive = true;
                code.Margins[2].Width = 20;

                for (int j = 25; j <= 31; j++)
                {
                    code.Markers[j].SetForeColor(SystemColors.ControlLightLight);
                    code.Markers[j].SetBackColor(SystemColors.ControlDark);
                }

                code.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
                code.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
                code.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected;
                code.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
                code.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
                code.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine;
                code.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner;

                code.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);
                code.SetKeywords(0, "arguments break case catch continue debugger default delete do else enum eval export extends false finally for function goto if implements import in instanceof let new null return super switch this throw throws true try typeof while with");
                code.SetKeywords(1, "abstract boolean byte char const double final float int interface long native package private protected public short static synchronized transient var void volatile yield");

                //code.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

                int NUM = 8;

                // Indicador de codigo añadido
                code.Indicators[NUM].Style = IndicatorStyle.StraightBox;
                code.Indicators[NUM].Under = true;
                code.Indicators[NUM].ForeColor = Color.Green;
                code.Indicators[NUM].OutlineAlpha = 100;
                code.Indicators[NUM].Alpha =100;

                NUM = 9;
                // Indicador de codigo eliminado
                code.Indicators[NUM].Style = IndicatorStyle.StraightBox;
                code.Indicators[NUM].Under = true;
                code.Indicators[NUM].ForeColor = Color.Red;
                code.Indicators[NUM].OutlineAlpha = 100;
                code.Indicators[NUM].Alpha = 100;
        }
Ejemplo n.º 3
0
        private void listObjetos_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listObjetos.SelectedItems.Count == 0)
                return;

            ListViewItemCustom itemVersion = (ListViewItemCustom)listObjetos.SelectedItems[0];

            listObjetos.Items[0].Selected = true;
            listObjetos_MouseClick(null, null);

            TabPageCustom tab = (TabPageCustom)tabs.SelectedTab;
            string guidRegistro = tab.guidRegistro;

            string guidObjeto = tab.guidObjeto;

            string guidVersion = itemVersion.guid;
            Objeto obj = getObjeto(guidRegistro, guidObjeto);
            if (guidVersion == obj.codigos[0].guid)
            {
                return;
            }

            Codigo codigoVersion = getCodigo(guidRegistro, guidObjeto, guidVersion);

            HLCode code = new HLCode();

            code.guidCodigo = guidVersion;
            code.guidObjeto = guidObjeto;
            code.guidRegistro = guidRegistro;
            code.nombreObjeto = obj.nombre_objeto + " V" + codigoVersion.version;
            code.Dock = DockStyle.Fill;
            code.Text = codigoVersion.codigo;
            code.ReadOnly = true;
            iniciarConfiguracionCodigo(code);

            TabPageCustom tabNueva = new TabPageCustom(obj.nombre_objeto + " V" + codigoVersion.version);
            tabNueva.guidCodigo = guidVersion;
            tabNueva.guidRegistro = guidRegistro;
            tabNueva.guidObjeto = guidObjeto;
            tabNueva.ImageIndex = 1;
            tabNueva.esVersionAntigua = true;
            tabNueva.Controls.Add(code);
            tabs.TabPages.Insert(tabs.TabPages.Count - 1, tabNueva);
            tabs_Click(tabNueva, null);
        }
Ejemplo n.º 4
0
        private void actualizarLineasMostradas(HLCode code, int lineaInicio, bool forzar = false)
        {
            if (!modoDiferencias)
            {
                for (int i = 1; i <= code.Lines.Count; i++)
                {

                    code.Lines[i - 1].MarginStyle = Style.LineNumber;
                    code.Lines[i - 1].MarginText = i.ToString();

                }
            }
            if (forzar)
            {
                for (int i = 1; i <= code.Lines.Count; i++)
                {

                    code.Lines[i - 1].MarginStyle = Style.LineNumber;
                    code.Lines[i - 1].MarginText = i.ToString();

                }
            }
        }