private void Btn_Open_Click(object sender, RoutedEventArgs e)
        {
            Controls.Button btn = (Controls.Button)sender;
            btn.IsSelected = true;

            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Multiselect = false;
            ofd.Filter      = "Data Sources (*.jpg, *.gif, *.png)|*.jpg*;*.gif;*.png";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OpenFileDelegate del1 = delegate()
                {
                    images = new Ghost.Files.ImageCollection(System.IO.Path.GetDirectoryName(ofd.FileName));
                    Imaging.PixelSnappedImage psi = new Ghost.Imaging.PixelSnappedImage();
                    psi.Source     = Utilities.GetBitmapSourceFromUrlPath(String.Format("{1}/{0}", System.IO.Path.GetFileName(ofd.FileName), System.IO.Path.GetDirectoryName(ofd.FileName)));
                    btn.IsSelected = false;
                    WorkspaceControl.Children.Clear();
                    ControlInView = psi;
                    WorkspaceControl.Children.Add(psi);
                    UpdateMenuWithImages(images);
                    SetOpenMenu();
                };
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, del1);
            }
            else
            {
                btn.IsSelected = false;
            }
        }
        public NewWadForm(OpenFileDelegate openFile)
        {
            openFileNow = openFile;
            InitializeComponent();

            listPictures.ListViewItemSorter = new ListViewIndexComparer();
            helpBrowser.DocumentText        = Properties.Resources.wad_help_text;
        }
示例#3
0
 public WDDocumentApp(NewFileDelegate onNewFile, OpenFileDelegate onOpenFile, SaveFileDelegate onSaveFile, DocumentUpdateDelegate onUpdate)
 {
     System.Diagnostics.Debug.Assert(onNewFile != null);
     this.onNewFile  = onNewFile;
     this.onOpenFile = onOpenFile;
     this.onSaveFile = onSaveFile;
     this.onUpdate   = onUpdate;
     Undo            = new UndoHandler <DOCTYPE>(delegate(DOCTYPE newDoc) { this._document = newDoc; });
 }
示例#4
0
 public FolderDiffForm(CustomDictionary<string,string, PreviewUnit> previewFilesList,
     CustomDictionary<string,string, PreviewUnit> previewFoldersList,
     SyncTask task)
 {
     InitializeComponent();
     _previewFilesList = previewFilesList;
     _previewFoldersList = previewFoldersList;
     _source = task.Source;
     _target = task.Target;
     _sortColumn = -1;
     lblName.Text = task.Name;
     lblSource.Text = _source;
     lblTarget.Text = _target;
     _openFileCaller = new OpenFileDelegate(OpenFile);
     _filter = "";
     this.Text = "[" + lblName.Text + "] Synchronization Preview";
 }
