예제 #1
0
 private void ReloadWindows()
 {
     try
     {
         m_machineChanging = true;
         lsvWindows.BeginUpdate();
         lsvWindows.Items.Clear();
         int index = 1;
         foreach (var cnt in MainWindow.Instance.GetContents())
         {
             if (cnt.ParentFrame != null)
             {
                 continue;                          // don't show child frames
             }
             var item = lsvWindows.Items.Add(Texts.Get(cnt.PageTitle));
             item.SubItems.Add(Texts.Get(cnt.PageTypeTitle));
             item.SubItems.Add(index.ToString());
             item.ImageIndex = m_imgCache.GetImageIndex(cnt.Image);
             item.Tag        = cnt;
             index++;
         }
         lsvWindows.EndUpdate();
     }
     finally
     {
         m_machineChanging = false;
     }
 }
예제 #2
0
        private TreeNode FindOrCreate(TreeNode parent, TreeNodeCollection parentNodes, string[] subpath, SettingsPageStruct page)
        {
            if (subpath.Length == 0)
            {
                return(parent);
            }
            //TreeNode[] childs = parentNodes.Find(Texts.Get(subpath[0]), false);
            TreeNode child = null;

            foreach (TreeNode n in parentNodes)
            {
                if (n.Text == Texts.Get(subpath[0]))
                {
                    child = n;
                    break;
                }
            }
            //if (childs.Length > 0) child = childs[0];
            if (child != null)
            {
                return(FindOrCreate(child, child.Nodes, PyList.SliceFrom(subpath, 1), page));
            }
            child = new TreeNode();
            if (page != null && page.Attribute.ImageName != null)
            {
                child.ImageIndex = m_imgCache.GetImageIndex(ImageTool.ImageFromName(page.Attribute.ImageName, CoreIcons.settings));
            }
            else
            {
                child.ImageIndex = m_imgCache.GetImageIndex(CoreIcons.settings);
            }
            child.SelectedImageIndex = child.ImageIndex;
            parentNodes.Add(child);
            child.Text = Texts.Get(subpath[0]);
            if (subpath.Length == 1)
            {
                child.Tag = page;
                if ((page.Attribute.Targets & Target) == 0)
                {
                    parentNodes.Remove(child);
                }
            }
            return(FindOrCreate(child, child.Nodes, PyList.SliceFrom(subpath, 1), page));
        }
예제 #3
0
        private void ReloadItemsCore()
        {
            List <AppObject> objs;

            if (!m_graySearch && !tbxSearch.Text.IsEmpty())
            {
                objs = new List <AppObject>();
                string s = tbxSearch.Text.ToUpper();
                foreach (var obj in m_objs)
                {
                    if (obj.ToString().ToUpper().Contains(s))
                    {
                        objs.Add(obj);
                    }
                }
            }
            else
            {
                objs = m_objs;
            }
            foreach (var obj in objs)
            {
                AppObject ao;
                if (obj.SupportSerialize)
                {
                    ao          = obj.Clone();
                    ao.Owner    = this;
                    ao.ConnPack = ConnPack;
                }
                else
                {
                    ao = obj;
                }

                string title = ao.ToString();
                var    props = new Dictionary <string, string>();
                if (Columns != null && Columns.Count > 0)
                {
                    ao.GetAppObjectProperties(props);
                    title = props.Get(Columns[0].DataSource, "");
                }
                var item = listView1.Items.Add(title);
                if (Columns != null && Columns.Count > 0)
                {
                    for (int i = 1; i < Columns.Count; i++)
                    {
                        item.SubItems.Add(props.Get(Columns[i].DataSource, ""));
                    }
                }
                item.Tag        = ao;
                item.ImageIndex = m_imgCache.GetImageIndex(ao.Image);
            }
        }
예제 #4
0
 public int GetImageIndex(Bitmap image)
 {
     return(m_imgCache.GetImageIndex(image));
 }
