Exemplo n.º 1
0
        public XmlControl(FileTabItem parent, OpenedFile fileDef, string skinName = "")
        {
            m_curSearchIndex = 0;

            InitializeComponent();
            m_parent = parent;
            m_showGL = false;

            m_openedFile = fileDef;
            m_openedFile.m_frame = this;

            try
            {
                m_xmlDoc = new XmlDocument();
                m_xmlDoc.Load(m_openedFile.m_path);
            }
            catch
            {
                return;
            }

            m_openedFile.m_lstOpt = new XmlOperation.HistoryList(MainWindow.s_pW, this, 65535);
            refreshControl(skinName);
            refreshXmlText();
        }
Exemplo n.º 2
0
 public UnknownControl(FileTabItem parent, OpenedFile fileDef)
 {
     InitializeComponent();
     m_parent = parent;
     m_openedFile = fileDef;
     m_openedFile.m_frame = this;
 }
Exemplo n.º 3
0
        public PngControl(FileTabItem parent, OpenedFile fileDef)
        {
            InitializeComponent();
            m_parent = parent;
            m_openedFile = fileDef;
            m_openedFile.m_frame = this;

            string path = this.m_parent.m_filePath;

            if(System.IO.File.Exists(path))
            {
                m_Bitmap = DevIL.DevIL.LoadBitmap(path);
                try
                {
                    IntPtr ip = m_Bitmap.GetHbitmap();
                    m_imgSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                        ip, IntPtr.Zero, Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                    MainWindow.DeleteObject(ip);

                    m_imgHeight = m_imgSource.PixelHeight;
                    m_imgWidth = m_imgSource.PixelWidth;
                    m_parent.itemFrame.Height = m_imgHeight;
                    m_parent.itemFrame.Width = m_imgWidth;
                    mx_image.Source = m_imgSource;
                    mx_image.Stretch = Stretch.Uniform;
                }
                catch
                {
                    Public.ResultLink.createResult("这不是一个合法的png文件(虽然后缀名是png)。");
                }
            }
        }
Exemplo n.º 4
0
        public HtmlControl(FileTabItem tabItem, OpenedFile fileDef)
        {
            m_tabItem = tabItem;
            m_openedFile = fileDef;
            InitializeComponent();
            //mx_browser.Source = new Uri(tabItem.m_filePath, UriKind.Relative);
            string path = System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location);

            mx_browser.Source = new Uri("file:///" + path + "\\" + m_tabItem.m_filePath);
        }
Exemplo n.º 5
0
        public PngControl(string path)
        {
            InitializeComponent();
            m_parent = null;
            m_openedFile = null;

            if (System.IO.File.Exists(path))
            {
                m_Bitmap = DevIL.DevIL.LoadBitmap(path);
                IntPtr ip = m_Bitmap.GetHbitmap();
                m_imgSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    ip, IntPtr.Zero, Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                MainWindow.DeleteObject(ip);

                m_imgHeight = m_imgSource.PixelHeight;
                m_imgWidth = m_imgSource.PixelWidth;
                mx_image.Source = m_imgSource;
                mx_image.Stretch = Stretch.Uniform;
            }
        }
Exemplo n.º 6
0
        public FileTabItem(OpenedFile fileDef, string skinName = "")
        {
            m_filePath = "";
            InitializeComponent();

            if (m_filePath == "")
            {
                UserControl tabContent;
                MainWindow parentWindow = Window.GetWindow(this) as MainWindow;

                m_fileDef = fileDef;
                m_filePath = fileDef.m_path;
                this.filePath.Text = m_filePath;

                m_fileType = StringDic.getFileType(m_filePath).ToLower();
                switch (m_fileType)
                {
                    case "bmp":
                    case "cut":
                    case "dcx":
                    case "dds":
                    case "ico":
                    case "gif":
                    case "jpg":
                    case "lbm":
                    case "lif":
                    case "mdl":
                    case "pcd":
                    case "pcx":
                    case "pic":
                    case "png":
                    case "pnm":
                    case "psd":
                    case "psp":
                    case "raw":
                    case "sgi":
                    case "tga":
                    case "tif":
                    case "wal":
                    case "act":
                    case "pal":
                        {
                            tabContent = new PngControl(this, fileDef);
                            MainWindow.s_pW.showGLCtrl(false);
                        }
                        break;
                    case "xml":
                        {
                            tabContent = new XmlControl(this, fileDef, skinName);
                        }
                        break;
                    case "htm":
                    case "html":
                    case "php":
                        {
                            tabContent = new HtmlControl(this, fileDef);
                        }
                        break;
                    case "bolos":
                    case "txt":
                        {
                            tabContent = new BoloScript.TextControl(this, fileDef);
                            MainWindow.s_pW.showGLCtrl(false);
                        }
                        break;
                    default:
                        {
                            tabContent = new UnknownControl(this, fileDef);
                            MainWindow.s_pW.showGLCtrl(false);
                        }
                        break;
                }
                this.itemFrame.Children.Clear();
                this.itemFrame.Children.Add(tabContent);
                m_child = tabContent;
            }
            mx_wsBckBrush.ImageSource = new BitmapImage(new Uri(@".\data\image\hyaline.png", UriKind.Relative));
        }
Exemplo n.º 7
0
        public static void closeAllFile(OpenedFile exFileDef = null)
        {
            List<OpenedFile> lstFileDef = new List<OpenedFile>();

            foreach(KeyValuePair<string, OpenedFile> pairFileDef in MainWindow.s_pW.m_mapOpenedFiles.ToList())
            {
                if (pairFileDef.Value != null && pairFileDef.Value != exFileDef)
                {
                    lstFileDef.Add(pairFileDef.Value);
                }
            }

            foreach(OpenedFile fileDef in lstFileDef)
            {
                fileDef.m_tabItem.closeFile();
            }
        }
Exemplo n.º 8
0
        public void openFileByDef(OpenedFile fileDef)
        {
            OpenedFile openedFile;

            if (fileDef != null)
            {
                if (m_mapOpenedFiles.TryGetValue(fileDef.m_path, out openedFile))
                {
                    mx_workTabs.SelectedItem = fileDef.m_tab;
                }
                else
                {
                    m_mapOpenedFiles.Add(fileDef.m_path, fileDef);
                    mx_workTabs.Items.Add(fileDef.m_tab);
                    mx_workTabs.SelectedItem = fileDef.m_tab;
                    m_curFile = fileDef.m_path;
                    if (fileDef.m_frame != null && fileDef.m_frame is XmlControl)
                    {
                        XmlControl xmlCtrl = (XmlControl)fileDef.m_frame;

                        if (xmlCtrl.m_treeUI != null)
                        {
                            if (xmlCtrl.m_treeUI.Parent != null && xmlCtrl.m_treeUI.Parent is ItemsControl)
                            {
                                ((ItemsControl)xmlCtrl.m_treeUI.Parent).Items.Remove(xmlCtrl.m_treeUI);
                            }
                            MainWindow.s_pW.mx_treeCtrlFrame.Items.Add(xmlCtrl.m_treeUI);
                        }
                        if (xmlCtrl.m_treeSkin != null)
                        {
                            if (xmlCtrl.m_treeSkin.Parent != null && xmlCtrl.m_treeSkin.Parent is ItemsControl)
                            {
                                ((ItemsControl)xmlCtrl.m_treeSkin.Parent).Items.Remove(xmlCtrl.m_treeSkin);
                            }
                            MainWindow.s_pW.mx_treeSkinFrame.Items.Add(xmlCtrl.m_treeSkin);
                        }
                    }
                }
            }
        }