예제 #1
0
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            ValueCommentAlias comment = e.Row.DataContext as ValueCommentAlias;
            TextBox           textBox = e.EditingElement as TextBox;

            if (e.Column == elementComment)
            {
                if (comment != null && textBox != null)
                {
                    ValueCommentManager.UpdateComment(comment.Name, textBox.Text);
                }
            }
            else if (e.Column == elementAlias)
            {
                if (comment != null && textBox != null)
                {
                    if (textBox.Text != string.Empty && !ValueAliasManager.CheckAlias(comment.Name, textBox.Text))
                    {
                        LocalizedMessageBox.Show(Properties.Resources.Message_Alias_Exist, LocalizedMessageIcon.Warning);
                        e.Cancel = true;
                    }
                    else
                    {
                        ValueAliasManager.UpdateAlias(comment.Name, textBox.Text);
                    }
                }
            }
        }
예제 #2
0
        public void Execute()
        {
            IEnumerable <FuncBlockReplaceWordCommand> fit
                = items.Where((cmd) => { return(cmd.Element.FBVModel.IsReadOnly); });

            if (fit.Count() > 0)
            {
                LocalizedMessageBox.Show(Properties.Resources.Message_Text, LocalizedMessageIcon.Warning);
            }
            items.Sort((cmd1, cmd2) =>
            {
                return(cmd1.Element.Offset.CompareTo(cmd2.Element.Offset));
            });
            int    offset = 0;
            string word   = null;

            foreach (FuncBlockReplaceWordCommand cmd in items)
            {
                cmd.Element.Offset += offset;
                cmd.Execute();
                offset += cmd.NewWord.Length - cmd.OldWord.Length;
                word    = cmd.OldWord;
            }
            parent.Find(word);
        }
