コード例 #1
0
 public static void RegisterUndo(HistoryObject UndoStep, HistoryObject.HistoryParameter Params = null)
 {
     Current.AddUndoCleanup();
     Current.AddToHistory(UndoStep);
     Current.CurrentStage = Undo.Current.History.Count;
     UndoStep.Register(Params);
 }
コード例 #2
0
ファイル: MySqlEntry.xaml.cs プロジェクト: lanicon/DBStudio
        void ConnectCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtServername.Text))
            {
                return;
            }
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                return;
            }

            LoginInfo_MySql info = new LoginInfo_MySql()
            {
                Server            = txtServername.Text,
                Database          = txtDbName.Text,
                Username          = txtUsername.Text,
                Pwd               = passwordBox1.Password,
                Port              = int.Parse(txtPort.Text),
                ConnectionTimeOut = 2000,
            };

            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    #region Save to Opened History Info
                    MySqlObjects mysqlItem = new MySqlObjects();
                    mysqlItem.ServerAddress = info.Server;
                    mysqlItem.Port          = info.Port;
                    mysqlItem.Username      = info.Username;

                    if (!SerializeClass.DatabaseHistoryInfo.MySqlHistory.IsContainSubValue(mysqlItem.ServerAddress))
                    {
                        HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                        oldObject.MySqlHistory.Add(mysqlItem);

                        SerializeClass.DatabaseHistoryInfo = oldObject;
                    }
                    #endregion
                    App.MainEngineer.CurDatabase = txtDbName.Text;
                    App.MainEngineer.CurPwd      = passwordBox1.Password;
                    RibbionIDE ide = new RibbionIDE();

                    ide.Title = info.Server;

                    ide.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                //ee._获取我的异常详细信息().Show();
                App.ResetMainEngineer();
                ee.HandleMyException();
            }
        }
コード例 #3
0
 public int AddToRedoHistory(HistoryObject NewHistoryStep)
 {
     RedoHistory.Add(NewHistoryStep);
     if (RedoHistory.Count - 1 >= MaxHistoryLength)
     {
         //Destroy(RedoHistory[0].gameObject);
         RedoHistory.RemoveAt(0);
     }
     return(RedoHistory.Count - 1);
 }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: tsvx/RawParser
 private void RotateLeftButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     if (rawImage != null)
     {
         var t = new HistoryObject(EffectType.Rotate, EditionValue.GetCopy()) { oldValue = EditionValue.Rotation };
         EditionValue.Rotation--;
         t.value = EditionValue.Rotation;
         History.Add(t);
         ResetButtonVisibility.Value = true;
         UpdatePreview(false);
     }
 }
コード例 #5
0
 public virtual async Task SaveObject <T>(T entity) where T : BaseEntity
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     var history = new HistoryObject()
     {
         CreatedOnUtc = DateTime.UtcNow,
         Object       = entity
     };
     await _historyRepository.InsertAsync(history);
 }
コード例 #6
0
ファイル: OleDbMain.xaml.cs プロジェクト: lanicon/DBStudio
        private void OpenOleDbFile(string srcFile, CoreEA.LoginInfo.OleDBVersion curVersion)
        {
            if (!System.IO.File.Exists(srcFile))
            {
                "FileNotFound".GetFromResourece().Show();
                return;
            }

            LoginInfo_Oledb info = new LoginInfo_Oledb()
            {
                Database            = srcFile,
                Pwd                 = pwd.Password,
                CurrentOleDBVersion = curVersion,
            };

            App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.OleDb).X_Handler;

            try
            {
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    OleDbObjects oleItem = new OleDbObjects();
                    oleItem.DbFileFullPath = info.Database;
                    if (!SerializeClass.DatabaseHistoryInfo.OleDbHistory.IsContainSubValue(oleItem.DbFileFullPath))
                    {
                        HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                        oldObject.OleDbHistory.Add(oleItem);

                        SerializeClass.DatabaseHistoryInfo = oldObject;
                    }

                    App.MainEngineer.CurDatabase = info.Database;
                    App.MainEngineer.CurPwd      = info.Pwd;

                    pwd.Password            = "";
                    txtFileInput.X_FileName = "";
                    RibbionIDE ide = new RibbionIDE();
                    ide.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                App.ResetMainEngineer();
                ee.HandleMyException();
            }
            finally
            {
            }
        }
