Beispiel #1
0
        static int TriggerNewAssetSave(TextBox box)
        {
            DirectoryTreeItem selectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;

            if (selectedItem.IsDirectory == false)
            {
                selectedItem = selectedItem.GetParentSave() as DirectoryTreeItem;
            }


            CDCCDefinition def = CApplicationSettings.Instance.GetDCCProgram(m_sRequesteDCCPackage);


            string savepath = selectedItem.FullPath + "\\" + box.Text;


            if (savepath.LastIndexOf('.') == -1)
            {
                // HACK: Add a dot if there is none, so def.Start won't crop the last letter
                savepath += '.';
            }


            def.Start(savepath);


            selectedItem.Items.Clear();

            DirectoryInfo info = new DirectoryInfo(selectedItem.FullPath);

            TraverseDirectory(info, ref selectedItem);

            selectedItem.IsExpanded = true;
            return(0);
        }
Beispiel #2
0
        void OnRemoveDefClicked(object sender, RoutedEventArgs args)
        {
            CDCCDefinition def = GetCurrentDefinition();

            if (def != null)
            {
                m_dccDefCopy.Remove(def.Name);
            }

            RefreshDCCDefDropdown();
        }
Beispiel #3
0
        private void SaveCurrentEntry()
        {
            ComboBoxItem selectedItem = dccDefDropdown.SelectedItem as ComboBoxItem;

            if (selectedItem != null)
            {
                string defName = (string)selectedItem.Content;

                var def = new CDCCDefinition();

                def.Name = defName;
            }
        }
Beispiel #4
0
        void OnRemoveProgramClicked(object sender, RoutedEventArgs args)
        {
            SDCCProgram prog = GetCurrentProgram();

            if (prog != null)
            {
                CDCCDefinition def = GetCurrentDefinition();

                if (def != null)
                {
                    def.Programs.Remove(prog.Name);
                    UpdateListViews();
                }
            }
        }
Beispiel #5
0
        private void UpdateListViews()
        {
            if (dccDefDropdown.Items.Count == 0 || dccDefDropdown.SelectedItem == null)
            {
                return;
            }

            //if (programsListView.Items.Count != 0)
            programsListView.Items.Clear();

            //if (startupFileListView.Items != null)
            startupFileListView.Items.Clear();
            CDCCDefinition def     = null;
            string         defName = (string)(dccDefDropdown.SelectedItem as ComboBoxItem).Content;

            m_dccDefCopy.TryGetValue(defName, out def);

            foreach (string key in def.Programs.Keys)
            {
                var item = new ListViewItem();
                item.Content = def.GetProgram(key).Name;
                programsListView.Items.Add(item);

                foreach (string filekey in def.GetProgram(key).StartupFiles.Keys)
                {
                    item = new ListViewItem();

                    item.Content = filekey;
                    startupFileListView.Items.Add(item);
                }
            }

            if (programsListView.Items.Count > 0)
            {
                programsListView.SelectedIndex = 0;
            }

            if (startupFileListView.Items.Count > 0)
            {
                startupFileListView.SelectedIndex = 0;
            }

            UpdateDataGrid();
        }
Beispiel #6
0
        void OnOKClicked(object sender, RoutedEventArgs e)
        {
            // Check if path in textbox is valid
            if (!ValidateFilePath(DesiredSavePath))
            {
                return;
            }

            ComboBoxItem item     = (ComboBoxItem)dccProgramDropdown.SelectedItem;
            string       progName = (string)item.Content;

            CDCCDefinition prog = CApplicationSettings.Instance.GetDCCProgram(progName);

            prog.Start(DesiredSavePath);

            // TODO: Implement prog.Start();

            Close();
        }
