Ejemplo n.º 1
0
        private void OnDrawElementLocation(Rect rect, int index, bool isactive, bool isfocused)
        {
            SaveMethod      saveMethod = settingObject.SaveLocations[index];
            IListItemDrawer itemDrawer = (IListItemDrawer)settingObject.SaveLocations[index];

            EditorGUI.BeginChangeCheck();

            if (itemDrawer != null)
            {
                itemDrawer.OnDrawElement(rect, line_height);
            }
            else if (saveMethod != null)
            {
                GUI.Label(new Rect(rect.position, new Vector2(rect.width - 40, 16)), saveMethod.SaveName);
            }
            else
            {
                settingObject.SaveLocations[index] = (SaveMethod)EditorGUI.ObjectField(
                    new Rect(rect.position, new Vector2(rect.width, line_height)),
                    saveMethod, typeof(SaveMethod), false);
            }


            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(saveMethod);
                SaveChanges();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the data from the most recent save location
        /// </summary>
        public void LoadData()
        {
            Dictionary <int, string> _da = new Dictionary <int, string>();
            // find the most recent save
            DateTime   lastSave = new DateTime(1900, 1, 1);
            SaveMethod _mR      = null;

            foreach (SaveMethod _m in SaveLocations)
            {
                if (_m != null && _m.LastSave >= lastSave)
                {
                    _mR = _m;//_da = _m.LoadData(_data);
                }
            }
            if (_mR != null)
            {
                _da = _mR.LoadData(_data);
                // load data
                foreach (SavableVariable d in Data)
                {
                    if (d == null)
                    {
                        continue;
                    }

                    if (_da.ContainsKey(d.GetInstanceID()))
                    {
                        d.OnLoadData(_da[d.GetInstanceID()]);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /**
         * <summary>Serializes an object, either by XML, Binary or Json, depending on the platform.</summary>
         * <param name = "dataObject">The object to serialize</param>
         * <param name = "addMethodName">If True, the name of the serialization method (XML, Binary or Json) will be appended to the start of the serialized string. This is useful when the same file is read later by a different serialization method.</param>
         * <returns>The object, serialized to a string</returns>
         */
        public static string SerializeObject <T> (object dataObject, bool addMethodName = false)
        {
            SaveMethod saveMethod       = SaveSystem.GetSaveMethod();
            string     serializedString = "";

            if (saveMethod == SaveMethod.XML)
            {
                serializedString = SerializeObjectXML <T> (dataObject);
            }
            else if (saveMethod == SaveMethod.Binary)
            {
                serializedString = SerializeObjectBinary(dataObject);
            }
            else if (saveMethod == SaveMethod.Json)
            {
                serializedString = SerializeObjectJson(dataObject);
            }

            if (serializedString != "" && addMethodName)
            {
                serializedString = saveMethod.ToString() + serializedString;
            }

            return(serializedString);
        }
Ejemplo n.º 4
0
 public GameConfig()
 {
     // set Cryption
     if (UseSaveMethod == SaveMethod.None)
     {
         UseSaveMethod = SaveMethod.Xml;
     }
 }
Ejemplo n.º 5
0
 /* ----------------------------------------------------------------- */
 ///
 /// ExtractDirectory
 ///
 /// <summary>
 /// Initializes a new instance of the ExtractDirectory class with
 /// the specified arguments.
 /// </summary>
 ///
 /// <param name="src">Path of the root directory.</param>
 /// <param name="method">Save method.</param>
 /// <param name="filters">
 /// Collection of file or directory names to filter.
 /// </param>
 ///
 /* ----------------------------------------------------------------- */
 public ExtractDirectory(string src, SaveMethod method, IEnumerable <string> filters)
 {
     Source      = src;
     Value       = src;
     ValueToOpen = src;
     Method      = method;
     Filters     = filters;
 }
Ejemplo n.º 6
0
 private void SetMethod()
 {
     foreach (PlatformMethod pm in platformMethods)
     {
         if (pm.platform == Application.platform)
         {
             _currentMethod = pm.method;
             return;
         }
     }
     _currentMethod = defaultMethod;
 }
Ejemplo n.º 7
0
    public bool Save(SaveMethod method)
    {
        var s = BuildSaveString();

        if (method == SaveMethod.Local)
        {
            PlayerPrefs.SetString("SaveString", s);
            return(true);
        }

        return(false);
    }
Ejemplo n.º 8
0
 private void FindSaveLocations()
 {
     string[] ass = AssetDatabase.FindAssets("t:SaveMethod");
     foreach (string a in ass)
     {
         if (AssetDatabase.GUIDToAssetPath(a).Contains("/" + settingObject.name + "/"))
         {
             SaveMethod sv = (SaveMethod)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(a), typeof(SaveMethod));
             if (!settingObject.SaveLocations.Contains(sv))
             {
                 settingObject.SaveLocations.Add(sv);
             }
         }
     }
     EditorUtility.SetDirty(settingObject);
 }
Ejemplo n.º 9
0
        /**
         * <summary>De-serializes a RememberData class, either from XML or Binary, depending on the platform.</summary>
         * <param name = "dataString">The RememberData class, serialized as a string</param>
         * <returns>The de-serialized RememberData class</return>
         */
        public static T LoadScriptData <T> (string dataString) where T : RememberData
        {
            SaveMethod saveMethod = SaveSystem.GetSaveMethod();

            if (dataString.StartsWith(saveMethod.ToString()))
            {
                dataString = dataString.Remove(0, saveMethod.ToString().ToCharArray().Length);
            }

            if (saveMethod == SaveMethod.Binary)
            {
                return((T)Serializer.DeserializeRememberData <T> (dataString));
            }
            else
            {
                return(Serializer.DeserializeObject <T> (dataString));
            }
        }
Ejemplo n.º 10
0
        public void Execute(object parameter)
        {
            var values   = (object[])parameter;
            var video    = values[0] as Video;
            var subtitle = values[1] as Subtitle;

            if (video == null || subtitle == null)
            {
                return;
            }

            var saveFileDialog = new System.Windows.Forms.SaveFileDialog();

            saveFileDialog.Filter      = EXTENSION_FILTER;
            saveFileDialog.FilterIndex = mLastFilterIndex;
            saveFileDialog.FileName    = getFilenameExceptIllegalCharacter(video.Title);

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                mLastFilterIndex = saveFileDialog.FilterIndex;

                string ext = Path.GetExtension(saveFileDialog.FileName).ToLower();

                FileStream   fileStream   = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write);
                StreamWriter streamWriter = new StreamWriter(fileStream);

                SaveMethod saveMethod = saveAsTXT;
                for (int i = 0; i < METHODS.Length; ++i)
                {
                    if (EXTENSIONS[i] == ext)
                    {
                        saveMethod = METHODS[i];
                        break;
                    }
                }
                // 저장 메서드 호출
                saveMethod(streamWriter, video, subtitle);

                streamWriter.Flush();
                streamWriter.Close();
                fileStream.Close();
            }
        }
Ejemplo n.º 11
0
        /**
         * <summary>Deserializes a string into an OptionsData class.</summary>
         * <param name = "dataString">The OptionsData, serialized as a string</param>
         * <returns>The de-serialized OptionsData class</returns>
         */
        public static OptionsData DeserializeOptionsData(string dataString)
        {
            SaveMethod saveMethod = SaveSystem.GetSaveMethod();

            if (dataString.StartsWith(saveMethod.ToString()))
            {
                dataString = dataString.Remove(0, saveMethod.ToString().ToCharArray().Length);
            }
            else
            {
                if (dataString.StartsWith("XML") || dataString.StartsWith("Json") || dataString.StartsWith("Binary"))
                {
                    // Switched method, so make new
                    return(new OptionsData());
                }
            }

            return((OptionsData)DeserializeObject <OptionsData> (dataString));
        }
Ejemplo n.º 12
0
        /**
         * <summary>De-serializes an object from a string, according to the game's SaveMethod.</summary>
         * <param name = "dataString">The object, serialized into a string</param>
         * <returns>The object, deserialized</returns>
         */
        public static T DeserializeObject <T> (string dataString)
        {
            SaveMethod saveMethod = SaveSystem.GetSaveMethod();

            if (dataString == null || dataString.Length == 0)
            {
                return(default(T));
            }
            else if (dataString.Contains("<?xml") || dataString.Contains("xml version"))
            {
                saveMethod = SaveMethod.XML;
            }
            else if (saveMethod == SaveMethod.XML && !dataString.Contains("<?xml") && !dataString.Contains("xml version"))
            {
                return(default(T));
            }

            if (dataString.StartsWith(saveMethod.ToString()))
            {
                dataString = dataString.Remove(0, saveMethod.ToString().ToCharArray().Length);
            }

            T result = default(T);

            if (saveMethod == SaveMethod.XML)
            {
                result = (T)DeserializeObjectXML <T> (dataString);
            }
            else if (saveMethod == SaveMethod.Binary)
            {
                result = (T)DeserializeObjectBinary <T> (dataString);
            }
            else if (saveMethod == SaveMethod.Json)
            {
                result = (T)DeserializeObjectJson <T> (dataString);
            }

            if (result != null && result is T)
            {
                return((T)result);
            }
            return(default(T));
        }
Ejemplo n.º 13
0
        public void CaptureImages(CaptureMethod capturemethod, SaveMethod savemethod)
        {
            _saveMethod = savemethod;

            switch (capturemethod)
            {
            case CaptureMethod.Pixels:
                StartCoroutine(ReadPixels());
                break;

            case CaptureMethod.Tex:
                StartCoroutine(RenderToTex());
                break;

            case CaptureMethod.App:
                StartCoroutine(ScreenShot());
                break;
            }
        }
Ejemplo n.º 14
0
    private SaveState ReadSaveData(SaveMethod method)
    {
        SaveState r;

        if (method == SaveMethod.Local)
        {
            var registry = PlayerPrefs.GetString("SaveString");
            if (registry != "")
            {
                r = new SaveState(registry);
            }
            else
            {
                r = new SaveState();
            }
        }
        else
        {
            r = new SaveState("999%999%0%11%11%11");
        }

        return(r);
    }
Ejemplo n.º 15
0
        public bool Save(SaveMethod Method)
        {
            string dummy;

            return(Save(Method, out dummy));
        }
Ejemplo n.º 16
0
        public ShaderViewer(Core core, bool custom, string entry, Dictionary<string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            constantRegs.Font =
                variableRegs.Font =
                watchRegs.Font =
                inSig.Font =
                outSig.Font =
                core.Config.PreferredFont;

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible = false;
            outSigBox.Visible = false;

            m_Core = core;
            m_SaveCallback = saveCallback;
            m_CloseCallback = closeCallback;

            if (m_Core.LogLoaded)
                pointLinearSamplersToolStripMenuItem.Visible = (m_Core.APIProps.pipelineType == APIPipelineStateType.D3D11);

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown += new KeyEventHandler(editScintilla_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                    sel = w;

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            m_FindAll = new FindAllDialog(FindAllFiles);
            m_FindAll.Hide();

            if (files.Count > 3)
                AddFileList();

            if (sel != null)
                sel.Show();

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }
Ejemplo n.º 17
0
 public bool Save(BaseSettings settings, string path) => SaveMethod?.Invoke(Object, new object[] { settings, path }) as bool? ?? false;
Ejemplo n.º 18
0
 public void SetSaveMethod(SaveMethod saveMethod)
 {
     this.useSaveMethod = saveMethod;
 }
Ejemplo n.º 19
0
        public ShaderViewer(Core core, bool custom, string entry, Dictionary <string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible  = false;
            outSigBox.Visible = false;

            m_Core          = core;
            m_SaveCallback  = saveCallback;
            m_CloseCallback = closeCallback;

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag        = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown        += new KeyEventHandler(scintilla1_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton        = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                {
                    sel = w;
                }

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            if (sel != null)
            {
                sel.Show();
            }

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }
Ejemplo n.º 20
0
        public bool Save(SaveMethod Method, out string NewFilename)
        {
            NewFilename = "";
            if ((Method == SaveMethod.SAVE_AS) ||
                (Method == SaveMethod.SAVE_COPY_AS) ||
                (DocumentInfo.DocumentFilename == null))
            {
                // we need a file name
                string oldName = "";
                if ((Method == SaveMethod.SAVE_AS) &&
                    (DocumentInfo.FullPath != null))
                {
                    oldName = DocumentInfo.FullPath;
                }

                if (!QueryFilename(out NewFilename))
                {
                    return(false);
                }
                if (DocumentInfo.DocumentFilename == null)
                {
                    // a new filename
                    if (DocumentInfo.Project == null)
                    {
                        DocumentInfo.DocumentFilename = NewFilename;
                    }
                    else
                    {
                        DocumentInfo.DocumentFilename = GR.Path.RelativePathTo(System.IO.Path.GetFullPath(DocumentInfo.Project.Settings.BasePath), true, NewFilename, false);
                        if (DocumentInfo.Element != null)
                        {
                            DocumentInfo.Element.Name      = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);
                            DocumentInfo.Element.Node.Text = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);
                            DocumentInfo.Element.Filename  = DocumentInfo.DocumentFilename;
                            if (DocumentInfo.Element.Settings.Count == 0)
                            {
                                DocumentInfo.Element.Settings["Default"] = new ProjectElement.PerConfigSettings();
                            }
                        }
                    }
                    Text    = System.IO.Path.GetFileNameWithoutExtension(DocumentInfo.DocumentFilename) + "*";
                    TabText = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);
                    SetupWatcher();

                    if (!PerformSave(NewFilename))
                    {
                        return(false);
                    }
                    SetUnmodified();
                    return(true);
                }

                if (Method == SaveMethod.SAVE_AS)
                {
                    if (!PerformSave(NewFilename))
                    {
                        return(false);
                    }

                    // rename during save
                    if (DocumentInfo.Project != null)
                    {
                        DocumentInfo.DocumentFilename  = GR.Path.RelativePathTo(System.IO.Path.GetFullPath(DocumentInfo.Project.Settings.BasePath), true, NewFilename, false);
                        DocumentInfo.Element.Name      = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);
                        DocumentInfo.Element.Node.Text = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);
                        DocumentInfo.Element.Filename  = DocumentInfo.DocumentFilename;
                        if (DocumentInfo.Element.Settings.Count == 0)
                        {
                            DocumentInfo.Element.Settings["Default"] = new ProjectElement.PerConfigSettings();
                        }
                    }
                    else
                    {
                        DocumentInfo.DocumentFilename = NewFilename;
                    }
                    Text    = System.IO.Path.GetFileNameWithoutExtension(DocumentInfo.DocumentFilename) + "*";
                    TabText = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename);

                    // need to rename file in project (dependencies, etc.)
                    string newName = DocumentInfo.FullPath;

                    DisableFileWatcher();
                    try
                    {
                        System.IO.File.Delete(oldName);
                    }
                    catch (System.IO.FileNotFoundException)
                    {
                        // ignore this specific error, go on renaming
                    }
                    catch (System.Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show("An error occurred while deleting old file\r\n" + ex.Message, "Error while renaming");
                    }
                    if (Core.Navigating.Solution != null)
                    {
                        Core.Navigating.Solution.RenameElement(DocumentInfo.Element, oldName, newName);
                    }
                    DocumentInfo?.Project?.SetModified();
                    SetUnmodified();
                    return(true);
                }
                if (!PerformSave(NewFilename))
                {
                    return(false);
                }
                SetUnmodified();
                return(true);
            }

            if (!PerformSave(DocumentInfo.FullPath))
            {
                return(false);
            }
            SetUnmodified();
            return(true);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Save a person
        /// </summary>
        /// <param name="person"></param>
        /// <param name="method"></param>
        public void SavePerson(Person person, SaveMethod method)
        {
            StringBuilder str = new StringBuilder();
            DataSet data;
            DataRow row;
            int res;
            bool isEmpty = false;

            if(method == SaveMethod.CreateNew) {
                person.ID = Helper.NewGuid;
            }

            // load
            str.Remove(0, str.Length);
            str.Append("SELECT * ");
            str.Append(" FROM tbl_persons");

            if(this._cfg.ProviderType != ProviderType.SQLite) {
                str.Append(" WHERE pkid = '" + person.ID + "'");
            }
            else {
                str.Append(" WHERE lower(pkid) = lower('{" + person.ID + "}')");
            }

            // load data
            try {
                data = this._db.ExecuteQuery(str.ToString());
            }
            catch(Exception ex) {
                throw new Exception("Error on loading person from table!", ex);
            }

            // get row
            if(method == SaveMethod.CreateNew
            || method == SaveMethod.CreateNewWithoutID) {
                row = data.Tables[0].NewRow();
                isEmpty = true;
            }
            else {
                row = data.Tables[0].Rows[0];
            }

            // data
            row["pkid"] = person.ID;
            row["firstname"] = person.Firstname + "";
            row["lastname"] = person.Lastname + "";
            row["is_actor"] = person.IsActor;
            row["is_director"] = person.IsDirector;
            row["is_producer"] = person.IsProducer;
            row["is_musician"] = person.IsMusician;
            row["is_cameraman"] = person.IsCameraman;
            row["is_cutter"] = person.IsCutter;
            row["is_writer"] = person.IsWriter;

            // add row
            if(isEmpty) {
                data.Tables[0].Rows.Add(row);
            }

            // save
            try {
                res = this._db.ExecuteUpdate(data, "tbl_persons");
            }
            catch(Exception ex) {
                throw new Exception("Error on updating person to table!", ex);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Save a movie
        /// </summary>
        /// <param name="movie"></param>
        /// <param name="method"></param>
        public void SaveMovie(Movie movie, SaveMethod method)
        {
            StringBuilder str = new StringBuilder();
            DataSet data;
            DataRow row;
            int res;
            bool isEmpty = false;

            if(method == SaveMethod.CreateNew) {
                movie.Id = Helper.NewGuid;

                if(movie.Number == default(int)) {
                    movie.Number = this.GetNextMovieNumber();
                }
            }

            // load
            str.Remove(0, str.Length);
            str.Append("SELECT * ");
            str.Append(" FROM tbl_movies");

            if(this._cfg.ProviderType != ProviderType.SQLite) {
                str.Append(" WHERE pkid = '" + movie.Id + "'");
            }
            else {
                str.Append(" WHERE lower(pkid) = lower('{" + movie.Id + "}')");
            }

            // load data
            try {
                data = this._db.ExecuteQuery(str.ToString());
            }
            catch(Exception ex) {
                throw new Exception("Error on loading movie from table!", ex);
            }

            // get row
            if(method == SaveMethod.CreateNew) {
                row = data.Tables[0].NewRow();
                isEmpty = true;
            }
            else {
                row = data.Tables[0].Rows[0];
            }

            // data
            row["pkid"] = movie.Id;
            row["sort_value"] = ( movie.SortValue.IsNullOrTrimmedEmpty() ? null : movie.SortValue );
            row["language"] = ( movie.Language.IsNullOrTrimmedEmpty() ? null : movie.Language );
            row["number"] = movie.Number;
            row["name"] = movie.Name + "";
            row["note"] = movie.Note + "";
            row["has_cover"] = movie.HasCover;
            row["is_original"] = movie.IsOriginal;
            row["is_conferred"] = movie.IsConferred;
            row["codec"] = (int)movie.Codec;
            row["conferred_to"] = movie.ConferredTo + "";
            row["disc_amount"] = movie.DiscAmount;
            row["year"] = movie.Year;
            row["country"] = movie.Country + "";
            row["quality"] = (int)movie.Quality;

            // add row
            if(isEmpty) {
                data.Tables[0].Rows.Add(row);
            }

            // save
            try {
                res = this._db.ExecuteUpdate(data, "tbl_movies");
            }
            catch(Exception ex) {
                throw new Exception("Error on updating movie to table!", ex);
            }

            // save genres
            str.Remove(0, str.Length);
            str.Append("DELETE ");
            str.Append(" FROM tbl_movies_to_genres");

            if(this._cfg.ProviderType != ProviderType.SQLite) {
                str.Append(" WHERE movie_pkid = '" + movie.Id + "'");
            }
            else {
                str.Append(" WHERE lower(movie_pkid) = lower('{" + movie.Id + "}')");
            }

            res = this._db.ExecuteNonQuery(str.ToString());

            str.Remove(0, str.Length);
            str.Append("SELECT * ");
            str.Append(" FROM tbl_movies_to_genres");

            try {
                data = null;
                data = this._db.ExecuteQuery(str.ToString());
            }
            catch(Exception ex) {
                throw new Exception("Error on loading genres from table!", ex);
            }

            foreach(Genre g in movie.Genres) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["genre_pkid"] = g.ID;
                hrow["movie_pkid"] = movie.Id;

                data.Tables[0].Rows.Add(hrow);
            }

            try {
                res = this._db.ExecuteUpdate(data, "tbl_movies_to_genres");
            }
            catch(Exception ex) {
                throw new Exception("Error on updating genres to table!", ex);
            }

            // save categories
            str.Remove(0, str.Length);
            str.Append("DELETE ");
            str.Append(" FROM tbl_movies_to_categories");

            if(this._cfg.ProviderType != ProviderType.SQLite) {
                str.Append(" WHERE movie_pkid = '" + movie.Id + "'");
            }
            else {
                str.Append(" WHERE lower(movie_pkid) = lower('{" + movie.Id + "}')");
            }

            res = this._db.ExecuteNonQuery(str.ToString());

            str.Remove(0, str.Length);
            str.Append("SELECT * ");
            str.Append(" FROM tbl_movies_to_categories");

            try {
                data = null;
                data = this._db.ExecuteQuery(str.ToString());
            }
            catch(Exception ex) {
                throw new Exception("Error on loading categories from table!", ex);
            }

            foreach(Category c in movie.Categories) {
                DataRow hrow = data.Tables[0].NewRow();

                //hrow["pkid"] = Helper.NewGuid;
                hrow["category_pkid"] = c.ID;
                hrow["movie_pkid"] = movie.Id;

                data.Tables[0].Rows.Add(hrow);
            }

            try {
                res = this._db.ExecuteUpdate(data, "tbl_movies_to_categories");
            }
            catch(Exception ex) {
                throw new Exception("Error on updating categories to table!", ex);
            }

            // save persons
            //List<Person> list = new List<Person>();
            //list.AddRange(movie.Actors);
            //list.AddRange(movie.Directors);
            //list.AddRange(movie.Producers);

            str.Remove(0, str.Length);
            str.Append("DELETE ");
            str.Append(" FROM tbl_movies_to_persons");

            if(this._cfg.ProviderType != ProviderType.SQLite) {
                str.Append(" WHERE movie_pkid = '" + movie.Id + "'");
            }
            else {
                str.Append(" WHERE lower(movie_pkid) = lower('{" + movie.Id + "}')");
            }

            res = this._db.ExecuteNonQuery(str.ToString());

            str.Remove(0, str.Length);
            str.Append("SELECT * ");
            str.Append(" FROM tbl_movies_to_persons");

            try {
                data = null;
                data = this._db.ExecuteQuery(str.ToString());
            }
            catch(Exception ex) {
                throw new Exception("Error on loading persons from table!", ex);
            }

            // actors
            foreach(Person p in movie.Actors) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_actor"] = true;

                if(!p.Rolename.IsNullOrTrimmedEmpty()) {
                    hrow["role_name"] = p.Rolename;
                }

                if(!p.Roletype.IsNullOrTrimmedEmpty()) {
                    hrow["role_type"] = p.Roletype.ToInt32();
                }

                data.Tables[0].Rows.Add(hrow);
            }

            // directors
            foreach(Person p in movie.Directors) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_director"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            // producer
            foreach(Person p in movie.Producers) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_producer"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            // musician
            foreach(Person p in movie.Musicians) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_musician"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            // cameraman
            foreach(Person p in movie.Cameramans) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_cameraman"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            // cutter
            foreach(Person p in movie.Cutters) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_cutter"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            // writer
            foreach(Person p in movie.Writers) {
                DataRow hrow = data.Tables[0].NewRow();

                hrow["pkid"] = Helper.NewGuid;
                hrow["person_pkid"] = p.ID;
                hrow["movie_pkid"] = movie.Id;
                hrow["as_writer"] = true;

                data.Tables[0].Rows.Add(hrow);
            }

            try {
                res = this._db.ExecuteUpdate(data, "tbl_movies_to_persons");
            }
            catch(Exception ex) {
                throw new Exception("Error on updating persons to table!", ex);
            }
        }
Ejemplo n.º 23
0
        public ShaderViewer(Core core, bool custom, string entry, Dictionary<string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible = false;
            outSigBox.Visible = false;

            m_Core = core;
            m_SaveCallback = saveCallback;
            m_CloseCallback = closeCallback;

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown += new KeyEventHandler(scintilla1_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                    sel = w;

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            if(sel != null)
                sel.Show();

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }