예제 #1
0
        void SPTabView_MouseDown(object sender, MouseEventArgs e)
        {
            int pos = -scrollX;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                foreach (SPTab tab in this.Views.Values)
                {
                    if (e.X >= pos && e.X <= pos + 120)
                    {
                        Navigate(tab.Title, tab.Uri);
                        break;
                    }
                    pos += 120;
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
            {
                int i = 0;
                foreach (KeyValuePair <String, SPTab> tab in this.Views)
                {
                    if (e.X >= pos && e.X <= pos + 120)
                    {
                        if (tab.Value.Control is ISPComponent)
                        {
                            ISPComponent component = (ISPComponent)tab.Value.Control;
                            if (component.Close())
                            {
                                this.Views.Remove(tab.Key);
                                this.Controls.Remove(tab.Value.Control); // Remove view
                                if (i > 0)
                                {
                                    SPTab prevTab = this.Views.Values.ElementAt(i - 1);
                                    this.Navigate(prevTab.Title, prevTab.Uri);
                                }
                                else
                                {
                                    try
                                    {
                                        SPTab prevTab = this.Views.Values.ElementAt(i + 1);
                                        this.Navigate(prevTab.Title, prevTab.Uri);
                                    }
                                    catch (Exception ex)
                                    {
                                        this.Navigate("Home", new Uri("http://static.cobresia.webfactional.com/spotdev/index.html"));
                                    }
                                }
                                break;
                            }
                            i++;
                        }
                        break;
                    }
                    pos += 120;
                }
                this.Draw(CreateGraphics());
            }
        }
예제 #2
0
        /// <summary>
        /// Show a control
        /// </summary>
        /// <param name="control"></param>
        /// <param name="title"></param>
        /// <param name="uri"></param>
        public void ShowControl(Control control, String title, Uri uri)
        {
            String url = uri.ToString();

            contentPanel.Controls.Add(control);
            control.Dock = DockStyle.Fill;
            SPTab tab = new SPTab();

            tab.Control    = control;
            tab.Title      = title;
            tab.Uri        = uri;
            this.activeTab = tab;
            Views.Add(url, tab);
            control.BringToFront();
            if (control is ISPComponent)
            {
                ISPComponent comp = (ISPComponent)control;
                comp.Changed += new EventHandler(comp_Changed);
                comp.Saved   += new EventHandler(comp_Saved);
            }
        }
예제 #3
0
        public void Navigate(String title, Uri uri)
        {
            // Add navigation handler here
            String url = uri.ToString();

            if (!Views.ContainsKey(url))
            {
                if (url.StartsWith("http://") || url.StartsWith("mako://"))
                {
                    ShowControl(new SPWebBrowser(url), "Browser", uri);
                }
                if (url.StartsWith("spotdev:start"))
                {
                    ShowControl(new SPWebBrowser(), "Browser", uri);
                }
                if (url.Split(':')[1] == "project")
                {
                    // Create a new window based on query
                    String        app    = url.Split(':')[2];
                    String[]      tokens = url.Split(':');
                    StringBuilder path   = new StringBuilder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Spotify");
                    for (int i = 2; i < tokens.Length - 1; i++)
                    {
                        path.Append("\\" + tokens[i]);
                    }
                    FileInfo file = new FileInfo(path.ToString());

                    if (file.Name == "manifest.json")
                    {
#if (manifest)
                        SPManifestEditor manifestEditor = new SPManifestEditor();
                        manifestEditor.LoadFile(file.FullName);
                        ShowControl(manifestEditor, file.Name, uri);
                        if (this.TabChanged != null)
                        {
                            this.TabChanged(this, new EventArgs());
                        }
#else
                        SPTextEditor textEditor = new SPTextEditor();
                        textEditor.LoadFile(file.FullName);
                        ShowControl(textEditor, file.Name, uri);
                        if (this.TabChanged != null)
                        {
                            this.TabChanged(this, new EventArgs());
                        }
#endif
                    }
                    else
                    {
                        switch (file.Extension)
                        {
                        case ".txt":
                        case ".css":
                        case ".js":
                        case ".json":
                        {
                            SPTextEditor textEditor = new SPTextEditor();
                            textEditor.LoadFile(file.FullName);
                            ShowControl(textEditor, file.Name, uri);
                            if (this.TabChanged != null)
                            {
                                this.TabChanged(this, new EventArgs());
                            }
                        }
                        break;

                        case ".html":
                        case ".xhtml":

                        {
                            SPHTMLEditor textEditor = new SPHTMLEditor();
                            textEditor.LoadFile(file.FullName);
                            ShowControl(textEditor, file.Name, uri);
                            if (this.TabChanged != null)
                            {
                                this.TabChanged(this, new EventArgs());
                            }
                        }
                        break;
                        }
                    }
                }
            }
            else
            {
                SPTab c = Views[url];
                this.activeTab = c;
                c.Control.BringToFront();
            }
            this.Draw(this.CreateGraphics());
        }
예제 #4
0
        /// <summary>
        /// Show a control
        /// </summary>
        /// <param name="control"></param>
        /// <param name="title"></param>
        /// <param name="uri"></param>
        public void ShowControl(Control control, String title, Uri uri)
        {
            String url = uri.ToString();

            contentPanel.Controls.Add(control);
            control.Dock = DockStyle.Fill;
            SPTab tab = new SPTab();
            tab.Control = control;
            tab.Title = title;
            tab.Uri = uri;
            this.activeTab = tab;
            Views.Add(url, tab);
            control.BringToFront();
            if (control is ISPComponent)
            {
                ISPComponent comp = (ISPComponent)control;
                comp.Changed += new EventHandler(comp_Changed);
                comp.Saved += new EventHandler(comp_Saved);
            }
        }
예제 #5
0
        public void Navigate(String title, Uri uri)
        {
            // Add navigation handler here
            String url = uri.ToString();

            if (!Views.ContainsKey(url))
            {
                if (url.StartsWith("http://") || url.StartsWith("mako://"))
                {
                    ShowControl(new SPWebBrowser(url), "Browser", uri);
                }
                if (url.StartsWith("spotdev:start"))
                {
                    ShowControl(new SPWebBrowser(), "Browser", uri);
                }
                if (url.Split(':')[1] == "project")
                {
                    // Create a new window based on query
                    String app = url.Split(':')[2];
                    String[] tokens = url.Split(':');
                    StringBuilder path = new StringBuilder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+"\\Spotify");
                    for (int i = 2; i <tokens.Length-1 ; i++)
                    {
                        path.Append("\\" + tokens[i] );
                    }
                    FileInfo file = new FileInfo(path.ToString());

                    if (file.Name == "manifest.json")
                    {
            #if(manifest)

                        SPManifestEditor manifestEditor = new SPManifestEditor();
                        manifestEditor.LoadFile(file.FullName);
                        ShowControl(manifestEditor, file.Name, uri);
                        if (this.TabChanged != null)
                            this.TabChanged(this, new EventArgs());
            #else
                        SPTextEditor textEditor = new SPTextEditor();
                        textEditor.LoadFile(file.FullName);
                        ShowControl(textEditor, file.Name, uri);
                        if (this.TabChanged != null)
                            this.TabChanged(this, new EventArgs());
            #endif
                    }
                    else
                    {
                        switch (file.Extension)
                        {

                            case ".txt":
                            case ".css":
                            case ".js":
                            case ".json":
                                {
                                    SPTextEditor textEditor = new SPTextEditor();
                                    textEditor.LoadFile(file.FullName);
                                    ShowControl(textEditor, file.Name, uri);
                                    if (this.TabChanged != null)
                                        this.TabChanged(this, new EventArgs());

                                }
                                break;
                            case ".html":
                            case ".xhtml":

                                {
                                    SPHTMLEditor textEditor = new SPHTMLEditor();
                                    textEditor.LoadFile(file.FullName);
                                    ShowControl(textEditor, file.Name, uri);
                                    if (this.TabChanged != null)
                                        this.TabChanged(this, new EventArgs());

                                }
                                break;
                        }
                    }

                }
            }
            else
            {
                SPTab c = Views[url];
                this.activeTab = c;
                c.Control.BringToFront();
            }
            this.Draw(this.CreateGraphics());
        }