예제 #3
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            ElementAddressType Type   = (ElementAddressType)Enum.ToObject(typeof(ElementAddressType), EleTypeCombox.SelectedIndex);
            Device             device = PLCDeviceManager.GetPLCDeviceManager().SelectDevice;

            if (EleTypeCombox.SelectedIndex == 0 || EleTypeCombox.SelectedIndex == 1 || EleTypeCombox.SelectedIndex == 13 || EleTypeCombox.SelectedIndex == 14)
            {
                LocalizedMessageBox.Show(Properties.Resources.Message_Can_Not_Be_Written, LocalizedMessageIcon.Error);
            }
            else if (!ElementAddressHelper.AssertAddrRange(Type, uint.Parse(textBox.Text) + uint.Parse(LengthTextbox.Text), device))
            {
                LocalizedMessageBox.Show(Properties.Resources.Message_Over_Max_Len, LocalizedMessageIcon.Error);
            }
            else
            {
                if (ElementAddressHelper.IsBitAddr(Type))
                {
                    for (uint i = 0; i < uint.Parse(LengthTextbox.Text); i++)
                    {
                        AddElement(GenerateElementModel(true, Type.ToString(), uint.Parse(textBox.Text) + i, 0));
                    }
                }
                else
                {
                    for (uint i = 0; i < uint.Parse(LengthTextbox.Text); i++)
                    {
                        AddElement(GenerateElementModel(false, Type.ToString(), uint.Parse(textBox.Text) + i, DataTypeCombox.SelectedIndex + 1));
                    }
                }
            }
        }
 public void Rename(string errormsg = null)
 {
     if (errormsg == null && HasRenaming)
     {
         LocalizedMessageBox.Show(Properties.Resources.Message_Renamed_Error, LocalizedMessageIcon.Error);
         return;
     }
     _contextmenu        = this.ContextMenu;
     this.ContextMenu    = null;
     IsRenaming          = true;
     HasRenaming         = true;
     IsSelected          = true;
     TBL_Text.Visibility = Visibility.Hidden;
     TBO_Text.Visibility = Visibility.Visible;
     TBO_Text.IsEnabled  = true;
     if (errormsg != null)
     {
         TB_ErrorMsg.Visibility = Visibility.Visible;
         TB_ErrorMsg.Text       = errormsg;
         TBO_Text.Focus();
         TBO_Text.SelectAll();
     }
     else
     {
         TB_ErrorMsg.Visibility = Visibility.Collapsed;
     }
 }
        /// <summary>
        /// レイアウト保存
        /// </summary>
        public void SaveLayout(WorkAreaViewModel?vm)
        {
            if (vm != null)
            {
                var(onOK, layoutName) = SelectStringDialog.ShowDialog("Lang:EditLayoutName", "Lang:LayoutName", "", IsValidLayoutName);
                if (onOK)
                {
                    try
                    {
                        SettingDatabase.Instance.BeginTransaction();
                        var layoutID = vm.SaveLayout(layoutName);
                        SettingDatabase.Instance.Commit();

                        Layouts.Add(new LayoutMenuItem(layoutID, layoutName, false));
                    }
                    catch (Exception ex)
                    {
                        SettingDatabase.Instance.Rollback();
                        LocalizedMessageBox.Show("Lang:LayoutSaveFailedMessage", "Lang:Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, ex.Message);
                    }

                    LocalizedMessageBox.Show("Lang:LayoutSavedMessage", "Lang:Confirmation", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, vm.Title, layoutName);
                }
            }
            else
            {
                LocalizedMessageBox.Show("Lang:TabDoesNotSelectedMessage", "Lang:Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
예제 #6
0
        private void OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            IElementInitializeModel model = e.Row.DataContext as IElementInitializeModel;

            if (e.EditingElement is TextBox)
            {
                TextBox textBox = e.EditingElement as TextBox;
                if (model is BitElementModel)
                {
                    if (model.ShowValue.Trim().ToUpper() != "ON" && model.ShowValue.Trim().ToUpper() != "OFF")
                    {
                        e.Cancel = true;
                        LocalizedMessageBox.Show(Properties.Resources.Invalid_Input, LocalizedMessageIcon.Error);
                    }
                    else
                    {
                        if (model.ShowValue.Trim().ToUpper() == "ON")
                        {
                            model.Value = 1;
                        }
                        else
                        {
                            model.Value = 0;
                        }
                    }
                }
                else
                {
                    try
                    {
                        uint tempvalue = ValueConverter.ParseShowValue(textBox.Text, (WordType)Enum.ToObject(typeof(WordType), model.DataType));
                        model.Value = tempvalue;
                    }
                    catch (Exception ex)
                    {
                        e.Cancel = true;
                        LocalizedMessageBox.Show(Properties.Resources.Invalid_Input, LocalizedMessageIcon.Error);
                    }
                }
            }
            else
            {
                ComboBox combox = e.EditingElement as ComboBox;
                if (model is WordElementModel && model.SelectIndex != combox.SelectedIndex)
                {
                    WordType oldType = (WordType)Enum.ToObject(typeof(WordType), model.SelectIndex + 1);
                    WordType newType = (WordType)Enum.ToObject(typeof(WordType), combox.SelectedIndex + 1);
                    try
                    {
                        model.ShowValue = ValueConverter.ChangeShowValue(oldType, newType, model.Value);
                    }
                    catch (Exception ex)
                    {
                        e.Cancel = true;
                        LocalizedMessageBox.Show(Properties.Resources.Message_Converter_Error, LocalizedMessageIcon.Error);
                    }
                }
            }
        }
예제 #7
0
 public static void EnterIngame(string gameMode)
 {
     if (!Binding.FCE_Editor_ValidateIngame())
     {
         LocalizedMessageBox.Show(MainForm.Instance, Localizer.LocalizeCommon("MSG_DESC_INGAME_INVALID_OBJECTS"), Localizer.Localize("WARNING"), Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
     }
     MainForm.Instance.EnterIngame();
     Binding.FCE_Editor_EnterIngame(gameMode);
 }
예제 #8
0
        /// <summary>
        /// 作業エリアが閉じられる時
        /// </summary>
        /// <param name="vm">閉じようとしている作業エリア</param>
        /// <returns></returns>
        public bool DocumentClosing(WorkAreaViewModel vm)
        {
            var canceled = false;

            // 変更があったか?
            if (vm.HasChanged)
            {
                var result = LocalizedMessageBox.Show("Lang:PlanClosingConfirmMessage", "Lang:Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel, vm.Title);

                switch (result)
                {
                // 保存する場合
                case MessageBoxResult.Yes:
                    vm.Save();
                    canceled = vm.HasChanged;           // 保存したはずなのに変更点がある(保存キャンセルされた等)場合、閉じないようにする
                    break;

                // 保存せずに閉じる場合
                case MessageBoxResult.No:
                    break;

                // キャンセルする場合
                case MessageBoxResult.Cancel:
                    canceled = true;
                    break;
                }
            }

            // 閉じる場合、リソースを開放
            if (!canceled)
            {
                vm.Dispose();
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    Documents.Remove(vm);

                    // 最後のタブを閉じた時にAvalonDockのActiveContentが更新されないためここでnullにする
                    // → nullにしないと閉じたはずのタブを保存できてしまう
                    if (Documents.Count == 0)
                    {
                        ActiveContent = null;
                    }
                }), DispatcherPriority.Background);

                // ガーベジコレクション用タイマー開始
                if (!_GCTimer.IsEnabled)
                {
                    _GCTimer.Start();
                }

                // 時間計測用ストップウォッチを初期化
                _GCStopWatch.Reset();
            }

            return(canceled);
        }
예제 #9
0
        private void EnsureButton_Click(object sender, RoutedEventArgs e)
        {
            ElementAddressType Type   = (ElementAddressType)Enum.ToObject(typeof(ElementAddressType), comboBox.SelectedIndex);
            Device             device = PLCDeviceManager.GetPLCDeviceManager().SelectDevice;

            if (Type == ElementAddressType.H || Type == ElementAddressType.K)
            {
                LocalizedMessageBox.Show(Properties.Resources.Constant_Monitor, LocalizedMessageIcon.Warning);
            }
            else if (ElementAddressHelper.AssertAddrRange(Type, uint.Parse(textBox.Text), device))
            {
                if ((bool)checkbox1.IsChecked && !ElementAddressHelper.AssertAddrRange(ElementAddressHelper.GetIntrasegmentAddrType(comboBox1.SelectedIndex), uint.Parse(textBox1.Text), device))
                {
                    LocalizedMessageBox.Show(Properties.Resources.Intra_Cross, LocalizedMessageIcon.Warning);
                }
                else if ((bool)checkbox.IsChecked && !ElementAddressHelper.AssertAddrRange(Type, uint.Parse(textBox.Text) + uint.Parse(rangeTextBox.GetTextBox().Text) - 1, device))
                {
                    LocalizedMessageBox.Show(Properties.Resources.Exceed_Adddress, LocalizedMessageIcon.Warning);
                }
                else
                {
                    if (EnsureButtonClick != null)
                    {
                        AddrType  = Type.ToString();
                        StartAddr = uint.Parse(textBox.Text);
                        if ((bool)checkbox1.IsChecked)
                        {
                            IntrasegmentType = ElementAddressHelper.GetIntrasegmentAddrType(comboBox1.SelectedIndex).ToString();
                            IntrasegmentAddr = uint.Parse(textBox1.Text);
                        }
                        if (ElementAddressHelper.IsBitAddr(Type))
                        {
                            DataType = 0;
                        }
                        else
                        {
                            DataType = DataTypeCombox.SelectedIndex + 1;
                        }
                        if ((bool)checkbox.IsChecked)
                        {
                            AddNums = int.Parse(rangeTextBox.GetTextBox().Text);
                        }
                        else
                        {
                            AddNums = 1;
                        }
                        EnsureButtonClick.Invoke(this, new RoutedEventArgs());
                    }
                }
            }
            else
            {
                LocalizedMessageBox.Show(Properties.Resources.Address_Cross, LocalizedMessageIcon.Warning);
            }
        }
        /// <summary>
        /// レイアウト削除
        /// </summary>
        private void DeleteLayout(LayoutMenuItem menuItem)
        {
            var result = LocalizedMessageBox.Show("Lang:DeleteLayoutConfirmMessage", "Lang:Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, menuItem.LayoutName);

            if (result == MessageBoxResult.Yes)
            {
                SettingDatabase.Instance.ExecQuery($"DELETE FROM WorkAreaLayouts WHERE LayoutID = {menuItem.LayoutID}");
                Layouts.Remove(menuItem);
                _ActiveLayout.Value = null;
            }
        }
예제 #11
0
 public bool AssertEdit(IUndoableCommand command)
 {
     if (ldvmodel != null &&
         ldvmodel.LadderMode != LadderMode.Edit &&
         !(command is NetworkReplaceBreakpointCommand))
     {
         LocalizedMessageBox.Show(Properties.Resources.Change_Mode, LocalizedMessageIcon.Warning);
         return(false);
     }
     return(true);
 }
예제 #12
0
 public static void OnSaveCompleted(bool success)
 {
     if (!success)
     {
         LocalizedMessageBox.Show(Localizer.Localize("ERROR_SAVE_FAILED"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
     }
     if (EditorDocument.m_saveCompletedCallback != null)
     {
         EditorDocument.m_saveCompletedCallback(success);
     }
 }
        /// <summary>
        /// レイアウト名が有効か判定
        /// </summary>
        /// <param name="layoutName">レイアウト名</param>
        /// <returns>レイアウト名が有効か</returns>
        private static bool IsValidLayoutName(string layoutName)
        {
            var ret = true;

            if (string.IsNullOrWhiteSpace(layoutName))
            {
                LocalizedMessageBox.Show("Lang:InvalidLayoutNameMessage", "Lang:Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning);
                ret = false;
            }

            return(ret);
        }
예제 #14
0
 public static void OnLoadCompleted(bool success)
 {
     if (!success)
     {
         LocalizedMessageBox.Show(Localizer.Localize("ERROR_LOAD_FAILED"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         MainForm.Instance.ClearMapPath();
     }
     if (EditorDocument.m_loadCompletedCallback != null)
     {
         EditorDocument.m_loadCompletedCallback(success);
     }
 }
예제 #15
0
 private void action_TestDash()
 {
     if (!GameModeDash.ValidateIngame())
     {
         if (LocalizedMessageBox.Show(MainForm.Instance, Localizer.LocalizeCommon("MSG_DESC_DASH_TEST_INVALID"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_YES"), Localizer.Localize("Generic", "GENERIC_NO"), null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
         {
             MainForm.Instance.CurrentTool = ToolValidation.Instance;
         }
         return;
     }
     Editor.EnterIngame("FCXDash");
 }
예제 #16
0
        private void OnSaveMonitorList(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "ssm文件|*.ssm";
            if (saveFileDialog.ShowDialog() == true)
            {
                if (MTable.Save(saveFileDialog.FileName) != 0)
                {
                    LocalizedMessageBox.Show("无法保存监视文件!", LocalizedMessageIcon.Information);
                }
            }
        }
예제 #17
0
        private void OnLoadMonitorList(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "ssm文件|*.ssm";
            if (openFileDialog.ShowDialog() == true)
            {
                if (MTable.Load(openFileDialog.FileName) != 0)
                {
                    LocalizedMessageBox.Show("不正确的监视文件,监视文件已损坏!", LocalizedMessageIcon.Information);
                }
            }
        }
예제 #18
0
 private void QuickAddElement()
 {
     using (QuickAddElementDialog dialog = new QuickAddElementDialog())
     {
         dialog.EnsureButtonClick += (sender1, e1) =>
         {
             LocalizedMessageResult result = LocalizedMessageBox.Show(Properties.Resources.Message_Tooltip, LocalizedMessageButton.OKCancel, LocalizedMessageIcon.Warning);
             if (result == LocalizedMessageResult.Yes)
             {
                 tables.Clear();
                 if (!(bool)dialog.checkbox.IsChecked)
                 {
                     AddElementByAllRoutine();
                 }
                 else
                 {
                     if (dialog.combox1.SelectedIndex == 0)
                     {
                         AddElementByAllRoutine();
                     }
                     else
                     {
                         if ((bool)dialog.checkbox1.IsChecked && dialog.combox.SelectedIndex == 1)
                         {
                             int startIndex = int.Parse(dialog.textbox1.Text);
                             int endIndex   = int.Parse(dialog.textbox2.Text);
                             if (startIndex > endIndex)
                             {
                                 LocalizedMessageBox.Show(string.Format(Properties.Resources.Message_Network_Range_Error), LocalizedMessageIcon.Error);
                                 return;
                             }
                             else
                             {
                                 AddElementByCurrentRoutine(false, startIndex, endIndex);
                             }
                         }
                         else
                         {
                             AddElementByCurrentRoutine(true, 0, 0);
                         }
                     }
                 }
                 ShowTable(0);
                 dialog.Close();
                 Manager.Initialize();
             }
         };
         dialog.ShowDialog();
     }
 }
예제 #19
0
 private void OnLostFocus(object sender, RoutedEventArgs e)
 {
     if (textbox.Text == string.Empty)
     {
         textbox.Text = oldTableName;
         return;
     }
     foreach (var table in tables.Where(x => { return(x != CurrentTable); }))
     {
         if (textbox.Text.Equals(table.TableName, StringComparison.CurrentCultureIgnoreCase))
         {
             textbox.Text = oldTableName;
             LocalizedMessageBox.Show(Properties.Resources.Message_Table_Name_Exist, LocalizedMessageIcon.Warning);
             return;
         }
     }
 }
        private void OnDialogEnsureClick(object sender, RoutedEventArgs e)
        {
            string name    = dialog.TB_Name.Text;
            string comment = dialog.TB_Comment.Text;

            if (name.Equals(String.Empty))
            {
                LocalizedMessageBox.Show(Properties.Resources.Message_Name_Needed, LocalizedMessageIcon.Information);
                return;
            }
            IEnumerable <ModbusTableModel> fit = models.Where(
                (ModbusTableModel model) => { return(model.Name.Equals(name)); });

            switch (DialogType)
            {
            case DIALOG_CREATE:
                if (fit.Count() > 0)
                {
                    LocalizedMessageBox.Show(Properties.Resources.Message_Table_Exist, LocalizedMessageIcon.Warning);
                }
                else
                {
                    ModbusTableModel model = new ModbusTableModel();
                    model.Name    = name;
                    model.Comment = comment;
                    AddModel(model, currentindex);
                    dialog.Close();
                }
                break;

            case DIALOG_RENAME:
                if (fit.Count() > 0 && fit.First() != Current)
                {
                    LocalizedMessageBox.Show(Properties.Resources.Message_Table_Exist, LocalizedMessageIcon.Warning);
                }
                else
                {
                    Current.Name    = name;
                    Current.Comment = comment;
                    ModelChanged(this, e);
                    IsModify = true;
                    dialog.Close();
                }
                break;
            }
        }
예제 #21
0
 public void Activate()
 {
     if (!EditorDocument.NavmeshEnabled)
     {
         if (LocalizedMessageBox.Show(MainForm.Instance, Localizer.LocalizeCommon("EDITOR_NAVMESH_PROMPT"), Localizer.Localize("EDITOR_CONFIRMATION"), Localizer.Localize("Generic", "GENERIC_YES"), Localizer.Localize("Generic", "GENERIC_NO"), null, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
         {
             MainForm.Instance.CurrentTool = null;
             return;
         }
         EditorDocument.NavmeshEnabled = true;
     }
     this.m_displayAlpha.Value   = 1f - Navmesh.DebugAlpha;
     this.m_displayNavmesh.Value = EditorSettings.IsNavmeshVisible;
     this.m_paramLayer.Value     = EditorSettings.NavmeshLayer;
     this.m_displayAP.Value      = EditorSettings.ShowCovers;
     this.UpdateDisplay();
 }
예제 #22
0
        /// <summary>
        /// 程序发生未捕捉的异常而崩溃时调用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            //保存用户正在编辑的文件
            ((MainWindow)Current.MainWindow).SaveProjectByException();
            AppFinalize();
            //写入Debug信息
            TempDebugger.WriteLine(DateTime.Now);
            TempDebugger.WriteLine(e.Exception.Message);
            TempDebugger.WriteLine();
            TempDebugger.WriteLine(e.Exception.StackTrace);
            TempDebugger.WriteLine();
            TempDebugger.Dispose();

            LocalizedMessageBox.Show(AppMain.Properties.Resources.Unknowed_Exception, AppMain.Properties.Resources.Error, LocalizedMessageIcon.Error);
            Current.Shutdown();
            e.Handled = true;
        }
        /// <summary>
        /// ウィンドウが閉じられる時
        /// </summary>
        /// <returns>キャンセルされたか</returns>
        public bool WindowClosing()
        {
            var canceled = false;

            // 未保存の内容が存在するか?
            if (_WorkAreaManager.Documents.Any(x => x.HasChanged))
            {
                var result = LocalizedMessageBox.Show("Lang:MainWindowClosingConfirmMessage", "Lang:Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                switch (result)
                {
                // 保存する場合
                case MessageBoxResult.Yes:
                    foreach (var doc in _WorkAreaManager.Documents)
                    {
                        doc.Save();
                    }
                    break;

                // 保存せずに閉じる場合
                case MessageBoxResult.No:
                    break;

                // キャンセルする場合
                case MessageBoxResult.Cancel:
                    canceled = true;
                    break;
                }
            }

            // 閉じる場合、開いていたファイル一覧を保存する
            if (!canceled)
            {
                var param = new SQLiteCommandParameters(1);

                var pathes = _WorkAreaManager.Documents.Where(x => File.Exists(x.SaveFilePath))
                             .Select(x => x.SaveFilePath);

                param.AddRange("path", System.Data.DbType.String, pathes);

                SettingDatabase.Instance.ExecQuery("INSERT INTO OpenedFiles(Path) VALUES(:path)", param);
            }

            return(canceled);
        }
        /// <summary>
        /// DB更新
        /// </summary>
        public void UpdateDB()
        {
            var result = LocalizedMessageBox.Show("Lang:DBUpdateConfirmationMessage", "Lang:Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                if (X4Database.UpdateDB())
                {
                    // DB更新成功
                    LocalizedMessageBox.Show("Lang:DBUpdateRestartRequestMessage", "Lang:Confirmation", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    // DB更新失敗
                    LocalizedMessageBox.Show("Lang:DBUpdateFailureMessage", "Lang:Error", MessageBoxButton.YesNo, MessageBoxImage.Error);
                }
            }
        }
        /// <summary>
        /// DB更新
        /// </summary>
        public void UpdateDB()
        {
            var result = LocalizedMessageBox.Show("Lang:MainWindow_Menu_File_UpdateDB_DBUpdate_ConfirmationMessage", "Lang:Common_MessageBoxTitle_Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                if (X4Database.UpdateDB())
                {
                    // DB更新成功
                    LocalizedMessageBox.Show("Lang:MainWindow_Menu_File_UpdateDB_DBUpdate_RestartRequestMessage", "Lang:Common_MessageBoxTitle_Confirmation", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    // DB更新失敗
                    LocalizedMessageBox.Show("Lang:MainWindow_Menu_File_UpdateDB_DBUpdate_FailureMessage", "Lang:Common_MessageBoxTitle_Error", MessageBoxButton.YesNo, MessageBoxImage.Error);
                }
            }
        }
예제 #26
0
        private void OnSDModelSaveAll(object sender, SimulateDataModelEventArgs e)
        {
            SaveFileDialog sfdialog = new SaveFileDialog();

            sfdialog.Filter = "SimuWave文件|*.siw";
            sfdialog.Title  = "保存仿真波形文件";
            if (sfdialog.ShowDialog() == true)
            {
                try
                {
                    string filename = sfdialog.FileName;
                    SaveXml(filename);
                }
                catch (Exception)
                {
                    LocalizedMessageBox.Show("保存波形文件失败!", LocalizedMessageIcon.Error);
                }
            }
        }
예제 #27
0
        private void OnSDModelLoadAll(object sender, SimulateDataModelEventArgs e)
        {
            OpenFileDialog ofdialog = new OpenFileDialog();

            ofdialog.Filter = "SimuWave文件|*.siw";
            ofdialog.Title  = "读取仿真波形文件";
            if (ofdialog.ShowDialog() == true)
            {
                try
                {
                    string filename = ofdialog.FileName;
                    LoadXml(filename);
                }
                catch (Exception)
                {
                    LocalizedMessageBox.Show("读取波形文件失败!", LocalizedMessageIcon.Error);
                }
            }
        }
예제 #28
0
        /// <summary>
        /// 上書き保存
        /// </summary>
        /// <param name="WorkArea">作業エリア</param>
        public bool Save(IWorkArea WorkArea)
        {
            if (string.IsNullOrEmpty(SaveFilePath))
            {
                return(SaveAs(WorkArea));
            }

            try
            {
                SaveMain(WorkArea);
                return(true);
            }
            catch (Exception e)
            {
                LocalizedMessageBox.Show("Lang:MainWindow_SaveDataWriteFailureMessage", "Lang:Common_MessageBoxTitle_Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, e.Message, e.StackTrace ?? "");
            }

            return(false);
        }
        private uint?ParseValueByDataType(string value, WordType type)
        {
            try
            {
                switch (type)
                {
                case WordType.INT16:
                    return((uint)short.Parse(value));

                case WordType.POS_INT16:
                    return(ushort.Parse(value));

                case WordType.INT32:
                    return((uint)int.Parse(value));

                case WordType.POS_INT32:
                    return(uint.Parse(value));

                case WordType.BCD:
                    ushort outvalue = ValueConverter.ToUINT16(ushort.Parse(value));
                    if (outvalue > 9999)
                    {
                        throw new OverflowException();
                    }
                    else
                    {
                        return(outvalue);
                    }

                case WordType.FLOAT:
                    return(ValueConverter.FloatToUInt(float.Parse(value)));

                default:
                    return(null);
                }
            }
            catch (Exception e)
            {
                LocalizedMessageBox.Show(Properties.Resources.Message_Number_Error, LocalizedMessageIcon.Error);
                return(null);
            }
        }
        /// <summary>
        /// ウィンドウが閉じられる時
        /// </summary>
        /// <returns>キャンセルされたか</returns>
        public bool WindowClosing()
        {
            var canceled = false;

            // 未保存の内容が存在するか?
            if (_WorkAreaManager.Documents.Any(x => x.HasChanged))
            {
                var result = LocalizedMessageBox.Show("Lang:MainWindow_ClosingConfirmMessage", "Lang:Common_MessageBoxTitle_Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                switch (result)
                {
                // 保存する場合
                case MessageBoxResult.Yes:
                    foreach (var doc in _WorkAreaManager.Documents)
                    {
                        doc.Save();
                    }
                    break;

                // 保存せずに閉じる場合
                case MessageBoxResult.No:
                    break;

                // キャンセルする場合
                case MessageBoxResult.Cancel:
                    canceled = true;
                    break;
                }
            }

            // 閉じる場合、開いていたファイル一覧を保存する
            if (!canceled)
            {
                var pathes = _WorkAreaManager.Documents
                             .Where(x => File.Exists(x.SaveFilePath))
                             .Select(x => new { Path = x.SaveFilePath });

                SettingDatabase.Instance.Execute("INSERT INTO OpenedFiles(Path) VALUES(@Path)", pathes);
            }

            return(canceled);
        }