コード例 #1
0
 public void ReadChildData(BinaryReader reader)
 {
     _textData.ReadBinary(reader);
     for (int x = 0; x < _messageElements.Count; x++)
     {
         MessageElements.AddNew();
         MessageElements[x].Read(reader);
     }
     for (int x = 0; x < _messageElements.Count; x++)
     {
         MessageElements[x].ReadChildData(reader);
     }
     for (int x = 0; x < _messages.Count; x++)
     {
         Messages.AddNew();
         Messages[x].Read(reader);
     }
     for (int x = 0; x < _messages.Count; x++)
     {
         Messages[x].ReadChildData(reader);
     }
 }
コード例 #2
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _textData.ReadBinary(reader);
                for (x = 0; (x < _messageElements.Count); x = (x + 1))
                {
                    MessageElements.Add(new HudMessageElementsBlockBlock());
                    MessageElements[x].Read(reader);
                }
                for (x = 0; (x < _messageElements.Count); x = (x + 1))
                {
                    MessageElements[x].ReadChildData(reader);
                }
                for (x = 0; (x < _messages.Count); x = (x + 1))
                {
                    Messages.Add(new HudMessagesBlockBlock());
                    Messages[x].Read(reader);
                }
                for (x = 0; (x < _messages.Count); x = (x + 1))
                {
                    Messages[x].ReadChildData(reader);
                }
            }
コード例 #3
0
        /// <summary>
        /// save a file with given filename
        /// </summary>
        /// <param name="fileName">
        /// filename under which file will be saved
        /// </param>
        /// <returns>
        /// true: if saving was successful
        ///     false: if an error occurred
        /// </returns>
        public bool SaveAs(string fileName)
        {
            try
            {
                bool   result    = false;
                string directory = Path.GetDirectoryName(fileName);
                if (directory == null)
                {
                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "System.IO.Path.GetDirectoryName returned null.");
                    this.Close();
                }
                else
                {
                    if (Directory.Exists(directory) == false)
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The directory: \"" + directory + "\" does not exist.");
                        this.Close();
                    }
                    else
                    {
                        if ((new IsSaveAsDialogOpen()).Run())
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Dialog is open");
                        }
                        else
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Dialog is not open");
                        }

                        Text   text       = new SaveAsFileBrowserElements().TextFileName;
                        Button buttonSave = new SaveAsFileBrowserElements().ButtonSave;
                        if (text == null || buttonSave == null)
                        {
                            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Text field or Save button is null");
                            this.Close();
                        }
                        else
                        {
                            text.Click(DefaultValues.locDefaultLocation);
                            text.TextValue = string.Empty;

                            Keyboard.Press(fileName);
                            Keyboard.Press(Keys.Tab);

                            buttonSave.MoveTo(DefaultValues.locDefaultLocation);
                            buttonSave.Click(DefaultValues.locDefaultLocation);

                            // check if File already exists dialog appears, look for ok button
                            Button buttonYes = new MessageElements().buttonYes;
                            if (buttonYes == null)
                            {
                                // saving was successful
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "File " + "[" + fileName + "]" + "Saved successfully");
                                result = true;
                            }
                            else
                            {
                                // button yes available -> file with that filename already exists, replace file dialog appeared, replace file;
                                buttonYes.Click(DefaultValues.locDefaultLocation);
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "File " + "[" + fileName + "]" + " already exists, overwriting...");
                                result = true;
                            }
                        }
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                this.Close();
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// Load specified file, close dialog if file is not available
        /// </summary>
        /// <param name="fileName">
        /// Filename for loading.
        /// </param>
        /// <returns>
        /// <br>True: If call worked fine</br>
        ///     <br>False: If an error occurred</br>
        /// </returns>
        public bool Load(string fileName)
        {
            try
            {
                bool   result    = false;
                string directory = System.IO.Path.GetDirectoryName(fileName);
                if (directory == null)
                {
                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "System.IO.Path.GetDirectoryName returned null.");
                    this.Close();
                }
                else
                {
                    if (System.IO.Directory.Exists(directory) == false)
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The directory: \"" + directory + "\" does not exist.");
                        this.Close();
                    }
                    else
                    {
                        if (System.IO.File.Exists(fileName) == false)
                        {
                            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The file: \"" + fileName + "\" does not exist.");
                            this.Close();
                        }
                        else
                        {
                            Text   text       = new OpenFileBrowserElements().textFileName;
                            Button buttonOpen = new OpenFileBrowserElements().buttonOpen;

                            if (text == null || buttonOpen == null)
                            {
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Text field or Open button is null");
                                this.Close();
                            }
                            else
                            {
                                text.Click(DefaultValues.locDefaultLocation);
                                text.TextValue = string.Empty;

                                Keyboard.Press(fileName);
                                Keyboard.Press(Keys.Tab);

                                buttonOpen.MoveTo(DefaultValues.locDefaultLocation);
                                buttonOpen.Click(DefaultValues.locDefaultLocation);

                                // check if ok button from the "file not found" dialog is visible
                                Button buttonOk = new MessageElements().buttonOk;
                                if (buttonOk == null)
                                {
                                    // file was available and has been loaded
                                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "File " + "[" + fileName + "]" + " loaded successfully");
                                    result = true;
                                }
                                else
                                {
                                    buttonOk.Click(DefaultValues.locDefaultLocation);
                                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "File " + "[" + fileName + "]" + " is not available");
                                    this.Close();
                                }
                            }
                        }
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                this.Close();
                return(false);
            }
        }