コード例 #7
0
        public void ConnectCmd_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            LoginInfo_Oracle info = new LoginInfo_Oracle()
            {
                SID      = txtServerName.Text,
                Username = txtUsername.Text,
                Password = passwordBox1.Password,
                HostName = txtHostName.Text,
                Port     = int.Parse(txtPort.Text),
            };

            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Oracle).X_Handler;
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    #region Save to Opened History Info
                    OracleObjects oracleItem = new OracleObjects();
                    oracleItem.HostName = info.HostName;
                    oracleItem.Username = info.Username;
                    oracleItem.SID      = info.SID;

                    if (!SerializeClass.DatabaseHistoryInfo.OracleHistory.IsContainSubValue(oracleItem.HostName))
                    {
                        HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                        oldObject.OracleHistory.Add(oracleItem);

                        SerializeClass.DatabaseHistoryInfo = oldObject;
                    }
                    #endregion

                    App.MainEngineer.CurPwd = passwordBox1.Password;
                    RibbionIDE ide = new RibbionIDE();

                    ide.Title = info.SID;
                    ide.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                //ee._获取我的异常详细信息().Show();
                App.ResetMainEngineer();
                ee.HandleMyException();
            }
        }
コード例 #8
0
        /// <summary>
        /// Clear all saved info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butClearDbOpendHistoryInfo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                HistoryObject historyObject = SerializeClass.DatabaseHistoryInfo;

                historyObject.MySqlHistory.Clear();
                historyObject.SqlServerHistory.Clear();
                historyObject.OleDbHistory.Clear();
                historyObject.SSCEHistory.Clear();

                SerializeClass.DatabaseHistoryInfo = historyObject;

                "ClearedOpendHistoryInfo".GetFromResourece().Notify();
            }
            catch (Exception ee)
            {
                ee.Notify();
            }
        }
コード例 #9
0
        static void Main(string[] args)
        {
            var h = new HistoryObject();

            h.Value  = 5;
            h.Value  = "foo";
            h.Value += "bar";

            var history = h.ToArray();

            for (int i = 0; i < history.Length; i++)
            {
                Console.Write("{0}{1}", history[i], ((i >= history.Length - 1) ? "\n" : " <- "));
            }

            h.Undo();
            h.Undo();
            h.Undo();

            Console.WriteLine(h.Value);
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: tsvx/RawParser
 private void CropAccept_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     HideCropUI();
     double top = CropUI.Top;
     double left = CropUI.Left;
     double right = CropUI.Right;
     double bottom = CropUI.Bottom;
     if (rawImage?.fullSize != null && rawImage?.preview != null)
     {
         rawImage.fullSize.offset = new Point2D((uint)(rawImage.fullSize.UncroppedDim.width * left), (uint)(rawImage.fullSize.UncroppedDim.height * top));
         rawImage.fullSize.dim = new Point2D((uint)(rawImage.fullSize.UncroppedDim.width * right), (uint)(rawImage.fullSize.UncroppedDim.height * bottom));
         rawImage.preview.offset = new Point2D((uint)(rawImage.preview.UncroppedDim.width * left), (uint)(rawImage.preview.UncroppedDim.height * top));
         rawImage.preview.dim = new Point2D((uint)(rawImage.preview.UncroppedDim.width * right), (uint)(rawImage.preview.UncroppedDim.height * bottom));
         UpdatePreview(true);
         //set the display size
         SetImageSizeText();
     }
     var t = new HistoryObject(EffectType.Crop, EditionValue.GetCopy()) { oldValue = 0 };
     History.Add(t);
     ResetButtonVisibility.Value = true;
 }
コード例 #11
0
 public static void RegisterRedo(HistoryObject RedoStep, HistoryObject.HistoryParameter Params = null)
 {
     Undo.Current.AddToRedoHistory(RedoStep);
     Undo.Current.CurrentStage = Undo.Current.History.Count;
     RedoStep.Register(Params);
 }
コード例 #12
0
        private void LoginInSqlServer(WPFCommonControl.SqlServerLoginControl.X_CollectionData controlResult)
        {
            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer).X_Handler;
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
                return;
            }

            LoginInfo_SqlServer info = new LoginInfo_SqlServer()
            {
                X_Server              = controlResult.Server,
                X_Database            = controlResult.DbName,
                X_Pwd                 = controlResult.PWD,
                X_UserName            = controlResult.UID,
                X_Port                = controlResult.Port.ToString(),
                X_CurDbConnectionMode = controlResult.CurType.CurConnMode,
                IsTrustedConn         = controlResult.IsTrust,
                AttchFile             = controlResult.DbFileLocation,
            };

            try
            {
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    #region Save to Opened History Info
                    SqlServerObjects sqlserverItem = new SqlServerObjects();
                    sqlserverItem.ServerAddress = info.X_Server;
                    if (info.X_Port.IsNotEmpty())
                    {
                        sqlserverItem.Port = int.Parse(info.X_Port);
                    }
                    sqlserverItem.Username = info.X_UserName;

                    if (!SerializeClass.DatabaseHistoryInfo.SqlServerHistory.IsContainSubValue(sqlserverItem.ServerAddress))
                    {
                        HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                        oldObject.SqlServerHistory.Add(sqlserverItem);

                        SerializeClass.DatabaseHistoryInfo = oldObject;
                    }
                    #endregion

                    App.MainEngineer.CurDatabase = controlResult.DbName;

                    RibbionIDE ide = new RibbionIDE();
                    //this.Visibility = Visibility.Hidden;
                    //ide.Closed += (a, b) => { this.Visibility = Visibility.Visible; };
                    ide.Title = info.X_Server;

                    ide.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                App.ResetMainEngineer();
                ee.HandleMyException();
            }
        }