예제 #5
0
 private void AddLogMessage(LogMessageRecord msg)
 {
     if (IsTargetList)
     {
         if (m_source.Capacity != null)
         {
             while (lvMessages.Items.Count > m_source.Capacity)
             {
                 lvMessages.Items.RemoveAt(0);
             }
         }
         ListViewItem added = lvMessages.Items.Add(Texts.Get(msg.Level.GetTitle()), m_imgCache.GetImageIndex(msg.Level.GetImage()));
         added.SubItems.Add(Texts.Get(msg.Category));
         added.SubItems.Add(msg.Message);
         added.Tag = msg;
         if (btnAutoScroll.Checked)
         {
             added.EnsureVisible();
         }
     }
     if (IsTargetTrace)
     {
         codeEditor1.ReadOnly = false;
         codeEditor1.Document.Insert(codeEditor1.Document.TextLength, msg.Message);
         codeEditor1.Document.Insert(codeEditor1.Document.TextLength, "\n");
         if (btnAutoScroll.Checked)
         {
             codeEditor1.ActiveTextAreaControl.Caret.Line = codeEditor1.Document.LineSegmentCollection.Count - 1;
         }
         codeEditor1.ReadOnly = true;
         m_traceCount++;
         if (m_source.Capacity != null && m_traceCount > m_source.Capacity * 2)
         {
             FillMessages();
         }
     }
 }
예제 #6
0
        private void UpdateTabs()
        {
            if (!IsContentVisible || m_suspendedDashboard)
            {
                return;
            }
            //tabControl1.TabPages.Clear();
            try
            {
                m_updatingTabs      = true;
                tabControl1.Enabled = false;

                var widgets = TreeNodeExtension.GetAllWidgets(m_selectedObject);

                int pgindex = 0;
                foreach (IWidget widget in widgets)
                {
                    TabPage pg = FindPage(widget, pgindex);
                    if (pg != null)
                    {
                        if (tabControl1.TabPages.IndexOf(pg) != pgindex)
                        {
                            int origindex = tabControl1.TabPages.IndexOf(pg);
                            tabControl1.TabPages.RemoveAt(origindex);
                            tabControl1.TabPages.Insert(pgindex, pg);
                            List <PageRecord> tmp  = new List <PageRecord>(m_loadedPages);
                            PageRecord        orig = tmp[origindex];
                            tmp[pgindex].Dispose();
                            tmp.RemoveAt(origindex);
                            tmp.Insert(pgindex, orig);
                            m_loadedPages = tmp.ToArray();
                        }
                        m_loadedPages[pgindex].isloaded = false;
                        m_loadedPages[pgindex].ReplaceWidget(widget);
                        pg.Text       = Texts.Get(widget.PageTitle);
                        pg.ImageIndex = m_imgCache.GetImageIndex(widget.Image);
                    }
                    else
                    {
                        List <PageRecord> tmp    = new List <PageRecord>(m_loadedPages);
                        PageRecord        newrec = new PageRecord();
                        newrec.widget = widget;
                        tabControl1.TabPages.Insert(pgindex, Texts.Get(widget.PageTitle));
                        tabControl1.TabPages[pgindex].ImageIndex = m_imgCache.GetImageIndex(widget.Image);
                        tmp.Insert(pgindex, newrec);
                        m_loadedPages = tmp.ToArray();
                    }
                    pgindex++;
                }
                try
                {
                    while (tabControl1.TabPages.Count > widgets.Count)
                    {
                        tabControl1.SelectedIndex = 0;
                        tabControl1.TabPages.RemoveAt(widgets.Count);
                    }
                    List <PageRecord> tmp = new List <PageRecord>(m_loadedPages);
                    for (int i = widgets.Count; i < tmp.Count; i++)
                    {
                        tmp[i].Dispose();
                    }
                    tmp.RemoveRange(widgets.Count, tmp.Count - widgets.Count);
                    m_loadedPages = tmp.ToArray();
                }
                catch (Exception)
                {
                    tabControl1.TabPages.Clear();
                    foreach (PageRecord pgrec in m_loadedPages)
                    {
                        pgrec.Dispose();
                    }
                    m_loadedPages = new PageRecord[] { };
                    UpdateTabs();
                }
            }
            finally
            {
                m_updatingTabs      = false;
                tabControl1.Enabled = true;
            }
            LoadCurPage();
        }