示例#5
0
 public void SetOpenFileEvent(string id, OpenFileDelegate action)
 {
     openFileActions.Add(id, action);
 }
        public void OpenFile(string filePath)
        {
            if (InvokeRequired)
            {
                var d = new OpenFileDelegate(OpenFile);
                Invoke(d, new object[] { filePath });
            }
            else
            {
                try
                {
                    //create or switch to TabPage
                    string fileName = Path.GetFileNameWithoutExtension(filePath);
                    var    foundTab = uiScriptTabControl.TabPages.Cast <TabPage>().Where(t => t.ToolTipText == filePath)
                                      .FirstOrDefault();
                    if (foundTab == null)
                    {
                        TabPage newtabPage = new TabPage(fileName);
                        newtabPage.Name        = fileName;
                        newtabPage.ToolTipText = filePath;

                        uiScriptTabControl.TabPages.Add(newtabPage);
                        newtabPage.Controls.Add(NewLstScriptActions(fileName));
                        uiScriptTabControl.SelectedTab = newtabPage;
                    }
                    else
                    {
                        uiScriptTabControl.SelectedTab = foundTab;
                        return;
                    }

                    _selectedTabScriptActions = (UIListView)uiScriptTabControl.SelectedTab.Controls[0];

                    //get deserialized script
                    Script deserializedScript = Script.DeserializeFile(filePath);

                    //check if script is a part of the currently opened project
                    string openScriptProjectName = deserializedScript.ProjectName;

                    if (openScriptProjectName != _scriptProject.ProjectName)
                    {
                        uiScriptTabControl.TabPages.RemoveAt(uiScriptTabControl.TabCount - 1);
                        throw new Exception("Attempted to load a script not part of the currently open project");
                    }

                    //reinitialize
                    _selectedTabScriptActions.Items.Clear();
                    _scriptVariables = new List <ScriptVariable>();
                    _scriptElements  = new List <ScriptElement>();

                    if (deserializedScript.Commands.Count == 0)
                    {
                        Notify("Error Parsing File: Commands not found!");
                    }

                    //update file path and reflect in title bar
                    ScriptFilePath = filePath;

                    string scriptFileName = Path.GetFileNameWithoutExtension(ScriptFilePath);
                    _selectedTabScriptActions.Name = $"{scriptFileName}ScriptActions";

                    //assign variables
                    _scriptVariables.AddRange(deserializedScript.Variables);
                    _scriptElements.AddRange(deserializedScript.Elements);
                    uiScriptTabControl.SelectedTab.Tag = new ScriptObject(_scriptVariables, _scriptElements);

                    //update ProjectPath variable
                    var projectPathVariable = _scriptVariables.Where(v => v.VariableName == "ProjectPath").SingleOrDefault();
                    if (projectPathVariable != null)
                    {
                        projectPathVariable.VariableValue = _scriptProjectPath;
                    }
                    else
                    {
                        projectPathVariable = new ScriptVariable
                        {
                            VariableName  = "ProjectPath",
                            VariableValue = _scriptProjectPath
                        };
                        _scriptVariables.Add(projectPathVariable);
                    }

                    //populate commands
                    PopulateExecutionCommands(deserializedScript.Commands);

                    FileInfo scriptFileInfo = new FileInfo(_scriptFilePath);
                    uiScriptTabControl.SelectedTab.Text = scriptFileInfo.Name.Replace(".json", "");

                    //notify
                    Notify("Script Loaded Successfully!");
                }
                catch (Exception ex)
                {
                    //signal an error has happened
                    Notify("An Error Occured: " + ex.Message);
                }
            }
        }
示例#7
0
 public ExtractWadBsp(OpenFileDelegate openFileDlg)
 {
     InitializeComponent();
     this.openFileNow = openFileDlg;
 }
示例#8
0
 public static void CreatePdfSampleTapped()
 {
     OpenFileDelegate?.Invoke("document.pdf");
 }
 public NewWadForm(OpenFileDelegate openFile)
 {
     openFileNow = openFile;
     InitializeComponent();
     listPictures.ListViewItemSorter = new ListViewIndexComparer();
 }
示例#10
0
 public VheManager(OpenFileDelegate openFileDelegate, string currentWad = null)
 {
     InitializeComponent();
     VheManager.currentWad = currentWad;
     this.openFileNow = openFileDelegate;
 }
        public void OpenFile(string filePath)
        {
            if (InvokeRequired)
            {
                var d = new OpenFileDelegate(OpenFile);
                Invoke(d, new object[] { filePath });
            }
            else
            {
                try
                {
                    //create or switch to TabPage
                    string fileName = Path.GetFileNameWithoutExtension(filePath);
                    var    foundTab = uiScriptTabControl.TabPages.Cast <TabPage>().Where(t => t.ToolTipText == filePath)
                                      .FirstOrDefault();
                    if (foundTab == null)
                    {
                        TabPage newtabPage = new TabPage(fileName)
                        {
                            Name        = fileName,
                            ToolTipText = filePath
                        };

                        uiScriptTabControl.TabPages.Add(newtabPage);
                        newtabPage.Controls.Add(NewLstScriptActions(fileName));
                        uiScriptTabControl.SelectedTab = newtabPage;
                    }
                    else
                    {
                        uiScriptTabControl.SelectedTab = foundTab;
                        return;
                    }

                    _selectedTabScriptActions = (UIListView)uiScriptTabControl.SelectedTab.Controls[0];

                    //get deserialized script
                    Script deserializedScript = Script.DeserializeFile(filePath);

                    //reinitialize
                    _selectedTabScriptActions.Items.Clear();
                    _scriptVariables = new List <ScriptVariable>();
                    _scriptElements  = new List <ScriptElement>();

                    if (deserializedScript.Commands.Count == 0)
                    {
                        Notify("Error Parsing File: Commands not found!", Color.Red);
                    }

                    //update file path and reflect in title bar
                    ScriptFilePath = filePath;

                    string scriptFileName = Path.GetFileNameWithoutExtension(ScriptFilePath);
                    _selectedTabScriptActions.Name = $"{scriptFileName}ScriptActions";

                    //assign variables
                    _scriptVariables.AddRange(deserializedScript.Variables);
                    _scriptElements.AddRange(deserializedScript.Elements);
                    uiScriptTabControl.SelectedTab.Tag = new ScriptObject(_scriptVariables, _scriptElements);

                    //populate commands
                    PopulateExecutionCommands(deserializedScript.Commands);

                    FileInfo scriptFileInfo = new FileInfo(_scriptFilePath);
                    uiScriptTabControl.SelectedTab.Text = scriptFileInfo.Name.Replace(".json", "");

                    //notify
                    Notify("Script Loaded Successfully!", Color.White);
                }
                catch (Exception ex)
                {
                    //signal an error has happened
                    Notify("An Error Occured: " + ex.Message, Color.Red);
                }
            }
        }
