Exemple #1
0
 public SendToConfirm(LibraryType AddType, LibraryType ToType)
 {
     InitializeComponent();
     DialogResult            = 2;
     this.labelControl1.Text = "Create a new " + ToType.ToString().ToLower() + " or add " + AddType.ToString().ToLower() + " to existing " + ToType.ToString().ToLower() + ".";
     this.Text = "Create New " + ToType.ToString();
 }
        public static string ToFriendlyName(this LibraryType libraryType)
        {
            string baseName = libraryType.ToString();

            // Walk through the string and find all of the capital characters
            List <int> capitalIndexes = new List <int>();

            for (int i = 0; i < baseName.Length; ++i)
            {
                if (char.IsUpper(baseName[i]))
                {
                    capitalIndexes.Add(i);
                }
            }

            string scoredName = baseName;

            foreach (int capitalIndex in capitalIndexes)
            {
                if (capitalIndex > 0)
                {
                    scoredName = baseName.Insert(capitalIndex, "_");
                }
            }

            return(scoredName.ToLower());
        }
Exemple #3
0
        public async Task Run(MessageCreateEventArgs e)
        {
            string valueToAdd = e.Message.Content.Substring(9 + _libraryType.ToString().Length);
            int    newKey     = await _library.Add(valueToAdd);

            await e.Message.RespondAsync($"{_libraryType} added to library id:{newKey}");
        }
        //private string _caption;
        public MessageSaveForm(LibraryType libraryType)
        {
            InitializeComponent();
            if (!DesignMode)
            {
                InitializeResource();
                Image image = null;
                try
                {
                    System.IO.MemoryStream mStream = new System.IO.MemoryStream();

                    if (libraryType == LibraryType.Message)
                    {
                        image = Resources.Resource.GetImage(Resources.Resource.Images.MessageIcon16x16);// Resource.GetIcon(Resource.Icons.Message);
                    }
                    if (libraryType == LibraryType.Playlist)
                    {
                        image = Resources.Resource.GetImage(Resources.Resource.Images.PlaylistIcon16x16);// Resource.GetIcon(Resource.Icons.Message);
                    }
                    if (libraryType == LibraryType.Schedule)
                    {
                        image = Resources.Resource.GetImage(Resources.Resource.Images.SchedulerIcon16x16);// Resource.GetIcon(Resource.Icons.Message);
                    }
                    image.Save(mStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    this.Icon = Icon.FromHandle(new Bitmap(mStream).GetHicon());
                    mStream.Close();
                }
                catch
                { }

                this.Text     = libraryType.ToString() + " " + "Save"; //Resource.GetString(Resource.Strings.Save).ToLower();
                lblTitle.Text = Resource.GetFormatString(Resource.Strings.InputName, libraryType.ToString());
                _libraryType  = libraryType;
                Init();
            }
        }
    private void AddFunctionListToContextMenu(GenericMenu menu, Vector2 mousePos)
    {
        if (GraphToEdit == null)
        {
            menu.AddDisabledItem(new GUIContent("No graph available"));
            return;
        }

        foreach (System.Type LibraryType in RegisteredFunctionDictionary.Keys)
        {
            string libraryName = LibraryType.ToString();
            foreach (string MethodName in RegisteredFunctionDictionary[LibraryType])
            {
                menu.AddItem(new GUIContent(libraryName + "/" + MethodName), false, () => OnClick_AddNode(LibraryType, MethodName, mousePos));
            }
        }
    }
Exemple #6
0
        private void CreateLibrary_Type_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (createLibrary_Type.SelectedItem == null)
                {
                    return;
                }

                _libraryType = (LibraryType)createLibrary_Type.SelectedItem;
                createLibrary_TypeText.Text = _libraryType.ToString();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                TmLogs.Report(ex.ToString());
            }
        }
Exemple #7
0
        public static bool CopyLibraryFile(string sourceFile, string libraryName, LibraryType type)
        {
            if (string.IsNullOrEmpty(sourceFile))
            {
                return(false);
            }

            try
            {
                if (!File.Exists(sourceFile))
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(libraryName))
                {
                    libraryName = Path.GetFileName(sourceFile);
                }

                string targetName = libraryName;
                if (type == LibraryType.Image)
                {
                    targetName = Constance.LibraryImageDir + libraryName;
                }
                else if (type == LibraryType.Video)
                {
                    targetName = Constance.LibraryVideoDir + libraryName;
                }
                else
                {
                    return(false);
                }

                if (File.Exists(targetName))
                {
                    return(false);
                }

                File.Copy(sourceFile, targetName, false);
                return(true);
            }
            catch (Exception ex)
            {
                _log.Error("Copy library file error: SourceFile<" + sourceFile + ">; LibraryName<" + libraryName + ">.Type<" + type.ToString() + ">");
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Exemple #8
0
 private Library(LibraryType libraryType)
 {
     _libraryType = libraryType;
     _path        = $"../storage/libraries/{libraryType.ToString().ToLower()}.json";
 }
 /// <summary>
 /// Function:Save
 /// Author: Jerry Xu
 /// Date:2008-7-13
 /// </summary>
 /// <returns></returns>
 private void OnSave()
 {
     try
     {
         //Check the input value
         if (Check())
         {
             _modelName = txtModelName.Text;
             if (LibraryGroup.Current.Contains(_modelName, _libraryType))
             {
                 if (MsgBox.Warning(Resource.GetFormatString(Resource.Strings.LibrarySaveFormNameExists, new object[] { _libraryType.ToString().ToLower(), _modelName }), Resource.GetString(Resource.Strings.SaveAs), MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     _isUpdate = true;
                     _keyFlag  = false;
                     this.Close();
                 }
                 else
                 {
                     _isUpdate  = false;
                     _keyFlag   = false;
                     _modelName = string.Empty;
                     txtModelName.Focus();
                     return;
                 }
                 return;
             }
             else
             {
                 _isUpdate = false;
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         DataGate.Log.Error(Resource.GetString(Resource.Strings.PlayListTimeSliceGroupEditFormSaveException), ex);
     }
 }