コード例 #13
0
        private void butOpen_Click(object sender, RoutedEventArgs e)
        {
            string dbName = txtDbPath.Text;
            string dbPwd  = txtPwd.Password;

            if (string.IsNullOrEmpty(dbName))
            {
                "Please input database name".Notify();
                return;
            }

            if (Utility.DetectNetworkDriver.IsPathOnNetworkDrive(dbName))
            {
                "SQLCE do not support open from network".Notify();
                return;
            }
            OpenModeClass CurOpenMode = null;

            if (cmbOpenMode.SelectedItem == null)
            {
                CurOpenMode = cmbOpenMode.Items[0] as OpenModeClass;
            }
            else
            {
                CurOpenMode = cmbOpenMode.SelectedItem as OpenModeClass;
            }

            uint maxDbSize = (uint)txtMaxDBSize.Value;

            //If open db ok ,and get tables info ok , then do
            //otherwise do nothing
            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlCE35).X_Handler;
                App.MainEngineer.Open(new LoginInfo_SSCE()
                {
                    DbName      = dbName, Pwd = txtPwd.Password,
                    CurOpenMode = CurOpenMode.mode,
                    MaxDbSize   = maxDbSize
                });
            }
            catch (SqlCeInvalidDatabaseFormatException sqe)
            {
                Debug.WriteLine("*****************" + sqe.Message);

                #region
                if (wf.DialogResult.Yes == wf.MessageBox.Show("Your database format is old version ,do you want to upgrade it ,so this software can modify it?", "Warning",
                                                              wf.MessageBoxButtons.YesNo, wf.MessageBoxIcon.Question, wf.MessageBoxDefaultButton.Button1))
                {
                    try
                    {
                        if (Properties.Settings.Default.AutoBackupOldVersionFileBeforeUpgrade)
                        {
                            if (!Directory.Exists(Config.AutoBackupFolder))
                            {
                                Directory.CreateDirectory(Config.AutoBackupFolder);
                            }

                            File.Copy(dbName, Config.AutoBackupFolder + Path.GetFileName(dbName), true);
                        }
                    }
                    catch (Exception ee)
                    {
#if DEBUG
                        throw ee;
#else
                        ee.Message.Show();
#endif
                    }


                    SqlCeEngine d = new SqlCeEngine(CoreEA.ConnSTR.DbConnectionString.SSCE.GetSSCEConnectionString(
                                                        dbName, dbPwd, (bool)chkIsEncrypted.IsChecked, CurOpenMode));

                    try
                    {
                        d.Upgrade();
                        "Upgrade Successful".Notify();
                    }
                    catch (Exception dee)
                    {
                        dee.Message.Notify();
                        App.ResetMainEngineer();
                        return;
                    }
                    goto ReOpen;
                }
                else
                {
                    App.ResetMainEngineer();
                    return;
                }

                #endregion
            }
            catch (Exception eee)
            {
                eee.Message.Notify();
            }

ReOpen:
            if (App.MainEngineer.IsOpened)
            {
                App.MainEngineer.CurDatabase = dbName;
                App.MainEngineer.CurPwd      = txtPwd.Password;

                //this.Hide();
                txtDbPath.Text  = string.Empty;
                txtPwd.Password = string.Empty;
                Properties.Settings.Default.LastestOpenedDb    = dbName;
                Properties.Settings.Default.LastestOpenedDbPwd = dbPwd;
                Properties.Settings.Default.Save();

                #region Save to Opened History Info

                SSCEObjects ssceItem = new SSCEObjects();
                ssceItem.DbFileFullPath = dbName;
                if (!SerializeClass.DatabaseHistoryInfo.SSCEHistory.IsContainSubValue(ssceItem.DbFileFullPath))
                {
                    HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                    ssceItem.LatestVisitTime = DateTime.Now;
                    oldObject.SSCEHistory.Add(ssceItem);

                    SerializeClass.DatabaseHistoryInfo = oldObject;
                }
                #endregion


                RefreshLastOpenedDbsStatus();

                RibbionIDE ide = new RibbionIDE();

                ide.WindowState = WindowState.Maximized;
                ide.BringIntoView();
                ide.ShowDialog();
            }
            else
            {
                App.ResetMainEngineer();
            }
        }