예제 #7
0
        public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
        {
            var res      = new List <ICompletionData>();
            int tblindex = m_imgCache.GetImageIndex(StdIcons.table);
            int vindex   = m_imgCache.GetImageIndex(StdIcons.view);

            var context = m_anal.GetContext(textArea.Caret.Line, textArea.Caret.Column);

            switch (context)
            {
            case SqlEditorAnalyser.CodeContext.Table:
            {
                var prefixName = FindPrefix(textArea);
                if (prefixName == null)         // do not handle table prefixes
                {
                    foreach (var tbl in m_anal.TableNames)
                    {
                        res.Add(new SqlCompletionData(tbl.Name, tbl.ToString(), tblindex, GetFullName(tbl)));
                    }
                    foreach (var tbl in m_anal.ViewNames)
                    {
                        res.Add(new SqlCompletionData(tbl.Name, tbl.ToString(), vindex, GetFullName(tbl)));
                    }
                }
            }
            break;

            case SqlEditorAnalyser.CodeContext.Column:
            case SqlEditorAnalyser.CodeContext.ColumnWithoutQualifier:
            {
                var  prefixName = FindPrefix(textArea);
                int  colindex   = m_imgCache.GetImageIndex(StdIcons.column);
                int  starindex  = m_imgCache.GetImageIndex(StdIcons.star_blue);
                bool qual       = context == SqlEditorAnalyser.CodeContext.Column;

                if (prefixName != null)
                {
                    var used = m_anal.FindUsedMatch(prefixName);
                    if (used != null)
                    {
                        string alltext = String.Format("all ({0})", used.FullName);
                        string allins  = "";
                        foreach (var col in used.Structure.Columns)
                        {
                            if (allins.Length > 0)
                            {
                                allins += ", ";
                                allins += (qual ? prefixName.ToString() + "." : "") + GetShortName(col.ColumnName);
                            }
                            else
                            {
                                allins += GetShortName(col.ColumnName);
                            }
                        }
                        res.Add(new SqlCompletionData(alltext, allins, starindex, allins));

                        foreach (var col in used.Structure.Columns)
                        {
                            string text = String.Format("{0} ({1})", col.ColumnName, used.FullName);
                            string ins  = GetShortName(col.ColumnName);
                            res.Add(new SqlCompletionData(text, text, colindex, ins));
                        }
                    }
                }
                else
                {
                    foreach (var tbl in m_anal.UsedTables)
                    {
                        string alltext = String.Format("all ({0})", (tbl.Alias ?? tbl.FullName.ToString()));
                        string allins  = "";
                        foreach (var col in tbl.Structure.Columns)
                        {
                            if (allins.Length > 0)
                            {
                                allins += ", ";
                            }
                            string ins = (qual ? (tbl.Alias ?? GetFullName(tbl.FullName)) + "." : "") + GetShortName(col.ColumnName);
                            allins += ins;
                        }
                        res.Add(new SqlCompletionData(alltext, allins, starindex, allins));
                        if (qual)
                        {
                            int imgindex = m_anal.ViewNames.IndexOf(tbl.FullName) >= 0 ? vindex : tblindex;
                            res.Add(new SqlCompletionData(tbl.Alias ?? tbl.FullName.Name, tbl.Alias ?? tbl.FullName.ToString(), imgindex, tbl.Alias ?? GetFullName(tbl.FullName)));
                        }

                        foreach (var col in tbl.Structure.Columns)
                        {
                            string text = String.Format("{0} ({1}{2})", col.ColumnName, tbl.FullName, tbl.Alias != null ? ":" + tbl.Alias : "");
                            string ins  = (qual ? (tbl.Alias ?? GetFullName(tbl.FullName)) + "." : "") + GetShortName(col.ColumnName);
                            res.Add(new SqlCompletionData(text, text, colindex, ins));
                        }
                    }
                }
            }
            break;
            }
            return(res.ToArray());
        }