Beispiel #7
0
        //#########################################################################################
        // Callbacks
        //#########################################################################################
        int ProgramDefAddCallback(TextBox box, System.Windows.Forms.DialogResult res)
        {
            if (res != System.Windows.Forms.DialogResult.Cancel)
            {
                if (m_dccDefCopy.ContainsKey(box.Text))
                {
                    CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefDuplicateEntry + " " + box.Text);
                    return(0);
                }

                CDCCDefinition newDef = new CDCCDefinition();
                newDef.Name = box.Text;

                m_dccDefCopy.Add(newDef.Name, newDef);

                RefreshDCCDefDropdown();

                TrySelectDCCDef(newDef.Name);
            }
            return(0);
        }
Beispiel #8
0
        private void ApplyAllChanges()
        {
            // The copy becomes the actual one..

            // clean original
            foreach (string name in CApplicationSettings.Instance.GetAllDCCProgramNames())
            {
                CApplicationSettings.Instance.RemoveDCCProgram(name);
            }

            // add new entries to original
            foreach (string key in m_dccDefCopy.Keys)
            {
                CDCCDefinition def = null;
                m_dccDefCopy.TryGetValue(key, out def);

                if (def != null && def.Programs.Count > 0)
                {
                    CApplicationSettings.Instance.SetDCCProgram(def);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Checks whether sPath is CE conform and actually contains a file name
        /// </summary>
        /// <param name="sPath"></param>
        /// <returns>True if valid, else false</returns>
        private bool ValidateFilePath(string sPath)
        {
            // Need to check for a valid filename because user can enter stuff in the textbox itself

            int            dotPos = DesiredSavePath.LastIndexOf('.');
            int            dirPos = DesiredSavePath.LastIndexOf('\\');
            ComboBoxItem   item   = dccProgramDropdown.SelectedItem as ComboBoxItem;
            CDCCDefinition prog   = CApplicationSettings.Instance.GetDCCProgram(item.Content as string);

            if ((dotPos < dirPos && dotPos != -1) || dirPos == DesiredSavePath.Length - 1)
            {
                MessageBox.Show("Please specify a valid filname with extension", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            // It's valid but doesn't have an extension
            // Irrelevant since the name is only used for naming anyway

            /*if (dotPos == -1)
             * {
             *
             *
             *      DesiredSavePath += "." + prog.FileExtension;
             * }
             * else
             * {
             *      // Check for the correct extension
             *      string extension = DesiredSavePath.Substring(dotPos + 1, DesiredSavePath.Length - dotPos -1);
             *
             *      if (extension != prog.FileExtension)
             *      {
             *              string newPath = DesiredSavePath.Substring(0, dotPos + 1) + prog.FileExtension;
             *      }
             * }
             */


            return(CPathUtils.IsStringCEConform(sPath));
        }
Beispiel #10
0
        bool AddProgramEntryCallback(TextBox box, System.Windows.Forms.DialogResult res)
        {
            if (GetCurrentDefinition() != null)
            {
                CDCCDefinition def = GetCurrentDefinition();

                if (def.Programs.ContainsKey(box.Text))
                {
                    CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefDuplicateEntry + " " + box.Text);
                    return(false);
                }

                SDCCProgram prog = new SDCCProgram();
                prog.Name = box.Text;

                def.Programs.Add(prog.Name, prog);


                UpdateListViews();
            }

            return(true);
        }
Beispiel #11
0
        public static void SetupContextMenu()
        {
            if (m_viewItemContextMenu == null)
            {
                m_viewItemContextMenu = new ContextMenu();
            }

            m_viewItemContextMenu.Items.Clear();

            Separator sep = new Separator();

            // Setup all the different DCCPackages
            var item = new MenuItem();

            item.Header = "New asset";             // LOCALIZE

            List <string> dccdefs = CApplicationSettings.Instance.GetAllDCCProgramNames();


            foreach (string dccdef in dccdefs)
            {
                MenuItem notherItem = new MenuItem();

                notherItem.Header = dccdef;
                notherItem.Click += OnContextNewAssetClicked;

                item.Items.Add(notherItem);
            }

            if (item.Items.Count == 0)
            {
                item.IsEnabled = false;
            }
            m_viewItemContextMenu.Items.Add(item);

            //---------------------------------
            MenuItem runWithItem = new MenuItem();

            runWithItem.Header = "Run with...";             // LOCALIZE

            item        = new MenuItem();
            item.Header = "Run with rc";             // LOCALIZE
            item.Click += OnContextRunRCClicked;
            runWithItem.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Run with gfxExporter";             // LOCALIZE
            item.Click += OnContextRunGFXClicked;
            runWithItem.Items.Add(item);

            List <string> defs = CApplicationSettings.Instance.GetAllDCCProgramNames();

            if (defs.Count > 0)
            {
                sep = new Separator();
                runWithItem.Items.Add(sep);
            }
            List <string> addedPrograms = new List <string>();

            foreach (string defName in defs)
            {
                CDCCDefinition def = CApplicationSettings.Instance.GetDCCProgram(defName);

                foreach (SDCCProgram program in def.Programs.Values)
                {
                    if (addedPrograms.Contains(program.Name))
                    {
                        continue;
                    }

                    MenuItem programItem = new MenuItem();

                    programItem.Header = program.Name;

                    programItem.Click += delegate
                    {
                        DirectoryTreeItem selectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;
                        if (selectedItem != null)
                        {
                            if (!selectedItem.IsDirectory)
                            {
                                Process proc = new Process();
                                proc.StartInfo           = new ProcessStartInfo(program.ExecutablePath);
                                proc.StartInfo.Arguments = selectedItem.FullPath;

                                proc.Start();
                            }
                        }
                    };

                    runWithItem.Items.Add(programItem);
                    addedPrograms.Add(program.Name);
                }
            }

            m_viewItemContextMenu.Items.Add(runWithItem);
            //----------------------------------

            sep = new Separator();
            m_viewItemContextMenu.Items.Add(sep);

            item        = new MenuItem();
            item.Header = "Copy";             // LOCALIZE
            item.Click += OnContextCopyClicked;
            m_viewItemContextMenu.Items.Add(item);

            item = new MenuItem();

            item.Header = "Cut";             // LOCALIZE
            item.Click += OnContextCutClicked;

            m_viewItemContextMenu.Items.Add(item);

            item = new MenuItem();

            item.Header = "Paste";             // LOCALIZE
            item.Click += OnContextPasteClicked;

            m_viewItemContextMenu.Items.Add(item);


            item = new MenuItem();

            item.Header = "Move to Recycle Bin";             // LOCALIZE
            item.Click += OnContextRecycleClicked;

            m_viewItemContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Delete";             // LOCALIZE
            item.Click += OnContextDeleteClicked;
            m_viewItemContextMenu.Items.Add(item);

            item = new MenuItem();

            item.Header = "Rename";             // LOCALIZE
            item.Click += OnContextRenameClicked;

            m_viewItemContextMenu.Items.Add(item);


            sep = new Separator();
            m_viewItemContextMenu.Items.Add(sep);

            item = new MenuItem();


            item.Header = "New Directory";             // LOCALIZE
            item.Click += OnContextNewDirectoryClicked;

            m_viewItemContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Open in explorer";             // LOCALIZE
            item.Click += OnContextOpenInExplorerClicked;
            m_viewItemContextMenu.Items.Add(item);

            sep = new Separator();
            m_viewItemContextMenu.Items.Add(sep);

            item        = new MenuItem();
            item.Header = "Track file";             // LOCALIZE
            item.Click += OnContextTrackClicked;
            m_viewItemContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Stop tracking file";             // LOCALIZE
            item.Click += OnContextStopTrackClicked;
            m_viewItemContextMenu.Items.Add(item);
        }
Beispiel #12
0
        private void SetUpToolsContextMenu()
        {
            m_ToolsContextMenu                 = new ContextMenu();
            m_profileHistoryContextMenu        = new MenuItem();
            m_profileHistoryContextMenu.Header = Properties.Resources.ToolsProfileHistory;

            MenuItem item = new MenuItem();

            item.Header = "Settings";             // LOCALIZE
            item.Click += ToolContextSettingsClicked;
            m_ToolsContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Restore Sandbox Layout";             // LOCALIZE
            item.Click += ToolContextRestoreSBLayoutClicked;
            m_ToolsContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = "Run...";             // LOCALIZE
            List <string> defNames = CApplicationSettings.Instance.GetAllDCCProgramNames();
            MenuItem      progItem;

            List <string> addedPrograms = new List <string>();

            foreach (string defName in defNames)
            {
                CDCCDefinition def = CApplicationSettings.Instance.GetDCCProgram(defName);

                foreach (SDCCProgram program in def.Programs.Values)
                {
                    if (addedPrograms.Contains(program.Name))
                    {
                        continue;
                    }

                    progItem        = new MenuItem();
                    progItem.Header = program.Name;

                    progItem.Click += delegate(object sender, RoutedEventArgs e)
                    {
                        Process          proc = new Process();
                        ProcessStartInfo info = new ProcessStartInfo(program.ExecutablePath);
                        proc.StartInfo = info;
                        proc.Start();
                    };

                    item.Items.Add(progItem);
                    addedPrograms.Add(program.Name);
                }
            }

            if (item.Items.Count == 0)
            {
                item.IsEnabled = false;
            }
            m_ToolsContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = Properties.Resources.ToolsSourceTrackingSubmenu;
            SetupSourceFileContextMenu(ref item);
            m_ToolsContextMenu.Items.Add(item);

            //============================================================================

            var sep = new Separator();

            m_ToolsContextMenu.Items.Add(sep);

            item        = new MenuItem();
            item.Header = Properties.Resources.ToolsLoadProfile;
            item.Click += OnLoadProfileClicked;
            m_ToolsContextMenu.Items.Add(item);

            item        = new MenuItem();
            item.Header = Properties.Resources.ToolsSaveProfile;
            item.Click += OnSaveProfileClicked;
            m_ToolsContextMenu.Items.Add(item);



            RefreshProfileHistory();
            if (m_profileHistoryContextMenu.Items.Count <= 0)
            {
                m_profileHistoryContextMenu.IsEnabled = false;
            }

            m_ToolsContextMenu.Items.Add(m_profileHistoryContextMenu);
        }
Beispiel #13
0
        void OnBrowseDirClicked(object sender, RoutedEventArgs e)
        {
            // TODO: Remimplement
            System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog();

            // Error checking can be omitted since there are only valid entries to begin with
            ComboBoxItem item     = (ComboBoxItem)dccProgramDropdown.SelectedItem;
            string       progName = (string)item.Content;

            CDCCDefinition prog = CApplicationSettings.Instance.GetDCCProgram(progName);

            if (prog != null)
            {
                string filter = "";
                int    j      = 0;

                foreach (string key in prog.Programs.Keys)
                {
                    SDCCProgram program = prog.GetProgram(key);

                    int i = 0;

                    foreach (string fileKey in program.StartupFiles.Keys)
                    {
                        SStartupFile file = program.GetFile(fileKey);

                        if (i == 0)
                        {
                            filter += program.Name + " Files|";
                        }

                        filter += "*." + file.Extension;

                        if (i < program.StartupFiles.Count - 1)
                        {
                            filter += ";";
                        }
                        ++i;
                    }


                    // TODO: What if there are two progs but only one startup?

                    if (j < prog.Programs.Count - 1)
                    {
                        filter += "|";
                    }

                    ++j;
                }

                dialog.Filter = filter;
            }

            dialog.InitialDirectory = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();

            System.Windows.Forms.DialogResult res = dialog.ShowDialog();

            if (res == System.Windows.Forms.DialogResult.Cancel)
            {
                if (saveFileTextBox.Text != CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString())
                {
                    return;
                }
                string sRootPath   = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString();
                string sGameFolder = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();

                sGameFolder = sGameFolder == null ? "" : sGameFolder;
                SetDesiredSavePath(sGameFolder + "\\Objects\\");
            }
            else
            {
                SetDesiredSavePath(dialog.FileName);
            }
        }