コード例 #14
0
        /// <summary>
        /// Handle Navigation though the app
        /// Handle history
        /// Get the Message and the dest string, add/remove from history, load correct ViewModel
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="dest"></param>
        public void Navigator(MessageBase obj, string dest)
        {
            ViewModelBase Source = (ViewModelBase)obj.Sender;

            if (Source.GetType() == typeof(AdminPanelViewModel))
            {
                this.RefreshListView();
            }

            if (Source.GetType() == typeof(LoginViewModel) || Source.GetType() == typeof(ProfileViewModel))
            {
                this.RefreshUser();
            }

            HistoryObject HistoryObject = null;
            string        pageName;

            if (string.IsNullOrEmpty(dest)) // call the history or the ViewModel Name - (get the class name as string)
            {
                HistoryObject = this.History.Pop();
                pageName      = HistoryObject.NomVM;
            }
            else
            {
                pageName = dest;
                if (Source.GetType() != typeof(LoginViewModel))
                {
                    this.History.Push(new HistoryObject(Source)); // push the source ViewModel in History (as his className string)
                    // don't add to history if it's LoginViewModel
                }
            }

            switch (pageName)
            {
            case "HomeViewModel":
                this.CurrentVM = ServiceLocator.Current.GetInstance <HomeViewModel>();
                this.History.Clear();     // Clear history
                break;

            case "HeroViewModel":
                if (HistoryObject == null && ((HeroMessage)obj).Hero == null)
                {
                    this.CurrentVM = ServiceLocator.Current.GetInstance <HomeViewModel>();
                    this.History.Clear();     // Clear history
                }
                else
                {
                    HeroViewModel tempHeroVM = ServiceLocator.Current.GetInstance <HeroViewModel>();
                    tempHeroVM.Hero = HistoryObject != null ? HistoryObject.Hero : ((HeroMessage)obj).Hero;
                    this.CurrentVM  = tempHeroVM;
                }
                break;

            case "FilmViewModel":
                if (HistoryObject == null && ((MovieMessage)obj).Movie == null)
                {
                    this.CurrentVM = ServiceLocator.Current.GetInstance <HomeViewModel>();
                    this.History.Clear();     // Clear history
                }
                else
                {
                    FilmViewModel tempMovieVM = ServiceLocator.Current.GetInstance <FilmViewModel>();
                    tempMovieVM.Movie = HistoryObject != null ? HistoryObject.Movie : ((MovieMessage)obj).Movie;
                    this.CurrentVM    = tempMovieVM;
                }
                break;

            case "SerieViewModel":
                if (HistoryObject == null && ((MovieMessage)obj).Movie == null)
                {
                    this.CurrentVM = ServiceLocator.Current.GetInstance <HomeViewModel>();
                    this.History.Clear();     // Clear history
                }
                else
                {
                    SerieViewModel tempMovieVM = ServiceLocator.Current.GetInstance <SerieViewModel>();
                    tempMovieVM.Movie = HistoryObject != null ? HistoryObject.Movie : ((MovieMessage)obj).Movie;
                    this.CurrentVM    = tempMovieVM;
                }
                break;

            case "ProfileViewModel":
                if (ServiceLocator.Current.GetInstance <CurrentUserHandler>().GetUser() != null)
                {
                    ProfileViewModel tempProfile = ServiceLocator.Current.GetInstance <ProfileViewModel>();
                    tempProfile.CurrentUser = ServiceLocator.Current.GetInstance <CurrentUserHandler>().GetUser();
                    this.CurrentVM          = tempProfile;
                }
                else
                {
                    this.CurrentVM = ServiceLocator.Current.GetInstance <LoginViewModel>();
                }
                break;

            case "AdminPanelViewModel":
                this.CurrentVM = ServiceLocator.Current.GetInstance <AdminPanelViewModel>();
                break;

            case "ListHeroViewModel":
                this.CurrentVM = ServiceLocator.Current.GetInstance <ListHeroViewModel>();
                break;

            case "ListMovieViewModel":
                this.CurrentVM = ServiceLocator.Current.GetInstance <ListMovieViewModel>();
                break;

            default:
                this.CurrentVM = ServiceLocator.Current.GetInstance <HomeViewModel>();
                this.History.Clear();     // Clear history
                break;
            }
        }