示例#12
0
        private ModelX Load(Stream stream, OpenFileDelegate openFileDelegate)
        {
            Dictionary <VertexPositionNormalTexture, int> vertexToIndex = new Dictionary <VertexPositionNormalTexture, int>();
            List <ModelSubset> subsets = new List <ModelSubset>();
            List <VertexPositionNormalTexture> vertices = new List <VertexPositionNormalTexture>();

            List <Vector3> positions = new List <Vector3>();
            List <Vector3> normals   = new List <Vector3>();
            List <Vector2> coords    = new List <Vector2>();

            StreamReader reader = new StreamReader(stream);

            List <Int16> subsetIndices = new List <Int16>();

            List <Tuple <String, Material> > materials = new List <Tuple <String, Material> >();

            int           subsetMaterial = -1;
            List <String> temp           = new List <String>();

            while (!reader.EndOfStream)
            {
                String   line  = reader.ReadLine();
                String[] parts = line.Split(' ', '\t');

                temp.Clear();

                foreach (var part in parts)
                {
                    if (!String.IsNullOrWhiteSpace(part))
                    {
                        temp.Add(part);
                    }
                }

                if (temp.Count == 0)
                {
                    continue;
                }

                parts = temp.ToArray();

                switch (parts[0])
                {
                case "mtllib":
                {
                    String name = parts[1];

                    for (int idx = 2; idx < parts.Length; ++idx)
                    {
                        name += " " + parts[idx];
                    }

                    name = name.Trim();

                    if (name.StartsWith("./"))
                    {
                        name = name.Substring(2);
                    }

                    using (Stream matStream = openFileDelegate(name))
                    {
                        ReadMaterials(materials, matStream);
                    }
                }

                break;

                case "v":
                    AddVector3(positions, parts);
                    break;

                case "vn":
                    AddVector3(normals, parts);
                    break;

                case "vt":
                    AddVector2(coords, parts);
                    break;

                case "f":
                    AddIndices(subsetIndices, parts, vertices, vertexToIndex, positions, normals, coords);
                    break;

                case "usemtl":

                    if (subsetMaterial >= 0)
                    {
                        AddNewSubset(subsets, subsetIndices, ref subsetMaterial);
                    }

                    subsetMaterial = FindMaterial(parts[1], materials);

                    if (subsetMaterial < 0)
                    {
                        throw new InvalidDataException(String.Format("Unknown material: {0}.", parts[1]));
                    }

                    break;
                }
            }

            if (subsetMaterial >= 0)
            {
                AddNewSubset(subsets, subsetIndices, ref subsetMaterial);
            }

            return(new ModelX(new List <Material[]>()
            {
                GetArrayOfMaterials(materials)
            }, subsets.ToArray(), vertices.ToArray()));
        }
示例#13
0
 public ModelX Import(Stream stream, OpenFileDelegate openFileDelegate)
 {
     return(Load(stream, openFileDelegate));
 }
示例#14
0
 public NewSpriteForm(OpenFileDelegate openFile)
 {
     openFileNow = openFile;
     InitializeComponent();
     listPictures.ListViewItemSorter = new ListViewIndexComparer();
 }
示例#15
0
 public VheManager(OpenFileDelegate openFileDelegate, string currentWad = null)
 {
     InitializeComponent();
     VheManager.currentWad = currentWad;
     this.openFileNow      = openFileDelegate;
 }
 public ExtractWadBsp(OpenFileDelegate openFileDlg)
 {
     InitializeComponent();
     this.openFileNow = openFileDlg;
 }